about call eax

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
rootel77

about call eax

Post by rootel77 »

can anyone tell me what is the diff between the tow codes below

form1

Code: Select all

mov eax, int_handler
call eax
and form2

Code: Select all

call int_handler
and why the first form is encountered in all samples i've read about interrupt handlers (written in asm and calling a c handler)?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:about call eax

Post by Pype.Clicker »

beside the fact that form1 is more complex for the pipeline, i don't see any difference. I guess that's just because people copy-and-paste IRQ stubs without completely getting what's going on. Clicker do

Code: Select all

   ; ...
   and eax,byte 0x7f
        push eax                   ; IRQ number
        call _processIrqList    ; call list processing
        add esp,4
    ; ...
and it works just fine :P
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:about call eax

Post by Candy »

rootel77 wrote: can anyone tell me what is the diff between the tow codes below

form1

Code: Select all

mov eax, int_handler
call eax
and form2

Code: Select all

call int_handler
and why the first form is encountered in all samples i've read about interrupt handlers (written in asm and calling a c handler)?
IIRC, the first makes it an absolute indirect call, while the second would make it a relative direct call.

I'm not sure why you would make it an absolute indirect call, but I assume there's some pointer to the location in the mov that loads the address. If so, you can replace that instantly without any significant delay. You can't just replace a relative call, and some compilers optimize relative calls to nearby code to a shorter opcode. If they do that, the code is smaller and you get unpredictable crashes.
rootel77

Re:about call eax

Post by rootel77 »

I assume there's some pointer to the location in the mov that loads the address. If so, you can replace that instantly without any significant delay. You can't just replace a relative call, and some compilers optimize relative calls to nearby code to a shorter opcode. If they do that, the code is smaller and you get unpredictable crashes.

it seems to be the only valid reason, this is a commentary in the irq stub from the OSD (http://my.execpc.com/~geezer/osd/)

Code: Select all

; setvect() changes the operand of the CALL instruction at run-time,
; so we need its location = 27 bytes from start of stub. We also want
; the CALL to use absolute addressing instead of EIP-relative, so:
         mov eax,fault   ; (26)
         call eax   ; (31)
Post Reply