SW15 switches the terminal from the PC's serial line to a Z-80 running at 90 MHz from its own clock, with 64 KB of block RAM preloaded with BASIC. - rtl/z80_cpu.v: Z-80 built for speed (one clock per memory access, next byte read during decode), full documented instruction set plus the common undocumented forms; no interrupts. - rtl/z80_system.v: RAM, console/timer/7-segment ports, toggle handshakes to the terminal clock. - basic/: BASIC interpreter in C for SDCC, start-up code, prebuilt image. - tools/z80emu.py, tools/cputest.py, scripts/cpusim.sh: reference emulator and random tests comparing the CPU after every instruction. - SW14 feeds the PC's UART into the Z-80 for pasting programs; BTND resets the Z-80 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
665 B
Python
20 lines
665 B
Python
#!/usr/bin/env python3
|
|
"""Convert an Intel HEX file to a raw binary and a 64 KB $readmemh image."""
|
|
import sys
|
|
|
|
mem = bytearray(65536)
|
|
top = 0
|
|
for line in open(sys.argv[1]):
|
|
line = line.strip()
|
|
if not line.startswith(":"):
|
|
continue
|
|
b = bytes.fromhex(line[1:])
|
|
n, addr, kind = b[0], b[1] << 8 | b[2], b[3]
|
|
if kind == 0:
|
|
mem[addr:addr + n] = b[4:4 + n]
|
|
top = max(top, addr + n)
|
|
open(sys.argv[2], "wb").write(mem[:top])
|
|
open(sys.argv[3], "w").write("".join("%02x\n" % v for v in mem))
|
|
code = max(a for a in range(0x8000) if mem[a]) + 1 if any(mem[:0x8000]) else 0
|
|
print("image: %d bytes, code ends at 0x%04X" % (top, code))
|