Guest User

return in pmode from a v86 task

a guest
Aug 13th, 2014
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 7c00h
  2.  
  3. use16
  4.  
  5. cli
  6. lgdt[gdt]
  7. mov eax,cr4
  8. or al,1
  9. mov cr4,eax
  10. mov eax,cr0
  11. or al,1
  12. mov cr0,eax
  13. jmp gdt_code-gdt_table:pmode
  14.  
  15. vm86:
  16. mov ax,0e41h
  17. mov bx,7
  18. int 10h
  19. mov ax,gdt_data-gdt_table
  20. mov gs,ax
  21. mov fs,ax
  22. mov ds,ax
  23. mov es,ax
  24. mov ss,ax
  25. push ss
  26. push esp
  27. pushf
  28. push gdt_code-gdt_table
  29. push return
  30. iretd
  31. jmp $
  32.  
  33. use32
  34.  
  35. pmode:
  36. mov ax,gdt_data-gdt_table
  37. mov gs,ax
  38. mov fs,ax
  39. mov ds,ax
  40. mov es,ax
  41. mov ss,ax
  42. mov esp,9fffch
  43. mov ax,18h
  44. ltr ax
  45. push 0
  46. push 0
  47. push 0
  48. push 0
  49. push 0
  50. push 0fffeh
  51. push 20000h
  52. push 0
  53. push vm86
  54. iret
  55. jmp $
  56. return:
  57. mov dword[0b8000h],41h
  58. mov dword[0b8000h+1],7
  59. jmp $
  60.  
  61. gdt:
  62. dw gdt_end-gdt_table-1
  63. dd gdt_table
  64.  
  65. gdt_table:
  66. dq 0
  67.  
  68. gdt_code:
  69. dw 0ffffh
  70. dw 0
  71. db 0
  72. db 9ah
  73. db 0cfh
  74. db 0
  75.  
  76. gdt_data:
  77. dw 0ffffh
  78. dw 0
  79. db 0
  80. db 92h
  81. db 0cfh
  82. db 0
  83.  
  84. gdt_tss:
  85. dw 0ffffh
  86. dw 0
  87. db 0
  88. db 89h
  89. db 8fh
  90. db 0
  91.  
  92. gdt_end:
  93.  
  94. times 510-($-$$) db 0
  95. dw 0aa55h
Advertisement
Add Comment
Please, Sign In to add comment