Skip to content

Commit

Permalink
New x86 instrution test
Browse files Browse the repository at this point in the history
  • Loading branch information
feliam committed Jul 14, 2020
1 parent be9bdd1 commit 6c24f8d
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/native/test_cpu_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,36 @@ def test_DAA_0(self):
self.assertEqual(cpu.PF, True)
self.assertEqual(cpu.CF, True)

def test_DAS_0(self):
"""Decimal Adjust AL after Subtraction."""

cs = ConstraintSet()
mem = SMemory32(cs)
cpu = I386Cpu(mem)
# alloc/map a little mem
code = mem.mmap(0x1000, 0x1000, "rwx")
stack = mem.mmap(0xF000, 0x1000, "rw")

# 2F DAS
mem[code] = BitVecConstant(8, 0x2F)
cpu.EIP = code

cpu.AL = 0xAE
cpu.OF = True
cpu.SF = True
cpu.ZF = False
cpu.AF = False
cpu.PF = False
cpu.CF = False

cpu.execute()
self.assertEqual(cpu.AL, 0x48)
self.assertEqual(cpu.SF, False)
self.assertEqual(cpu.ZF, False)
self.assertEqual(cpu.AF, True)
self.assertEqual(cpu.PF, True)
self.assertEqual(cpu.CF, True)


if __name__ == "__main__":
unittest.main()

0 comments on commit 6c24f8d

Please sign in to comment.