Page 1 of 1

Interrupt Code

Posted: Wed May 29, 2002 11:00 pm
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?

RE:Interrupt Code

Posted: Fri May 31, 2002 11:00 pm
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!

RE:Interrupt Code

Posted: Sat Jun 01, 2002 11:00 pm
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.

RE:Interrupt Code

Posted: Sat Jun 01, 2002 11:00 pm
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.