mirror of
https://github.com/pevans/erc-c.git
synced 2025-02-14 18:31:41 +00:00
Advance PC by # of bytes consumed
This commit is contained in:
parent
7ceee608b3
commit
af7dae6924
@ -13,6 +13,7 @@
|
||||
|
||||
#include "log.h"
|
||||
#include "mos6502.h"
|
||||
#include "mos6502.dis.h"
|
||||
|
||||
// All of our address modes, instructions, etc. are defined here.
|
||||
#include "mos6502.enums.h"
|
||||
@ -353,10 +354,19 @@ void
|
||||
mos6502_execute(mos6502 *cpu, vm_8bit opcode)
|
||||
{
|
||||
vm_8bit operand = 0;
|
||||
int cycles;
|
||||
int cycles, bytes;
|
||||
mos6502_address_resolver resolver;
|
||||
mos6502_instruction_handler handler;
|
||||
|
||||
// We want to know how many bytes this opcode and its operand
|
||||
// consume. We know the opcode is one byte.
|
||||
bytes = 1;
|
||||
|
||||
// The disassembler knows how many bytes each operand requires
|
||||
// (maybe this code doesn't belong in the disassembler); let's use
|
||||
// that to figure out the total number of bytes to skip.
|
||||
bytes += mos6502_dis_expected_bytes(mos6502_addr_mode(opcode));
|
||||
|
||||
// First, we need to know how to resolve our effective address and
|
||||
// how to execute anything.
|
||||
resolver = mos6502_get_address_resolver(opcode);
|
||||
@ -393,6 +403,9 @@ mos6502_execute(mos6502 *cpu, vm_8bit opcode)
|
||||
// something.
|
||||
usleep(cycles * 100000);
|
||||
|
||||
// Update the counter to move beyond the opcode and its operand.
|
||||
cpu->PC += bytes;
|
||||
|
||||
// Ok -- we're done! This wasn't so hard, was it?
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user