ray@j.cc.purdue.edu (Ray Moody) (02/07/88)
This is a posting for a friend. Please reply to c13@s.cc.purdue.edu, not
me.
Ray
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Well, after spending at least 5 hours in a nightmare debugging session, I have
found what I am sure is a bug in TurboC V1.0. The problem is that in between
doing two inportb's (macro version) the compiler did a push dx and then never
popped it off!! If I delete the push dx, it works fine. Is this a known bug
in the compiler?!? If so, has this been fixed in the new version of TurboC ??
I would appreciate any help on this subject!
Roy C Riggs
c13@s.cc.purdue.edu
Just in case it is relevant:
AT clone, 12Mhz
Hercules graphics
30M hard drive
360K drive
512K base 1024K expansion
DAS-8 a/d convertor
DOS 3.2
TurboC V1.0
The source and the asm follow:
/* test program that crashes due to bug in TurboC V1.0 */
/* WARNING: you will have to reboot after running this */
#include <dos.h>
main()
{
printf("test %d\n", inportb(768) + inportb(769));
}
/* test.asm created by tcc -S test.c */
/* it has not been edited in ANY way, the bug is 4 lines after ;Line 8 */
name test
_text segment byte public 'code'
dgroup group _data,_bss
assume cs:_text,ds:dgroup,ss:dgroup
_text ends
_data segment word public 'data'
_d@ label byte
_data ends
_bss segment word public 'bss'
_b@ label byte
_bss ends
_text segment byte public 'code'
; Line 7
_main proc near
; Line 8
mov dx,768
in al,dx
mov ah,0
push dx
mov dx,769
push ax
in al,dx
mov ah,0
pop bx
add bx,ax
push bx
mov ax,offset _s@
push ax
call near ptr _printf
pop cx
pop cx
; Line 9
@1:
ret
_main endp
_text ends
_data segment word public 'data'
_s@ label byte
db 116
db 101
db 115
db 116
db 32
db 37
db 100
db 10
db 0
_data ends
_text segment byte public 'code'
extrn _printf:near
public _main
_text ends
end