However, you're expected to write a lot of similar functions:
Using a simple fasm macro you can avoid that, and write the code once. This makes your program less vulnerable to typing errors.Code: Select all
global _isr0 global _isr1 global _isr2 ... ; Fill in the rest here! global _isr30 global _isr31 ; 0: Divide By Zero Exception _isr0: cli push byte 0 ; A normal ISR stub that pops a dummy error code to keep a ; uniform stack frame push byte 0 jmp isr_common_stub ... ; Fill in from 2 to 7 here! ; 8: Double Fault Exception (With Error Code!) _isr8: cli push byte 8 ; Note that we DON'T push a value on the stack in this one! ; It pushes one already! Use this type of stub for exceptions ; that pop error codes! jmp isr_common_stub ... ; You should fill in from _isr9 to _isr31 here. Remember to ; use the correct stubs to handle error codes and push dummies!
I made two different macros, one to generate code for the ISRs that need to push a dummy error code and one for the ISRs where the processor pushes the error code.
Code: Select all
macro ISR_AUTOERR [NUM] {
public isr#NUM
isr#NUM:
cli
push 0
push NUM
jmp isr_common_stub
}
macro ISR_CPUERR [NUM] {
public isr#NUM
isr#NUM:
cli
push NUM
jmp isr_common_stub
}
; This works the same as calling the macro many times with
; a different number as the parameter each time.
; Reason for this is the [] around NUM in the macro declaration
ISR_AUTOERR 0, 1, 2, 3, 4, 5, 6, 7
ISR_CPUERR 8
ISR_AUTOERR 9
ISR_CPUERR 10, 11, 12, 13, 14
ISR_AUTOERR 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
ISR_AUTOERR 25, 26, 27, 28, 29, 30, 31