mirror of
https://github.com/toyoshim/Applerm-II.git
synced 2024-06-12 14:29:27 +00:00
Bug fix on shift operations that set a result to a wrong register
This commit is contained in:
parent
bc8b0b0906
commit
8d94c76d47
24
6502.S
24
6502.S
|
@ -9,6 +9,14 @@
|
||||||
.extern cpu6502_load
|
.extern cpu6502_load
|
||||||
.extern cpu6502_store
|
.extern cpu6502_store
|
||||||
|
|
||||||
|
.extern prn
|
||||||
|
.macro prn reg
|
||||||
|
push {r0-r3}
|
||||||
|
mov r0, \reg
|
||||||
|
bl prn
|
||||||
|
pop {r0-r3}
|
||||||
|
.endm
|
||||||
|
|
||||||
#define T0 r4
|
#define T0 r4
|
||||||
#define T1 r5
|
#define T1 r5
|
||||||
#define PC r6
|
#define PC r6
|
||||||
|
@ -363,11 +371,11 @@
|
||||||
bics r0, r0, r1
|
bics r0, r0, r1
|
||||||
__se FLAG_C
|
__se FLAG_C
|
||||||
1:
|
1:
|
||||||
lsls r0, r0, #1
|
lsls T0, r0, #1
|
||||||
bne 1f
|
bne 1f
|
||||||
__se FLAG_Z
|
__se FLAG_Z
|
||||||
1:
|
1:
|
||||||
tst r0, r1
|
tst T0, r1
|
||||||
beq 1f
|
beq 1f
|
||||||
__se FLAG_N
|
__se FLAG_N
|
||||||
1:
|
1:
|
||||||
|
@ -463,12 +471,12 @@
|
||||||
beq 1f
|
beq 1f
|
||||||
__se FLAG_C
|
__se FLAG_C
|
||||||
1:
|
1:
|
||||||
lsrs r0, r0, #1
|
lsrs T0, r0, #1
|
||||||
bne 1f
|
bne 1f
|
||||||
__se FLAG_Z
|
__se FLAG_Z
|
||||||
1:
|
1:
|
||||||
movs r1, #FLAG_N
|
movs r1, #FLAG_N
|
||||||
tst r0, r1
|
tst T0, r1
|
||||||
beq 1f
|
beq 1f
|
||||||
__se FLAG_N
|
__se FLAG_N
|
||||||
1:
|
1:
|
||||||
|
@ -490,11 +498,11 @@
|
||||||
1:
|
1:
|
||||||
lsls r0, r0, #1
|
lsls r0, r0, #1
|
||||||
uxtb r0, r0
|
uxtb r0, r0
|
||||||
adds r0, r0, r2
|
adds T0, r0, r2
|
||||||
bne 1f
|
bne 1f
|
||||||
__se FLAG_Z
|
__se FLAG_Z
|
||||||
1:
|
1:
|
||||||
tst r0, r1
|
tst T0, r1
|
||||||
beq 1f
|
beq 1f
|
||||||
__se FLAG_N
|
__se FLAG_N
|
||||||
1:
|
1:
|
||||||
|
@ -512,12 +520,12 @@
|
||||||
__se FLAG_C
|
__se FLAG_C
|
||||||
1:
|
1:
|
||||||
lsrs r0, r0, #1
|
lsrs r0, r0, #1
|
||||||
adds r0, r0, r2
|
adds T0, r0, r2
|
||||||
bne 1f
|
bne 1f
|
||||||
__se FLAG_Z
|
__se FLAG_Z
|
||||||
1:
|
1:
|
||||||
movs r1, #FLAG_N
|
movs r1, #FLAG_N
|
||||||
tst r0, r1
|
tst T0, r1
|
||||||
beq 1f
|
beq 1f
|
||||||
__se FLAG_N
|
__se FLAG_N
|
||||||
1:
|
1:
|
||||||
|
|
4
test.c
4
test.c
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
uint8_t mem[0x10000];
|
uint8_t mem[0x10000];
|
||||||
|
|
||||||
|
void prn(int c) {
|
||||||
|
printf("### $%02x ###\n", c);
|
||||||
|
}
|
||||||
|
|
||||||
void cpu6502_dump(
|
void cpu6502_dump(
|
||||||
uint16_t pc, uint8_t a, uint8_t x, uint8_t y, uint8_t sp, uint8_t sr) {
|
uint16_t pc, uint8_t a, uint8_t x, uint8_t y, uint8_t sp, uint8_t sr) {
|
||||||
printf("*** dump *** PC=$%04x A=$%02x X=$%02x Y=$%02x SP=$%02x "
|
printf("*** dump *** PC=$%04x A=$%02x X=$%02x Y=$%02x SP=$%02x "
|
||||||
|
|
Loading…
Reference in New Issue
Block a user