rdos/boot/serial.asm

90 lines
1023 B
NASM
Raw Normal View History

2019-06-24 18:47:31 +02:00
org 0x7c00
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
jmp 0:start
getc:
mov ah, 0x02
mov dx, 0x0000
int 0x14
test ah, 0x80
jnz getc
ret
putc:
mov ah, 0x01
mov dx, 0x0000
int 0x14
ret
init_port:
mov ah, 0x00
mov al, 0b11100011
mov dx, 0x0000
int 0x14
ret
dump:
mov si, 0x500
mov cx, di
sub cx, si
.loop:
lodsb
call print8
loop .loop
mov al, 0x0A
call putc
mov al, 0x0D
call putc
ret
line_reset:
cmp di, 0x500
je .reset
call line_process
.reset:
mov di, 0x500
xor bp, bp
jmp mainloop
line_process:
call dump
ret
start:
call init_port
mov di, 0x500
jmp line_reset
mainloop:
call getc
cmp al, ':'
je line_reset
cmp al, 0x20
jb line_reset
sub al, 0x30
cmp al, 9
jbe .noadjust
sub al, 7
.noadjust:
test bp, bp
jnz .secondnib
mov cl, 4
shl al, cl
mov [di], al
not bp
jmp mainloop
.secondnib:
or [di], al
inc di
not bp
jmp mainloop
%include "print.asm"
times 510-($-$$) db 0x00
db 0x55,0xaa