コード例 #1
0
ファイル: x6502.py プロジェクト: blackchip-org/mach8-py
 def push2(self, value):
     """
     Pushes an unsigned word, *value*, to the stack. Raises an 
     :class:`OverflowError` if *value* is not an unsigned word. Raises a
     :class:`StackError` on a stack overflow. 
     """ 
     self._push(vm.hb(value), STACK_ADDRESS)
     self._push(vm.lb(value), STACK_ADDRESS) 
コード例 #2
0
ファイル: test_text.py プロジェクト: blackchip-org/mach8-py
 def test_txtrst(self):
     suite.banner(self.test_txtrst)
     a = self.a 
     
     _;      a.macro     (ldxy_imm, x16(0xffff)) 
     _;      a.macro     (stxy_zp,  'TEXT_WORK_PTR')
     _;      a(jsr,      'TXTRST')
     _;      a.macro     (ldxy_zp, 'TEXT_WORK_PTR')
     
     self.run_test() 
     self.assertEquals(vm.lb(memmap.TEXT_WORK), self.cpu.x)
     self.assertEquals(vm.hb(memmap.TEXT_WORK), self.cpu.y) 
コード例 #3
0
ファイル: test_string.py プロジェクト: blackchip-org/mach8-py
 def test_findmsg_last(self):
     suite.banner(self.test_findmsg_last) 
     a = self.a        
     
     _;      a.macro     (ldxy_imm, 'test.table')
     _;      a(lda_imm,  2)
     _;      a(jsr,      'FINDMSG')
     _;      a(brk)
     _;      a(nop)
     
     _;  a('test.table')
     _;      a.data      ('000000', 0)
     _;      a.data      ('000000', 0)
     _;  a('answer')
     _;      a.data      ('123456', 0)
     
     self.run_test() 
     ptr = self.meta.lookup('answer')
     self.assertEquals(vm.lb(ptr), self.cpu.x) 
     self.assertEquals(vm.hb(ptr), self.cpu.y) 
コード例 #4
0
ファイル: tools.py プロジェクト: blackchip-org/mach8-py
 def next(self):
     """
     Description
     """
     d = Disassembled()
     d.address = vm.size16(self.position)
     d.labels = self.meta.get_labels(d.address) 
     d.remarks = self.meta.get_remarks(d.address)
     d.argument = self.meta.get_argument(d.address) 
     d.data = self.meta.get_data(d.address) 
     if d.data is not None: 
         self.position = d.data.address + d.data.length 
         return d 
     
     opcode = self.pc.load()
     if opcode in self._opcodes: 
         i = self._opcodes[opcode]
     else:
         op = '?{:02X}'.format(opcode)
         i = x6502.Instruction(opcode, op, am.IMP, None)
     d.instruction = i
     if i.addressing_mode in AM_ADDRESS_16:
         arg = self.pc.load2()
         d.bytes = [opcode, vm.lb(arg), vm.hb(arg)] 
     elif (i.addressing_mode in AM_ADDRESS_8 or 
           i.addressing_mode in (am.REL, am.IMM)):
         arg = self.pc.load()
         if i.addressing_mode == am.REL and d.argument is None: 
             # Branch is displacement after consuming bytes, therefore
             # add two. 
             d.argument = vm.hex16(d.address + vm.twos_inverse(arg) + 2) 
         d.bytes = [opcode, arg]                 
     elif i.addressing_mode in AM_NO_ARGUMENT:
         d.bytes = [opcode]
     else: 
         assert False 
     return d
コード例 #5
0
ファイル: test_vm.py プロジェクト: blackchip-org/mach8-py
 def test_hb(self):
     self.assertEquals(0x12, vm.hb(0x1234))