1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-11-18 21:07:00 +00:00

Add ROL and ROR emulation. Too old to ror and to rol!

This commit is contained in:
Radosław Kujawa 2017-01-23 15:25:32 +01:00
parent f9708ca049
commit 0dd63f2bf0
2 changed files with 80 additions and 10 deletions

View File

@ -37,15 +37,15 @@ OP_NOPI_23,"nop",IMMEDIATE,2,NULL
OP_NOPI_24,"nop",IMPLIED,1,NULL
OP_BIT_ZP,"bit",ZP,2,NULL
OP_AND_ZP,"and",ZP,2,emul_and
OP_ROL_ZP,"rol",ZP,2,NULL
OP_ROL_ZP,"rol",ZP,2,emul_rol
OP_RMB2_ZP,"rmb2",ZP,2,NULL
OP_PLP,"plp",IMPLIED,1,emul_plp
OP_AND_IMM,"and",IMMEDIATE,2,emul_and
OP_ROL,"rol",ACCUMULATOR,1,NULL
OP_ROL,"rol",ACCUMULATOR,1,emul_rol
OP_NOPI_2C,"nop",IMPLIED,1,NULL
OP_BIT_ABS,"bit",ABSOLUTE,3,NULL
OP_AND_ABS,"and",ABSOLUTE,3,NULL
OP_ROL_ABS,"rol",ABSOLUTE,3,NULL
OP_ROL_ABS,"rol",ABSOLUTE,3,emul_rol
OP_BBR2_REL,"bbr2",ZPR,2,NULL
OP_BMI_REL,"bmi",RELATIVE,2,NULL
OP_AND_IZPY,"and",IZPY,2,NULL
@ -53,7 +53,7 @@ OP_AND_IZP,"and",IZP,2,NULL
OP_NOPI_34,"nop",IMPLIED,1,NULL
OP_BIT_ZPX,"bit",ZPX,2,NULL
OP_AND_ZPX,"and",ZPX,2,NULL
OP_ROL_ZPX,"rol",ZPX,2,NULL
OP_ROL_ZPX,"rol",ZPX,2,emul_rol
OP_RMB3_ZP,"rmb3",ZP,2,NULL
OP_SEC,"sec",IMPLIED,1,emul_sec
OP_AND_ABSY,"and",ABSOLUTEY,3,NULL
@ -61,7 +61,7 @@ OP_DEC,"dec",ACCUMULATOR,1,NULL
OP_NOPI_3C,"nop",IMPLIED,1,NULL
OP_BIT_ABSX,"bit",ABSOLUTEX,3,NULL
OP_AND_ABSX,"and",ABSOLUTEX,3,NULL
OP_ROL_ABSX,"rol",ABSOLUTEX,3,NULL
OP_ROL_ABSX,"rol",ABSOLUTEX,3,emul_rol
OP_BBR3_REL,"bbr3",ZPR,2,NULL
OP_RTI,"rti",IMPLIED,1,NULL
OP_EOR_IZPX,"eor",IZPX,2,emul_eor
@ -101,15 +101,15 @@ OP_NOPI_63,"nop",IMMEDIATE,2,NULL
OP_NOPI_64,"nop",IMPLIED,1,NULL
OP_STZ_ZP,"stz",ZP,2,emul_stz
OP_ADC_ZP,"adc",ZP,2,NULL
OP_ROR_ZP,"ror",ZP,2,NULL
OP_ROR_ZP,"ror",ZP,2,emul_ror
OP_RMB6_ZP,"rmb6",ZP,2,NULL
OP_PLA,"pla",IMPLIED,1,emul_pla
OP_ADC_IMM,"adc",IMMEDIATE,2,NULL
OP_ROR,"ror",ACCUMULATOR,1,NULL
OP_ROR,"ror",ACCUMULATOR,1,emul_ror
OP_NOPI_6C,"nop",IMPLIED,1,NULL
OP_JMP_IABS,"jmp",IABSOLUTE,3,NULL
OP_ADC_ABS,"adc",ABSOLUTE,3,NULL
OP_ROR_ABS,"ror",ABSOLUTE,3,NULL
OP_ROR_ABS,"ror",ABSOLUTE,3,emul_ror
OP_BBR6_REL,"bbr6",ZPR,2,NULL
OP_BVS_REL,"bvs",RELATIVE,2,NULL
OP_ADC_IZPY,"adc",IZPY,2,NULL
@ -117,7 +117,7 @@ OP_ADC_IZP,"adc",IZP,2,NULL
OP_NOPI_74,"nop",IMPLIED,1,NULL
OP_STZ_ZPX,"stz",ZPX,2,emul_stz
OP_ADC_ZPX,"adc",ZPX,2,NULL
OP_ROR_ZPX,"ror",ZPX,2,NULL
OP_ROR_ZPX,"ror",ZPX,2,emul_ror
OP_RMB7_ZP,"rmb7",ZP,2,NULL
OP_SEI,"sei",IMPLIED,1,NULL
OP_ADC_ABSY,"adc",ABSOLUTEY,3,NULL
@ -125,7 +125,7 @@ OP_PLY,"ply",IMPLIED,1,NULL
OP_NOPI_7C,"nop",IMPLIED,1,NULL
OP_JMP_IABSX,"jmp",IABSOLUTEX,3,NULL
OP_ADC_ABSX,"adc",ABSOLUTEX,3,NULL
OP_ROR_ABSX,"ror",ABSOLUTEX,3,NULL
OP_ROR_ABSX,"ror",ABSOLUTEX,3,emul_ror
OP_BBR7_REL,"bbr7",ZPR,2,NULL
OP_BRA_REL,"bra",RELATIVE,2,NULL
OP_STA_IZPX,"sta",IZPX,2,emul_sta

1 opcode_id mnemonic addressing size emulation
37 OP_NOPI_24 nop IMPLIED 1 NULL
38 OP_BIT_ZP bit ZP 2 NULL
39 OP_AND_ZP and ZP 2 emul_and
40 OP_ROL_ZP rol ZP 2 NULL emul_rol
41 OP_RMB2_ZP rmb2 ZP 2 NULL
42 OP_PLP plp IMPLIED 1 emul_plp
43 OP_AND_IMM and IMMEDIATE 2 emul_and
44 OP_ROL rol ACCUMULATOR 1 NULL emul_rol
45 OP_NOPI_2C nop IMPLIED 1 NULL
46 OP_BIT_ABS bit ABSOLUTE 3 NULL
47 OP_AND_ABS and ABSOLUTE 3 NULL
48 OP_ROL_ABS rol ABSOLUTE 3 NULL emul_rol
49 OP_BBR2_REL bbr2 ZPR 2 NULL
50 OP_BMI_REL bmi RELATIVE 2 NULL
51 OP_AND_IZPY and IZPY 2 NULL
53 OP_NOPI_34 nop IMPLIED 1 NULL
54 OP_BIT_ZPX bit ZPX 2 NULL
55 OP_AND_ZPX and ZPX 2 NULL
56 OP_ROL_ZPX rol ZPX 2 NULL emul_rol
57 OP_RMB3_ZP rmb3 ZP 2 NULL
58 OP_SEC sec IMPLIED 1 emul_sec
59 OP_AND_ABSY and ABSOLUTEY 3 NULL
61 OP_NOPI_3C nop IMPLIED 1 NULL
62 OP_BIT_ABSX bit ABSOLUTEX 3 NULL
63 OP_AND_ABSX and ABSOLUTEX 3 NULL
64 OP_ROL_ABSX rol ABSOLUTEX 3 NULL emul_rol
65 OP_BBR3_REL bbr3 ZPR 2 NULL
66 OP_RTI rti IMPLIED 1 NULL
67 OP_EOR_IZPX eor IZPX 2 emul_eor
101 OP_NOPI_64 nop IMPLIED 1 NULL
102 OP_STZ_ZP stz ZP 2 emul_stz
103 OP_ADC_ZP adc ZP 2 NULL
104 OP_ROR_ZP ror ZP 2 NULL emul_ror
105 OP_RMB6_ZP rmb6 ZP 2 NULL
106 OP_PLA pla IMPLIED 1 emul_pla
107 OP_ADC_IMM adc IMMEDIATE 2 NULL
108 OP_ROR ror ACCUMULATOR 1 NULL emul_ror
109 OP_NOPI_6C nop IMPLIED 1 NULL
110 OP_JMP_IABS jmp IABSOLUTE 3 NULL
111 OP_ADC_ABS adc ABSOLUTE 3 NULL
112 OP_ROR_ABS ror ABSOLUTE 3 NULL emul_ror
113 OP_BBR6_REL bbr6 ZPR 2 NULL
114 OP_BVS_REL bvs RELATIVE 2 NULL
115 OP_ADC_IZPY adc IZPY 2 NULL
117 OP_NOPI_74 nop IMPLIED 1 NULL
118 OP_STZ_ZPX stz ZPX 2 emul_stz
119 OP_ADC_ZPX adc ZPX 2 NULL
120 OP_ROR_ZPX ror ZPX 2 NULL emul_ror
121 OP_RMB7_ZP rmb7 ZP 2 NULL
122 OP_SEI sei IMPLIED 1 NULL
123 OP_ADC_ABSY adc ABSOLUTEY 3 NULL
125 OP_NOPI_7C nop IMPLIED 1 NULL
126 OP_JMP_IABSX jmp IABSOLUTEX 3 NULL
127 OP_ADC_ABSX adc ABSOLUTEX 3 NULL
128 OP_ROR_ABSX ror ABSOLUTEX 3 NULL emul_ror
129 OP_BBR7_REL bbr7 ZPR 2 NULL
130 OP_BRA_REL bra RELATIVE 2 NULL
131 OP_STA_IZPX sta IZPX 2 emul_sta

View File

@ -146,6 +146,76 @@ emul_plp(rk65c02emu_t *e, void *id, instruction_t *i)
e->regs.P = stack_pop(e) | P_UNDEFINED;
}
/* ROL - rotate left */
void
emul_rol(rk65c02emu_t *e, void *id, instruction_t *i)
{
bool ncarry;
uint8_t val;
ncarry = false;
val = instruction_data_read_1(e, (instrdef_t *) id, i);
/* new carry flag value equals contents of bit 7 */
if (val & 0x80)
ncarry = true;
/* shift left by one bit */
val <<= 1;
/* bit 0 is set from current value of carry flag */
if (e->regs.P & P_CARRY)
val |= 0x1;
else
val &= ~0x1;
if (ncarry)
e->regs.P |= P_CARRY;
else
e->regs.P &= ~P_CARRY;
instruction_status_adjust_zero(e, val);
instruction_status_adjust_negative(e, val);
instruction_data_write_1(e, (instrdef_t *) id, i, val);
}
/* ROR - rotate right */
void
emul_ror(rk65c02emu_t *e, void *id, instruction_t *i)
{
bool ncarry;
uint8_t val;
ncarry = false;
val = instruction_data_read_1(e, (instrdef_t *) id, i);
/* new carry flag value equals contents of bit 0 */
if (val & 0x1)
ncarry = true;
/* shift right by one bit */
val >>= 1;
/* bit 7 is set from current value of carry flag */
if (e->regs.P & P_CARRY)
val |= 0x80;
else
val &= ~0x80;
if (ncarry)
e->regs.P |= P_CARRY;
else
e->regs.P &= ~P_CARRY;
instruction_status_adjust_zero(e, val);
instruction_status_adjust_negative(e, val);
instruction_data_write_1(e, (instrdef_t *) id, i, val);
}
/* SEC - set the carry flag */
void
emul_sec(rk65c02emu_t *e, void *id, instruction_t *i)