cleaner assembly function ...
"Stefan M. Fendt" <[email protected]> Fri, 08 Feb 2008 10:47:00 +0100
| Newsgroups | gmane.comp.video.mjpeg.devel |
|---|---|
| Message-ID | <1202464020.25781.21.camel@lionfish> |
Hi,
I have written a fast(? maybe it is possible to do faster...)
inline-assembly-function to rotate an image-plane by 180 degrees.
currently it looks like this (the example code is not too good in
explaining the real problem I have, see below):
----[CODE]-------------------------------------------------------------
void Rotate180Image420p ( uint8_t* dImg[3],
uint8_t* sImg[3],
int w,
int h )
{
static uint32_t width;
static uint32_t height;
static uint8_t* Src;
static uint8_t* Dst;
Dst = dImg[0];
Src = sImg[0]+w*h-1;
width = w;
height = h;
asm(
" \n\t" /* fast 180 degr. rotate */
".intel_syntax noprefix \n\t" /* ---------------------- */
" \n\t"
"pusha \n\t" /* safe register state */
" \n\t"
"mov eax,%[width] \n\t" /* setup registers */
"mov ebx,%[height] \n\t"
"mul ebx \n\t"
"mov ecx,eax \n\t"
"mov edi,%[dImg] \n\t"
"mov esi,%[sImg] \n\t"
" \n\t"
"FLIP_LOOP_Y: \n\t"
" \n\t"
"mov byte ptr dl,[esi] \n\t" /* copy data ... */
"mov byte ptr [edi],dl \n\t"
" \n\t"
"dec esi \n\t"
"inc edi \n\t"
" \n\t"
"loop FLIP_LOOP_Y \n\t"
" \n\t"
"popa \n\t" /* restore register state */
" \n\t"
".att_syntax prefix \n\t"
" \n\t"
:
:
[width] "m" (width),
[height] "m" (height),
[dImg] "m" (Dst),
[sImg] "m" (Src)
);
};
----[/CODE]-------------------------------------------------------------
Well, what I do not like is that clumsy stuff with the static variables.
For this short example I could have done it without them, but if the
parameter-list gets longer...
asm volatile ( ...
:
:
[width] "m" (width),
[height] "m" (height),
[dImg] "m" (Dst),
[sImg] "m" (Src)
[xdat] "m" (XOffsetTable),
[ydat] "m" (YOffsetTable),
[zdat] "m" (ZOffsetTable)
);
... and I try it without that static-variables-hack, GCC/GAS runs out of
registers. And that contrary to the fact that each of the variables I
want access to, *can* be reached somewhere in memory (checked by looking
at the .s-file produced).
Same question formulated different (because I am not sure if I could
really make it clear from the above...): Is there a way to explicitly
tell GCC/GAS to use a memory representation of a variable? "m" does not
enforce it, it just allows for it... and so GCC keeps trying to use
registers (which makes sense with just a few variables), but when using
more variables than there are available registers is completely
pointless... But GCC tries nonetheless and fails without even trying to
use the available memory-pointer.
cu
Stefan
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mjpeg-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mjpeg-developer
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQBHrCUUYAr+TNUy5vARAtKHAJsHXLRXJ8a2wTGXTHnj7TgUDUY8owCfUEGA wJQ+Uc3xo4EO02rd3ud4sUs= =hQmG -----END PGP SIGNATURE-----