Mail Archives: djgpp/1994/09/26/16:25:00
Hello,
In the file dosmem.s in libsrc/c/dos gas produces for the jcxz zero
instructions code for a jump with 16 bit displacements. This will mask
the high word of EIP, so (when cx is zero) it will jump from say
0x00012345 to 0x00002347 instead of the correct 0x00012347. In the
gas manual, there is mentioned, that using jcxz may be risky, but I
really don't understand what they mean. The code should get assembled
correctly (with 8-bit displacement, "short" jump). The following
patch seems to fix the problem (using jz instead of jcxz).
Note, that this breaks code, that uses the conio library (in libpc).
BTW, this was quite tricky to find, because it will only show when
dosmem is linked at a high enough address. If you want to write
a small program, to find the problem, it won't show anymore.
Dieter
*** dosmem.os Sat Oct 9 18:42:28 1993
--- dosmem.s Fri Sep 9 00:05:00 1994
***************
*** 100,112 ****
movl 24(%ebp),%ecx
pushl %ecx
shrl $2,%ecx
! jcxz no_big_move
rep
movsl
no_big_move:
popl %ecx
andl $3,%ecx
! jcxz no_little_move
rep
movsb
no_little_move:
--- 100,112 ----
movl 24(%ebp),%ecx
pushl %ecx
shrl $2,%ecx
! jz no_big_move
rep
movsl
no_big_move:
popl %ecx
andl $3,%ecx
! jz no_little_move
rep
movsb
no_little_move:
- Raw text -