Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. ; comment
  2.  
  3. [BITS 32]
  4. [GLOBAL start]
  5. [EXTERN kmain]
  6. start:
  7. mov esp, _sys_stack
  8. call kmain
  9. cli
  10. hlt
  11.  
  12. ALIGN 4
  13. mboot:
  14. MULTIBOOT_PAGE_ALIGN equ 1 << 0
  15. MULTIBOOT_MEMORY_INFO equ 1 << 1
  16. MULTIBOOT_AOUT_KLUDGE equ 1 << 16
  17. MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
  18. MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
  19. MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
  20. EXTERN code, bss, end
  21.  
  22. dd MULTIBOOT_HEADER_MAGIC
  23. dd MULTIBOOT_HEADER_FLAGS
  24. dd MULTIBOOT_CHECKSUM
  25.  
  26. dd mboot
  27. dd code
  28. dd bss
  29. dd end
  30. dd start
  31.  
  32. [GLOBAL flush_gdt]
  33. [EXTERN gdtp]
  34. flush_gdt:
  35. lgdt [gdtp]
  36. mov ax, 0x10
  37. mov fs, ax
  38. mov gs, ax
  39. mov ss, ax
  40. mov ds, ax
  41. mov es, ax
  42. jmp 0x08:flush2
  43. flush2:
  44. ret
  45.  
  46. [GLOBAL flush_idt]
  47. [EXTERN idtp]
  48. flush_idt:
  49. lidt [idtp]
  50. ret
  51.  
  52. [GLOBAL isr0]
  53. [GLOBAL isr1]
  54. [GLOBAL isr2]
  55. [GLOBAL isr3]
  56. [GLOBAL isr4]
  57. [GLOBAL isr5]
  58. [GLOBAL isr6]
  59. [GLOBAL isr7]
  60. [GLOBAL isr8]
  61. [GLOBAL isr9]
  62. [GLOBAL isr10]
  63. [GLOBAL isr11]
  64. [GLOBAL isr12]
  65. [GLOBAL isr13]
  66. [GLOBAL isr14]
  67. [GLOBAL isr15]
  68. [GLOBAL isr16]
  69. [GLOBAL isr17]
  70. [GLOBAL isr18]
  71. [GLOBAL isr19]
  72. [GLOBAL isr20]
  73. [GLOBAL isr21]
  74. [GLOBAL isr22]
  75. [GLOBAL isr23]
  76. [GLOBAL isr24]
  77. [GLOBAL isr25]
  78. [GLOBAL isr26]
  79. [GLOBAL isr27]
  80. [GLOBAL isr28]
  81. [GLOBAL isr29]
  82. [GLOBAL isr30]
  83. [GLOBAL isr31]
  84.  
  85. isr0:
  86. cli
  87. push byte 0
  88. push byte 0
  89. jmp isr_common_stub
  90.  
  91. isr1:
  92. cli
  93. push byte 0
  94. push byte 1
  95. jmp isr_common_stub
  96.  
  97. isr2:
  98. cli
  99. push byte 0
  100. push byte 2
  101. jmp isr_common_stub
  102.  
  103. isr3:
  104. cli
  105. push byte 0
  106. push byte 3
  107. jmp isr_common_stub
  108.  
  109. isr4:
  110. cli
  111. push byte 0
  112. push byte 4
  113. jmp isr_common_stub
  114.  
  115. isr5:
  116. cli
  117. push byte 0
  118. push byte 5
  119. jmp isr_common_stub
  120.  
  121. isr6:
  122. cli
  123. push byte 0
  124. push byte 6
  125. jmp isr_common_stub
  126.  
  127. isr7:
  128. cli
  129. push byte 0
  130. push byte 7
  131. jmp isr_common_stub
  132.  
  133. isr8:
  134. cli
  135. push byte 8
  136. jmp isr_common_stub
  137.  
  138. isr9:
  139. cli
  140. push byte 0
  141. push byte 9
  142. jmp isr_common_stub
  143.  
  144. isr10:
  145. cli
  146. push byte 10
  147. jmp isr_common_stub
  148.  
  149. isr11:
  150. cli
  151. push byte 11
  152. jmp isr_common_stub
  153.  
  154. isr12:
  155. cli
  156. push byte 12
  157. jmp isr_common_stub
  158.  
  159. isr13:
  160. cli
  161. push byte 13
  162. jmp isr_common_stub
  163.  
  164. isr14:
  165. cli
  166. push byte 14
  167. jmp isr_common_stub
  168.  
  169. isr15:
  170. cli
  171. push byte 0
  172. push byte 15
  173. jmp isr_common_stub
  174.  
  175. isr16:
  176. cli
  177. push byte 0
  178. push byte 16
  179. jmp isr_common_stub
  180.  
  181. isr17:
  182. cli
  183. push byte 0
  184. push byte 17
  185. jmp isr_common_stub
  186.  
  187. isr18:
  188. cli
  189. push byte 0
  190. push byte 18
  191. jmp isr_common_stub
  192.  
  193. isr19:
  194. cli
  195. push byte 0
  196. push byte 19
  197. jmp isr_common_stub
  198.  
  199. isr20:
  200. cli
  201. push byte 0
  202. push byte 20
  203. jmp isr_common_stub
  204.  
  205. isr21:
  206. cli
  207. push byte 0
  208. push byte 21
  209. jmp isr_common_stub
  210.  
  211. isr22:
  212. cli
  213. push byte 0
  214. push byte 22
  215. jmp isr_common_stub
  216.  
  217. isr23:
  218. cli
  219. push byte 0
  220. push byte 23
  221. jmp isr_common_stub
  222.  
  223. isr24:
  224. cli
  225. push byte 0
  226. push byte 24
  227. jmp isr_common_stub
  228.  
  229. isr25:
  230. cli
  231. push byte 0
  232. push byte 25
  233. jmp isr_common_stub
  234.  
  235. isr26:
  236. cli
  237. push byte 0
  238. push byte 26
  239. jmp isr_common_stub
  240.  
  241. isr27:
  242. cli
  243. push byte 0
  244. push byte 27
  245. jmp isr_common_stub
  246.  
  247. isr28:
  248. cli
  249. push byte 0
  250. push byte 28
  251. jmp isr_common_stub
  252.  
  253. isr29:
  254. cli
  255. push byte 0
  256. push byte 29
  257. jmp isr_common_stub
  258.  
  259. isr30:
  260. cli
  261. push byte 0
  262. push byte 30
  263. jmp isr_common_stub
  264.  
  265. isr31:
  266. cli
  267. push byte 0
  268. push byte 31
  269. jmp isr_common_stub
  270.  
  271. [EXTERN isrs_handler]
  272. isr_common_stub:
  273. pusha
  274. push ds
  275. push es
  276. push fs
  277. push gs
  278. mov ax, 0x10
  279. mov ds, ax
  280. mov es, ax
  281. mov fs, ax
  282. mov gs, ax
  283. mov eax, esp
  284. push eax
  285. mov eax, isrs_handler
  286. call eax
  287. pop eax
  288. pop gs
  289. pop fs
  290. pop es
  291. pop ds
  292. popa
  293. add esp, 8
  294. iret
  295.  
  296. SECTION .bss
  297. resb 8192
  298. _sys_stack:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement