Add prototype for serial bootloader

This commit is contained in:
Nero 2019-06-24 16:47:31 +00:00
parent 1259fe14fe
commit 78d5b6aa28
2 changed files with 95 additions and 2 deletions

View File

@ -4,7 +4,7 @@ FD_SECTORS = 9
QEMU_ARCH = $(shell uname -m) QEMU_ARCH = $(shell uname -m)
QEMU = qemu-system-$(QEMU_ARCH) QEMU = qemu-system-$(QEMU_ARCH)
QEMU_ARGS = QEMU_ARGS = -serial stdio
ifdef KVM ifdef KVM
QEMU_ARGS += --enable-kvm QEMU_ARGS += --enable-kvm
@ -39,3 +39,6 @@ qemu-rom: kernel.rom
qemu-floppy: fdimage.img qemu-floppy: fdimage.img
$(QEMU) $(QEMU_ARGS) -boot c -hda fdimage.img $(QEMU) $(QEMU_ARGS) -boot c -hda fdimage.img
qemu-serial: boot/serial.bin
$(QEMU) $(QEMU_ARGS) -hda boot/serial.bin

90
boot/serial.asm Normal file
View File

@ -0,0 +1,90 @@
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