Re: cleaner assembly function ...

"Stefan M. Fendt" <[email protected]> Sun, 10 Feb 2008 10:21:07 +0100
Newsgroups gmane.comp.video.mjpeg.devel
Message-ID <1202635267.29870.31.camel@lionfish>
Am Samstag, den 09.02.2008, 10:32 -0800 schrieb Scott Smith:

> You might want to look at the byte swap instructions...

Oh, yes ... :-) I really forgot about that. Thanks!

> Also you probably should tell GCC which registers you're using.

Hmm, yeah, this is what I usually do (and BTW I do it for this function,
too, now...). But my real problem is that if one has more variables to
deliver into the assembly-function then there are registers on that
machine... My understanding is, that in this case (when the compiler
runs out of registers) the statement below

": [asm_name] "m" (c_name)" 

should use a memory reference for the variable c_name instead of a
register (as there is none left)... but it doesn't. It still tries to
use a register... and then it just issues this error message:

asm.c: error: can't find a register in class 'GENERAL_REGS' while
reloading 'asm'

And besides that, it sometimes gives this error:

asm.s:711: Error: invalid operand for 'mov' ('(' unexpected)
asm.s:712: Error: invalid operand for 'mov' ('(' unexpected)
asm.s:724: Error: invalid operand for 'add' ('(' unexpected)

This happens (I guess), because of switching from AT+T syntax to Intel
syntax noprefix and back, as the file looks like this at these lines:

711: 	mov   eax,28(%ebp) 
712:	mov   ebx,32(%ebp)
724:	add   edi,28(%ebp)

These should be 

711:	mov   eax,28[ebp]
712:	mov   ebx,32[ebp]
724:	add   edi,28[ebp]

with ".intel_syntax noprefix"...

Strange enough, as there are these lines, which do not get any
error-message (and they are not correct anyways...):

717:	mov   ebp,(%edi)                 
718:	mov   edi,(%ebx) 

BTW: I do not like AT+T syntax too much, as there are to many
"%"-signs :-) and I do not like the idea of converting some hundreds of
already existing code-lines to AT+T syntax... I guess, I was asking for
trouble by just using ".intel_syntax noprefix" and "att_syntax prefix"
to do the syntax-switch...

Maybe, I should use "gcc -masm=Intel" and avoid switching from/to AT+T
syntax inside the source to avoid the "invalid operand"-trouble... (the
longer I think about it, this might be the solution for that one) but
for the "can't find a register in class..." I am totally clueless and it
seems totally invariant against either syntax...

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)

iD8DBQBHrsIDYAr+TNUy5vARAthZAJ9cqdK7f2dt5Y7W/NmcvE0kz1xPtQCfdQ5c
sITGB9SswCxXg/4g0Lxqy4s=
=b7yV
-----END PGP SIGNATURE-----