diff --git a/src/emulation.c b/src/emulation.c index fc090e6..c29c0dd 100644 --- a/src/emulation.c +++ b/src/emulation.c @@ -10,10 +10,16 @@ emul_lda(rk65c02emu_t *e, instruction_t *i) e->regs.A = instruction_data_read_1(e, &id, i); - /* adjust status flags */ + if (e->regs.A & NEGATIVE) + e->regs.P |= P_NEGATIVE; + else + e->regs.P &= ~P_NEGATIVE; - + if (e->regs.A == 0) + e->regs.P |= P_ZERO; + else + e->regs.P &= ~P_ZERO; } void diff --git a/src/rk65c02.h b/src/rk65c02.h index 95e7cce..6b0e698 100644 --- a/src/rk65c02.h +++ b/src/rk65c02.h @@ -28,6 +28,8 @@ struct reg_state { #define P_SIGN_OVERFLOW 0x40 #define P_NEGATIVE 0x80 +#define NEGATIVE P_NEGATIVE + typedef struct reg_state reg_state_t; struct rk65c02emu {