new memory and project layout

This commit is contained in:
Joppe Blondel
2026-10-01 12:17:47 +02:00
parent 9b1fcac8ee
commit d19ffc70a1
10 changed files with 397 additions and 272 deletions
+104 -38
View File
@@ -1,11 +1,9 @@
STACK_TOP = 0xFFFF
DELAY_LOOPS_PER_MS = 40
MONITOR_BASE = 0xC000
MONITOR_ROM_SOURCE = 0x0080
TINYBASIC_BASE = 0xD000
TINYBASIC_ROM_SOURCE = 0x1000
RESIDENT_BASE = 0xC000
RESIDENT_ROM_SOURCE = 0x0080
.include "tinybasic.inc"
.include "bios.inc"
.globl _main
.globl _delay_ms
@@ -14,9 +12,11 @@ TINYBASIC_ROM_SOURCE = 0x1000
.globl _enable_interrupts
.globl _disable_interrupts
.globl _jump_to
.globl _monitor_uart_putc
.globl _monitor_uart_getc
.globl monitor_image_end
.globl _bios_putc
.globl _bios_try_getc
.globl _bios_getc
.globl _bios_init
.globl resident_image_end
.globl s__DATA
.globl l__DATA
.globl s__INITIALIZER
@@ -31,50 +31,56 @@ TINYBASIC_ROM_SOURCE = 0x1000
boot_copy:
di
ld sp, #STACK_TOP
ld hl, #MONITOR_ROM_SOURCE
ld de, #MONITOR_BASE
ld bc, #(monitor_image_end - MONITOR_BASE)
ldir
ld hl, #TINYBASIC_ROM_SOURCE
ld de, #TINYBASIC_BASE
ld bc, #TINYBASIC_SIZE
ld hl, #RESIDENT_ROM_SOURCE
ld de, #RESIDENT_BASE
ld bc, #(resident_image_end - RESIDENT_BASE)
ldir
jp init
.area _ITABLE (ABS)
; The executable vector page is part of the image copied to high RAM.
.org MONITOR_BASE
.org RESIDENT_BASE
jp init
.org MONITOR_BASE + 0x08
.org RESIDENT_BASE + 0x08
reti
.org MONITOR_BASE + 0x10
.org RESIDENT_BASE + 0x10
reti
.org MONITOR_BASE + 0x18
.org RESIDENT_BASE + 0x18
reti
.org MONITOR_BASE + 0x20
.org RESIDENT_BASE + 0x20
reti
.org MONITOR_BASE + 0x28
.org RESIDENT_BASE + 0x28
reti
.org MONITOR_BASE + 0x30
.org RESIDENT_BASE + 0x30
reti
.org MONITOR_BASE + 0x38
.org RESIDENT_BASE + 0x38
reti
; IM 2 table: the CTC supplies vectors 40, 42, 44, and 46.
.org MONITOR_BASE + 0x40
.org RESIDENT_BASE + 0x40
.dw ctc_isr ; CTC channel 0: vector 0x40
.dw ctc_isr ; CTC channel 1: vector 0x42
.dw ctc_isr ; CTC channel 2: vector 0x44
.dw uart_isr ; CTC channel 3: vector 0x46
; Stable entry points for programs living alongside the monitor.
; C050: write the character in A. C053: return a character in A, or 0.
.org MONITOR_BASE + 0x50
jp monitor_service_putc
.org MONITOR_BASE + 0x53
jp monitor_service_getc
; Stable BIOS jump table for ROM-resident applications.
; C050 putc(A), C053 try_getc(), C056 getc(), C059 io_out(A,L),
; C05C io_in(A), C05F delay_ms(HL), C062 monitor warm start.
.org BIOS_PUTC
jp bios_service_putc
.org BIOS_TRY_GETC
jp bios_service_try_getc
.org BIOS_GETC
jp bios_service_getc
.org BIOS_IO_OUT
jp bios_service_io_out
.org BIOS_IO_IN
jp bios_service_io_in
.org BIOS_DELAY_MS
jp bios_service_delay_ms
.org BIOS_MONITOR
jp init
.area _HOME
init:
@@ -87,6 +93,7 @@ init:
ld a, #0xC0
ld i, a
im 2
call _bios_init
call _main
hang:
@@ -124,20 +131,19 @@ clear_loop:
gsinit_done:
.area _GSFINAL
ret
monitor_image_end:
resident_image_end:
.area _CODE
; Monitor ABI services preserve all working registers. PUTC also preserves AF;
; GETC returns the received byte (or zero) in A.
monitor_service_putc:
; BIOS ABI services preserve registers except documented return values.
bios_service_putc:
push af
push bc
push de
push hl
push ix
push iy
call _monitor_uart_putc
call _bios_putc
pop iy
pop ix
pop hl
@@ -146,13 +152,13 @@ monitor_service_putc:
pop af
ret
monitor_service_getc:
bios_service_try_getc:
push bc
push de
push hl
push ix
push iy
call _monitor_uart_getc
call _bios_try_getc
pop iy
pop ix
pop hl
@@ -160,6 +166,66 @@ monitor_service_getc:
pop bc
ret
bios_service_getc:
push bc
push de
push hl
push ix
push iy
call _bios_getc
pop iy
pop ix
pop hl
pop de
pop bc
ret
bios_service_io_out:
push af
push bc
push de
push hl
push ix
push iy
call _io_out
pop iy
pop ix
pop hl
pop de
pop bc
pop af
ret
bios_service_io_in:
push bc
push de
push hl
push ix
push iy
call _io_in
pop iy
pop ix
pop hl
pop de
pop bc
ret
bios_service_delay_ms:
push af
push bc
push de
push hl
push ix
push iy
call _delay_ms
pop iy
pop ix
pop hl
pop de
pop bc
pop af
ret
.macro MAKE_ISR entry, handler
.globl handler
entry: