diff --git a/hw/efinix_fpga/super6502.xml b/hw/efinix_fpga/super6502.xml index 44671f3..44c05a4 100644 --- a/hw/efinix_fpga/super6502.xml +++ b/hw/efinix_fpga/super6502.xml @@ -1,5 +1,5 @@ - + diff --git a/sw/kernel/boot.s b/sw/kernel/boot.s index 1d86ca1..631fdd7 100644 --- a/sw/kernel/boot.s +++ b/sw/kernel/boot.s @@ -17,7 +17,7 @@ ; --------------------------------------------------------------------------- ; Place the startup code in a special segment -.segment "CODE" +.segment "STARTUP" ; --------------------------------------------------------------------------- ; A little light 6502 housekeeping diff --git a/sw/kernel/link.ld b/sw/kernel/link.ld index 8348fad..2dd5332 100644 --- a/sw/kernel/link.ld +++ b/sw/kernel/link.ld @@ -11,13 +11,12 @@ MEMORY SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; STARTUP: load = KERNEL, type = ro; - CODE: load = KERNEL, type = ro; ONCE: load = KERNEL, type = ro, optional = yes; + CODE: load = KERNEL, type = ro; + RODATA: load = KERNEL, type = ro; DATA: load = KERNEL, type = rw, define = yes; BSS: load = KERNEL, type = rw, define = yes; HEAP: load = KERNEL, type = rw, define = yes, optional = yes; - RODATA: load = KERNEL, type = ro; - VECTORS: load = ROM, type = ro, start = $FFFA; } FILES @@ -27,7 +26,7 @@ FILES FORMATS { - o65: os = super, version = 0, type = small, + o65: os = lunix, version = 0, type = small, export = _init; } diff --git a/sw/kernel/vectors.s b/sw/kernel/vectors.s deleted file mode 100644 index 9fd31a1..0000000 --- a/sw/kernel/vectors.s +++ /dev/null @@ -1,16 +0,0 @@ -.segment "VECTORS" - -.addr _nmi_int ; NMI vector -.addr _na ; Reset vector (Doesn't matter, will go back to ROM) -.addr _irq_int ; IRQ/BRK vector - -.segment "CODE" - -_na: - rti - -_nmi_int: - rti - -_irq_int: - rti diff --git a/sw/script/o65dump.py b/sw/script/o65dump.py index d2a8645..b01b648 100755 --- a/sw/script/o65dump.py +++ b/sw/script/o65dump.py @@ -1,6 +1,43 @@ #!/usr/bin/python import sys +import io + +class O65(): + + header: dict[str, int] = {} + options: list[(int, int, bytes)] = [] + text: bytes + data: bytes + + def __init__(self, filename: str) -> None: + with open(filename, "rb") as _file: + self.header["no_c64"] = int.from_bytes(_file.read(2)) + self.header["magic"] = int.from_bytes(_file.read(3)) + self.header["version"] = int.from_bytes(_file.read(1)) + self.header["mode"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["tbase"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["tlen"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["dbase"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["dlen"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["bbase"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["blen"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["zbase"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["zlen"] = int.from_bytes(_file.read(2), byteorder="little") + self.header["stack"] = int.from_bytes(_file.read(2), byteorder="little") + + olen = int.from_bytes(_file.read(1)) + while olen != 0: + otype = int.from_bytes(_file.read(1)) + obytes = _file.read(olen - 2) + self.options.append((olen, otype, obytes)) + olen = int.from_bytes(_file.read(1)) + + self.text = _file.read(self.header["tlen"]) + self.data = _file.read(self.header["dlen"]) + + + def main() -> None: if len(sys.argv) < 2: @@ -8,8 +45,15 @@ def main() -> None: return filename = sys.argv[1] print(filename) - with open(filename, "rb") as file: - print(file.read(1)) + o65 = O65(filename) + for item, value in o65.header.items(): + print(f"{item}:\t{value:x}") + + for option in o65.options: + print(f"Type: {option[1]}, Data: {option[2]}") + + with open("text.bin", "wb") as textfile: + textfile.write(o65.text) if __name__ == "__main__": main() \ No newline at end of file diff --git a/sw/test_exec/Makefile b/sw/test_exec/Makefile index a02cbfe..5a26b91 100644 --- a/sw/test_exec/Makefile +++ b/sw/test_exec/Makefile @@ -1,4 +1,4 @@ -CC=cl65 +CC=../cc65/bin/cl65 CFLAGS=-T -t super6502 -I. --cpu "65C02" test: CFLAGS=-T -t sim65c02 -I. LDFLAGS=-C link.ld -m $(NAME).map diff --git a/sw/test_exec/link.ld b/sw/test_exec/link.ld index ade4e99..c1c36c8 100644 --- a/sw/test_exec/link.ld +++ b/sw/test_exec/link.ld @@ -10,13 +10,13 @@ FILES { SEGMENTS { ZEROPAGE: load = ZP, type = zp, define = yes; - DATA: load = SDRAM, type = rw, define = yes, run = SDRAM; - BSS: load = SDRAM, type = bss, define = yes; - HEAP: load = SDRAM, type = bss, optional = yes; STARTUP: load = SDRAM, type = ro; ONCE: load = SDRAM, type = ro, optional = yes; CODE: load = SDRAM, type = ro; RODATA: load = SDRAM, type = ro; + DATA: load = SDRAM, type = rw, define = yes, run = SDRAM; + BSS: load = SDRAM, type = bss, define = yes; + HEAP: load = SDRAM, type = bss, optional = yes; } FEATURES {