--- /dev/null
+[FORMAT "WCOFF"]\r
+[INSTRSET "i486p"]\r
+[BITS 32]\r
+[FILE "nasfunc1.nas"]\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler00\r
+ EXTERN _CPU_ExceptionHandler00\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler01\r
+ EXTERN _CPU_ExceptionHandler01\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler02\r
+ EXTERN _CPU_ExceptionHandler02\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler03\r
+ EXTERN _CPU_ExceptionHandler03\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler04\r
+ EXTERN _CPU_ExceptionHandler04\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler05\r
+ EXTERN _CPU_ExceptionHandler05\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler06\r
+ EXTERN _CPU_ExceptionHandler06\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler07\r
+ EXTERN _CPU_ExceptionHandler07\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler08\r
+ EXTERN _CPU_ExceptionHandler08\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler09\r
+ EXTERN _CPU_ExceptionHandler09\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler0a\r
+ EXTERN _CPU_ExceptionHandler0a\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler0b\r
+ EXTERN _CPU_ExceptionHandler0b\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler0c\r
+ EXTERN _CPU_ExceptionHandler0c\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler0d\r
+ EXTERN _CPU_ExceptionHandler0d\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler0e\r
+ EXTERN _CPU_ExceptionHandler0e\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler0f\r
+ EXTERN _CPU_ExceptionHandler0f\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler10\r
+ EXTERN _CPU_ExceptionHandler10\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler11\r
+ EXTERN _CPU_ExceptionHandler11\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler12\r
+ EXTERN _CPU_ExceptionHandler12\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler13\r
+ EXTERN _CPU_ExceptionHandler13\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler14\r
+ EXTERN _CPU_ExceptionHandler14\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler15\r
+ EXTERN _CPU_ExceptionHandler15\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler16\r
+ EXTERN _CPU_ExceptionHandler16\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler17\r
+ EXTERN _CPU_ExceptionHandler17\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler18\r
+ EXTERN _CPU_ExceptionHandler18\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler19\r
+ EXTERN _CPU_ExceptionHandler19\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler1a\r
+ EXTERN _CPU_ExceptionHandler1a\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler1b\r
+ EXTERN _CPU_ExceptionHandler1b\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler1c\r
+ EXTERN _CPU_ExceptionHandler1c\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler1d\r
+ EXTERN _CPU_ExceptionHandler1d\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler1e\r
+ EXTERN _CPU_ExceptionHandler1e\r
+\r
+ GLOBAL _asm_CPU_ExceptionHandler1f\r
+ EXTERN _CPU_ExceptionHandler1f\r
+\r
+ GLOBAL _asm_InterruptHandler20\r
+ EXTERN _InterruptHandler20\r
+\r
+ GLOBAL _asm_InterruptHandler21\r
+ EXTERN _InterruptHandler21\r
+\r
+ GLOBAL _asm_InterruptHandler27\r
+ EXTERN _InterruptHandler27\r
+\r
+ GLOBAL _asm_InterruptHandler2c\r
+ EXTERN _InterruptHandler2c\r
+\r
+ GLOBAL _asm_API_Execute\r
+ EXTERN _API_Execute\r
+\r
+ GLOBAL APP_Terminate\r
+\r
+\r
+[SECTION .text]\r
+\r
+_asm_CPU_ExceptionHandler00:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler00\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler01:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler01\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler02:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler02\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler03:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler03\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler04:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler04\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler05:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler05\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler06:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler06\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler07:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler07\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler08:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler08\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler09:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler09\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler0a:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler0a\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler0b:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler0b\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler0c:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler0c\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler0d:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler0d\r
+;If returned value is not zero, terminate application. EAX is address of ESP0 value.\r
+ cmp eax,0\r
+ jne APP_Terminate\r
+;End of terminate code.\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler0e:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler0e\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler0f:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler0f\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler10:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler10\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler11:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler11\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler12:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler12\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler13:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler13\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler14:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler14\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler15:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler15\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler16:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler16\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler17:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler17\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler18:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler18\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler19:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler19\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler1a:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler1a\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler1b:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler1b\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler1c:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler1c\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler1d:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler1d\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler1e:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler1e\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_CPU_ExceptionHandler1f:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _CPU_ExceptionHandler1f\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_InterruptHandler20:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _InterruptHandler20\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_InterruptHandler21:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _InterruptHandler21\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_InterruptHandler27:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _InterruptHandler27\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_InterruptHandler2c:\r
+ push es\r
+ push ds\r
+ pushad\r
+ mov eax,esp\r
+ push eax\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ call _InterruptHandler2c\r
+ pop eax\r
+ popad\r
+ pop ds\r
+ pop es\r
+ iretd\r
+\r
+_asm_API_Execute:\r
+ sti\r
+ push ds\r
+ push es\r
+ pushad\r
+ pushad\r
+ mov ax,ss\r
+ mov ds,ax\r
+ mov es,ax\r
+ mov fs,ax\r
+ mov gs,ax\r
+ call _API_Execute\r
+;If returned value is not zero, terminate application. EAX is address of ESP0 value.\r
+ cmp eax,0\r
+ jne APP_Terminate\r
+;End of terminate code.\r
+ add esp,32\r
+ popad\r
+ pop es\r
+ pop ds\r
+ iretd\r
+\r
+APP_Terminate: ;eax is address of esp0.\r
+ mov bx,ss\r
+ mov ds,bx\r
+ mov es,bx\r
+ mov fs,bx\r
+ mov gs,bx\r
+ mov esp,[eax]\r
+ popad\r
+ ret\r