51 lines
1.1 KiB
NASM
51 lines
1.1 KiB
NASM
.include "bios.inc"
|
|
|
|
.area TAPELOAD (ABS)
|
|
.org TAPE_LOADER_ROM_ADDRESS
|
|
|
|
COMP_PORT = 0x18
|
|
|
|
WORK_BASE = 0x0B000
|
|
LOAD_START = 0x08000
|
|
LOAD_LIMIT_HI = 0x0B0
|
|
STACK_TOP = 0x0BFFF
|
|
|
|
OLD_SP = WORK_BASE+0x00
|
|
|
|
start:
|
|
ld (OLD_SP), sp
|
|
ld sp, #STACK_TOP
|
|
|
|
di
|
|
|
|
poll_loop:
|
|
|
|
; Read from the hardware port COMP_PORT
|
|
in a, (COMP_PORT)
|
|
out (COMP_PORT), a
|
|
|
|
; Save the raw port status in register B
|
|
ld b, a
|
|
|
|
; Print a carriage return '\r' (ASCII 0x0D)
|
|
ld a, #0x0D
|
|
call BIOS_PUTC
|
|
|
|
; Restore the port status and isolate the relevant bit
|
|
; (Assuming bit 0 determines 0 or 1; adjust 'and' mask if it is a different bit)
|
|
ld a, b
|
|
and #0x01
|
|
|
|
; Convert the binary 0 or 1 into ASCII '0' (0x30) or '1' (0x31)
|
|
add a, #0x30
|
|
|
|
; Print the '0' or '1' character
|
|
call BIOS_PUTC
|
|
|
|
; Infinite loop: poll continuously
|
|
jr poll_loop
|
|
|
|
ld sp, (OLD_SP)
|
|
ei
|
|
ret
|