Advertisement
Guest User

start.asm

a guest
Sep 5th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. .global idt_init
  2. .type idt_init, @function
  3.  
  4. idt_init: lidt (idtr) # Load the idt pointed to by our idtr struct and return.
  5. ret
  6.  
  7.  
  8. ###########################################################################
  9. # ISRS #
  10. ###########################################################################
  11.  
  12.  
  13. .global isr0 # Divide exception
  14. .type isr0, @function
  15.  
  16. isr0: cli
  17. push 0 # Dummy error code
  18. push 0 # Reference number of exception
  19. jmp isr_common_stub # Jump to our default ISR handler
  20.  
  21.  
  22. # ... other ISR stubs go here...
  23.  
  24.  
  25. .extern isr_handle # External function defined in isr.c to print error message etc.
  26.  
  27. isr_common_stub:
  28. pusha
  29. push %ds
  30. push %es
  31. push %fs
  32. push %gs
  33. mov $0x10, %ax
  34. mov %ax, %ds
  35. mov %ax, %es
  36. mov %ax, %fs
  37. mov %ax, %gs # Push all data segment registers onto the stack, and then load them with data segment offset
  38. mov %esp, %eax
  39. push %eax # Push the location of our stack
  40.  
  41. mov isr_handle, %eax
  42. call %eax # Indirectly call isr_handle
  43.  
  44. pop %eax
  45. pop %gs
  46. pop %fs
  47. pop %es
  48. pop %ds
  49. popa
  50. add $8, %esp
  51. iret # Pop everything, clean up the stack and return.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement