greenber@timeinc.UUCP (Ross M. Greenberg) (06/23/85)
Many thanks to those of you who responded to my posting "Weirdness in PC".
It looks like I was making a whole bunch of mistakes, which I've
rectified. Primary was neglecting to address all variables via "CS:"
since my other segments are unknown at the time of the interrupt.
Returning from the interrupt with an 'iret' instruction was bogus, since
status and other data is transferred in the flag word, so the 'iret'
was replaced with a 'retf 2' after popping the flags manually.
So the code is much healthier --- but still doesn't function properly
(the way I want it to!).
Current problem: The dos interrupt is taken over and in turn is
called by my new interrupt routine. The code itself is terminate and stay
resident. And it seems to work --- until the *next* program is
loaded/executed and then tries to exit, where it goes out to lunch.
Why would this be? The memory is staying around after the terminate and
stay resident call, and the problem only seems to exist if I take over
the dos interrupt. Other interrupts seem to be okay. I've enclosed
the code I'm presently using below. Take a look and let me know where
the problem lies?
I'm certain that the code can be done more effeciently, and I'll do that
after the other bugs are out of the way.
Thanks in advance.....
==============================================
public set_dos, in_dos
include dos.mac
PSEG
in_dos dw 0
old_dos dd ?
set_dos proc far
push ds ;save the segment
xor ax,ax ;zero ax
mov ds,ax ;so we can zero the segment
mov si,84h ;start of int21 vector
mov ax, [si]
mov cs:old_dos, ax ;save the offset
mov ax, [si + 2]
mov cs:old_dos + 2,ax ;save the segment
push cs ;get the cs in bx
pop bx
mov ax,offset int21 ;put the offset of routine in ax
cli ;can't get interrupted now!
mov ds:[si], ax ;move in the offset
mov ds:[si + 2],bx ;and the segment
sti ;okay for interrupts
pop ds ;restore the old ds
ret ;back home
set_dos endp
int21 proc far
pushf ;save the flags because the 'inc'
inc cs:in_dos ; changes them. Inc the flag
popf ;restore the flags
pushf ;and put them on the stack
call dword ptr cs:[old_dos] ;call the "real dos"
cli
pushf ;save the flags because the 'dec'
dec cs:in_dos ; changes them. Dec the flag
popf ;get the flags back
ret 2 ;return after stripping the flags
int21 endp
endps
end
--
------------------------------------------------------------------
Ross M. Greenberg @ Time Inc, New York
--------->{ihnp4 | vax135}!timeinc!greenber<---------
I highly doubt that Time Inc. they would make me their spokesperson.