]> git.lizzy.rs Git - loadnothing.git/blob - stage1/boot.asm
096a4016a6e4ee2602d697783b812c9b2e5e84aa
[loadnothing.git] / stage1 / boot.asm
1 [bits 16]
2 [org 0x7c00]
3
4 ; Initialize registers
5 xor ax, ax
6 mov ds, ax
7 mov es, ax
8 mov bx, 0x8000
9
10 jmp boot
11
12 ; Print al register
13 print_al:
14         mov ah, 0x0e ; TTY output
15         mov bh, 0x00 ; Page 0
16         mov bl, 0x07 ; Color: Light grey on black background
17         int 0x10
18
19         ret
20
21 ; Call print_al on all characters in si
22 ; si must be null terminated
23 print_bytes_si:
24         mov cl, 0 ; Start with iteration 0 - equivalent of int i = 0
25 print_bytes_si_loop:
26         lodsb                  ; Load next characet of si into al
27         call print_al
28
29         inc cl
30
31         cmp cl, ch
32         jb print_bytes_si_loop
33
34         ret
35
36 ; Main
37 boot:
38         ; Clear the screen
39         mov ah, 0x06
40         mov al, 0x00
41         mov bh, 0x07
42         mov ch, 0x00
43         mov cl, 0x00
44         mov dh, 0xff
45         mov dl, 0xff
46         int 0x10
47
48         ; Move cursor to 0, 0 on page 0
49         mov ah, 0x02
50         mov bh, 0           ; Page
51         mov dh, 0           ; Row
52         mov dl, 0           ; Column
53         int 0x10
54
55         mov ch, 33          ; Our string is 33 characters long
56         mov si, hello
57         call print_bytes_si
58
59         jmp $               ; Infinite loop
60
61 hello db 'Welcome to loadnothing stage 1!', 13, 10                   ; \r\n
62
63 times (446 - ($ - $$)) db 0x00