Exemple #1
0
 def test_value(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.BYTE, OpType.VALUE, None, 255, None, None),
         self.cpu, self.ram, 0x1234,
     ), 255)
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.VALUE, None, 65535, None, None),
         self.cpu, self.ram, 0x1234,
     ), 65535)
     self.assertEqual(self.cpu.registers.get_register.call_count, 0)
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #2
0
 def test_address(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.ADDRESS, None, 1, None, None),
         self.cpu, self.ram, 0x1234,
     ), 0x1235)
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.ADDRESS, None, -1, None, None),
         self.cpu, self.ram, 0x1234,
     ), 0x1233)
     self.assertEqual(self.cpu.registers.get_register.call_count, 0)
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #3
0
 def test_address(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.ADDRESS, None, 1, None, None),
         self.cpu, self.ram, 0x1234,
     ), 0x1235)
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.ADDRESS, None, -1, None, None),
         self.cpu, self.ram, 0x1234,
     ), 0x1233)
     self.assertEqual(self.cpu.registers.get_register.call_count, 0)
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #4
0
 def test_value(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.BYTE, OpType.VALUE, None, 255, None, None),
         self.cpu, self.ram, 0x1234,
     ), 255)
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.VALUE, None, 65535, None, None),
         self.cpu, self.ram, 0x1234,
     ), 65535)
     self.assertEqual(self.cpu.registers.get_register.call_count, 0)
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #5
0
 def test_rel_ref_word_byte(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.BYTE, OpType.REL_REF_WORD_BYTE, None, None, -0x1111, 0x22),
         self.cpu, self.ram, 0x1234,
     ), 0xCC)
     self.assertEqual(self.cpu.registers.get_register.call_count, 0)
     self.assertEqual(self.ram.read_byte.call_count, 1)
     self.assertEqual(self.ram.read_byte.call_args_list[0][0][0], 0x0145)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #6
0
 def test_register(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.REGISTER, 'AX', 1, None, None),
         self.cpu, self.ram, 0x1234,
     ), 0xA0B0)
     self.assertEqual(self.cpu.registers.get_register.call_count, 1)
     self.assertEqual(self.cpu.registers.get_register.call_args_list[0][0][0], 'AX')
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #7
0
 def test_rel_ref_word_byte(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.BYTE, OpType.REL_REF_WORD_BYTE, None, None, -0x1111, 0x22),
         self.cpu, self.ram, 0x1234,
     ), 0xCC)
     self.assertEqual(self.cpu.registers.get_register.call_count, 0)
     self.assertEqual(self.ram.read_byte.call_count, 1)
     self.assertEqual(self.ram.read_byte.call_args_list[0][0][0], 0x0145)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #8
0
 def test_register(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.REGISTER, 'AX', 1, None, None),
         self.cpu, self.ram, 0x1234,
     ), 0xA0B0)
     self.assertEqual(self.cpu.registers.get_register.call_count, 1)
     self.assertEqual(self.cpu.registers.get_register.call_args_list[0][0][0], 'AX')
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 0)
Exemple #9
0
 def test_abs_ref_reg_w(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.ABS_REF_REG, 'AX', None, None, 0x01),
         self.cpu, self.ram, 0x1234,
     ), 0xCCDD)
     self.assertEqual(self.cpu.registers.get_register.call_count, 1)
     self.assertEqual(self.cpu.registers.get_register.call_args_list[0][0][0], 'AX')
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 1)
     self.assertEqual(self.ram.read_word.call_args_list[0][0][0], 0xA0B1)
Exemple #10
0
 def test_abs_ref_reg_w(self):
     self.assertEqual(get_operand_value(
         Operand(OpLen.WORD, OpType.ABS_REF_REG, 'AX', None, None, 0x01),
         self.cpu, self.ram, 0x1234,
     ), 0xCCDD)
     self.assertEqual(self.cpu.registers.get_register.call_count, 1)
     self.assertEqual(self.cpu.registers.get_register.call_args_list[0][0][0], 'AX')
     self.assertEqual(self.ram.read_byte.call_count, 0)
     self.assertEqual(self.ram.read_word.call_count, 1)
     self.assertEqual(self.ram.read_word.call_args_list[0][0][0], 0xA0B1)