mirror of
https://github.com/DavidBuchanan314/6502-emu.git
synced 2025-04-14 19:37:09 +00:00
Fixed memory wrapping in address-mode decoders
This commit is contained in:
parent
09f394cc45
commit
04e228bfef
14
6502.c
14
6502.c
@ -465,7 +465,7 @@ static void inst_TYA()
|
||||
|
||||
uint8_t * get_IMM()
|
||||
{
|
||||
return &memory[PC+1];
|
||||
return &memory[(uint16_t) (PC+1)];
|
||||
}
|
||||
|
||||
uint16_t get_uint16()
|
||||
@ -477,17 +477,17 @@ uint16_t get_uint16()
|
||||
|
||||
uint8_t * get_ZP()
|
||||
{
|
||||
return &memory[memory[PC+1]];
|
||||
return &memory[* get_IMM()];
|
||||
}
|
||||
|
||||
uint8_t * get_ZPX()
|
||||
{
|
||||
return &memory[(memory[PC+1] + X) & 0xFF];
|
||||
return &memory[((* get_IMM()) + X) & 0xFF];
|
||||
}
|
||||
|
||||
uint8_t * get_ZPY()
|
||||
{
|
||||
return &memory[(memory[PC+1] + Y) & 0xFF];
|
||||
return &memory[((* get_IMM()) + Y) & 0xFF];
|
||||
}
|
||||
|
||||
uint8_t * get_ACC()
|
||||
@ -502,12 +502,12 @@ uint8_t * get_ABS()
|
||||
|
||||
uint8_t * get_ABSX()
|
||||
{
|
||||
return &memory[get_uint16()+X];
|
||||
return &memory[(uint16_t) (get_uint16() + X)];
|
||||
}
|
||||
|
||||
uint8_t * get_ABSY()
|
||||
{
|
||||
return &memory[get_uint16()+Y];
|
||||
return &memory[(uint16_t) (get_uint16() + Y)];
|
||||
}
|
||||
|
||||
uint8_t * get_IND()
|
||||
@ -534,7 +534,7 @@ uint8_t * get_INDY()
|
||||
|
||||
uint8_t * get_REL()
|
||||
{
|
||||
return &memory[PC + (int8_t) memory[PC+1]];
|
||||
return &memory[(uint16_t) (PC + (int8_t) * get_IMM())];
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user