mirror of
https://github.com/mlaux/gb6.git
synced 2025-01-06 12:31:12 +00:00
CALL
This commit is contained in:
parent
2e77b9112b
commit
a4c720a0fb
19
src/cpu.c
19
src/cpu.c
@ -175,6 +175,19 @@ static void xor(struct cpu *regs, u8 value)
|
||||
clear_flag(regs, FLAG_CARRY);
|
||||
}
|
||||
|
||||
static void push(struct cpu *cpu, u16 value)
|
||||
{
|
||||
write16(cpu, cpu->sp - 2, value & 0xff);
|
||||
write16(cpu, cpu->sp - 1, value >> 8);
|
||||
cpu->sp -= 2;
|
||||
}
|
||||
|
||||
static u16 pop(struct cpu *cpu)
|
||||
{
|
||||
cpu->sp += 2;
|
||||
return read16(cpu, cpu->sp - 1) << 8 | read16(cpu, cpu->sp - 2);
|
||||
}
|
||||
|
||||
void cpu_step(struct cpu *cpu)
|
||||
{
|
||||
u8 temp;
|
||||
@ -261,6 +274,12 @@ void cpu_step(struct cpu *cpu)
|
||||
case 0x94:
|
||||
subtract(cpu, cpu->h);
|
||||
break;
|
||||
case 0xcd: // CALL a16
|
||||
temp = read16(cpu, cpu->pc);
|
||||
cpu->pc += 2;
|
||||
push(cpu, cpu->pc);
|
||||
cpu->pc = temp;
|
||||
break;
|
||||
case 0xc3: // JP a16
|
||||
cpu->pc = read16(cpu, cpu->pc);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user