X-Git-Url: http://git.dujemihanovic.xyz/posts?a=blobdiff_plain;f=boot.s;h=51be5d92dd8ee19426be4092d2aaed2c1e96f46d;hb=eec791adfbaddde2f5724e0f5c7319e7d2aaef0e;hp=50730d0c39dd9566f3eef2e0b87582758af13444;hpb=4326df7844154f8c575a33b3898709944e08f74b;p=nameless-os.git diff --git a/boot.s b/boot.s index 50730d0..51be5d9 100644 --- a/boot.s +++ b/boot.s @@ -1,22 +1,71 @@ bits 16 ; boot sectors run in real mode - org 7c00h ; boot sector is always loaded at 0x7c00 - - mov al, 1 ; update cursor after write - mov bh, 0 ; write to page 0 - mov bl, 00000111b ; attribute: high nibble is foreground (light gray), - ; low nibble is background (black) - ; NOTE: in the binary, these will be inverted, so low nibble here will become high nibble in binary and vice versa! - mov cx, msg1end - msg1 ; size of message - mov dl, 0 ; column to write to - mov dh, 0 ; row to write to - push cs ; push code segment to stack - pop es ; pop pushed code segment to extra segment, this serves as the base to the string - mov bp, msg1 ; offset where the string is - mov ah, 13h ; write string subservice - int 10h ; call BIOS interrupt 0x10 - jmp msg1end ; jmp to endless loop - msg1 db "Gotta start somewhere" - msg1end: jmp msg1end + 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, waiting + call print + + 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 +waiting db "I await keystrokes", 0 +keystroke db "$", 0 +space db " ", 0 + +%include "print.s" times 510-($-$$) db 0 ; fill with 0 until 0x1fc is reached - dw 0xaa55 ; BIOS MBR signature + dw 0AA55h ; BIOS MBR signature