Skip to content

Commit

Permalink
Try to add vstr semantic
Browse files Browse the repository at this point in the history
  • Loading branch information
b14aa178 committed Sep 9, 2021
1 parent b2b0b43 commit e08c21d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 13 additions & 3 deletions miasm/arch/arm/sem.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,6 @@ def blx(ir, instr, a):
e.append(ExprAssign(LR, l))
return e, []

# todo
def vmov(ir, instr, a, b, c=None):
e = []
if c is None:
Expand All @@ -996,9 +995,20 @@ def vmov(ir, instr, a, b, c=None):

return e, []

# todo
def vstr(ir, instr, a, b):
raise NotImplementedError('Not implemented')
e = []
if a in spregs_expr:
e.append(ExprAssign(b, a))
elif a in dpregs_expr:
if instr.mode == 'l':
e.append(ExprAssign(b, a[:32]))
e.append(ExprAssign(ExprMem(b.ptr + ExprInt(4, 32), 32), a[32:]))
else:
e.append(ExprAssign(b, a[32:]))
e.append(ExprAssign(b, a[:32]))
else:
raise NotImplementedError('Not implemented')
return e, []

# todo
def vcvt(ir, instr, a, b):
Expand Down
6 changes: 6 additions & 0 deletions test/arch/arm/sem.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ def test_vmov(self):
self.assertEqual(compute_t('VMOV R0, S0', {S0: 0x1, R0: 0x2}), {S0: 0x1, R0: 0x1})
self.assertEqual(compute_t('VMOV D0, R0, R1', {D0: 0x1, R0: 0x2, R1:0x3}), {D0: 0x2 | (0x3 << 32), R0: 0x2, R1: 0x3})
self.assertEqual(compute_t('VMOV R0, R1, D0', {D0: 0xfffffffcfffffffe, R0: 0x2, R1:0x3}), {D0: 0xfffffffcfffffffe, R0: 0xfffffffe, R1: 0xfffffffc})
self.assertEqual(compute_t('VSTR S0, [SP, 0x30]',
{S0: 0x10000, SP: 0x20000, ExprMem(ExprOp('preinc', ExprInt(0x20000, 32), ExprInt(0x30, 32)), 32): 0x50}),
{S0: 0x10000, SP: 0x20000, ExprMem(ExprOp('preinc', ExprInt(0x20000, 32), ExprInt(0x30, 32)), 32): 0x10000})
self.assertEqual(compute_t('VSTR D0, [SP, 0x30]',
{D0: 0x1000000020000000, SP: 0x20000, ExprMem(ExprOp('preinc', ExprInt(0x20000, 32), ExprInt(0x30, 32)), 32): 0x50 , ExprMem(ExprOp('+', ExprOp('preinc', ExprInt(0x20000, 32), ExprInt(0x30, 32)), ExprInt(4, 32)), 32): 0x50}),
{D0: 0x1000000020000000, SP: 0x20000, ExprMem(ExprOp('preinc', ExprInt(0x20000, 32), ExprInt(0x30, 32)), 32): 0x20000000, ExprMem(ExprOp('+', ExprOp('preinc', ExprInt(0x20000, 32), ExprInt(0x30, 32)), ExprInt(4, 32)), 32): 0x10000000})

if __name__ == '__main__':
testsuite = unittest.TestLoader().loadTestsFromTestCase(TestARMSemantic)
Expand Down

0 comments on commit e08c21d

Please sign in to comment.