-
Notifications
You must be signed in to change notification settings - Fork 0
/
indef_02.asm
executable file
·84 lines (69 loc) · 954 Bytes
/
indef_02.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
74
75
76
77
78
79
80
81
82
83
84
[BITS 16]
[ORG 0x7C00]
_start:
cli
mov ax, cs
mov ds, ax
mov ss, ax
mov sp, _start
;; loading GDTR register
lgdt [gd_reg]
;; turning A20 on
in al, 0x92
or al, 2
out 0x92, al
;; setting PE bit of CR0 register
mov eax, cr0
or al, 1
mov cr0, eax
jmp 0x8: _protected
[BITS 32]
_protected:
;; loading DS, SS registers with data segment selector
mov ax, 0x10
mov ds, ax
mov ss, ax
mov esi, msg_hello
call kputs
;; pause cpu
hlt
jmp short $
cursor: dd 0
%define VIDEO_RAM 0xB8000
kputs:
pusha
.loop:
lodsb
test al, al
jz .quit
mov ecx, [cursor]
mov [VIDEO_RAM+ecx*2], al
inc dword [cursor]
jmp short .loop
.quit:
popa
ret
gdt:
dw 0, 0, 0, 0
db 0xFF
db 0xFF
db 0x00
db 0x00
db 0x00
db 10011010b
db 0xCF
db 0x00
db 0xFF
db 0xFF
db 0x00
db 0x00
db 0x00
db 10010010b
db 0xCF
db 0x00
gd_reg:
dw 8192
dd gdt
msg_hello: db "Indifirenza 0.0.0.1 32bit mode: ON", 0
times 510-($-$$) db 0
db 0xaa, 0x55