135 lines
2.1 KiB
NASM
135 lines
2.1 KiB
NASM
; SPDX-License-Identifier: MPL-2.0
|
|
; SPDX-FileCopyrightText: (c) 2025 A.M. Rowsell
|
|
; ============================================================
|
|
; ZONE OS main section
|
|
; ============================================================
|
|
.section "zone", "acrx"
|
|
.global os_print_vec
|
|
.global os_getch_vec
|
|
.global os_outbyte_vec
|
|
.global os_inbyte_vec
|
|
.global os_main_loop
|
|
.local os_print_signon
|
|
|
|
.set UARTSTATUS, 6
|
|
.set UARTDATA, 7
|
|
|
|
os_print_vec:
|
|
; this takes a character in a and sends it to the UART
|
|
push af
|
|
push bc
|
|
push de
|
|
ld d, a
|
|
ld c, UARTSTATUS
|
|
|
|
$1:
|
|
in a, (c); get status byte
|
|
bit 0, a; test bit 0
|
|
jr z, $1; jump back if UART not ready
|
|
ld a, d
|
|
ld c, UARTDATA
|
|
out (c), a; send byte to uart
|
|
pop de
|
|
pop bc
|
|
pop af
|
|
ret
|
|
|
|
os_getch_vec:
|
|
; this gets a character from the UART and puts in in a
|
|
push bc
|
|
ld c, UARTSTATUS
|
|
|
|
a2:
|
|
in a, (c); get status byte
|
|
bit 1, a
|
|
jr z, a2
|
|
ld c, UARTDATA
|
|
in a, (c)
|
|
pop bc
|
|
ret
|
|
|
|
os_outbyte_vec:
|
|
; this takes a byte in a and sends it to port in hl
|
|
push af
|
|
push bc
|
|
push hl
|
|
ld c, l
|
|
out (c), a
|
|
pop hl
|
|
pop bc
|
|
pop af
|
|
ret
|
|
|
|
os_inbyte_vec:
|
|
; this gets a byte from port in hl and returns it in a
|
|
push bc
|
|
push hl
|
|
ld c, l
|
|
in a, (c)
|
|
pop hl
|
|
pop bc
|
|
ret
|
|
|
|
os_main_loop:
|
|
call os_print_signon
|
|
|
|
os_busy_loop:
|
|
jp os_busy_loop
|
|
|
|
; ======================
|
|
; non-vectored functions
|
|
; ======================
|
|
|
|
os_print_signon:
|
|
ld hl, zoneSignon
|
|
ld a, (hl)
|
|
|
|
$2:
|
|
call os_print_vec
|
|
inc hl
|
|
ld a, (hl)
|
|
jr nz, $2
|
|
|
|
$3:
|
|
ld hl, zoneCopyright
|
|
ld a, (hl)
|
|
|
|
$4:
|
|
call os_print_vec
|
|
inc hl
|
|
ld a, (hl)
|
|
jr nz, $4
|
|
ret
|
|
|
|
zoneSignon:
|
|
.byte "ZONE OS ver. 0.01"
|
|
.byte 10, 13, 0
|
|
|
|
zoneCopyright:
|
|
.byte "(c) A.M. Rowsell, license MPLv2"
|
|
.byte 10, 13, 0
|
|
|
|
zonePrompt:
|
|
.string "z] "
|
|
|
|
; error messages
|
|
|
|
errorSyntax:
|
|
.string "Syntax error!"
|
|
|
|
errorTimeout:
|
|
.string "Command timed out."
|
|
|
|
errorNotFound:
|
|
.string "Command/file not found."
|
|
|
|
errorHardware:
|
|
.string "Hardware error!"
|
|
|
|
errorRAMFailed:
|
|
.string "RAM test failed!"
|
|
|
|
stringTable:
|
|
.word zoneSignon, zoneCopyright, zonePrompt
|
|
.word errorSyntax, errorTimeout, errorNotFound
|
|
.word errorHardware, errorRAMFailed
|