View difference between Paste ID: D6itfyBe and tV2ju9Dt
SHOW: | | - or go back to the newest paste.
1
org 7c00h
2
3
use16 
4
5
cli
6
lgdt[gdt]
7
lidt[idt]
8
mov eax,cr0 
9
or al,1 
10
mov cr0,eax 
11
jmp code32-table1:kernel 
12
13
use32 
14
15
kernel: 
16
mov ax,data32-table1 
17
mov gs,ax 
18
mov fs,ax 
19
mov ds,ax 
20
mov es,ax 
21
mov ss,ax 
22
mov esp,9fffch
23
mov eax,isr_fdc 
24-
out 21h,al
24+
25
mov word[table2+49*8+2],code32-table1 
26
mov word[table2+49*8+4],8e00h
27
shr eax,16 
28
mov [table2+49*8+6],ax
29
int 49
30
jmp $
31
32
isr_fdc:
33
mov dx,3f2h
34
mov al,1ch
35
out dx,al
36
call readmsr
37
mov dx,3f7h
38
mov al,0
39
out dx,al
40
call readmsr
41
mov dx,3f5h
42
mov al,0fh
43
out dx,al
44
mov al,0
45
out dx,al
46
mov al,0
47
out dx,al
48
call readmsr
49
mov al,6
50
out 0ah,al
51
mov al,0ffh
52
out 0ch,al
53
mov ax,start
54
out 4,al
55
mov al,ah
56
out 4,al
57
mov al,0ffh
58
out 0ch,al
59
out 5,al
60
mov al,1
61
out 5,al
62
mov al,code32-table1
63
out 81h,al
64
mov al,2
65
out 0ah,al
66
call readmsr
67
mov dx,3f5h
68
mov al,66h
69
out dx,al
70
mov al,0
71
out dx,al
72
mov al,0
73
out dx,al
74
mov al,0
75
out dx,al
76
mov al,2
77
out dx,al
78
mov al,2
79
out dx,al
80
mov al,18
81
out dx,al
82
mov al,27
83
out dx,al
84
mov al,0ffh
85
out dx,al
86
call readmsr
87
mov dx,3f5h
88
mov al,8
89
out dx,al
90
read_int_status:
91
mov dx,3f5h
92
in al,dx
93
test al,20h
94
jz read_int_status
95
iret
96
97
readmsr:
98
mov dx,3f4h
99
in al,dx
100
and al,0c0h
101
cmp al,80h
102
jne readmsr
103
ret
104
105
gdt: 
106
dw end_gdt-table1-1 
107
dd table1 
108
109
table1: 
110
dq 0 
111
112
code32: 
113
dw 0ffffh 
114
dw 0 
115
db 0 
116
db 9ah
117
db 0cfh 
118
db 0 
119
120
data32: 
121
dw 0ffffh 
122
dw 0 
123
db 0 
124
db 92h
125
db 0cfh 
126
db 0
127
128
end_gdt: 
129
130
idt: 
131
dw end_idt-(50*8)-1 
132
dd table2 
133
134
table2: 
135
dd 50*2 
136
137
end_idt:
138
139
times 510-($-$$) db 0 
140
dw 0aa55h
141
142
start:
143
mov di,0b800h
144
mov es,di
145
mov di,0
146
mov byte[es:di],42h
147
148
times 512-($-start) db 0