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