mirror of
https://github.com/pevans/erc-c.git
synced 2024-12-21 08:30:55 +00:00
Add read_byte function to return the next byte in memory
This commit is contained in:
parent
50a84b4099
commit
89ddd20658
@ -112,6 +112,7 @@ extern int mos6502_cycles(mos6502 *, vm_8bit);
|
||||
extern int mos6502_instruction(vm_8bit);
|
||||
extern mos6502_instruction_handler mos6502_get_instruction_handler(vm_8bit);
|
||||
extern void mos6502_execute(mos6502 *, vm_8bit);
|
||||
extern vm_8bit mos6502_read_byte(mos6502 *);
|
||||
|
||||
/*
|
||||
* Below are some functions that are defined in mos6502.addr.c
|
||||
|
@ -352,3 +352,18 @@ mos6502_execute(mos6502 *cpu, vm_8bit opcode)
|
||||
// Ok -- we're done! This wasn't so hard, was it?
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the next byte in memory according to the program counter
|
||||
* register, and then increment the register.
|
||||
*/
|
||||
vm_8bit
|
||||
mos6502_read_byte(mos6502 *cpu)
|
||||
{
|
||||
vm_8bit byte;
|
||||
|
||||
byte = vm_segment_get(cpu->memory, cpu->PC);
|
||||
cpu->PC++;
|
||||
|
||||
return byte;
|
||||
}
|
||||
|
@ -128,3 +128,24 @@ Test(mos6502, get_instruction_handler)
|
||||
cr_assert_eq(mos6502_get_instruction_handler(0x1D), mos6502_handle_ora);
|
||||
cr_assert_eq(mos6502_get_instruction_handler(0x20), mos6502_handle_jsr);
|
||||
}
|
||||
|
||||
Test(mos6502, execute)
|
||||
{
|
||||
START_CPU_TEST(mos6502);
|
||||
|
||||
vm_segment_set(cpu->memory, 0, 34);
|
||||
mos6502_execute(cpu, 0x69);
|
||||
cr_assert_eq(cpu->A, 34);
|
||||
|
||||
END_CPU_TEST(mos6502);
|
||||
}
|
||||
|
||||
Test(mos6502, read_byte)
|
||||
{
|
||||
START_CPU_TEST(mos6502);
|
||||
|
||||
vm_segment_set(cpu->memory, 0, 0x54);
|
||||
cr_assert_eq(mos6502_read_byte(cpu), 0x54);
|
||||
|
||||
END_CPU_TEST(mos6502);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user