Skip to content

Commit

Permalink
Fix disassembly bug
Browse files Browse the repository at this point in the history
  • Loading branch information
W0ni committed Sep 13, 2023
1 parent bb53a45 commit 71e4e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions miasm/arch/arm/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,8 +1148,12 @@ def decode(self, v):
shift_op = ExprInt(amount, 32)
a = regs_expr[rm]
if shift_op == ExprInt(0, 32):
#rrx
if shift_type == 3:
self.expr = ExprOp(allshifts[4], a)
#asr, lsr
elif shift_type == 1 or shift_type == 2:
self.expr = ExprOp(allshifts[shift_type], a, ExprInt(32, 32))
else:
self.expr = a
else:
Expand Down
4 changes: 2 additions & 2 deletions test/arch/arm/sem.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_shift(self):
self.assertEqual(
compute('MOV R4, R4 LSR 31', {R4: 0xDEADBEEF, }), {R4: 0x00000001, })
self.assertEqual(
compute('MOV R4, R4 LSR 32', {R4: 0xDEADBEEF, }), {R4: 0xDEADBEEF, })
compute('MOV R4, R4 LSR 32', {R4: 0xDEADBEEF, }), {R4: 0x0, })
self.assertRaises(ValueError, compute, 'MOV R4, R4 LSR 33')
self.assertEqual(
compute('MOV R4, R4 LSR R5', {R4: 0xDEADBEEF, R5: 0xBADBAD01, }), {R4: 0x6F56DF77, R5: 0xBADBAD01, })
Expand All @@ -93,7 +93,7 @@ def test_shift(self):
self.assertEqual(
compute('MOV R4, R4 ASR 31', {R4: 0xDEADBEEF, }), {R4: 0xFFFFFFFF, })
self.assertEqual(
compute('MOV R4, R4 ASR 32', {R4: 0xDEADBEEF, }), {R4: 0xDEADBEEF, })
compute('MOV R4, R4 ASR 32', {R4: 0xDEADBEEF, }), {R4: 0xFFFFFFFF, })
self.assertRaises(ValueError, compute, 'MOV R4, R4 ASR 33')
self.assertEqual(
compute('MOV R4, R4 ASR R5', {R4: 0xDEADBEEF, R5: 0xBADBAD01, }), {R4: 0xEF56DF77, R5: 0xBADBAD01, })
Expand Down

0 comments on commit 71e4e09

Please sign in to comment.