-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello_world.asm
40 lines (27 loc) · 909 Bytes
/
hello_world.asm
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
; This is a simple "Hello World" bootsector
; Made for the x86_64 architecture
[org 0x7c00] ; This is the address where the BIOS will load our bootloader
; Main program
main:
mov si, HelloWorld ; Load string into SI
call PutStr ; Call our procedure to print the string
jmp $ ; Infinite loop
; Everything after this is Procedures and Variables (data)
; Procedures
PutStr: ; Procedure to print a string
pusha ; Save registers
mov ah, 0x0e ; BIOS teletype function
mov al, [si] ; Get character from string
cmp al, 0 ; Check if character is null
je .done ; If it is, we're done
int 0x10 ; Call BIOS, print character
inc si ; Increment string index
jmp PutStr ; Repeat
.done:
popa ; Restore registers
ret ; Return to caller (main)
; Data
HelloWorld: db 'Hello World!', 0 ; Null terminated string
; Bootsector signature
times 510 - ($-$$) db 0
dw 0xaa55