Guest User

Untitled

a guest
Mar 22nd, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ; This will set up our new segment registers. We need to do
  2. ; something special in order to set CS. We do what is called a
  3. ; far jump. A jump that includes a segment as well as an offset.
  4. ; This is declared in C as 'extern void gdt_flush();'
  5. global _gdt_flush ; Allows the C code to link to this
  6. extern _gp ; Says that '_gp' is in another file
  7. _gdt_flush:
  8. lgdt [_gp] ; Load the GDT with our '_gp' which is a special pointer
  9. mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment
  10. mov ds, ax
  11. mov es, ax
  12. mov fs, ax
  13. mov gs, ax
  14. mov ss, ax
  15. jmp 0x08:flush2 ; 0x08 is the offset to our code segment: Far jump!
  16. flush2:
  17. ret ; Returns back to the C code!
  18.  
  19. .global gdt_flush /*Allows the C code to link to this*/
  20. .extern gp /*Says that '_gp' is in another file*/
  21. _gdt_flush:
  22. lgdt gp /*; Load the GDT with our '_gp' which is a special pointer*/
  23. mov %ax, 0x10 /* ; 0x10 is the offset in the GDT to our data segment*/
  24. mov %ds, %ax
  25. mov %es, %ax
  26. mov %fs, %ax
  27. mov %gs, %ax
  28. mov %ss, %ax
  29. jmp flush2 /*; 0x08 is the offset to our code segment: Far jump!*/
  30. flush2:
  31. ret /*; Returns back to the C code!*/
Add Comment
Please, Sign In to add comment