Skip to content

Instantly share code, notes, and snippets.

@agesome
Created April 2, 2013 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agesome/5294606 to your computer and use it in GitHub Desktop.
Save agesome/5294606 to your computer and use it in GitHub Desktop.
.globl go_realmode
.org 0
ivt:
.skip 1024, 0
ivt_ptr:
.hword 1023
.int ivt
go_realmode:
cli
mov $0x10, %eax /* 16-bit code descriptor in GDT */
mov %eax, %ds
mov %eax, %es
mov %eax, %fs
mov %eax, %gs
mov %eax, %ss
mov %cr0, %eax
and $0x7FFFFFFe, %eax
mov %eax, %cr0
ljmp $0, $realmode
realmode:
mov $0, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
lidt ivt_ptr
sti
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment