mirror of
https://github.com/cc65/cc65.git
synced 2025-01-12 02:30:44 +00:00
Merge pull request #2573 from sidneycadot/fix-6502x-illegals
sim65: properly implement 5 'illegal' 6502X opcodes.
This commit is contained in:
commit
07b168e062
@ -2718,7 +2718,20 @@ static void OPC_65SC02_92 (void)
|
||||
static void OPC_6502_93 (void)
|
||||
/* Opcode $93: SHA (zp),y */
|
||||
{
|
||||
STO_CB (ZPINDY, SHA);
|
||||
++Regs.PC;
|
||||
uint8_t zp_ptr_lo = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t zp_ptr_hi = zp_ptr_lo + 1;
|
||||
uint8_t baselo = MemReadByte(zp_ptr_lo);
|
||||
uint8_t basehi = MemReadByte(zp_ptr_hi);
|
||||
uint8_t basehi_incremented = basehi + 1;
|
||||
uint8_t write_value = Regs.AC & Regs.XR & basehi_incremented;
|
||||
uint8_t write_address_lo = (baselo + Regs.YR);
|
||||
bool pagecross = (baselo + Regs.YR) > 0xff;
|
||||
uint8_t write_address_hi = pagecross ? write_value : basehi;
|
||||
uint16_t write_address = write_address_lo + (write_address_hi << 8);
|
||||
MemWriteByte(write_address, write_value);
|
||||
Cycles=6;
|
||||
}
|
||||
|
||||
|
||||
@ -2796,7 +2809,20 @@ static void OPC_6502_9A (void)
|
||||
static void OPC_6502_9B (void)
|
||||
/* Opcode $9B: TAS abs,y */
|
||||
{
|
||||
STO_CB (ABSY, TAS);
|
||||
++Regs.PC;
|
||||
uint8_t baselo = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi_incremented = basehi + 1;
|
||||
uint8_t write_value = Regs.AC & Regs.XR & basehi_incremented;
|
||||
uint8_t write_address_lo = (baselo + Regs.YR);
|
||||
bool pagecross = (baselo + Regs.YR) > 0xff;
|
||||
uint8_t write_address_hi = pagecross ? write_value : basehi;
|
||||
uint16_t write_address = write_address_lo + (write_address_hi << 8);
|
||||
MemWriteByte(write_address, write_value);
|
||||
Regs.SP = Regs.AC & Regs.XR;
|
||||
Cycles=5;
|
||||
}
|
||||
|
||||
|
||||
@ -2804,7 +2830,19 @@ static void OPC_6502_9B (void)
|
||||
static void OPC_6502_9C (void)
|
||||
/* Opcode $9D: SHY abs,x */
|
||||
{
|
||||
STO_OP (ABSX, Regs.YR & ((address >> 8) + 1));
|
||||
++Regs.PC;
|
||||
uint8_t baselo = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi_incremented = basehi + 1;
|
||||
uint8_t write_value = Regs.YR & basehi_incremented;
|
||||
uint8_t write_address_lo = (baselo + Regs.XR);
|
||||
bool pagecross = (baselo + Regs.XR) > 0xff;
|
||||
uint8_t write_address_hi = pagecross ? write_value : basehi;
|
||||
uint16_t write_address = write_address_lo + (write_address_hi << 8);
|
||||
MemWriteByte(write_address, write_value);
|
||||
Cycles=5;
|
||||
}
|
||||
|
||||
|
||||
@ -2828,7 +2866,19 @@ static void OPC_6502_9D (void)
|
||||
static void OPC_6502_9E (void)
|
||||
/* Opcode $9E: SHX abs,x */
|
||||
{
|
||||
STO_OP (ABSY, Regs.XR & ((address >> 8) + 1));
|
||||
++Regs.PC;
|
||||
uint8_t baselo = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi_incremented = basehi + 1;
|
||||
uint8_t write_value = Regs.XR & basehi_incremented;
|
||||
uint8_t write_address_lo = (baselo + Regs.YR);
|
||||
bool pagecross = (baselo + Regs.YR) > 0xff;
|
||||
uint8_t write_address_hi = pagecross ? write_value : basehi;
|
||||
uint16_t write_address = write_address_lo + (write_address_hi << 8);
|
||||
MemWriteByte(write_address, write_value);
|
||||
Cycles=5;
|
||||
}
|
||||
|
||||
|
||||
@ -2844,7 +2894,19 @@ static void OPC_65SC02_9E (void)
|
||||
static void OPC_6502_9F (void)
|
||||
/* Opcode $9F: SHA abs,y */
|
||||
{
|
||||
STO_CB (ABSY, SHA);
|
||||
++Regs.PC;
|
||||
uint8_t baselo = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi = MemReadByte(Regs.PC);
|
||||
++Regs.PC;
|
||||
uint8_t basehi_incremented = basehi + 1;
|
||||
uint8_t write_value = Regs.AC & Regs.XR & basehi_incremented;
|
||||
uint8_t write_address_lo = (baselo + Regs.YR);
|
||||
bool pagecross = (baselo + Regs.YR) > 0xff;
|
||||
uint8_t write_address_hi = pagecross ? write_value : basehi;
|
||||
uint16_t write_address = write_address_lo + (write_address_hi << 8);
|
||||
MemWriteByte(write_address, write_value);
|
||||
Cycles=5;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user