Ok I've been looking at some interrupt handlers in a very simple os. They all start like this
push byte 0
db 6ah
db (interrupt num)
Can anyone tell me why?
Interrupt Code
RE:Interrupt Code
Personally, I would write an interrupt handler thus:
Handler:
pushad
;All of the handling stuff here
popad
iret
Sorry, I can't make ANY sense of that code of yours!
Handler:
pushad
;All of the handling stuff here
popad
iret
Sorry, I can't make ANY sense of that code of yours!
RE:Interrupt Code
> push byte 0
> db 6ah
> db (interrupt num)
0x6a is the intel opcode for push byte.
So for some reason that OS wants the handler to have the int number on the stack and the push opcode is being hand coded. Was this code disassembled or if not, what assembler is being used? This OS is just probably being really picky about the data structure of it's handler's stacks.
> db 6ah
> db (interrupt num)
0x6a is the intel opcode for push byte.
So for some reason that OS wants the handler to have the int number on the stack and the push opcode is being hand coded. Was this code disassembled or if not, what assembler is being used? This OS is just probably being really picky about the data structure of it's handler's stacks.
RE:Interrupt Code
Hmm, that code looks familiar.
My own OS has a unified interrupt handler. All interrupts are (eventually)
handled by the same code. However, I need a way for that code to distinguish
interrupts, so I push the interrupt number on the stack.
With NASM, "push byte" complains if the byte is greater than 127.
I used "db" simply to suppress the warning message.
Some exceptions (page fault, GPF) push an error code on the stack. This one
doesn't, so I use "push byte 0" to push a fake error code. This way, the stack
has the same layout for all exceptions.
My own OS has a unified interrupt handler. All interrupts are (eventually)
handled by the same code. However, I need a way for that code to distinguish
interrupts, so I push the interrupt number on the stack.
With NASM, "push byte" complains if the byte is greater than 127.
I used "db" simply to suppress the warning message.
Some exceptions (page fault, GPF) push an error code on the stack. This one
doesn't, so I use "push byte 0" to push a fake error code. This way, the stack
has the same layout for all exceptions.