Real mode assembly IV: Difference between revisions

m
Bot: Replace deprecated source tag with syntaxhighlight
[unchecked revision][unchecked revision]
m (Bot: Replace deprecated source tag with syntaxhighlight)
 
(7 intermediate revisions by 3 users not shown)
Line 11:
My style of handler goes like this:
 
<syntaxhighlight lang="asm">
inthandler:
cmp ah,0
Line 31 ⟶ 32:
; Do whatever needed here
iret
</syntaxhighlight>
 
But that's just an outline, you'd need to do it up however you need to use your calls. The FLAGS register is restored in an iret so you need to set it on the stack again depending on how it's set before the iret is done!
Line 36 ⟶ 38:
==Adding the Handler to the IVT==
 
This is fairly simple.
This is fairly simple. First, null out ES. Set AL=interrupt number, and BL=4h. Multiply AL by BL, and then put the result (AX) in BX. Move the word that is the address of the start of your interrupt handler into [es:bx], add 2 to BX, and then move your handler's segment into [es:bx]. There you go, your interrupt is done.
 
# First, null out ES.
# Set AL=interrupt number, and BL=4h.
# Multiply AL by BL, and then put the result (AX) in BX.
# Move the word that is the address of the start of your interrupt handler into [es:bx].
# Add 2 to BX.
# Move your handler's segment into [es:bx].
# Restore your original ES and you're done!
 
[[Category:Assembly]]
[[Category:Real mode assembly]]
<- [[Real mode assembly III]] | none ->