Interrupt Code

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Greg

Interrupt Code

Post by Greg »

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?
Compuboy

RE:Interrupt Code

Post by Compuboy »

  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!
Chase

RE:Interrupt Code

Post by Chase »

> 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.
geezer

RE:Interrupt Code

Post by geezer »

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.
Post Reply