Implement I/O for lpc1114
Now Apple BASIC can run on the LPC1114 device :)
This commit is contained in:
parent
826647fb93
commit
02c08505eb
2
6502.S
2
6502.S
|
@ -158,7 +158,9 @@
|
|||
.endm
|
||||
|
||||
.macro _decode
|
||||
#ifdef DUMP
|
||||
bl dump
|
||||
#endif
|
||||
mov r0, PC
|
||||
_ldb
|
||||
lsls r1, r0, #2
|
||||
|
|
4
Makefile
4
Makefile
|
@ -41,11 +41,11 @@ $(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 2> /dev/null
|
||||
$(CC) -mthumb -static $(FRAMEPTR) -DDUMP test.c 6502.S -o test && qemu-arm test 2> /dev/null
|
||||
|
||||
# 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 2> flog
|
||||
$(CC) -mthumb -static $(FRAMEPTR) -DDUMP ftest.c 6502.S -o ftest && qemu-arm ftest 2> flog
|
||||
|
||||
# Assume a CQ Mary comaptible board.
|
||||
run: $(APP).bin
|
||||
|
|
123
apple2.S
123
apple2.S
|
@ -5,6 +5,7 @@
|
|||
.thumb_func
|
||||
|
||||
.extern basic_rom
|
||||
.extern uart_putd
|
||||
|
||||
.section .rodata
|
||||
dump0:
|
||||
|
@ -19,6 +20,8 @@ dump4:
|
|||
.ascii " SP=$\000"
|
||||
dump5:
|
||||
.ascii " NV-B_DIZC=\000"
|
||||
ascii:
|
||||
.ascii "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?"
|
||||
|
||||
.text
|
||||
.global cpu6502_dump
|
||||
|
@ -90,26 +93,128 @@ cpu6502_dump:
|
|||
.global cpu6502_load
|
||||
.type cpu6502_load, %function
|
||||
cpu6502_load:
|
||||
movs r1, r0
|
||||
movs r2, r0
|
||||
lsrs r0, #8
|
||||
movs r2, #0xd0
|
||||
cmps r0, r2
|
||||
cmp r0, #0xd0
|
||||
bhs 1f
|
||||
// TODO: Load from RAM
|
||||
movs r0, #0
|
||||
cmp r0, #0x04
|
||||
blo 2f
|
||||
cmp r0, #0x08
|
||||
blo 3f
|
||||
cmp r0, #0xc0
|
||||
bhs 4f
|
||||
// Load from Fake RAM (0x0800-0xbfff)
|
||||
ldr r0, =#ramfake
|
||||
ldrb r0, [r0]
|
||||
mov pc, lr
|
||||
1:
|
||||
// Load from ROM (0xd000-0xffff)
|
||||
lsls r2, #8
|
||||
subs r1, r1, r2
|
||||
movs r0, #0xd0
|
||||
lsls r0, #8
|
||||
subs r2, r2, r0
|
||||
ldr r0, =#basic_rom
|
||||
adds r0, r0, r1
|
||||
adds r0, r0, r2
|
||||
ldrb r0, [r0]
|
||||
mov pc, lr
|
||||
2:
|
||||
// Load from RAM (0x0000-0x03ff)
|
||||
ldr r0, =#ram0000
|
||||
adds r0, r0, r2
|
||||
ldrb r0, [r0]
|
||||
mov pc, lr
|
||||
3:
|
||||
// Load from VRAM (0x0400-0x07ff)
|
||||
movs r0, #0xff
|
||||
mov pc, lr
|
||||
4:
|
||||
// Load from I/O (0xc000-0xcfff)
|
||||
movs r0, #0
|
||||
mov pc, lr
|
||||
|
||||
.global cpu6502_store
|
||||
.type cpu6502_store, %function
|
||||
cpu6502_store:
|
||||
// TODO
|
||||
movs r2, r0
|
||||
lsrs r0, #8
|
||||
cmp r0, #0xd0
|
||||
bhs 1f
|
||||
cmp r0, #0x04
|
||||
blo 2f
|
||||
cmp r0, #0x08
|
||||
blo 3f
|
||||
cmp r0, #0xc0
|
||||
bhs 4f
|
||||
// Store to Fake RAM (0x0800-0xbfff)
|
||||
ldr r0, =#ramfake
|
||||
strb r1, [r0]
|
||||
mov pc, lr
|
||||
1:
|
||||
// Store to ROM (0xd000-0xffff)
|
||||
mov pc, lr
|
||||
2:
|
||||
// Store to RAM (0x0000-0x0400)
|
||||
ldr r0, =#ram0000
|
||||
adds r0, r0, r2
|
||||
strb r1, [r0]
|
||||
mov pc, lr
|
||||
3:
|
||||
// Store to VRAM (0x0400-0x07ff)
|
||||
cmp r1, #0x7f
|
||||
bne 1f
|
||||
mov pc, lr
|
||||
1:
|
||||
push {lr}
|
||||
push {r1-r2}
|
||||
movs r0, #0x1b
|
||||
bl uart_putc
|
||||
movs r0, #'['
|
||||
bl uart_putc
|
||||
pop {r1-r2}
|
||||
movs r3, #0x04
|
||||
lsls r3, r3, #8
|
||||
subs r3, r2, r3
|
||||
movs r2, r3
|
||||
movs r0, #0x7f
|
||||
ands r2, r2, r0
|
||||
lsrs r3, r3, #7
|
||||
cmp r2, #0x50
|
||||
blo 1f
|
||||
subs r2, r2, #0x50
|
||||
adds r3, r3, #0x10
|
||||
1:
|
||||
cmp r2, #0x28
|
||||
blo 1f
|
||||
subs r2, r2, #0x28
|
||||
adds r3, r3, #0x08
|
||||
1:
|
||||
mov r0, r3
|
||||
adds r0, r0, #1
|
||||
push {r1-r2}
|
||||
bl uart_putd
|
||||
movs r0, #';'
|
||||
bl uart_putc
|
||||
pop {r1-r2}
|
||||
mov r0, r2
|
||||
adds r0, r0, #1
|
||||
push {r1}
|
||||
bl uart_putd
|
||||
movs r0, #'H'
|
||||
bl uart_putc
|
||||
pop {r1}
|
||||
ldr r2, =#ascii
|
||||
movs r3, #0x3f
|
||||
ands r3, r1, r3
|
||||
adds r3, r3, r2
|
||||
ldrb r0, [r3]
|
||||
bl uart_putc
|
||||
pop {pc}
|
||||
4:
|
||||
// Load from I/O (0xc000-0xcfff)
|
||||
movs r0, #0
|
||||
mov pc, lr
|
||||
|
||||
.bss
|
||||
ram0000:
|
||||
.skip 0x400
|
||||
ramfake:
|
||||
.byte 0
|
||||
|
|
7
reset.S
7
reset.S
|
@ -22,9 +22,10 @@ _reset:
|
|||
ldr r0, =#(_stack_top - 32)
|
||||
mov sp, r0
|
||||
bl uart_init
|
||||
ldr r0, =#hello
|
||||
bl uart_putstr
|
||||
|
||||
movs r0, #'>'
|
||||
bl uart_putc
|
||||
//ldr r0, =#hello
|
||||
//bl uart_putstr
|
||||
bl cpu6502_reset
|
||||
bl cpu6502_run
|
||||
1:
|
||||
|
|
55
uart.S
55
uart.S
|
@ -151,3 +151,58 @@ uart_puthex16:
|
|||
pop {pc}
|
||||
.size uart_puthex16, .-uart_puthex16
|
||||
|
||||
// void uart_putd(char n);
|
||||
.global uart_putd
|
||||
.type uart_putd, %function
|
||||
uart_putd:
|
||||
push {lr}
|
||||
movs r1, #0
|
||||
movs r2, #100
|
||||
movs r3, #0
|
||||
1:
|
||||
subs r0, r0, r2
|
||||
bcc 1f
|
||||
adds r1, r1, #1
|
||||
b 1b
|
||||
1:
|
||||
adds r0, r0, r2
|
||||
cmp r1, #0
|
||||
beq 2f
|
||||
push {r0}
|
||||
mov r0, r1
|
||||
bl uart_putx
|
||||
pop {r0}
|
||||
movs r3, #1
|
||||
2:
|
||||
movs r1, #0
|
||||
movs r2, #10
|
||||
1:
|
||||
subs r0, r0, r2
|
||||
bcc 1f
|
||||
adds r1, r1, #1
|
||||
b 1b
|
||||
1:
|
||||
adds r0, r0, r2
|
||||
cmp r1, #0
|
||||
bne 1f
|
||||
cmp r3, #0
|
||||
beq 2f
|
||||
1:
|
||||
push {r0}
|
||||
mov r0, r1
|
||||
bl uart_putx
|
||||
pop {r0}
|
||||
movs r3, #1
|
||||
2:
|
||||
movs r1, #0
|
||||
movs r2, #1
|
||||
1:
|
||||
subs r0, r0, r2
|
||||
bcc 1f
|
||||
adds r1, r1, #1
|
||||
b 1b
|
||||
1:
|
||||
mov r0, r1
|
||||
bl uart_putx
|
||||
pop {pc}
|
||||
|
||||
|
|
Loading…
Reference in New Issue