-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.asm
73 lines (60 loc) · 996 Bytes
/
start.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
global _start
extern start
MULTIBOOT_MAGIC equ 0xE85250D6
MULTIBOOT_ARCHITECTURE equ 0
MULTIBOOT_LENGTH equ (multiboot_end - multiboot)
section .multiboot
align 8
multiboot:
dd MULTIBOOT_MAGIC
dd MULTIBOOT_ARCHITECTURE
dd MULTIBOOT_LENGTH
dd -(MULTIBOOT_MAGIC + MULTIBOOT_ARCHITECTURE + MULTIBOOT_LENGTH)
align 8
dw 0
dw 0
dd 8
multiboot_end:
section .text
_start:
mov esp, stack_end
call load_gdt
call start
.stop:
hlt
jmp .stop
load_gdt:
lgdt [gdt.pointer]
jmp 0x08:.set_registers
.set_registers:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
ret
section .bss
stack:
resb 0x4000
stack_end:
section .rodata
gdt:
dq 0
.code:
dw 0xFFFF
dw 0
db 0
db 0x9A
db 11001111b
db 0
.data:
dw 0xFFFF
dw 0
db 0
db 0x92
db 11001111b
db 0
.pointer:
dw $ - gdt - 1
dd gdt