コード例 #1
0
ファイル: tools.py プロジェクト: blackchip-org/mach8-py
 def _resolve(self, uref):
     """
     Resolve the given unresolved reference. Get the symbol's value or
     re-evaluate an expression and place that value in the reference's
     address. 
     """
     if uref.expr is None: 
         value = self.meta.lookup(uref.ref) 
     else:
         value = uref.expr.eval(self.meta) 
         
     if uref.type == REFERENCE_VALUE: 
         self.mem[uref.address] = vm.size8(value)  
     elif uref.type == REFERENCE_ABSOLUTE: 
         self.mem[uref.address::2] = vm.size16(value)
     elif uref.type == REFERENCE_ZERO_PAGE: 
         self.mem[uref.address] = vm.size8(value) 
     elif uref.type == REFERENCE_RELATIVE: 
         abs_address = vm.size16(value)
         # Branch is relative to PC after opcode and displacement
         # have been consumed. Since abs_address points to where
         # the displacement should go, add one to this value. 
         rel_address = abs_address - (uref.address + 1) 
         assert_branch_displacement(rel_address)
         self.mem[uref.address] = vm.twos_forward(rel_address)
     else:
         assert False 
コード例 #2
0
ファイル: test_vm.py プロジェクト: blackchip-org/mach8-py
 def test_twos_forward_max_unsigned(self): 
     self.assertEquals(0xff, vm.twos_forward(255)) 
コード例 #3
0
ファイル: test_vm.py プロジェクト: blackchip-org/mach8-py
 def test_twos_forward_min_signed(self):
     self.assertEquals(0x80, vm.twos_forward(-128))
コード例 #4
0
ファイル: test_vm.py プロジェクト: blackchip-org/mach8-py
 def test_twos_forward_max_signed(self):
     self.assertEquals(0x7f, vm.twos_forward(127))
コード例 #5
0
ファイル: test_vm.py プロジェクト: blackchip-org/mach8-py
 def test_twos_forward_negative(self):
     self.assertEquals(0xfe, vm.twos_forward(-2))
コード例 #6
0
ファイル: test_vm.py プロジェクト: blackchip-org/mach8-py
 def test_twos_forward(self):
     self.assertEquals(0x02, vm.twos_forward(2))