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