diff --git a/hw/efinix_fpga/test_programs/Makefile b/hw/efinix_fpga/test_programs/Makefile new file mode 100644 index 0000000..955951e --- /dev/null +++ b/hw/efinix_fpga/test_programs/Makefile @@ -0,0 +1,12 @@ +TARGETS=stacktest runram + +all: $(TARGETS) + +$(TARGETS): + cl65 --cpu 65c02 -C link.ld -l $@.list $@.s + xxd -ps $@ | fold -w 2 > $@.hex + +clean: + rm $(TARGETS) + rm *.hex + rm *.list diff --git a/hw/efinix_fpga/test_programs/link.ld b/hw/efinix_fpga/test_programs/link.ld new file mode 100644 index 0000000..f4fb600 --- /dev/null +++ b/hw/efinix_fpga/test_programs/link.ld @@ -0,0 +1,30 @@ +MEMORY +{ + ZP: start = $0, size = $100, type = rw, define = yes; + SDRAM: start = $200, size = $ff00, type = rw, define = yes; + ROM: start = $ff00, size = $100, file = %O; +} + +SEGMENTS { + ZEROPAGE: load = ZP, type = zp, define = yes; + CODE: load = ROM, type = ro; + RODATA: load = ROM, type = ro; + VECTORS: load = ROM, type = ro, start = $FFFA; +} + +FEATURES { + CONDES: segment = STARTUP, + type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__; + CONDES: segment = STARTUP, + type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__; +} + +SYMBOLS { + # Define the stack size for the application + __STACKSIZE__: value = $0200, type = weak; + __STACKSTART__: type = weak, value = $0800; # 2k stack +} diff --git a/hw/efinix_fpga/test_programs/runram.s b/hw/efinix_fpga/test_programs/runram.s new file mode 100644 index 0000000..58e6baf --- /dev/null +++ b/hw/efinix_fpga/test_programs/runram.s @@ -0,0 +1,36 @@ +.code + +loadaddr = $1000 + + +main: + ldx #(loadend-loadstart) +loadloop: + lda loadstart,x + sta loadaddr,x + dex + bpl loadloop + + jsr loadaddr + +end: bra end + + +loadstart: + +stacktest: + lda #$55 + pha + lda #$00 + pla + sta $efff + rts + +loadend: + + +.segment "VECTORS" + +.addr main +.addr main +.addr main \ No newline at end of file diff --git a/hw/efinix_fpga/test_programs/stacktest.s b/hw/efinix_fpga/test_programs/stacktest.s new file mode 100644 index 0000000..9ed069a --- /dev/null +++ b/hw/efinix_fpga/test_programs/stacktest.s @@ -0,0 +1,23 @@ +.code + + +main: lda #$ff + jsr stacktest +end: bra end + + + +stacktest: + lda #$55 + pha + lda #$00 + pla + sta $efff + rts + + +.segment "VECTORS" + +.addr main +.addr main +.addr main