Beispiel #1
0
 def test_jump_lt_zero(self):
     line = 'D=A;JLT'
     instruction = assembler.parse_c_instruction(line)
     expected_jump_code = '100'
     self.assertEqual(expected_jump_code, instruction[13:])
Beispiel #2
0
 def test_no_jump(self):
     line = 'D=A'
     instruction = assembler.parse_c_instruction(line)
     expected_jump_code = '000'
     self.assertEqual(expected_jump_code, instruction[13:])
Beispiel #3
0
 def test_unconditional_jump(self):
     line = 'D=A;JMP'
     instruction = assembler.parse_c_instruction(line)
     expected_jump_code = '111'
     self.assertEqual(expected_jump_code, instruction[13:])
Beispiel #4
0
 def test_store_md(self):
     line = 'MD=0;JMP'
     instruction = assembler.parse_c_instruction(line)
     expected_dest_code = '011'
     self.assertEqual(expected_dest_code, instruction[10:13])
Beispiel #5
0
 def test_store_nowhere(self):
     line = '0;JMP'
     instruction = assembler.parse_c_instruction(line)
     expected_dest_code = '000'
     self.assertEqual(expected_dest_code, instruction[10:13])
Beispiel #6
0
 def test_m_minus_d(self):
     line = 'D=A-D;JNE'
     instruction = assembler.parse_c_instruction(line)
     expected_comp_code = '000111'
     self.assertEqual(expected_comp_code, instruction[4:10])
Beispiel #7
0
 def test_a_and_d(self):
     line = 'M=A&D;JLE'
     instruction = assembler.parse_c_instruction(line)
     expected_comp_code = '000000'
     self.assertEqual(expected_comp_code, instruction[4:10])
Beispiel #8
0
 def test_a_flag_default(self):
     line = 'D=1'
     instruction = assembler.parse_c_instruction(line)
     expected_a_flag = '0'
     self.assertEqual(expected_a_flag, instruction[3])
Beispiel #9
0
 def test_a_flag_a(self):
     line = 'D=D+M'
     instruction = assembler.parse_c_instruction(line)
     expected_a_flag = '1'
     self.assertEqual(expected_a_flag, instruction[3])
Beispiel #10
0
 def test_op_code(self):
     line = 'AMD=0;JMP'
     instruction = assembler.parse_c_instruction(line)
     expected_op_code = '111'
     self.assertEqual(expected_op_code, instruction[:3])