mirror of
https://github.com/pevans/erc-c.git
synced 2025-01-21 14:30:39 +00:00
Add support for PHX, PHY, PLX, PLY
These instructions allow you to push and pull (pop) the X and Y registers via the stack.
This commit is contained in:
parent
f9a277e7bc
commit
8e1ab0e950
@ -105,8 +105,12 @@ enum instruction {
|
||||
ORA, // OR with Accumulator
|
||||
PHA, // PusH Accumulator
|
||||
PHP, // PusH Predicate register
|
||||
PHX, // PusH X register
|
||||
PHY, // PusH Y register
|
||||
PLA, // PulL Accumulator
|
||||
PLP, // PulL Predicate register
|
||||
PLX, // PulL X register
|
||||
PLY, // PulL Y register
|
||||
ROL, // ROtate Left
|
||||
ROR, // ROtate Right
|
||||
RTI, // ReTurn from Interrupt
|
||||
|
@ -214,8 +214,12 @@ DECL_INST(nop);
|
||||
DECL_INST(ora);
|
||||
DECL_INST(pha);
|
||||
DECL_INST(php);
|
||||
DECL_INST(phx);
|
||||
DECL_INST(phy);
|
||||
DECL_INST(pla);
|
||||
DECL_INST(plp);
|
||||
DECL_INST(plx);
|
||||
DECL_INST(ply);
|
||||
DECL_INST(rol);
|
||||
DECL_INST(ror);
|
||||
DECL_INST(rti);
|
||||
|
@ -81,8 +81,12 @@ static char *instruction_strings[] = {
|
||||
"ORA",
|
||||
"PHA",
|
||||
"PHP",
|
||||
"PHX",
|
||||
"PHY",
|
||||
"PLA",
|
||||
"PLP",
|
||||
"PLX",
|
||||
"PLY",
|
||||
"ROL",
|
||||
"ROR",
|
||||
"RTI",
|
||||
|
@ -52,6 +52,23 @@ DEFINE_INST(php)
|
||||
mos6502_push_stack(cpu, cpu->P);
|
||||
}
|
||||
|
||||
/*
|
||||
* Push the X register onto the stack. Sadly, this does not summon a
|
||||
* phoenix to assist you in hours of need.
|
||||
*/
|
||||
DEFINE_INST(phx)
|
||||
{
|
||||
mos6502_push_stack(cpu, cpu->X);
|
||||
}
|
||||
|
||||
/*
|
||||
* Push the Y register onto the stack
|
||||
*/
|
||||
DEFINE_INST(phy)
|
||||
{
|
||||
mos6502_push_stack(cpu, cpu->Y);
|
||||
}
|
||||
|
||||
/*
|
||||
* Here we pop the stack (or "pull" it), and assign to the accumulator.
|
||||
*/
|
||||
@ -71,6 +88,22 @@ DEFINE_INST(plp)
|
||||
cpu->P = mos6502_pop_stack(cpu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pop from the stack and assign that byte to the X register
|
||||
*/
|
||||
DEFINE_INST(plx)
|
||||
{
|
||||
cpu->X = mos6502_pop_stack(cpu);
|
||||
}
|
||||
|
||||
/*
|
||||
* Pop from the stack and assign that byte to the Y register
|
||||
*/
|
||||
DEFINE_INST(ply)
|
||||
{
|
||||
cpu->Y = mos6502_pop_stack(cpu);
|
||||
}
|
||||
|
||||
/*
|
||||
* The STA instruction assigns the value of the accumulator to a given
|
||||
* address in memory. (That is to say, it "stores" it.)
|
||||
|
@ -40,6 +40,20 @@ Test(mos6502_loadstor, php)
|
||||
cr_assert_eq(mos6502_get(cpu, 0x01ff), 0x43);
|
||||
}
|
||||
|
||||
Test(mos6502_loadstor, phx)
|
||||
{
|
||||
cpu->X = 123;
|
||||
mos6502_handle_phx(cpu, 0);
|
||||
cr_assert_eq(mos6502_get(cpu, 0x01ff), 123);
|
||||
}
|
||||
|
||||
Test(mos6502_loadstor, phy)
|
||||
{
|
||||
cpu->Y = 234;
|
||||
mos6502_handle_phy(cpu, 0);
|
||||
cr_assert_eq(mos6502_get(cpu, 0x01ff), 234);
|
||||
}
|
||||
|
||||
Test(mos6502_loadstor, pla)
|
||||
{
|
||||
mos6502_push_stack(cpu, 0x0033);
|
||||
@ -56,6 +70,22 @@ Test(mos6502_loadstor, plp)
|
||||
cr_assert_eq(cpu->P, 0x52);
|
||||
}
|
||||
|
||||
Test(mos6502_loadstor, plx)
|
||||
{
|
||||
mos6502_push_stack(cpu, 87);
|
||||
mos6502_handle_plx(cpu, 0);
|
||||
|
||||
cr_assert_eq(cpu->X, 87);
|
||||
}
|
||||
|
||||
Test(mos6502_loadstor, ply)
|
||||
{
|
||||
mos6502_push_stack(cpu, 44);
|
||||
mos6502_handle_ply(cpu, 0);
|
||||
|
||||
cr_assert_eq(cpu->Y, 44);
|
||||
}
|
||||
|
||||
Test(mos6502_loadstor, sta)
|
||||
{
|
||||
cpu->A = 123;
|
||||
|
Loading…
x
Reference in New Issue
Block a user