]> git.dujemihanovic.xyz Git - nameless-os.git/blob - boot.s
Allow controlling (no) newline when printing and listen to keystrokes
[nameless-os.git] / boot.s
1 bits 16 ; boot sectors run in real mode
2 org 7c00h ; boot sector is loaded at 0x7c00
3
4 _start
5 mov di, printing_numbers
6 call print
7
8 or bl, 1
9 mov dx, 0DEADh ; number to print
10 call print_word
11
12 mov di, space
13 call print
14
15 xor bl, bl
16 mov dx, 0BEEFh
17 call print_word
18
19 mov di, waiting
20 call print
21
22 mov di, keystroke
23 mov bl, 1
24
25 .loop
26 mov ah, 0
27 int 16h
28 cmp ah, 1Ch
29 je .enterpressed
30 jmp .continue
31 cmp ah, 0Eh
32 je .backspace
33 jmp .continue
34 .enterpressed
35 pusha
36 mov ah, 0Eh
37 mov al, 0Dh
38 int 10h
39 mov al, 0Ah
40 int 10h
41 popa
42 jmp .loop
43 .backspace
44 pusha
45 mov ah, 03h
46 mov bh, 0
47 int 10h
48 dec dl
49 mov ah, 02h
50 int 10h
51 mov ah, 0Eh
52 mov al, ' '
53 int 10h
54 mov ah, 02h
55 int 10h
56 popa
57 jmp .loop
58 .continue
59 mov [keystroke], al
60 call print
61 jmp .loop
62
63 printing_numbers db "Printing some random hex numbers", 0
64 waiting db "I await keystrokes", 0
65 keystroke db "$", 0
66 space db " ", 0
67
68 %include "print.s"
69
70 times 510-($-$$) db 0 ; fill with 0 until 0x1fc is reached
71 dw 0AA55h ; BIOS MBR signature