1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-12 10:30:23 +00:00

Introduce instruction-independent status adjustment functions.

For now only for negative and zero. Also use them in LDA emulation.
This commit is contained in:
Radosław Kujawa 2017-01-20 10:25:19 +01:00
parent 5201cfdc87
commit 3bcc7bb096
3 changed files with 22 additions and 10 deletions

View File

@ -10,16 +10,8 @@ emul_lda(rk65c02emu_t *e, instruction_t *i)
e->regs.A = instruction_data_read_1(e, &id, i); e->regs.A = instruction_data_read_1(e, &id, i);
/* adjust status flags */ instruction_status_adjust_zero(e->regs.A);
if (e->regs.A & NEGATIVE) instruction_status_adjust_negative(e->regs.A);
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 void

View File

@ -144,6 +144,24 @@ instruction_decode(uint8_t opcode)
return id; return id;
} }
void
instruction_status_adjust_zero(rk65c02emu_t *e, uint8_t regval)
{
if (regval == 0)
e->regs.P |= P_ZERO;
else
e->regs.P &= ~P_ZERO;
}
void
instruction_status_adjust_negative(rk65c02emu_t *e, uint8_t regval)
{
if (regval & NEGATIVE)
e->regs.P |= P_NEGATIVE;
else
e->regs.P &= ~P_NEGATIVE;
}
uint8_t uint8_t
instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i) instruction_data_read_1(rk65c02emu_t *e, instrdef_t *id, instruction_t *i)
{ {

View File

@ -44,6 +44,8 @@ instrdef_t instruction_decode(uint8_t);
void instruction_print(instruction_t *); void instruction_print(instruction_t *);
void disassemble(bus_t *, uint16_t); void disassemble(bus_t *, uint16_t);
uint8_t instruction_data_read_1(rk65c02emu_t *, instrdef_t *, instruction_t *); uint8_t instruction_data_read_1(rk65c02emu_t *, instrdef_t *, instruction_t *);
void instruction_status_adjust_zero(rk65c02emu_t *, uint8_t);
void instruction_status_adjust_negative(rk65c02emu_t *, uint8_t);
//void instruction_execute(rk65c02emu_t *, instruction_t *); //void instruction_execute(rk65c02emu_t *, instruction_t *);
#endif /* _INSTRUCTION_H_ */ #endif /* _INSTRUCTION_H_ */