Page 1 of 1

INT 0x18 services

Posted: Sat Feb 14, 2004 6:54 pm
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:
...

Re:INT 0x18 services

Posted: Sat Feb 14, 2004 8:01 pm
by Karig
Well, one idea is that you return from your interrupt handler with RET instead of IRET if AH != 0.

Re:INT 0x18 services

Posted: Sun Feb 15, 2004 2:24 pm
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 ;) )

Re:INT 0x18 services

Posted: Sun Feb 15, 2004 11:41 pm
by St8ic
Ya, I be saveing/restoring the ax register...any others?

Re:INT 0x18 services

Posted: Mon Feb 16, 2004 12:32 am
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?

Re:INT 0x18 services

Posted: Mon Feb 16, 2004 1:14 pm
by St8ic
80386 Real-Address Mode ;D ...

Re:INT 0x18 services

Posted: Mon Feb 16, 2004 1:52 pm
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 ...

Re:INT 0x18 services

Posted: Tue Feb 17, 2004 5:46 pm
by St8ic
SP is at 0x1300...that may be the problem?

Re:INT 0x18 services

Posted: Wed Feb 18, 2004 2:18 am
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 ...