mirror of
https://github.com/toyoshim/Applerm-II.git
synced 2024-06-12 14:29:27 +00:00
Use 6502_65C02_functional_tests, and two bug fixes
- transfer operations should update n and z flags - TSX should transfer SP, not SR
This commit is contained in:
parent
1f39658a0b
commit
d0ad06c86a
8
6502.S
8
6502.S
|
@ -645,7 +645,9 @@
|
|||
.endm
|
||||
|
||||
.macro _t from to
|
||||
mov \to, \from
|
||||
mov r0, \from
|
||||
mov \to, r0
|
||||
_flag_nz
|
||||
adds PC, PC, #1
|
||||
.endm
|
||||
|
||||
|
@ -1369,7 +1371,7 @@ opb9: // LDA - Absolute, Y
|
|||
_decode
|
||||
|
||||
opba: // TSX
|
||||
_t SR, RX
|
||||
_t SP, RX
|
||||
_decode
|
||||
|
||||
opbc: // LDY - Absolute, X
|
||||
|
@ -1913,6 +1915,8 @@ op_table:
|
|||
.long opff
|
||||
|
||||
.bss
|
||||
.global cpu6502_pc
|
||||
cpu6502_pc:
|
||||
r_pc: .long 0
|
||||
r_a: .long 0
|
||||
r_x: .long 0
|
||||
|
|
9
Makefile
9
Makefile
|
@ -11,6 +11,7 @@ SPEED = 115200
|
|||
#SPEED = 9600
|
||||
CLOCK = 12000
|
||||
ROM = applebasic
|
||||
//ROM = apple2o
|
||||
ROMOBJ = $(ROM).o
|
||||
ROMFLAG = -I binary -O elf32-littlearm -B arm --rename-section .data=.rodata
|
||||
FRAMEPTR= -fomit-frame-pointer
|
||||
|
@ -40,7 +41,13 @@ $(ROM).rom:
|
|||
|
||||
# Test binary that runs on qemu user mode emulation for testing
|
||||
test: 6502.S test.c
|
||||
$(CC) -mthumb -static $(FRAMEPTR) test.c 6502.S -o test && qemu-arm test
|
||||
$(CC) -mthumb -static $(FRAMEPTR) test.c 6502.S -o test && \
|
||||
qemu-arm test
|
||||
|
||||
# Test binary that runs on qemu user mode emulation for functional tests
|
||||
ftest: 6502.S ftest.c
|
||||
$(CC) -mthumb -static $(FRAMEPTR) ftest.c 6502.S -o ftest && \
|
||||
qemu-arm ftest
|
||||
|
||||
# Assume a CQ Mary comaptible board.
|
||||
run: $(APP).bin
|
||||
|
|
58
ftest.c
Normal file
58
ftest.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static uint8_t mem[0x10000];
|
||||
extern uint32_t cpu6502_pc;
|
||||
|
||||
void prn(int c) {
|
||||
uint8_t fp;
|
||||
__asm__("movs %0, r12": "=r"(fp));
|
||||
fprintf(stderr, "### $%02x ###\n", c);
|
||||
fflush(stderr);
|
||||
__asm__("movs r12, %0":: "r"(fp));
|
||||
}
|
||||
|
||||
void cpu6502_dump(
|
||||
uint16_t pc, uint8_t a, uint8_t x, uint8_t y, uint8_t sp, uint8_t sr) {
|
||||
uint8_t fp;
|
||||
__asm__("movs %0, r12": "=r"(fp));
|
||||
fprintf(stderr, "*** dump *** PC=$%04x A=$%02x X=$%02x Y=$%02x SP=$%02x "
|
||||
"NV-B_DIZC=%d%d-%d_%d%d%d%d\n",
|
||||
pc, a, x, y, sp, (sr >> 7) & 1, (sr >> 6) & 1, (sr >> 4) & 1,
|
||||
(sr >> 3) & 1, (sr >> 2) & 1, (sr >> 1) & 1, sr & 1);
|
||||
fflush(stderr);
|
||||
__asm__("movs r12, %0":: "r"(fp));
|
||||
}
|
||||
|
||||
uint8_t cpu6502_load(uint16_t addr) {
|
||||
uint8_t fp;
|
||||
uint8_t result = 0;
|
||||
__asm__("movs %0, r12": "=r"(fp));
|
||||
result = mem[addr];
|
||||
fprintf(stderr, "load $%04x => $%02x\n", addr, result);
|
||||
fflush(stderr);
|
||||
__asm__("movs r12, %0":: "r"(fp));
|
||||
return result;
|
||||
}
|
||||
|
||||
void cpu6502_store(uint16_t addr, uint8_t data) {
|
||||
uint8_t fp;
|
||||
__asm__("movs %0, r12": "=r"(fp));
|
||||
mem[addr] = data;
|
||||
fprintf(stderr, "store $%04x <= $%02x\n", addr, data);
|
||||
fflush(stderr);
|
||||
__asm__("movs r12, %0":: "r"(fp));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
FILE* fp = fopen("6502_functional_test.bin", "rb");
|
||||
fread(mem, 1, 0x10000, fp);
|
||||
fclose(fp);
|
||||
cpu6502_reset();
|
||||
cpu6502_pc = 0x400;
|
||||
fprintf(stderr, "quit: $%04x\n", cpu6502_run());
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user