-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootloader.S
47 lines (38 loc) · 829 Bytes
/
bootloader.S
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
[bits 16]
[org 0x7c00]
start:
mov ax, str_helloworld
call write_string
jmp $
; loop through reading and printing ascii keys
read_loop:
call read_char
jmp read_loop
; expects -- string pointer in si
write_string:
mov si, ax
xor ax,ax
lodsb
cmp al, 0x0
jz finish_write_string
call write_char
add si, 0x1
jmp write_string
finish_write_string:
ret
write_char:
mov ah, 0x0E ; write in teletype mode
int 0x10
ret
read_char:
mov ah, 0x0 ; read keyboard input
int 0x16 ;
; ah now contains the scan code, al contains the ascii character
cmp al, 0x0
jz skip_call_write_char
call write_char
skip_call_write_char:
ret
str_helloworld: db 'Hello world', 0x0A, 0x0D, 0
times 510-($-$$) db 0 ; padding
magic dw 0xAA55 ; magic for boot loader