-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasmhead.nas
171 lines (142 loc) · 2.43 KB
/
asmhead.nas
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
[INSTRSET "i486p"]
VBEMODE EQU 0x105
BOTPAK EQU 0x00280000
DSKCAC EQU 0x00100000
DSKCAC0 EQU 0x00008000
CYLS EQU 0x0ff0
LEDS EQU 0x0ff1
VMODE EQU 0x0ff2
SCRNX EQU 0x0ff4
SCRNY EQU 0x0ff6
VRAM EQU 0x0ff8
ORG 0xc200 ; このプログラムがどこに読み込まれるのかを示す
; VBEチェック
MOV AX,0x9000
MOV ES,AX
MOV DI,0
MOV AX,0x4f00
INT 0x10
CMP AX,0x004f
JNE scrn320
; VBEバージョンチェック
MOV AX,[ES:DI+4]
CMP AX,0x0200
JB scrn320
; 画面モード取得
MOV CX,VBEMODE
MOV AX,0x4f01
INT 0x10
CMP AX,0x004f
JNE scrn320
; 画面モード情報確認
CMP BYTE [ES:DI+0x19],8
JNE scrn320
CMP BYTE [ES:DI+0x1b],4
JNE scrn320
MOV AX,[ES:DI+0x00]
AND AX,0x0080
JZ scrn320
; 画面モード切替
;MOV BX,VBEMODE+0x4000
MOV BX,0x4101
MOV AX,0x4f02
INT 0x10
MOV BYTE [VMODE],8 ; ここから画面設定の記録
;MOV AX,[ES:DI+0x12]
;MOV [SCRNX],AX
;MOV AX,[ES:DI+0x14]
;MOV [SCRNY],AX
;MOV EAX,[ES:DI+0x28]
;MOV [VRAM],EAX
MOV WORD [SCRNX],640
MOV WORD [SCRNY],480
MOV DWORD [VRAM],0xe0000000
JMP keystatus
scrn320:
MOV AL,0x13
MOV AH,0x00
INT 0x10
MOV BYTE [VMODE],8
MOV WORD [SCRNX],320
MOV WORD [SCRNY],200
MOV DWORD [VRAM],0x000a0000
keystatus:
MOV AH,0x02
INT 0x16
MOV [LEDS],AL
MOV AL,0xff
OUT 0x21,AL
NOP
OUT 0xa1,AL
CLI
CALL waitkbdout
MOV AL,0xd1
OUT 0x64,AL
CALL waitkbdout
MOV AL,0xdf
OUT 0x60,AL
CALL waitkbdout
LGDT [GDTR0]
MOV EAX,CR0
AND EAX,0x7fffffff
OR EAX,0x00000001
MOV CR0,EAX
JMP pipelineflush
pipelineflush:
MOV AX,1*8
MOV DS,AX
MOV ES,AX
MOV FS,AX
MOV GS,AX
MOV SS,AX
MOV ESI,bootpack
MOV EDI,BOTPAK
MOV ECX,512*1024/4
CALL memcpy
MOV ESI,0x7c00
MOV EDI,DSKCAC
MOV ECX,512/4
CALL memcpy
MOV ESI,DSKCAC0+512
MOV EDI,DSKCAC+512
MOV ECX,0
MOV CL,BYTE [CYLS]
IMUL ECX,512*18*2/4
SUB ECX,512/4
CALL memcpy
MOV EBX,BOTPAK
MOV ECX,[EBX+16]
ADD ECX,3
SHR ECX,2
JZ skip
MOV ESI,[EBX+20]
ADD ESI,EBX
MOV EDI,[EBX+12]
CALL memcpy
skip:
MOV ESP,[EBX+12]
JMP DWORD 2*8:0x0000001b
waitkbdout:
IN AL,0x64
AND AL,0x02
JNZ waitkbdout
RET
memcpy:
MOV EAX,[ESI]
ADD ESI,4
MOV [EDI],EAX
ADD EDI,4
SUB ECX,1
JNZ memcpy
RET
ALIGNB 16
GDT0:
RESB 8
DW 0xffff,0x0000,0x9200,0x00cf
DW 0xffff,0x0000,0x9a28,0x0047
DW 0
GDTR0:
DW 8*3-1
DD GDT0
ALIGNB 16
bootpack: