-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtendedSpace.asm
91 lines (64 loc) · 1.58 KB
/
ExtendedSpace.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
85
86
87
88
89
90
91
[org 0x7e00]
jmp EnterProtectedMode
%include "gdt.asm"
%include "Print_16bit.asm"
EnterProtectedMode:
call EnableA20
cli
lgdt [gdt_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp CODE_SEG:StartProtectedMode
EnableA20:
in al, 0x92
or al, 2
out 0x92, al
ret
[bits 32]
%include "CPUID.asm"
%include "SimplePaging.asm"
StartProtectedMode:
mov ax, DATA_SEG
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
;mov ebx, Message
;call PrintString
;%include "Print_32bit.asm"
; ----------------- DELETE - Just for testing :)
mov al, 0x20
mov ecx, 0x0
VIDEO_MEMORY equ 0xb8000
WHITE_ON_BLACK equ 0x1f
; Prints a null-terminated string pointed to by EDX
PrintString:
pusha
mov edx, VIDEO_MEMORY ; Set edx to the start of vid mem
SomeLoop:
mov ah, WHITE_ON_BLACK ; Store the attributes in AH
mov [edx], ax ; Store char and attributes at current
; character cell.
cmp ecx, 1999
je SomeDone
add ecx, 1
add edx, 2
jmp SomeLoop
SomeDone:
popa
ret
; -----------------
call DetectCPUID
call DetectLongMode
; Enable identity paging
call SetUpIdentityPaging
call EditGDT
jmp CODE_SEG:Start64Bit
[bits 64]
Start64Bit:
jmp $
Message:
dw "Hello World!!", 0
times 2048-($-$$) db 0