www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/14/19:27:17

Xref: news2.mv.net comp.os.msdos.djgpp:8621
From: dbarrett AT piano DOT engin DOT umich DOT edu (David M Barrett)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: AT&T Syntax FPU Assembly
Date: 14 Sep 1996 22:40:33 GMT
Organization: University of Michigan Engineering, Ann Arbor
Lines: 61
Message-ID: <51fc91$og5@srvr1.engin.umich.edu>
References: <51anmi$3tl AT srvr1 DOT engin DOT umich DOT edu> <51ehbq$38l AT groa DOT uct DOT ac DOT za>
NNTP-Posting-Host: piano.engin.umich.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019