INT 0x18 services

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
St8ic

INT 0x18 services

Post by St8ic »

I'm trying to set up some basic OS services for my OS...
This code compiles fine, but crashes at boot. Any ideas?

Code: Select all

xor bx,bx
xor ax,ax
mov ss,ax
mov ax,cs
cli
mov word [ss:(0x20*4)],Int20_handler
mov word [ss:(0x20*4+2)],ax
sti

jmp normal

Int20_handler:
cmp ah,0x00
je mep
ret

mep:
blahblahblah
IRET

normal:
...
Karig

Re:INT 0x18 services

Post by Karig »

Well, one idea is that you return from your interrupt handler with RET instead of IRET if AH != 0.
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:INT 0x18 services

Post by Pype.Clicker »

saving/restoring registers would also be a good idea (but i'm sure you did it, but just skip it here to save keystrokes ;) )
St8ic

Re:INT 0x18 services

Post by St8ic »

Ya, I be saveing/restoring the ax register...any others?
asmboozer

Re:INT 0x18 services

Post by asmboozer »

St8ic wrote: I'm trying to set up some basic OS services for my OS...
This code compiles fine, but crashes at boot. Any ideas?

Code: Select all

xor bx,bx
xor ax,ax
mov ss,ax
mov ax,cs
cli
mov word [ss:(0x20*4)],Int20_handler
mov word [ss:(0x20*4+2)],ax
sti

jmp normal

Int20_handler:
cmp ah,0x00
je mep
ret

mep:
blahblahblah
IRET

normal:
...
btw which address mode the statement mov word [ss:(0x20*4)],Int20_handler belong to?
St8ic

Re:INT 0x18 services

Post by St8ic »

80386 Real-Address Mode ;D ...
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:INT 0x18 services

Post by Pype.Clicker »

what is the value for SP at that time ? zeroing the stack segment without altering the stack pointer looks like commiting suicide in real mode: as your stack grows it could destroy its interrupt handlers or the BIOS data area ...

If you need a 0-segment, rather use GS or FS or ES if DS is busy for other things, but using SS sounds really weird to me ...
St8ic

Re:INT 0x18 services

Post by St8ic »

SP is at 0x1300...that may be the problem?
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:INT 0x18 services

Post by Pype.Clicker »

well, if SS was different from 0 before entering the INT 20h setup function, it will definitiely cause trouble by the time you'll issue a RET instruction, as the return address will no longer be the same ...

avoid toying with the stack segment if you don't have to switch to another stack ...
Post Reply