From d8022e9eda1d83211b42c523483f6d9f7da3cefa Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 29 Jan 2015 12:49:30 -0800 Subject: [PATCH] properly sign-extend instructions in spike-dasm --- spike_main/spike-dasm.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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(); -- 2.30.2