]> git.proxmox.com Git - mirror_edk2.git/blame - DuetPkg/BootSector/efi64.S
Remove .rept directive to improve portability.
[mirror_edk2.git] / DuetPkg / BootSector / efi64.S
CommitLineData
f3eb2131 1#------------------------------------------------------------------------------\r
2#*\r
3#* Copyright 2006, Intel Corporation \r
4#* All rights reserved. This program and the accompanying materials \r
5#* are licensed and made available under the terms and conditions of the BSD License \r
6#* which accompanies this distribution. The full text of the license may be found at \r
7#* http://opensource.org/licenses/bsd-license.php \r
8#* \r
9#* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10#* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11#* \r
12#* efi64.asm\r
13#* \r
14#* Abstract:\r
15#*\r
16#------------------------------------------------------------------------------\r
17\r
18##############################################################################\r
19# Now in 64-bit long mode.\r
20##############################################################################\r
21\r
22 .486: \r
23 .stack: \r
24 .code: \r
25 .org 0x21000\r
26\r
27.equ DEFAULT_HANDLER_SIZE, INT1 - INT0\r
28\r
29.macro jmpCommonIdtEntry \r
30 # jmp commonIdtEntry - this must be hand coded to keep the assembler from\r
31 # using a 8 bit reletive jump when the entries are\r
32 # within 255 bytes of the common entry. This must\r
33 # be done to maintain the consistency of the size\r
34 # of entry points...\r
b29a823d 35 .byte 0xe9 # jmp 16 bit relative\r
36 .long commonIdtEntry - . - 4 # offset to jump to\r
f3eb2131 37.endm\r
38\r
39\r
40Start: \r
41\r
42 movl $0x001fffe8,%esp # make final stack aligned\r
43\r
44 # set OSFXSR and OSXMMEXCPT because some code will use XMM register\r
45 .byte 0xf\r
46 .byte 0x20\r
47 .byte 0xe0\r
48# mov rax, cr4\r
49 btsl $9,%eax\r
50 btsl $0xa,%eax\r
51 .byte 0xf\r
52 .byte 0x22\r
53 .byte 0xe0\r
54# mov cr4, rax\r
55\r
56 call ClearScreen\r
57\r
58 # Populate IDT with meaningful offsets for exception handlers...\r
b29a823d 59 sidt Idtr \r
60 \r
f3eb2131 61\r
b29a823d 62 movl Halt, %eax\r
f3eb2131 63 movl %eax,%ebx # use bx to copy 15..0 to descriptors\r
64 shrl $16,%eax # use ax to copy 31..16 to descriptors \r
65 # 63..32 of descriptors is 0\r
66 movl $0x78,%ecx # 78h IDT entries to initialize with unique entry points (exceptions)\r
b29a823d 67 movl (Idtr + 2), %esi\r
f3eb2131 68 movl (%esi),%edi\r
69\r
70LOOP_1: # loop through all IDT entries exception handlers and initialize to default handler\r
3bd0ef80 71 movw %bx, (%edi) # write bits 15..0 of offset\r
72 movw $0x38, 2(%edi) # SYS_CODE_SEL64 from GDT\r
b29a823d 73 movw $(0x0e00 | 0x8000), 4(%edi) # type = 386 interrupt gate, present\r
f3eb2131 74 movw %ax, 6(%edi) # write bits 31..16 of offset\r
3bd0ef80 75 movl $0, 8(%edi) # write bits 31..16 of offset \r
76 addl $16, %edi # move up to next descriptor\r
77 addw DEFAULT_HANDLER_SIZE, %bx # move to next entry point\r
f3eb2131 78 loopl LOOP_1 # loop back through again until all descriptors are initialized\r
79\r
80 ## at this point edi contains the offset of the descriptor for INT 20\r
81 ## and bx contains the low 16 bits of the offset of the default handler\r
82 ## so initialize all the rest of the descriptors with these two values...\r
83# mov ecx, 101 ; there are 100 descriptors left (INT 20 (14h) - INT 119 (77h)\r
84#@@: ; loop through all IDT entries exception handlers and initialize to default handler\r
85# mov word ptr [edi], bx ; write bits 15..0 of offset\r
86# mov word ptr [edi+2], 38h ; SYS_CODE64_SEL from GDT\r
87# mov word ptr [edi+4], 0e00h OR 8000h ; type = 386 interrupt gate, present\r
88# mov word ptr [edi+6], ax ; write bits 31..16 of offset\r
89# mov dword ptr [edi+8], 0 ; write bits 63..32 of offset\r
90# add edi, 16 ; move up to next descriptor\r
91# loop @b ; loop back through again until all descriptors are initialized\r
92\r
93\r
94## DUMP location of IDT and several of the descriptors\r
95# mov ecx, 8\r
96# mov eax, [offset Idtr + 2]\r
97# mov eax, [eax]\r
98# mov edi, 0b8000h\r
99# call PrintQword\r
100# mov esi, eax\r
101# mov edi, 0b80a0h\r
102# jmp OuterLoop\r
103\r
104## \r
105## just for fun, let's do a software interrupt to see if we correctly land in the exception handler...\r
106# mov eax, 011111111h\r
107# mov ebx, 022222222h\r
108# mov ecx, 033333333h\r
109# mov edx, 044444444h\r
110# mov ebp, 055555555h\r
111# mov esi, 066666666h\r
112# mov edi, 077777777h\r
113# push 011111111h\r
114# push 022222222h\r
115# push 033333333h\r
116# int 119\r
117\r
118 movl $0x22000,%esi # esi = 22000\r
119 movl 0x14(%esi),%eax # eax = [22014]\r
120 addl %eax,%esi # esi = 22000 + [22014] = Base of EFILDR.C\r
121 movl 0x3c(%esi),%ebp # ebp = [22000 + [22014] + 3c] = NT Image Header for EFILDR.C\r
122 addl %esi,%ebp\r
123 movl 0x30(%ebp),%edi # edi = [[22000 + [22014] + 3c] + 2c] = ImageBase (63..32 is zero, ignore)\r
124 movl 0x28(%ebp),%eax # eax = [[22000 + [22014] + 3c] + 24] = EntryPoint\r
125 addl %edi,%eax # eax = ImageBase + EntryPoint\r
b29a823d 126 movl %ebx, EfiLdrOffset \r
f3eb2131 127 movl %eax, (%ebx) # Modify far jump instruction for correct entry point\r
128\r
b29a823d 129 movw 6(%ebp), %bx # bx = Number of sections\r
f3eb2131 130 xorl %eax,%eax\r
b29a823d 131 movw 0x14(%ebp), %ax # ax = Optional Header Size\r
f3eb2131 132 addl %eax,%ebp\r
133 addl $0x18,%ebp # ebp = Start of 1st Section\r
134\r
135SectionLoop: \r
136 pushl %esi # Save Base of EFILDR.C\r
137 pushl %edi # Save ImageBase\r
138 addl 0x14(%ebp),%esi # esi = Base of EFILDR.C + PointerToRawData\r
139 addl 0x0c(%ebp),%edi # edi = ImageBase + VirtualAddress\r
140 movl 0x10(%ebp),%ecx # ecs = SizeOfRawData\r
141\r
142 cld\r
143 shrl $2,%ecx\r
144 rep\r
145 movsl\r
146\r
147 popl %edi # Restore ImageBase\r
148 popl %esi # Restore Base of EFILDR.C\r
149\r
150 addw $0x28,%bp # ebp = ebp + 028h = Pointer to next section record\r
151 .byte 0x66\r
152 .byte 0xff\r
153 .byte 0xcb\r
154# dec bx\r
155 cmpw $0,%bx\r
156 jne SectionLoop\r
157\r
b29a823d 158 movl (Idtr), %eax # get size of IDT\r
159 movzx (%edx), %eax\r
f3eb2131 160 .byte 0xff\r
161 .byte 0xc0\r
162# inc eax\r
b29a823d 163 addl 2(%edx), %eax # add to base of IDT to get location of memory map...\r
f3eb2131 164 xorl %ecx,%ecx\r
165 movl %eax,%ecx # put argument to RCX\r
166\r
167 .byte 0x48\r
168 .byte 0xc7\r
169 .byte 0xc0\r
170EfiLdrOffset: \r
171 .long 0x00401000 # Offset of EFILDR\r
172# mov rax, 401000h\r
173 .byte 0x50\r
174# push rax\r
175\r
176# ret\r
177 .byte 0xc3\r
178\r
179# db "**** DEFAULT IDT ENTRY ***",0\r
9811c392 180 .p2align 1\r
f3eb2131 181Halt: \r
182INT0: \r
183 pushl $0x0 # push error code place holder on the stack\r
184 pushl $0x0\r
185 jmpCommonIdtEntry \r
186# db 0e9h ; jmp 16 bit reletive \r
187# dd commonIdtEntry - $ - 4 ; offset to jump to\r
188\r
189INT1: \r
190 pushl $0x0 # push error code place holder on the stack\r
191 pushl $0x1\r
192 jmpCommonIdtEntry \r
193\r
194INT2: \r
195 pushl $0x0 # push error code place holder on the stack\r
196 pushl $0x2\r
197 jmpCommonIdtEntry \r
198\r
199INT3: \r
200 pushl $0x0 # push error code place holder on the stack\r
201 pushl $0x3\r
202 jmpCommonIdtEntry \r
203\r
204INT4: \r
205 pushl $0x0 # push error code place holder on the stack\r
206 pushl $0x4\r
207 jmpCommonIdtEntry \r
208\r
209INT5: \r
210 pushl $0x0 # push error code place holder on the stack\r
211 pushl $0x5\r
212 jmpCommonIdtEntry \r
213\r
214INT6: \r
215 pushl $0x0 # push error code place holder on the stack\r
216 pushl $0x6\r
217 jmpCommonIdtEntry \r
218\r
219INT7: \r
220 pushl $0x0 # push error code place holder on the stack\r
221 pushl $0x7\r
222 jmpCommonIdtEntry \r
223\r
224INT8: \r
225# Double fault causes an error code to be pushed so no phony push necessary\r
226 nop\r
227 nop\r
228 pushl $0x8\r
229 jmpCommonIdtEntry \r
230\r
231INT9: \r
232 pushl $0x0 # push error code place holder on the stack\r
233 pushl $0x9\r
234 jmpCommonIdtEntry \r
235\r
236INT10: \r
237# Invalid TSS causes an error code to be pushed so no phony push necessary\r
238 nop\r
239 nop\r
240 pushl $10\r
241 jmpCommonIdtEntry \r
242\r
243INT11: \r
244# Segment Not Present causes an error code to be pushed so no phony push necessary\r
245 nop\r
246 nop\r
247 pushl $11\r
248 jmpCommonIdtEntry \r
249\r
250INT12: \r
251# Stack fault causes an error code to be pushed so no phony push necessary\r
252 nop\r
253 nop\r
254 pushl $12\r
255 jmpCommonIdtEntry \r
256\r
257INT13: \r
258# GP fault causes an error code to be pushed so no phony push necessary\r
259 nop\r
260 nop\r
261 pushl $13\r
262 jmpCommonIdtEntry \r
263\r
264INT14: \r
265# Page fault causes an error code to be pushed so no phony push necessary\r
266 nop\r
267 nop\r
268 pushl $14\r
269 jmpCommonIdtEntry \r
270\r
271INT15: \r
272 pushl $0x0 # push error code place holder on the stack\r
273 pushl $15\r
274 jmpCommonIdtEntry \r
275\r
276INT16: \r
277 pushl $0x0 # push error code place holder on the stack\r
278 pushl $16\r
279 jmpCommonIdtEntry \r
280\r
281INT17: \r
282# Alignment check causes an error code to be pushed so no phony push necessary\r
283 nop\r
284 nop\r
285 pushl $17\r
286 jmpCommonIdtEntry \r
287\r
288INT18: \r
289 pushl $0x0 # push error code place holder on the stack\r
290 pushl $18\r
291 jmpCommonIdtEntry \r
292\r
293INT19: \r
294 pushl $0x0 # push error code place holder on the stack\r
295 pushl $19\r
296 jmpCommonIdtEntry \r
297\r
298INTUnknown: \r
208628f8 299# The following segment repeats (0x78 - 20) times:\r
300# No. 1\r
f3eb2131 301 pushl $0x0 # push error code place holder on the stack\r
302# push xxh ; push vector number\r
303 .byte 0x6a\r
304 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
305 jmpCommonIdtEntry \r
208628f8 306# No. 2\r
307 pushl $0x0 # push error code place holder on the stack\r
308# push xxh ; push vector number\r
309 .byte 0x6a\r
310 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
311 jmpCommonIdtEntry \r
312# No. 3\r
313 pushl $0x0 # push error code place holder on the stack\r
314# push xxh ; push vector number\r
315 .byte 0x6a\r
316 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
317 jmpCommonIdtEntry \r
318# No. 4\r
319 pushl $0x0 # push error code place holder on the stack\r
320# push xxh ; push vector number\r
321 .byte 0x6a\r
322 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
323 jmpCommonIdtEntry \r
324# No. 5\r
325 pushl $0x0 # push error code place holder on the stack\r
326# push xxh ; push vector number\r
327 .byte 0x6a\r
328 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
329 jmpCommonIdtEntry \r
330# No. 6\r
331 pushl $0x0 # push error code place holder on the stack\r
332# push xxh ; push vector number\r
333 .byte 0x6a\r
334 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
335 jmpCommonIdtEntry \r
336# No. 7\r
337 pushl $0x0 # push error code place holder on the stack\r
338# push xxh ; push vector number\r
339 .byte 0x6a\r
340 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
341 jmpCommonIdtEntry \r
342# No. 8\r
343 pushl $0x0 # push error code place holder on the stack\r
344# push xxh ; push vector number\r
345 .byte 0x6a\r
346 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
347 jmpCommonIdtEntry \r
348# No. 9\r
349 pushl $0x0 # push error code place holder on the stack\r
350# push xxh ; push vector number\r
351 .byte 0x6a\r
352 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
353 jmpCommonIdtEntry \r
354# No. 10\r
355 pushl $0x0 # push error code place holder on the stack\r
356# push xxh ; push vector number\r
357 .byte 0x6a\r
358 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
359 jmpCommonIdtEntry \r
360# No. 11\r
361 pushl $0x0 # push error code place holder on the stack\r
362# push xxh ; push vector number\r
363 .byte 0x6a\r
364 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
365 jmpCommonIdtEntry \r
366# No. 12\r
367 pushl $0x0 # push error code place holder on the stack\r
368# push xxh ; push vector number\r
369 .byte 0x6a\r
370 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
371 jmpCommonIdtEntry \r
372# No. 13\r
373 pushl $0x0 # push error code place holder on the stack\r
374# push xxh ; push vector number\r
375 .byte 0x6a\r
376 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
377 jmpCommonIdtEntry \r
378# No. 14\r
379 pushl $0x0 # push error code place holder on the stack\r
380# push xxh ; push vector number\r
381 .byte 0x6a\r
382 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
383 jmpCommonIdtEntry \r
384# No. 15\r
385 pushl $0x0 # push error code place holder on the stack\r
386# push xxh ; push vector number\r
387 .byte 0x6a\r
388 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
389 jmpCommonIdtEntry \r
390# No. 16\r
391 pushl $0x0 # push error code place holder on the stack\r
392# push xxh ; push vector number\r
393 .byte 0x6a\r
394 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
395 jmpCommonIdtEntry \r
396# No. 17\r
397 pushl $0x0 # push error code place holder on the stack\r
398# push xxh ; push vector number\r
399 .byte 0x6a\r
400 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
401 jmpCommonIdtEntry \r
402# No. 18\r
403 pushl $0x0 # push error code place holder on the stack\r
404# push xxh ; push vector number\r
405 .byte 0x6a\r
406 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
407 jmpCommonIdtEntry \r
408# No. 19\r
409 pushl $0x0 # push error code place holder on the stack\r
410# push xxh ; push vector number\r
411 .byte 0x6a\r
412 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
413 jmpCommonIdtEntry \r
414# No. 20\r
415 pushl $0x0 # push error code place holder on the stack\r
416# push xxh ; push vector number\r
417 .byte 0x6a\r
418 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
419 jmpCommonIdtEntry \r
420# No. 21\r
421 pushl $0x0 # push error code place holder on the stack\r
422# push xxh ; push vector number\r
423 .byte 0x6a\r
424 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
425 jmpCommonIdtEntry \r
426# No. 22\r
427 pushl $0x0 # push error code place holder on the stack\r
428# push xxh ; push vector number\r
429 .byte 0x6a\r
430 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
431 jmpCommonIdtEntry \r
432# No. 23\r
433 pushl $0x0 # push error code place holder on the stack\r
434# push xxh ; push vector number\r
435 .byte 0x6a\r
436 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
437 jmpCommonIdtEntry \r
438# No. 24\r
439 pushl $0x0 # push error code place holder on the stack\r
440# push xxh ; push vector number\r
441 .byte 0x6a\r
442 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
443 jmpCommonIdtEntry \r
444# No. 25\r
445 pushl $0x0 # push error code place holder on the stack\r
446# push xxh ; push vector number\r
447 .byte 0x6a\r
448 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
449 jmpCommonIdtEntry \r
450# No. 26\r
451 pushl $0x0 # push error code place holder on the stack\r
452# push xxh ; push vector number\r
453 .byte 0x6a\r
454 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
455 jmpCommonIdtEntry \r
456# No. 27\r
457 pushl $0x0 # push error code place holder on the stack\r
458# push xxh ; push vector number\r
459 .byte 0x6a\r
460 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
461 jmpCommonIdtEntry \r
462# No. 28\r
463 pushl $0x0 # push error code place holder on the stack\r
464# push xxh ; push vector number\r
465 .byte 0x6a\r
466 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
467 jmpCommonIdtEntry \r
468# No. 29\r
469 pushl $0x0 # push error code place holder on the stack\r
470# push xxh ; push vector number\r
471 .byte 0x6a\r
472 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
473 jmpCommonIdtEntry \r
474# No. 30\r
475 pushl $0x0 # push error code place holder on the stack\r
476# push xxh ; push vector number\r
477 .byte 0x6a\r
478 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
479 jmpCommonIdtEntry \r
480# No. 31\r
481 pushl $0x0 # push error code place holder on the stack\r
482# push xxh ; push vector number\r
483 .byte 0x6a\r
484 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
485 jmpCommonIdtEntry \r
486# No. 32\r
487 pushl $0x0 # push error code place holder on the stack\r
488# push xxh ; push vector number\r
489 .byte 0x6a\r
490 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
491 jmpCommonIdtEntry \r
492# No. 33\r
493 pushl $0x0 # push error code place holder on the stack\r
494# push xxh ; push vector number\r
495 .byte 0x6a\r
496 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
497 jmpCommonIdtEntry \r
498# No. 34\r
499 pushl $0x0 # push error code place holder on the stack\r
500# push xxh ; push vector number\r
501 .byte 0x6a\r
502 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
503 jmpCommonIdtEntry \r
504# No. 35\r
505 pushl $0x0 # push error code place holder on the stack\r
506# push xxh ; push vector number\r
507 .byte 0x6a\r
508 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
509 jmpCommonIdtEntry \r
510# No. 36\r
511 pushl $0x0 # push error code place holder on the stack\r
512# push xxh ; push vector number\r
513 .byte 0x6a\r
514 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
515 jmpCommonIdtEntry \r
516# No. 37\r
517 pushl $0x0 # push error code place holder on the stack\r
518# push xxh ; push vector number\r
519 .byte 0x6a\r
520 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
521 jmpCommonIdtEntry \r
522# No. 38\r
523 pushl $0x0 # push error code place holder on the stack\r
524# push xxh ; push vector number\r
525 .byte 0x6a\r
526 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
527 jmpCommonIdtEntry \r
528# No. 39\r
529 pushl $0x0 # push error code place holder on the stack\r
530# push xxh ; push vector number\r
531 .byte 0x6a\r
532 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
533 jmpCommonIdtEntry \r
534# No. 40\r
535 pushl $0x0 # push error code place holder on the stack\r
536# push xxh ; push vector number\r
537 .byte 0x6a\r
538 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
539 jmpCommonIdtEntry \r
540# No. 41\r
541 pushl $0x0 # push error code place holder on the stack\r
542# push xxh ; push vector number\r
543 .byte 0x6a\r
544 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
545 jmpCommonIdtEntry \r
546# No. 42\r
547 pushl $0x0 # push error code place holder on the stack\r
548# push xxh ; push vector number\r
549 .byte 0x6a\r
550 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
551 jmpCommonIdtEntry \r
552# No. 43\r
553 pushl $0x0 # push error code place holder on the stack\r
554# push xxh ; push vector number\r
555 .byte 0x6a\r
556 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
557 jmpCommonIdtEntry \r
558# No. 44\r
559 pushl $0x0 # push error code place holder on the stack\r
560# push xxh ; push vector number\r
561 .byte 0x6a\r
562 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
563 jmpCommonIdtEntry \r
564# No. 45\r
565 pushl $0x0 # push error code place holder on the stack\r
566# push xxh ; push vector number\r
567 .byte 0x6a\r
568 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
569 jmpCommonIdtEntry \r
570# No. 46\r
571 pushl $0x0 # push error code place holder on the stack\r
572# push xxh ; push vector number\r
573 .byte 0x6a\r
574 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
575 jmpCommonIdtEntry \r
576# No. 47\r
577 pushl $0x0 # push error code place holder on the stack\r
578# push xxh ; push vector number\r
579 .byte 0x6a\r
580 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
581 jmpCommonIdtEntry \r
582# No. 48\r
583 pushl $0x0 # push error code place holder on the stack\r
584# push xxh ; push vector number\r
585 .byte 0x6a\r
586 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
587 jmpCommonIdtEntry \r
588# No. 49\r
589 pushl $0x0 # push error code place holder on the stack\r
590# push xxh ; push vector number\r
591 .byte 0x6a\r
592 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
593 jmpCommonIdtEntry \r
594# No. 50\r
595 pushl $0x0 # push error code place holder on the stack\r
596# push xxh ; push vector number\r
597 .byte 0x6a\r
598 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
599 jmpCommonIdtEntry \r
600# No. 51\r
601 pushl $0x0 # push error code place holder on the stack\r
602# push xxh ; push vector number\r
603 .byte 0x6a\r
604 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
605 jmpCommonIdtEntry \r
606# No. 52\r
607 pushl $0x0 # push error code place holder on the stack\r
608# push xxh ; push vector number\r
609 .byte 0x6a\r
610 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
611 jmpCommonIdtEntry \r
612# No. 53\r
613 pushl $0x0 # push error code place holder on the stack\r
614# push xxh ; push vector number\r
615 .byte 0x6a\r
616 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
617 jmpCommonIdtEntry \r
618# No. 54\r
619 pushl $0x0 # push error code place holder on the stack\r
620# push xxh ; push vector number\r
621 .byte 0x6a\r
622 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
623 jmpCommonIdtEntry \r
624# No. 55\r
625 pushl $0x0 # push error code place holder on the stack\r
626# push xxh ; push vector number\r
627 .byte 0x6a\r
628 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
629 jmpCommonIdtEntry \r
630# No. 56\r
631 pushl $0x0 # push error code place holder on the stack\r
632# push xxh ; push vector number\r
633 .byte 0x6a\r
634 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
635 jmpCommonIdtEntry \r
636# No. 57\r
637 pushl $0x0 # push error code place holder on the stack\r
638# push xxh ; push vector number\r
639 .byte 0x6a\r
640 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
641 jmpCommonIdtEntry \r
642# No. 58\r
643 pushl $0x0 # push error code place holder on the stack\r
644# push xxh ; push vector number\r
645 .byte 0x6a\r
646 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
647 jmpCommonIdtEntry \r
648# No. 59\r
649 pushl $0x0 # push error code place holder on the stack\r
650# push xxh ; push vector number\r
651 .byte 0x6a\r
652 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
653 jmpCommonIdtEntry \r
654# No. 60\r
655 pushl $0x0 # push error code place holder on the stack\r
656# push xxh ; push vector number\r
657 .byte 0x6a\r
658 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
659 jmpCommonIdtEntry \r
660# No. 61\r
661 pushl $0x0 # push error code place holder on the stack\r
662# push xxh ; push vector number\r
663 .byte 0x6a\r
664 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
665 jmpCommonIdtEntry \r
666# No. 62\r
667 pushl $0x0 # push error code place holder on the stack\r
668# push xxh ; push vector number\r
669 .byte 0x6a\r
670 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
671 jmpCommonIdtEntry \r
672# No. 63\r
673 pushl $0x0 # push error code place holder on the stack\r
674# push xxh ; push vector number\r
675 .byte 0x6a\r
676 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
677 jmpCommonIdtEntry \r
678# No. 64\r
679 pushl $0x0 # push error code place holder on the stack\r
680# push xxh ; push vector number\r
681 .byte 0x6a\r
682 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
683 jmpCommonIdtEntry \r
684# No. 65\r
685 pushl $0x0 # push error code place holder on the stack\r
686# push xxh ; push vector number\r
687 .byte 0x6a\r
688 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
689 jmpCommonIdtEntry \r
690# No. 66\r
691 pushl $0x0 # push error code place holder on the stack\r
692# push xxh ; push vector number\r
693 .byte 0x6a\r
694 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
695 jmpCommonIdtEntry \r
696# No. 67\r
697 pushl $0x0 # push error code place holder on the stack\r
698# push xxh ; push vector number\r
699 .byte 0x6a\r
700 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
701 jmpCommonIdtEntry \r
702# No. 68\r
703 pushl $0x0 # push error code place holder on the stack\r
704# push xxh ; push vector number\r
705 .byte 0x6a\r
706 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
707 jmpCommonIdtEntry \r
708# No. 69\r
709 pushl $0x0 # push error code place holder on the stack\r
710# push xxh ; push vector number\r
711 .byte 0x6a\r
712 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
713 jmpCommonIdtEntry \r
714# No. 70\r
715 pushl $0x0 # push error code place holder on the stack\r
716# push xxh ; push vector number\r
717 .byte 0x6a\r
718 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
719 jmpCommonIdtEntry \r
720# No. 71\r
721 pushl $0x0 # push error code place holder on the stack\r
722# push xxh ; push vector number\r
723 .byte 0x6a\r
724 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
725 jmpCommonIdtEntry \r
726# No. 72\r
727 pushl $0x0 # push error code place holder on the stack\r
728# push xxh ; push vector number\r
729 .byte 0x6a\r
730 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
731 jmpCommonIdtEntry \r
732# No. 73\r
733 pushl $0x0 # push error code place holder on the stack\r
734# push xxh ; push vector number\r
735 .byte 0x6a\r
736 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
737 jmpCommonIdtEntry \r
738# No. 74\r
739 pushl $0x0 # push error code place holder on the stack\r
740# push xxh ; push vector number\r
741 .byte 0x6a\r
742 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
743 jmpCommonIdtEntry \r
744# No. 75\r
745 pushl $0x0 # push error code place holder on the stack\r
746# push xxh ; push vector number\r
747 .byte 0x6a\r
748 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
749 jmpCommonIdtEntry \r
750# No. 76\r
751 pushl $0x0 # push error code place holder on the stack\r
752# push xxh ; push vector number\r
753 .byte 0x6a\r
754 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
755 jmpCommonIdtEntry \r
756# No. 77\r
757 pushl $0x0 # push error code place holder on the stack\r
758# push xxh ; push vector number\r
759 .byte 0x6a\r
760 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
761 jmpCommonIdtEntry \r
762# No. 78\r
763 pushl $0x0 # push error code place holder on the stack\r
764# push xxh ; push vector number\r
765 .byte 0x6a\r
766 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
767 jmpCommonIdtEntry \r
768# No. 79\r
769 pushl $0x0 # push error code place holder on the stack\r
770# push xxh ; push vector number\r
771 .byte 0x6a\r
772 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
773 jmpCommonIdtEntry \r
774# No. 80\r
775 pushl $0x0 # push error code place holder on the stack\r
776# push xxh ; push vector number\r
777 .byte 0x6a\r
778 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
779 jmpCommonIdtEntry \r
780# No. 81\r
781 pushl $0x0 # push error code place holder on the stack\r
782# push xxh ; push vector number\r
783 .byte 0x6a\r
784 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
785 jmpCommonIdtEntry \r
786# No. 82\r
787 pushl $0x0 # push error code place holder on the stack\r
788# push xxh ; push vector number\r
789 .byte 0x6a\r
790 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
791 jmpCommonIdtEntry \r
792# No. 83\r
793 pushl $0x0 # push error code place holder on the stack\r
794# push xxh ; push vector number\r
795 .byte 0x6a\r
796 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
797 jmpCommonIdtEntry \r
798# No. 84\r
799 pushl $0x0 # push error code place holder on the stack\r
800# push xxh ; push vector number\r
801 .byte 0x6a\r
802 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
803 jmpCommonIdtEntry \r
804# No. 85\r
805 pushl $0x0 # push error code place holder on the stack\r
806# push xxh ; push vector number\r
807 .byte 0x6a\r
808 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
809 jmpCommonIdtEntry \r
810# No. 86\r
811 pushl $0x0 # push error code place holder on the stack\r
812# push xxh ; push vector number\r
813 .byte 0x6a\r
814 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
815 jmpCommonIdtEntry \r
816# No. 87\r
817 pushl $0x0 # push error code place holder on the stack\r
818# push xxh ; push vector number\r
819 .byte 0x6a\r
820 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
821 jmpCommonIdtEntry \r
822# No. 88\r
823 pushl $0x0 # push error code place holder on the stack\r
824# push xxh ; push vector number\r
825 .byte 0x6a\r
826 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
827 jmpCommonIdtEntry \r
828# No. 89\r
829 pushl $0x0 # push error code place holder on the stack\r
830# push xxh ; push vector number\r
831 .byte 0x6a\r
832 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
833 jmpCommonIdtEntry \r
834# No. 90\r
835 pushl $0x0 # push error code place holder on the stack\r
836# push xxh ; push vector number\r
837 .byte 0x6a\r
838 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
839 jmpCommonIdtEntry \r
840# No. 91\r
841 pushl $0x0 # push error code place holder on the stack\r
842# push xxh ; push vector number\r
843 .byte 0x6a\r
844 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
845 jmpCommonIdtEntry \r
846# No. 92\r
847 pushl $0x0 # push error code place holder on the stack\r
848# push xxh ; push vector number\r
849 .byte 0x6a\r
850 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
851 jmpCommonIdtEntry \r
852# No. 93\r
853 pushl $0x0 # push error code place holder on the stack\r
854# push xxh ; push vector number\r
855 .byte 0x6a\r
856 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
857 jmpCommonIdtEntry \r
858# No. 94\r
859 pushl $0x0 # push error code place holder on the stack\r
860# push xxh ; push vector number\r
861 .byte 0x6a\r
862 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
863 jmpCommonIdtEntry \r
864# No. 95\r
865 pushl $0x0 # push error code place holder on the stack\r
866# push xxh ; push vector number\r
867 .byte 0x6a\r
868 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
869 jmpCommonIdtEntry \r
870# No. 96\r
871 pushl $0x0 # push error code place holder on the stack\r
872# push xxh ; push vector number\r
873 .byte 0x6a\r
874 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
875 jmpCommonIdtEntry \r
876# No. 97\r
877 pushl $0x0 # push error code place holder on the stack\r
878# push xxh ; push vector number\r
879 .byte 0x6a\r
880 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
881 jmpCommonIdtEntry \r
882# No. 98\r
883 pushl $0x0 # push error code place holder on the stack\r
884# push xxh ; push vector number\r
885 .byte 0x6a\r
886 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
887 jmpCommonIdtEntry \r
888# No. 99\r
889 pushl $0x0 # push error code place holder on the stack\r
890# push xxh ; push vector number\r
891 .byte 0x6a\r
892 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
893 jmpCommonIdtEntry \r
894# No. 100\r
895 pushl $0x0 # push error code place holder on the stack\r
896# push xxh ; push vector number\r
897 .byte 0x6a\r
898 .byte ( . - INTUnknown - 3 ) / 9 + 20 # vector number\r
899 jmpCommonIdtEntry \r
900\r
f3eb2131 901\r
902commonIdtEntry: \r
903 pushl %eax\r
904 pushl %ecx\r
905 pushl %edx\r
906 pushl %ebx\r
907 pushl %esp\r
908 pushl %ebp\r
909 pushl %esi\r
910 pushl %edi\r
911 .byte 0x41\r
912 .byte 0x50\r
913# push r8\r
914 .byte 0x41\r
915 .byte 0x51\r
916# push r9\r
917 .byte 0x41\r
918 .byte 0x52\r
919# push r10\r
920 .byte 0x41\r
921 .byte 0x53\r
922# push r11\r
923 .byte 0x41\r
924 .byte 0x54\r
925# push r12\r
926 .byte 0x41\r
927 .byte 0x55\r
928# push r13\r
929 .byte 0x41\r
930 .byte 0x56\r
931# push r14\r
932 .byte 0x41\r
933 .byte 0x57\r
934# push r15\r
935 .byte 0x48\r
936 movl %esp,%ebp\r
937# mov rbp, rsp\r
938\r
939##\r
940## At this point the stack looks like this:\r
941##\r
942## Calling SS\r
943## Calling RSP\r
944## rflags\r
945## Calling CS\r
946## Calling RIP\r
947## Error code or 0\r
948## Int num or 0ffh for unknown int num\r
949## rax\r
950## rcx\r
951## rdx\r
952## rbx\r
953## rsp\r
954## rbp\r
955## rsi\r
956## rdi\r
957## r8\r
958## r9\r
959## r10\r
960## r11\r
961## r12\r
962## r13\r
963## r14\r
964## r15 <------- RSP, RBP\r
965## \r
966\r
967 call ClearScreen\r
968 mov String1, %esi \r
969 call PrintString\r
970 .byte 0x48\r
971 movl 16*8(%ebp),%eax ## move Int number into RAX \r
972 .byte 0x48\r
973 cmpl $18,%eax\r
974 ja PrintDefaultString\r
975PrintExceptionString: \r
976 shll $3,%eax ## multiply by 8 to get offset from StringTable to actual string address\r
b29a823d 977 addl StringTable, %eax\r
f3eb2131 978 movl (%eax),%esi\r
979 jmp PrintTheString\r
980PrintDefaultString: \r
b29a823d 981 movl IntUnknownString, %esi\r
f3eb2131 982 # patch Int number\r
983 movl %eax,%edx\r
984 call A2C\r
985 movb %al,1(%esi)\r
986 movl %edx,%eax\r
987 shrl $4,%eax\r
988 call A2C\r
989 movb %al,(%esi)\r
990PrintTheString: \r
991 call PrintString\r
b29a823d 992 movl String2, %esi\r
f3eb2131 993 call PrintString\r
994 .byte 0x48\r
995 movl 19*8(%ebp),%eax # CS\r
996 call PrintQword\r
997 movb $':', %al\r
b29a823d 998 movb %al, (%edi)\r
f3eb2131 999 addl $2,%edi\r
1000 .byte 0x48\r
1001 movl 18*8(%ebp),%eax # RIP\r
1002 call PrintQword\r
b29a823d 1003 movl String3, %esi\r
f3eb2131 1004 call PrintString\r
1005\r
1006 movl $0xb8140,%edi\r
1007\r
b29a823d 1008 movl StringRax, %esi\r
f3eb2131 1009 call PrintString\r
1010 .byte 0x48\r
1011 movl 15*8(%ebp),%eax\r
1012 call PrintQword\r
1013\r
b29a823d 1014 movl StringRcx, %esi\r
f3eb2131 1015 call PrintString\r
1016 .byte 0x48\r
1017 movl 14*8(%ebp),%eax\r
1018 call PrintQword\r
1019\r
b29a823d 1020 movl StringRdx, %esi\r
f3eb2131 1021 call PrintString\r
1022 .byte 0x48\r
1023 movl 13*8(%ebp),%eax\r
1024 call PrintQword\r
1025\r
1026 movl $0xb81e0,%edi\r
1027\r
b29a823d 1028 movl StringRbx, %esi\r
f3eb2131 1029 call PrintString\r
1030 .byte 0x48\r
1031 movl 12*8(%ebp),%eax\r
1032 call PrintQword\r
1033\r
b29a823d 1034 movl StringRsp, %esi\r
f3eb2131 1035 call PrintString\r
1036 .byte 0x48\r
1037 movl 21*8(%ebp),%eax\r
1038 call PrintQword\r
1039\r
b29a823d 1040 movl StringRbp, %esi\r
f3eb2131 1041 call PrintString\r
1042 .byte 0x48\r
1043 movl 10*8(%ebp),%eax\r
1044 call PrintQword\r
1045\r
1046 movl $0xb8280,%edi\r
1047\r
b29a823d 1048 movl StringRsi, %esi\r
f3eb2131 1049 call PrintString\r
1050 .byte 0x48\r
1051 movl 9*8(%ebp),%eax\r
1052 call PrintQword\r
1053\r
b29a823d 1054 movl StringRdi, %esi\r
f3eb2131 1055 call PrintString\r
1056 .byte 0x48\r
1057 movl 8*8(%ebp),%eax\r
1058 call PrintQword\r
1059\r
b29a823d 1060 movl StringEcode, %esi\r
f3eb2131 1061 call PrintString\r
1062 .byte 0x48\r
1063 movl 17*8(%ebp),%eax\r
1064 call PrintQword\r
1065\r
1066 movl $0xb8320,%edi\r
1067\r
b29a823d 1068 movl StringR8, %esi\r
f3eb2131 1069 call PrintString\r
1070 .byte 0x48\r
1071 movl 7*8(%ebp),%eax\r
1072 call PrintQword\r
1073\r
b29a823d 1074 movl StringR9, %esi\r
f3eb2131 1075 call PrintString\r
1076 .byte 0x48\r
1077 movl 6*8(%ebp),%eax\r
1078 call PrintQword\r
1079\r
b29a823d 1080 movl StringR10, %esi\r
f3eb2131 1081 call PrintString\r
1082 .byte 0x48\r
1083 movl 5*8(%ebp),%eax\r
1084 call PrintQword\r
1085\r
1086 movl $0xb83c0,%edi\r
1087\r
b29a823d 1088 movl StringR11, %esi\r
f3eb2131 1089 call PrintString\r
1090 .byte 0x48\r
1091 movl 4*8(%ebp),%eax\r
1092 call PrintQword\r
1093\r
b29a823d 1094 movl StringR12, %esi\r
f3eb2131 1095 call PrintString\r
1096 .byte 0x48\r
1097 movl 3*8(%ebp),%eax\r
1098 call PrintQword\r
1099\r
b29a823d 1100 movl StringR13, %esi\r
f3eb2131 1101 call PrintString\r
1102 .byte 0x48\r
1103 movl 2*8(%ebp),%eax\r
1104 call PrintQword\r
1105\r
1106 movl $0xb8460,%edi\r
1107\r
b29a823d 1108 movl StringR14, %esi\r
f3eb2131 1109 call PrintString\r
1110 .byte 0x48\r
1111 movl 1*8(%ebp),%eax\r
1112 call PrintQword\r
1113\r
b29a823d 1114 movl StringR15, %esi\r
f3eb2131 1115 call PrintString\r
1116 .byte 0x48\r
1117 movl 0*8(%ebp),%eax\r
1118 call PrintQword\r
1119\r
b29a823d 1120 movl StringSs, %esi\r
f3eb2131 1121 call PrintString\r
1122 .byte 0x48\r
1123 movl 22*8(%ebp),%eax\r
1124 call PrintQword\r
1125\r
1126 movl $0xb8500,%edi\r
1127\r
b29a823d 1128 movl StringRflags, %esi\r
f3eb2131 1129 call PrintString\r
1130 .byte 0x48\r
1131 movl 20*8(%ebp),%eax\r
1132 call PrintQword\r
1133\r
1134 movl $0xb8640,%edi\r
1135\r
1136 movl %ebp,%esi\r
1137 addl $23*8,%esi\r
1138 movl $4,%ecx\r
1139\r
1140\r
1141OuterLoop: \r
1142 pushl %ecx\r
1143 movl $4,%ecx\r
1144 .byte 0x48\r
1145 movl %edi,%edx\r
1146\r
1147InnerLoop: \r
1148 .byte 0x48\r
1149 movl (%esi),%eax\r
1150 call PrintQword\r
1151 addl $8,%esi\r
b29a823d 1152 mov $0x00, %al \r
f3eb2131 1153 movb %al,(%edi)\r
1154 addl $2,%edi\r
1155 loop InnerLoop\r
1156\r
1157 popl %ecx\r
1158 addl $0xa0,%edx\r
1159 movl %edx,%edi\r
1160 loop OuterLoop\r
1161\r
1162\r
1163 movl $0xb8960,%edi\r
1164\r
1165 .byte 0x48\r
1166 movl 18*8(%ebp),%eax # RIP\r
1167 subl $8*8,%eax\r
1168 .byte 0x48\r
1169 movl %eax,%esi # esi = rip - 8 QWORD linear (total 16 QWORD)\r
1170\r
1171 movl $4,%ecx\r
1172\r
1173OuterLoop1: \r
1174 pushl %ecx\r
1175 movl $4,%ecx\r
1176 movl %edi,%edx\r
1177\r
1178InnerLoop1: \r
1179 .byte 0x48\r
1180 movl (%esi),%eax\r
1181 call PrintQword\r
1182 addl $8,%esi\r
b29a823d 1183 movb $0x00, %al\r
f3eb2131 1184 movb %al,(%edi)\r
1185 addl $2,%edi\r
1186 loop InnerLoop1\r
1187\r
1188 popl %ecx\r
1189 addl $0xa0,%edx\r
1190 movl %edx,%edi\r
1191 loop OuterLoop1\r
1192\r
1193\r
1194\r
1195 #wbinvd\r
3bd0ef80 1196LN_C1: \r
f3eb2131 1197 jmp LN_C1\r
1198\r
1199#\r
1200# return\r
1201#\r
1202 movl %ebp,%esp\r
1203# mov rsp, rbp\r
1204 .byte 0x41\r
1205 .byte 0x5f\r
1206# pop r15\r
1207 .byte 0x41\r
1208 .byte 0x5e\r
1209# pop r14\r
1210 .byte 0x41\r
1211 .byte 0x5d\r
1212# pop r13\r
1213 .byte 0x41\r
1214 .byte 0x5c\r
1215# pop r12\r
1216 .byte 0x41\r
1217 .byte 0x5b\r
1218# pop r11\r
1219 .byte 0x41\r
1220 .byte 0x5a\r
1221# pop r10\r
1222 .byte 0x41\r
1223 .byte 0x59\r
1224# pop r9\r
1225 .byte 0x41\r
1226 .byte 0x58\r
1227# pop r8\r
1228 popl %edi\r
1229 popl %esi\r
1230 popl %ebp\r
1231 popl %eax # esp\r
1232 popl %ebx\r
1233 popl %edx\r
1234 popl %ecx\r
1235 popl %eax\r
1236\r
1237 .byte 0x48\r
1238 .byte 0x83\r
1239 .byte 0xc4\r
1240 .byte 0x10\r
1241# add esp, 16 ; error code and INT number\r
1242\r
1243 .byte 0x48\r
1244 .byte 0xcf\r
1245# iretq\r
1246\r
1247PrintString: \r
1248 pushl %eax\r
1249LN_C2: \r
b29a823d 1250 movb (%esi), %al\r
f3eb2131 1251 cmpb $0,%al\r
1252 je LN_C3\r
b29a823d 1253 movb %al, (%edi)\r
f3eb2131 1254 .byte 0xff\r
1255 .byte 0xc6\r
1256# inc esi\r
1257 addl $2,%edi\r
1258 jmp LN_C2\r
1259LN_C3: \r
1260 popl %eax\r
1261 ret\r
1262\r
1263## RAX contains qword to print\r
1264## RDI contains memory location (screen location) to print it to\r
1265PrintQword: \r
1266 pushl %ecx\r
1267 pushl %ebx\r
1268 pushl %eax\r
1269\r
1270 .byte 0x48\r
1271 .byte 0xc7\r
1272 .byte 0xc1\r
1273 .long 16\r
1274# mov rcx, 16\r
1275looptop: \r
1276 .byte 0x48\r
1277 roll $4,%eax\r
1278 movb %al,%bl\r
1279 andb $0xf,%bl\r
1280 addb $'0', %bl\r
1281 cmpb $'9', %bl\r
1282 jle @f\r
1283 addb $7,%bl\r
1284@@: \r
b29a823d 1285 movb %bl, (%edi)\r
f3eb2131 1286 addl $2,%edi\r
1287 loop looptop\r
1288 #wbinvd\r
1289\r
1290 popl %eax\r
1291 popl %ebx\r
1292 popl %ecx\r
1293 ret\r
1294\r
1295ClearScreen: \r
1296 pushl %eax\r
1297 pushl %ecx\r
1298\r
b29a823d 1299 movb $0x00, %al\r
f3eb2131 1300 movb $0xc,%ah\r
1301 movl $0xb8000,%edi\r
1302 movl $80*24,%ecx\r
1303LN_C4: \r
b29a823d 1304 movw %ax, (%edi)\r
f3eb2131 1305 addl $2,%edi\r
1306 loop LN_C4\r
1307 movl $0xb8000,%edi\r
1308\r
1309 popl %ecx\r
1310 popl %eax\r
1311\r
1312 ret\r
1313\r
1314A2C: \r
1315 andb $0xf,%al\r
1316 addb $'0', %al\r
1317 cmpb $'9', %al\r
1318 jle @f\r
1319 addb $7,%al\r
1320LN_C5: \r
1321 ret\r
1322\r
1323String1: .asciz "*** INT "\r
1324\r
3bd0ef80 1325Int0String: .asciz "00h Divide by 0 -"\r
1326Int1String: .asciz "01h Debug exception -"\r
1327Int2String: .asciz "02h NMI -"\r
1328Int3String: .asciz "03h Breakpoint -"\r
1329Int4String: .asciz "04h Overflow -"\r
1330Int5String: .asciz "05h Bound -"\r
1331Int6String: .asciz "06h Invalid opcode -"\r
1332Int7String: .asciz "07h Device not available -"\r
1333Int8String: .asciz "08h Double fault -"\r
1334Int9String: .asciz "09h Coprocessor seg overrun (reserved) -"\r
1335Int10String: .asciz "0Ah Invalid TSS -"\r
1336Int11String: .asciz "0Bh Segment not present -"\r
1337Int12String: .asciz "0Ch Stack fault -"\r
1338Int13String: .asciz "0Dh General protection fault -"\r
1339Int14String: .asciz "0Eh Page fault -"\r
1340Int15String: .asciz "0Fh (Intel reserved) -"\r
1341Int16String: .asciz "10h Floating point error -"\r
1342Int17String: .asciz "11h Alignment check -"\r
1343Int18String: .asciz "12h Machine check -"\r
1344Int19String: .asciz "13h SIMD Floating-Point Exception -"\r
f3eb2131 1345IntUnknownString: .asciz "??h Unknown interrupt -"\r
1346\r
3bd0ef80 1347StringTable: .long Int0String, Int1String, Int2String, Int3String, \\r
1348 Int4String, Int5String, Int6String, Int7String, \\r
1349 Int8String, Int9String, Int10String, Int11String, \\r
1350 Int12String, Int13String, Int14String, Int15String,\\r
f3eb2131 1351 Int16String, Int17String, Int18String, Int19String\r
1352\r
1353String2: .asciz " HALT!! *** ("\r
1354String3: .asciz ")"\r
1355StringRax: .asciz "RAX="\r
1356StringRcx: .asciz " RCX="\r
1357StringRdx: .asciz " RDX="\r
1358StringRbx: .asciz "RBX="\r
1359StringRsp: .asciz " RSP="\r
1360StringRbp: .asciz " RBP="\r
1361StringRsi: .asciz "RSI="\r
1362StringRdi: .asciz " RDI="\r
1363StringEcode: .asciz " ECODE="\r
1364StringR8: .asciz "R8 ="\r
1365StringR9: .asciz " R9 ="\r
1366StringR10: .asciz " R10="\r
1367StringR11: .asciz "R11="\r
1368StringR12: .asciz " R12="\r
1369StringR13: .asciz " R13="\r
1370StringR14: .asciz "R14="\r
1371StringR15: .asciz " R15="\r
1372StringSs: .asciz " SS ="\r
1373StringRflags: .asciz "RFLAGS="\r
1374\r
1375Idtr: .float 0\r
1376 .float 0\r
1377\r
1378 .org 0x21ffe\r
1379BlockSignature: \r
1380 .word 0xaa55\r
1381\r