\r
\r
rmode_int:\r
- pushad\r
- push eax\r
- shr eax, 16 ; move high bits to ax\r
- mov word [realmode_ax], ax ; save new ax value\r
- pop eax ; restore\r
-\r
- push ebx\r
- shr ebx, 16 ; move high bits to bx\r
- mov byte [int_number], bl ; save int number to call\r
- pop ebx\r
-\r
- mov byte [realmode_error], 0 ; all variables is in the\r
- mov word [realmode_bx], bx ; realmode/variables.inc file\r
- mov word [realmode_cx], cx\r
- mov word [realmode_dx], dx\r
- call disable_irqs\r
- jmp pword 0x18:do_16pmode ; must substract 0x10000 from\r
- ; data addresses becasue of\r
- ; fasm strict "org" behavior\r
+ pushad\r
+ push eax\r
+ shr eax, 16 ; move high bits to ax\r
+ mov word [realmode_ax], ax ; save new ax value\r
+ pop eax ; restore\r
+\r
+ push ebx\r
+ shr ebx, 16 ; move high bits to bx\r
+ mov byte [int_number], bl ; save int number to call\r
+ pop ebx\r
+\r
+ mov byte [realmode_error], 0 ; all variables is in the\r
+ mov word [realmode_bx], bx ; realmode/variables.inc file\r
+ mov word [realmode_cx], cx\r
+ mov word [realmode_dx], dx\r
+ call disable_irqs\r
+ jmp pword 0x18:do_16pmode ; begin our dark journey into 16bit-land\r
+\r
use16\r
do_16pmode:\r
- mov ax, 0x20\r
- mov ds, ax\r
- mov es, ax\r
- mov fs, ax\r
- mov gs, ax\r
- mov ss, ax\r
+ mov ax, 0x20\r
+ mov ds, ax\r
+ mov es, ax\r
+ mov fs, ax\r
+ mov gs, ax\r
+ mov ss, ax\r
\r
- cli\r
- mov eax, cr0\r
- and al, 0xFE\r
- mov cr0, eax\r
+ cli\r
+ mov eax, cr0\r
+ and al, 0xFE\r
+ mov cr0, eax\r
\r
- jmp 0x1000:(do_realm)\r
+ jmp 0x0000:(do_realm) ; this should be triple checked!\r
\r
do_realm:\r
- mov ax, cs\r
- mov ds, ax\r
+ mov ax, cs\r
+ mov ds, ax\r
\r
- xor ax, ax\r
- mov es, ax\r
- mov fs, ax\r
- mov gs, ax\r
- mov ss, ax\r
+ xor ax, ax\r
+ mov es, ax\r
+ mov fs, ax\r
+ mov gs, ax\r
+ mov ss, ax\r
\r
- lidt [ridtr] ; realmode/variables.inc\r
- sti\r
+ lidt [ridtr] ; realmode/variables.inc\r
+ sti\r
\r
- mov ax, word [realmode_ax]\r
- mov bx, word [realmode_bx]\r
- mov cx, word [realmode_cx]\r
- mov dx, word [realmode_dx]\r
+ mov ax, word [realmode_ax]\r
+ mov bx, word [realmode_bx]\r
+ mov cx, word [realmode_cx]\r
+ mov dx, word [realmode_dx]\r
\r
- push ax ; this is some cool shit.. ;)\r
- mov al, [int_number] ; interrupt to preform\r
- mov [$+5], al ; move it to right pos.\r
- pop ax\r
- db 0xCD ; opcode for int.\r
- db 0x00 ; move int_number here\r
+ push ax ; this is some cool shit.. ;)\r
+ mov al, [int_number] ; interrupt to preform\r
+ mov [$+5], al ; move it to right pos.\r
+ pop ax\r
+ db 0xCD ; opcode for int.\r
+ db 0x00 ; move int_number here\r
\r
- jnc .no_error\r
- mov byte [realmode_error], 1\r
+ jnc .no_error\r
+ mov byte [realmode_error], 1\r
\r
- .no_error:\r
- mov word [realmode_ax], ax\r
- mov word [realmode_bx], bx\r
- mov word [realmode_cx], cx\r
- mov word [realmode_dx], dx\r
+ .no_error:\r
+ mov word [realmode_ax], ax\r
+ mov word [realmode_bx], bx\r
+ mov word [realmode_cx], cx\r
+ mov word [realmode_dx], dx\r
\r
- cli\r
+ cli\r
\r
- lgdt [gdtr]\r
- lidt [idtr]\r
- mov eax, cr0\r
- or al, 1\r
- mov cr0, eax\r
+ lgdt [gdtr]\r
+ lidt [idtr]\r
+ mov eax, cr0\r
+ or al, 1\r
+ mov cr0, eax\r
\r
- jmp pword 0x08:gobackto_pm\r
+ jmp pword 0x08:gobackto_pm\r
\r
\r
use32\r
gobackto_pm:\r
- mov ax, 0x10 ; refresh all segment registers\r
- mov ds, ax\r
- mov es, ax\r
- mov fs, ax\r
- mov gs, ax\r
- mov ss, ax\r
- call enable_irqs\r
- sti\r
- popad\r
- clc ; clear carry.\r
- cmp [realmode_error], 1 ; if error, then\r
- jne .end\r
- stc ; set carry.\r
- .end:\r
- ret
\ No newline at end of file
+ mov ax, 0x10 ; refresh all segment registers\r
+ mov ds, ax\r
+ mov es, ax\r
+ mov fs, ax\r
+ mov gs, ax\r
+ mov ss, ax\r
+ call enable_irqs\r
+ sti\r
+ popad\r
+ clc ; clear carry.\r
+ cmp [realmode_error], 1 ; if error, then\r
+ jne .end\r
+ stc ; set carry.\r
+ .end:\r
+ ret
\ No newline at end of file