Mail Archives: djgpp/1996/09/14/19:27:17
Fabian Nunez (fnunez AT cs DOT uct DOT ac DOT za) wrote:
: OK, this is probbly a bit of a kludge, but isn't reverse engineering always?
: 1. Make a short tasm source file containing a few instructions you want to
: check the AT&T syntax for
: 2. Compile the sucker
: 3. Use the emxaout program from ftp.scitechsoft.com to convert the .obj
: file into a .o file
: 4. Use objdump --disassemble to convert the .o file into a .S file
: OK, I haven't really tried this myself but I see no reason why it shouldn't
: work ;)
Wow, that is exotic. :) Actually, I've been doing a bunch of searching
and this is what I've found:
1. Use the standard AT&T Source, Destination order
2. Use normal opcodes but rarely append anything at the end (you know how
you usually add b or l to the end of an instruction to make it AT&T (such
as mov -> movb)? Well, floating point instructions have the same thing
(except using s, d and T for Single, Double and Temporary (32, 64 and
80bit)). But, I don't think I've used a single suffix yet in my
program. For instance, I would think that 'fist _Temp_Int', where
Temp_Int is a 32 bit integer would be written as 'fistl _Temp_Int' or
something, but it requires no changes.)
3. To push a variable into the FPU register stack using Extended ASM,
simply do:
__asm__ __volatile__(" .... " : : "f" (Float1), "f" (Float2) );
And it will push Float1 onto the stack, and then push Float2 (so st(0) is
actually Float2 and st(1) is Float1).
I guess it's all there in the manuals, but I had trouble piecing it
together. For instance, the "f" extended asm thing was found at:
info "gcc" "C Extensions" "Extended ASM"
Where "f" is used in an example with the VAX, but it never really said
where it would put it into the stack or if it would even work for x86.
Plus, I still don't know if there is a way to load a variable into a
particular register (although I doubt it because there is no single
instruction to do this).
More helpful information was found at:
info "as" "Machine Dependencies" "i386-Dependent(?)" "i386-Float"
If you know of any other refrences on how to work the FPU through AT&T
Asm, point me to it. Thanks!
-David :)
-----------------------------------------------------------------------------
David M. Barrett :) | University of Michigan / CAEN Hotline
dbarrett AT engin DOT umich DOT edu | http://www-personal.engin.umich.edu/~dbarrett
-----------------------------------------------------------------------------
- Raw text -