]> git.dujemihanovic.xyz Git - nameless-os.git/blobdiff - boot.s
Allow controlling (no) newline when printing and listen to keystrokes
[nameless-os.git] / boot.s
diff --git a/boot.s b/boot.s
index eb115d0324dd6a2e8e83d94aee9d197d71299392..51be5d92dd8ee19426be4092d2aaed2c1e96f46d 100644 (file)
--- a/boot.s
+++ b/boot.s
@@ -1,21 +1,69 @@
        bits 16 ; boot sectors run in real mode
        org 7c00h ; boot sector is loaded at 0x7c00
 
+_start
        mov di, printing_numbers
        call print
 
+       or bl, 1
        mov dx, 0DEADh ; number to print
        call print_word
+       
+       mov di, space
+       call print
+       
+       xor bl, bl
        mov dx, 0BEEFh
        call print_word
 
-       mov di, goodbye
+       mov di, waiting
        call print
 
-       jmp $
+       mov di, keystroke
+       mov bl, 1
+
+.loop
+       mov ah, 0
+       int 16h
+       cmp ah, 1Ch
+       je .enterpressed
+       jmp .continue
+       cmp ah, 0Eh
+       je .backspace
+       jmp .continue
+.enterpressed
+       pusha
+       mov ah, 0Eh
+       mov al, 0Dh
+       int 10h
+       mov al, 0Ah
+       int 10h
+       popa
+       jmp .loop
+.backspace
+       pusha
+       mov ah, 03h
+       mov bh, 0
+       int 10h
+       dec dl
+       mov ah, 02h
+       int 10h
+       mov ah, 0Eh
+       mov al, ' '
+       int 10h
+       mov ah, 02h
+       int 10h
+       popa
+       jmp .loop
+.continue
+       mov [keystroke], al
+       call print
+       jmp .loop
 
-printing_numbers: db "Printing some random hex numbers", 0
-goodbye: db "Thank you for your attention", 0
+printing_numbers db "Printing some random hex numbers", 0
+waiting db "I await keystrokes", 0
+keystroke db "$", 0
+space db " ", 0
 
 %include "print.s"