Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [BITS 64]
- %macro pushall 0
- push rax
- push rbx
- push rcx
- push rdx
- push rsi
- push rdi
- push rbp
- push r8
- push r9
- push r10
- push r11
- push r12
- push r13
- push r14
- push r15
- %endmacro
- %macro popall 0
- pop r15
- pop r14
- pop r13
- pop r12
- pop r11
- pop r10
- pop r9
- pop r8
- pop rbp
- pop rdi
- pop rsi
- pop rdx
- pop rcx
- pop rbx
- pop rax
- %endmacro
- %macro Interrupt_Name 1
- dq __interrupt_%1
- %endmacro
- %macro Interrupt_Err 1
- __interrupt_%1:
- push qword %1
- jmp __interrupt_call
- %endmacro
- %macro Interrupt_Noerr 1
- __interrupt_%1:
- push qword 0 ; no error
- push qword %1
- jmp __interrupt_call
- %endmacro
- section .text
- extern interrupt_handler
- __interrupt_call:
- cld
- pushall ; store the values in 64-bit registers
- mov rdi, rsp ; copy the value in rsp to rdi register
- call interrupt_handler ; call the C-function
- mov rsp, rax ; copy the value in rax to rsp register
- popall ; remove the last pushed values from the 64-bit registers
- add rsp, 16 ; pop error code and interrupt number
- iretq ; returns the control from the interrupt handler to the process interrupted
- Interrupt_Noerr 0 ; Divide by zero
- Interrupt_Noerr 1 ; Debug single step
- Interrupt_Noerr 2 ; Non-Maskable interrupt (NMI input on processor)
- Interrupt_Noerr 3 ; Debug breakpoints (INT3)
- Interrupt_Noerr 4 ; Arithmetic overflow (INTO)
- Interrupt_Noerr 5 ; Bounds range exceeded (BOUND)
- Interrupt_Noerr 6 ; Invalid Opcode (UD2)
- Interrupt_Noerr 7 ; Device not available (WAIT/FWAIT)
- Interrupt_Err 8 ; Double fault
- Interrupt_Noerr 9 ; Coprocessor segment overrun
- Interrupt_Err 10 ; Invalid TSS
- Interrupt_Err 11 ; Segment not present
- Interrupt_Err 12 ; Stack-segment fault
- Interrupt_Err 13 ; General protection fault
- Interrupt_Err 14 ; Page fault
- Interrupt_Noerr 15 ; Reserved
- Interrupt_Noerr 16 ; x87 FPU error
- Interrupt_Err 17 ; Alignment check
- Interrupt_Noerr 18 ; Machine check
- Interrupt_Noerr 19 ; SIMD floating-point exception
- Interrupt_Noerr 20 ; Reserved
- Interrupt_Noerr 21 ; Reserved
- Interrupt_Noerr 22 ; Reserved
- Interrupt_Noerr 23 ; Reserved
- Interrupt_Noerr 24 ; Reserved
- Interrupt_Noerr 25 ; Reserved
- Interrupt_Noerr 26 ; Reserved
- Interrupt_Noerr 27 ; Reserved
- Interrupt_Noerr 28 ; Reserved
- Interrupt_Noerr 29 ; Reserved
- Interrupt_Err 30 ; Reserved
- Interrupt_Noerr 31 ; Reserved
- %assign i 32
- %rep 224
- Interrupt_Noerr i
- %assign i i+1
- %endrep
- section .data
- global __interrupt_handlers
- ; Will be used while initializing IDT
- __interrupt_handlers:
- %assign i 0
- %rep 256
- Interrupt_Name i
- %assign i i+1
- %endrep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement