Mail Archives: djgpp/2000/01/01/11:50:14
Message-ID: | <386E0E85.6925D65@connection.com>
|
Date: | Sat, 01 Jan 2000 09:26:17 -0500
|
From: | sam <samirw AT connection DOT com>
|
X-Mailer: | Mozilla 4.6 [en] (Win95; I)
|
X-Accept-Language: | en
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Spilling registers - inline asm?
|
NNTP-Posting-Host: | pm4-25.connection.com
|
X-Trace: | 1 Jan 2000 09:40:07 -0500, pm4-25.connection.com
|
Lines: | 176
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Sorry, if this is not the right place to ask this but I have e-mailed
the author several days ago but no response, and soon it's back to
work.
First, I will ask where can I get some info on inline assembler (if any,
I couldn't find anything in RHIDE/help stdlib or djgpp text
documentation.)
My immediate problem is with one of the GRX23 library source and I don't
even have a clue what I am looking at, although I do know assembler.
----------------------------
/**
** SHIFTSCL.C ---- shift and copy an array (scanline)
** for 1bpp and 4bpp frame driver blit operations
**
** Copyright (c) 1998 Hartmut Schirmer
**
**/
#include "libgrx.h"
#include "highlow.h"
#ifdef __TURBOC__
#pragma inline
#endif
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;
# if defined(__GNUC__) && defined(__i386__)
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"
);
??/* HERE problem */
# elif defined(__TURBOC__)
asm push ds ;
asm mov bx, ws ;
asm mov cl, shift ;
asm les di, d ;
asm lds si, s ;
asm mov ch,[si] ;
asm std ;
looprv:
asm dec si ;
asm mov al, ch ;
asm mov ah, [si] ;
asm mov ch, ah ;
asm shr ax, cl ;
asm stosb ;
asm dec bx ;
asm jnz short looprv ;
asm mov al, ch ;
asm shr al, cl ;
asm stosb ;
asm pop ds ;
# else
int w = ws;
do {
--s;
*(d--) = highlowP(s)>>shift;
} while (--w);
*d = *s >> shift;
# endif
}
} else {
shift = 8-shift;
for (plane = 0; plane < planes; ++plane) {
GR_int8u far *s = *(src++);
GR_int8u far *d = *(dst++);
# if defined(__GNUC__) && defined(__i386__)
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"
);
# elif defined(__TURBOC__)
asm push ds ;
asm mov bx, ws ;
asm mov cl, shift ;
asm les di, d ;
asm lds si, s ;
asm mov ch,[si] ;
asm cld ;
loopfw:
asm inc si ;
asm mov ah, ch ;
asm mov al, [si] ;
asm mov ch, al ;
asm shr ax, cl ;
asm stosb ;
asm dec bx ;
asm jnz short loopfw ;
asm pop ds ;
# else
int w = ws;
do {
*(d++) = highlowP(s)>>shift /* sh */;
s++;
} while (--w);
# endif
}
}
GRX_LEAVE();
}
------------------------------------
The following is a screen dump of the error I am getting when compiling
the library for djgpp 2 from a DOS shell from RHIDE (32 Mb ram).
2:54:19.68
D:\DJGPP\CONTRIB\grx23\src>make -f makefdj2.mak
gcc -c -O6 -Wall -fomit-frame-pointer -I. -I./include -I../include
-I../addons/p
rint -I../addons/bmp utils/shiftscl.c -o utils/shiftscl.o
utils/shiftscl.c: In function `_GR_shift_scanline':
utils/shiftscl.c:48: Invalid `asm' statement:
utils/shiftscl.c:48: fixed or forbidden register 2 (cx) was spilled for
class CR
EG.
utils/shiftscl.c:102: Invalid `asm' statement:
utils/shiftscl.c:102: fixed or forbidden register 2 (cx) was spilled for
class C
REG.
make.exe: *** [utils/shiftscl.o] Error 1
Sounds like parser limitation, but I have no idea what to do about it.
Any help grately appreciated.
Cheers and happy new (1K-24)
Oh ya, I am using 486 (no MMX registers) if that makes any difference.
-----------------------------------------------
I guess I better start liking mainframes, can't have all this s--t
spilling all over the place.
- Raw text -