def test_do_assemble_passes_addr_for_relative_branch_calc(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('4000 bvs $4005') out = stdout.getvalue() self.assertEqual("$4000 70 03 BVS $4005\n", out)
def test_do_assemble_shows_overflow_error(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('c000 lda #$fff') out = stdout.getvalue() self.assertEqual("Overflow error: c000 lda #$fff\n", out)
def test_do_assemble_shows_bad_syntax_error(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('c000 foo') out = stdout.getvalue() self.assertEqual("Syntax error: foo\n", out)
def test_do_assemble_shows_bad_label_error(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('nonexistant rts') out = stdout.getvalue() self.assertEqual("Bad label: nonexistant rts\n", out)
def test_do_assemble_constrains_address_to_valid_range(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble("-1 lda #$ab") out = stdout.getvalue() self.assertEqual("Overflow error: -1 lda #$ab\n", out)
def test_do_assemble_shows_bad_statement_error(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('c000 foo') out = stdout.getvalue() self.assertEqual("Assemble failed: foo\n", out)
def test_do_assemble_outputs_disassembly(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('c000 lda #$ab') out = stdout.getvalue() self.assertEqual("$c000 a9 ab LDA #$ab\n", out)
def test_do_assemble_parses_start_address_label(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_add_label('c000 base') mon.do_assemble('c000 rts') mpu = mon._mpu self.assertEqual(0x60, mpu.memory[0xC000])
def test_do_assemble_assembles_valid_statement(self): stdout = StringIO() mon = Monitor(stdout=stdout) mon.do_assemble('c000 lda #$ab') mpu = mon._mpu self.assertEqual(0xA9, mpu.memory[0xC000]) self.assertEqual(0xAB, mpu.memory[0xC001])