summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2015-06-03 20:18:27 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2015-06-03 20:18:27 (GMT)
commit7eb0b43357bcf8a6ef224bce6426646631c45f66 (patch)
treec3fff5c17ec7985d8f2719fa0b3c515e1fc89a81
parent9313ff1d17e0f76e99ba50a5729fca5edb1a6b67 (diff)
downloadabc80-7eb0b43357bcf8a6ef224bce6426646631c45f66.zip
abc80-7eb0b43357bcf8a6ef224bce6426646631c45f66.tar.gz
abc80-7eb0b43357bcf8a6ef224bce6426646631c45f66.tar.bz2
abc80-7eb0b43357bcf8a6ef224bce6426646631c45f66.tar.xz
rambasic.asm: routine for copying ROM to RAM
Routine for copying RAM to ROM. Works on real hardware with Mikrodatorn's 64K expansion as well as FPGA.
-rw-r--r--data/Makefile6
-rw-r--r--data/rambasic.asm58
2 files changed, 63 insertions, 1 deletions
diff --git a/data/Makefile b/data/Makefile
index cd05483..fa0999b 100644
--- a/data/Makefile
+++ b/data/Makefile
@@ -9,7 +9,8 @@ Z80ASM = ../tools/z80asm/z80asm
all : keyboard.mif abc80rom.bin basic80.mif \
mmu.mif chargen.mif videoram.mif fgcol.mif sddrom.mif \
- abcsefi.bas abcdkno.bas abcintl.bas cpm.bas cpm.abs cpm.bac
+ abcsefi.bas abcdkno.bas abcintl.bas cpm.bas cpm.abs cpm.bac \
+ rambasic.bas
abc80rom.bin : buildrom.pl abcbasic.rom ufddos.bin printer.bin
$(PERL) buildrom.pl $@ 32768 \
@@ -70,6 +71,9 @@ cpm.abs: cpm.bin
cpm.bac: cpm.bin
$(PERL) bin2bac.pl $< 32768 32768 > $@ || ( rm -f $@ ; exit 1 )
+rambasic.bas: rambasic.bin
+ $(PERL) bin2poke.pl $< 0 > $@ || ( rm -f $@ ; exit 1 )
+
.bin.bas:
$(PERL) bin2poke.pl $< 16384 100 RETURN | cat charpoke.bah - > $@ \
|| ( rm -f $@ ; exit 1 )
diff --git a/data/rambasic.asm b/data/rambasic.asm
new file mode 100644
index 0000000..3b7323f
--- /dev/null
+++ b/data/rambasic.asm
@@ -0,0 +1,58 @@
+; This code must be position-independent.
+
+ org 0
+entry: ; On entry HL points here
+ inc h ; Buffer at +256 bytes
+ push hl ; Buffer address
+ xor a
+ ld l,a
+ ld h,a
+ ; DE -> ROM address
+
+ ; Wait for NMI before copying the first chunk
+ di
+ halt
+
+ ; Test for RAM
+ inc a ; A = 1
+ out (7),a
+ ld c,(hl)
+ add c
+ ld (hl),a
+ ld a,(hl)
+ sub c
+ jr z,error ; A = 0, HL = 0 on error
+
+copy:
+ xor a
+ out (7),a
+
+ ; Copy to buffer
+ pop de ; Buffer address
+ push de ; Buffer address
+ push hl ; ROM address
+ ld bc,256
+ ldir
+
+ inc a ; A = 1
+ out (7),a
+
+ ; Copy from buffer
+ pop de ; ROM address
+ pop hl ; Buffer address
+ push hl ; Buffer address
+ inc b ; BC <- 256
+ ldir
+
+ ex de,hl ; ROM address -> HL
+
+ bit 7,h
+ jr z,copy
+
+ ; A = 1, HL != 0
+
+error:
+ out (7),a
+ ei
+
+ ret