1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-08 13:28:05 +11:00
collapseos/parts/shell/shell.asm
2019-04-12 15:53:05 -04:00

60 lines
1.1 KiB
NASM

; shell
;
; Runs a shell over an asynchronous communication interface adapter (ACIA).
; *** STATUS ***
; Incomplete. This just outputs the welcome prompt then halts
#include "platform.inc"
; *** CONSTS ***
CR .equ 0x0d
LF .equ 0x0a
; *** CODE ***
jr init
init:
di ; no need for interrupts yet
; setup stack
ld hl, RAMEND
ld sp, hl
; setup ACIA
; CR7 (1) - Receive Interrupt enabled
; CR6:5 (00) - RTS low, transmit interrupt disabled.
; CR4:2 (101) - 8 bits + 1 stop bit
; CR1:0 (10) - Counter divide: 64
ld a, 0b10010110
out (ACIA_CTL), a
; print prompt
ld hl, d_welcome
call printstr
halt
; spits character in A in port SER_OUT
printc:
push af
.stwait:
in a, (ACIA_CTL) ; get status byte from SER
bit 1, a ; are we still transmitting?
jr z, .stwait ; if yes, wait until we aren't
pop af
out (ACIA_IO), a ; push current char
ret
; print null-terminated string pointed to by HL
printstr:
ld a, (hl) ; load character to send
or a ; is it zero?
ret z ; if yes, we're finished
call printc
inc hl
jr printstr
; no ret because our only way out is ret z above
; *** DATA ***
d_welcome: .byte "Welcome to Collapse OS", CR, LF, 0