Mail Archives: djgpp/1999/11/24/05:11:54
At 09:28 AM 11/23/99 -0800, you wrote:
>Anton Helm <tony AT dictator DOT nt DOT tuwien DOT ac DOT at> writes:
>
>> Is there some asm guru out there that can look into a 10-line inline asm
>> code that used to work with gcc 2.8.1 ?
>
>Post it.
Here it comes. First the complete inlined function (with some #ifdefs
for TURBOC and others already removed)
(from grx23.zip, src/utils/shiftscl.c)
void _GR_shift_scanline(GR_int8u far **dst,
GR_int8u far **src,
int ws, int shift, int planes) {
int plane;
GRX_ENTER();
if (shift <= 0) {
shift = -shift;
for (plane = 0; plane < planes; ++plane) {
GR_int8u far *s = *(src++) + ws;
GR_int8u far *d = *(dst++) + ws;
int w = ws;
/* sad but true: the x86 bytesex forces this inefficient code :( */
asm volatile ("\n"
" movb (%3),%%ch \n"
" jmp 1f \n"
" .align 4,0x90 \n"
"1: decl %3 \n"
" movb %%ch,%%al \n"
" movb (%3),%%ah \n"
" movb %%ah,%%ch \n"
" shrl %%cl,%%eax \n"
" movb %%al,(%4) \n"
" decl %4 \n"
" decl %5 \n"
" jne 1b \n"
" shrb %%cl,%%ch \n"
" movb %%ch,(%4) "
: "=r" ((void *)s), "=r" ((void *)d), "=r" ((int)w)
: "0" ((void *)s), "1" ((void *)d), "2" ((int)w), "c" ((int)shift)
: "ax", "cx"
);
}
} else {
shift = 8-shift;
for (plane = 0; plane < planes; ++plane) {
GR_int8u far *s = *(src++);
GR_int8u far *d = *(dst++);
int w = ws;
asm volatile ("\n"
" movb (%3),%%ch \n"
" jmp 1f \n"
" .align 4,0x90 \n"
"1: incl %3 \n"
" movb %%ch,%%ah \n"
" movb (%3),%%al \n"
" movb %%al,%%ch \n"
" shrl %%cl,%%eax \n"
" movb %%al,(%4) \n"
" incl %4 \n"
" decl %5 \n"
" jne 1b "
: "=r" ((void *)s), "=r" ((void *)d), "=r" ((int)w)
: "0" ((void *)s), "1" ((void *)d), "2" ((int)w), "c" ((int)shift)
: "ax", "cx"
);
}
}
GRX_LEAVE();
}
GCC 2.95 complains in both asm sections about the use of "cx" in the last line.
As far as I understand this is some kind of dummy register.
The patches mentioned earlier here in this mailing list/newsgroup change the
last three lines of both sections from
: "=r" ((void *)s), "=r" ((void *)d), "=r" ((int)w)
: "0" ((void *)s), "1" ((void *)d), "2" ((int)w), "c" ((int)shift)
: "ax", "cx"
into
: "=r" ((void *)s), "=r" ((void *)d), "=r" ((int)w), "=cx" (dummy)
: "0" ((void *)s), "1" ((void *)d), "2" ((int)w), "c" ((int)shift)
: "ax"
This now makes GCC 2.95 happy. The crash happens when the function is called
(by mouse pointer initialization). The core dump is just a single line which
symify maps to the source code line where the inline asm starts. Digging
somewhat deeper with gdb let me suspect that there might be something wrong
with the "jmp 1f" statement but that's only a guess.
There is a precompiled (GCC 2.8.1)library available from
http://www.gnu.de/software/GRX/download/
which is said to be compiled from the original code quoted above. This binary
doesn't produce runtime errors when calling the same function.
More questions ? -> Ask!
Tony
- Raw text -