Monitor: Z-80 assembler (ASM "file", A addr)
Two-pass table-driven assembler in the monitor: assembles BASIC-saved source files from the file system, or one line at a time with A addr. Labels, EQU/ORG/DB/DW/DS/END, expressions. Table generated from the disassembler (tools/gen-asmtab.py); round-trip and sdasz80 tests, plus a Z-80 build run in z80emu. Monitor RAM grows to 6000-7FFF for the symbol table. Works around an SDCC 4.5 inline strcpy bug with s_copy(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
88b5942da5
commit
fe1daf180d
16 files changed
+14320
-13257
No files matched your search
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# Check the assembler as SDCC compiles it for the Z-80 (it has had code
|
||||
# generation bugs, see s_copy in monitor.c): assemble every opcode form with
|
||||
# monitor/test/asm-z80.c in tools/z80emu.py and compare with the PC build.
|
||||
# Takes about two minutes.
|
||||
set -e
|
||||
cd "$(dirname "$0")"
|
||||
T=$(mktemp -d)
|
||||
sdasz80 -o $T/crt0.rel ../basic/crt0.s
|
||||
cp asm.c asmtab.h $T/ && cp test/asm-z80.c $T/t.c
|
||||
(cd $T && sdcc -mz80 --opt-code-size --max-allocs-per-node 20000 --std-sdcc11 -c t.c 2>/dev/null &&
|
||||
sdcc -mz80 --no-std-crt0 --code-loc 0x0080 --data-loc 0x8000 -o t.ihx crt0.rel t.rel)
|
||||
python3 ../tools/ihx2mem.py $T/t.ihx $T/t.bin $T/t.mem >/dev/null
|
||||
gcc -O1 -w -o $T/mon monitor.c
|
||||
$T/mon | awk -F'\t' '$2 != "NOP*" && $2 !~ /^DB /{print $2}' > $T/lines.txt
|
||||
(cat $T/lines.txt; echo) > $T/input.txt
|
||||
$T/mon line < $T/lines.txt > $T/host.txt
|
||||
python3 ../tools/z80emu.py $T/t.bin --input $T/input.txt --max 400000000 2>&1 | grep -v '^\[' | tr -d '\r' | tail -n +2 > $T/z80.txt
|
||||
if diff $T/z80.txt $T/host.txt > /dev/null; then
|
||||
echo "Z-80 build matches the PC build on $(wc -l < $T/lines.txt) lines"
|
||||
else
|
||||
echo "Z-80 BUILD DIFFERS:"; diff $T/z80.txt $T/host.txt | head; exit 1
|
||||
fi
|
||||
Reference in new issue
Block a user