diff options
Diffstat (limited to 'kernel/source/serial.asm')
-rw-r--r-- | kernel/source/serial.asm | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/kernel/source/serial.asm b/kernel/source/serial.asm new file mode 100644 index 0000000..071e525 --- /dev/null +++ b/kernel/source/serial.asm @@ -0,0 +1,58 @@ +bits 64 + +global serial_init +global serial_putchar + +section .text + +serial_init: + + xor al, al + mov dx, 0x03f9 + out dx, al + + mov al, 0x80 + mov dx, 0x03fb + out dx, al + + mov al, 0x03 + mov dx, 0x03f8 + out dx, al + + xor al, al + mov dx, 0x03f9 + out dx, al + + mov al, 0x03 + mov dx, 0x03fb + out dx, al + + mov al, 0xc7 + mov dx, 0x03fa + out dx, al + + ret + +serial_putchar: + + cmp dil, 0x0a + je .do_cr +.cr_ret: + + mov dx, 0x03fd + +.loop: + in al, dx + test al, 0x20 + jz .loop + + mov al, dil + mov dx, 0x03f8 + out dx, al + ret + +.do_cr: + mov dil, 0x0d + call serial_putchar + mov dil, 0x0a + jmp .cr_ret |