mirror of
https://github.com/rkujawa/rk65c02.git
synced 2024-12-12 10:30:23 +00:00
Add functions to pop/push emulated CPU stack.
This commit is contained in:
parent
a50da41388
commit
7862703c88
@ -220,3 +220,23 @@ instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i)
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* put value onto the stack */
|
||||
void
|
||||
stack_push(rk65c02emu_t *e, uint8_t val)
|
||||
{
|
||||
bus_write_1(e->bus, STACK_START+e->regs.SP, val);
|
||||
e->regs.SP--;
|
||||
}
|
||||
|
||||
/* pull/pop value from the stack */
|
||||
uint8_t
|
||||
stack_pop(rk65c02emu_t *e)
|
||||
{
|
||||
uint8_t val;
|
||||
|
||||
val = bus_read_1(e->bus, STACK_START+e->regs.SP);
|
||||
e->regs.SP++;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,10 @@ struct reg_state {
|
||||
#define P_SIGN_OVERFLOW 0x40
|
||||
#define P_NEGATIVE 0x80
|
||||
|
||||
#define NEGATIVE P_NEGATIVE
|
||||
#define NEGATIVE P_NEGATIVE /* sign bit */
|
||||
|
||||
#define STACK_START 0x0100
|
||||
#define STACK_END 0x01FF
|
||||
|
||||
typedef struct reg_state reg_state_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user