diff --git a/Makefile b/Makefile index 4d77fe5..4e8769c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ FD_SECTORS = 9 QEMU_ARCH = $(shell uname -m) QEMU = qemu-system-$(QEMU_ARCH) -QEMU_ARGS = +QEMU_ARGS = -serial stdio ifdef KVM QEMU_ARGS += --enable-kvm @@ -38,4 +38,7 @@ qemu-rom: kernel.rom $(QEMU) $(QEMU_ARGS) -option-rom kernel.rom qemu-floppy: fdimage.img - $(QEMU) $(QEMU_ARGS) -boot c -hda fdimage.img \ No newline at end of file + $(QEMU) $(QEMU_ARGS) -boot c -hda fdimage.img + +qemu-serial: boot/serial.bin + $(QEMU) $(QEMU_ARGS) -hda boot/serial.bin \ No newline at end of file diff --git a/boot/serial.asm b/boot/serial.asm new file mode 100644 index 0000000..b4b7e78 --- /dev/null +++ b/boot/serial.asm @@ -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 \ No newline at end of file