aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <waterman@cs.berkeley.edu>2015-01-29 12:49:30 -0800
committerAndrew Waterman <waterman@cs.berkeley.edu>2015-01-29 12:49:57 -0800
commitd8022e9eda1d83211b42c523483f6d9f7da3cefa (patch)
tree49f5c3ac07507085cc531053f023beae2afb4ed3
parentbf8c76bdbc924e52007d47168ef3f54d213fce8b (diff)
downloadriscv-isa-sim-d8022e9eda1d83211b42c523483f6d9f7da3cefa.zip
riscv-isa-sim-d8022e9eda1d83211b42c523483f6d9f7da3cefa.tar.gz
riscv-isa-sim-d8022e9eda1d83211b42c523483f6d9f7da3cefa.tar.bz2
properly sign-extend instructions in spike-dasm
-rw-r--r--spike_main/spike-dasm.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/spike_main/spike-dasm.cc b/spike_main/spike-dasm.cc
index d0af451..7f15db0 100644
--- a/spike_main/spike-dasm.cc
+++ b/spike_main/spike-dasm.cc
@@ -31,8 +31,13 @@ int main(int argc, char** argv)
if (end == string::npos)
break;
+ char* endp;
size_t numstart = start + strlen("DASM(");
- insn_bits_t bits = strtoull(&s[numstart], NULL, 16);
+ int64_t bits = strtoull(&s[numstart], &endp, 16);
+ size_t nbits = 4 * (endp - &s[numstart]);
+ if (nbits < 64)
+ bits = bits << (64 - nbits) >> (64 - nbits);
+
string dis = d.disassemble(bits);
s = s.substr(0, start) + dis + s.substr(end+1);
start += dis.length();