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

Add emulation of LDX, TXA, TYA, TXS, TAX, TAY, TSX.

This commit is contained in:
Radosław Kujawa 2017-01-23 14:38:50 +01:00
parent 3b2080403b
commit 5c38e5f05a
2 changed files with 78 additions and 11 deletions

View File

@ -137,7 +137,7 @@ OP_STX_ZP,"stx",ZP,2,NULL
OP_SMB0_ZP,"smb0",ZP,2,NULL
OP_DEY,"dey",IMPLIED,1,emul_dey
OP_BIT_IMM,"bit",IMMEDIATE,2,NULL
OP_TXA,"txa",IMPLIED,1,NULL
OP_TXA,"txa",IMPLIED,1,emul_txa
OP_NOPI_8C,"nop",IMPLIED,1,NULL
OP_STY_ABS,"sty",ABSOLUTE,3,NULL
OP_STA_ABS,"sta",ABSOLUTE,3,NULL
@ -151,9 +151,9 @@ OP_STY_ZPX,"sty",ZPX,2,NULL
OP_STA_ZPX,"sta",ZPX,2,NULL
OP_STX_ZPY,"stx",ZPY,2,NULL
OP_SMB1_ZP,"smb1",ZP,2,NULL
OP_TYA,"tya",IMPLIED,1,NULL
OP_TYA,"tya",IMPLIED,1,emul_tya
OP_STA_ABSY,"sta",ABSOLUTEY,3,NULL
OP_TXS,"txs",IMPLIED,1,NULL
OP_TXS,"txs",IMPLIED,1,emul_txs
OP_NOPI_9C,"nop",IMPLIED,1,NULL
OP_STZ_ABS,"stz",ABSOLUTE,3,emul_stz
OP_STA_ABSX,"sta",ABSOLUTEX,3,NULL
@ -161,19 +161,19 @@ OP_STZ_ABSX,"stz",ABSOLUTEX,3,emul_stz
OP_BBS1_REL,"bbs1",ZPR,2,NULL
OP_LDY_IMM,"ldy",IMMEDIATE,2,NULL
OP_LDA_IZPX,"lda",IZPX,2,emul_lda
OP_LDX_IMM,"ldx",IMMEDIATE,2,NULL
OP_LDX_IMM,"ldx",IMMEDIATE,2,emul_ldx
OP_NOPI_A4,"nop",IMPLIED,1,NULL
OP_LDY_ZP,"ldy",ZP,2,NULL
OP_LDA_ZP,"lda",ZP,2,emul_lda
OP_LDX_ZP,"ldx",ZP,2,NULL
OP_LDX_ZP,"ldx",ZP,2,emul_ldx
OP_SMB2_ZP,"smb2",ZP,2,NULL
OP_TAY,"tay",IMPLIED,1,NULL
OP_TAY,"tay",IMPLIED,1,emul_tay
OP_LDA_IMM,"lda",IMMEDIATE,2,emul_lda
OP_TAX,"tax",IMPLIED,1,NULL
OP_TAX,"tax",IMPLIED,1,emul_tax
OP_NOPI_AC,"nop",IMPLIED,1,NULL
OP_LDY_ABS,"ldy",ABSOLUTE,3,NULL
OP_LDA_ABS,"lda",ABSOLUTE,3,emul_lda
OP_LDX_ABS,"ldx",ABSOLUTE,3,NULL
OP_LDX_ABS,"ldx",ABSOLUTE,3,emul_ldx
OP_BBS2_REL,"bbs2",ZPR,2,NULL
OP_BCS_REL,"bcs",RELATIVE,2,NULL
OP_LDA_IZPY,"lda",IZPY,2,emul_lda
@ -181,15 +181,15 @@ OP_LDA_IZP,"lda",IZP,2,emul_lda
OP_NOPI_B4,"nop",IMPLIED,1,NULL
OP_LDY_ZPX,"ldy",ZPX,2,NULL
OP_LDA_ZPX,"lda",ZPX,2,emul_lda
OP_LDX_ZPY,"ldx",ZPY,1,NULL
OP_LDX_ZPY,"ldx",ZPY,1,emul_ldx
OP_SMB3_ZP,"smb3",ZP,2,NULL
OP_CLV,"clv",IMPLIED,1,NULL
OP_LDA_ABSY,"lda",ABSOLUTEY,3,emul_lda
OP_TSX,"tsx",IMPLIED,1,NULL
OP_TSX,"tsx",IMPLIED,1,emul_tsx
OP_NOPI_BC,"nop",IMPLIED,1,NULL
OP_LDY_ABSX,"ldy",ABSOLUTEX,3,NULL
OP_LDA_ABSX,"lda",ABSOLUTEX,3,emul_lda
OP_LDX_ABSY,"ldx",ABSOLUTEY,3,NULL
OP_LDX_ABSY,"ldx",ABSOLUTEY,3,emul_ldx
OP_BBS3_REL,"bbs3",ZPR,2,NULL
OP_CPY_IMM,"cpy",IMMEDIATE,2,NULL
OP_CMP_IZPX,"cmp",IZPX,2,NULL

1 opcode_id mnemonic addressing size emulation
137 OP_SMB0_ZP smb0 ZP 2 NULL
138 OP_DEY dey IMPLIED 1 emul_dey
139 OP_BIT_IMM bit IMMEDIATE 2 NULL
140 OP_TXA txa IMPLIED 1 NULL emul_txa
141 OP_NOPI_8C nop IMPLIED 1 NULL
142 OP_STY_ABS sty ABSOLUTE 3 NULL
143 OP_STA_ABS sta ABSOLUTE 3 NULL
151 OP_STA_ZPX sta ZPX 2 NULL
152 OP_STX_ZPY stx ZPY 2 NULL
153 OP_SMB1_ZP smb1 ZP 2 NULL
154 OP_TYA tya IMPLIED 1 NULL emul_tya
155 OP_STA_ABSY sta ABSOLUTEY 3 NULL
156 OP_TXS txs IMPLIED 1 NULL emul_txs
157 OP_NOPI_9C nop IMPLIED 1 NULL
158 OP_STZ_ABS stz ABSOLUTE 3 emul_stz
159 OP_STA_ABSX sta ABSOLUTEX 3 NULL
161 OP_BBS1_REL bbs1 ZPR 2 NULL
162 OP_LDY_IMM ldy IMMEDIATE 2 NULL
163 OP_LDA_IZPX lda IZPX 2 emul_lda
164 OP_LDX_IMM ldx IMMEDIATE 2 NULL emul_ldx
165 OP_NOPI_A4 nop IMPLIED 1 NULL
166 OP_LDY_ZP ldy ZP 2 NULL
167 OP_LDA_ZP lda ZP 2 emul_lda
168 OP_LDX_ZP ldx ZP 2 NULL emul_ldx
169 OP_SMB2_ZP smb2 ZP 2 NULL
170 OP_TAY tay IMPLIED 1 NULL emul_tay
171 OP_LDA_IMM lda IMMEDIATE 2 emul_lda
172 OP_TAX tax IMPLIED 1 NULL emul_tax
173 OP_NOPI_AC nop IMPLIED 1 NULL
174 OP_LDY_ABS ldy ABSOLUTE 3 NULL
175 OP_LDA_ABS lda ABSOLUTE 3 emul_lda
176 OP_LDX_ABS ldx ABSOLUTE 3 NULL emul_ldx
177 OP_BBS2_REL bbs2 ZPR 2 NULL
178 OP_BCS_REL bcs RELATIVE 2 NULL
179 OP_LDA_IZPY lda IZPY 2 emul_lda
181 OP_NOPI_B4 nop IMPLIED 1 NULL
182 OP_LDY_ZPX ldy ZPX 2 NULL
183 OP_LDA_ZPX lda ZPX 2 emul_lda
184 OP_LDX_ZPY ldx ZPY 1 NULL emul_ldx
185 OP_SMB3_ZP smb3 ZP 2 NULL
186 OP_CLV clv IMPLIED 1 NULL
187 OP_LDA_ABSY lda ABSOLUTEY 3 emul_lda
188 OP_TSX tsx IMPLIED 1 NULL emul_tsx
189 OP_NOPI_BC nop IMPLIED 1 NULL
190 OP_LDY_ABSX ldy ABSOLUTEX 3 NULL
191 OP_LDA_ABSX lda ABSOLUTEX 3 emul_lda
192 OP_LDX_ABSY ldx ABSOLUTEY 3 NULL emul_ldx
193 OP_BBS3_REL bbs3 ZPR 2 NULL
194 OP_CPY_IMM cpy IMMEDIATE 2 NULL
195 OP_CMP_IZPX cmp IZPX 2 NULL

View File

@ -72,6 +72,16 @@ emul_lda(rk65c02emu_t *e, void *id, instruction_t *i)
instruction_status_adjust_negative(e, e->regs.A);
}
/* LDX - load to X */
void
emul_ldx(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.X = instruction_data_read_1(e, (instrdef_t *) id, i);
instruction_status_adjust_zero(e, e->regs.X);
instruction_status_adjust_negative(e, e->regs.X);
}
/* NOP - do nothing */
void
emul_nop(rk65c02emu_t *e, void *id, instruction_t *i)
@ -130,3 +140,60 @@ emul_stz(rk65c02emu_t *e, void *id, instruction_t *i)
instruction_data_write_1(e, id, i, 0);
}
/* TAX - transfer accumulator to X */
void
emul_tax(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.X = e->regs.A;
instruction_status_adjust_zero(e, e->regs.X);
instruction_status_adjust_negative(e, e->regs.X);
}
/* TAY - transfer accumulator to Y */
void
emul_tay(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.Y = e->regs.A;
instruction_status_adjust_zero(e, e->regs.Y);
instruction_status_adjust_negative(e, e->regs.Y);
}
/* TSX - transfer stack pointer to X */
void
emul_tsx(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.X = e->regs.SP;
instruction_status_adjust_zero(e, e->regs.X);
instruction_status_adjust_negative(e, e->regs.X);
}
/* TXA - transfer X to accumulator */
void
emul_txa(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.A = e->regs.X;
instruction_status_adjust_zero(e, e->regs.A);
instruction_status_adjust_negative(e, e->regs.A);
}
/* TXS - transfer X to stack pointer */
void
emul_txs(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.SP = e->regs.X;
}
/* TYA - transfer Y to accumulator */
void
emul_tya(rk65c02emu_t *e, void *id, instruction_t *i)
{
e->regs.A = e->regs.Y;
instruction_status_adjust_zero(e, e->regs.A);
instruction_status_adjust_negative(e, e->regs.A);
}