A reference for AT&T syntax assembly floating point arithmetic?

Okay. Start with Intel syntax first, because most x86 assembly coders use it. Intel's manuals are a great resource for learning about how the x86 handles floating-point stuff.

Up vote 4 down vote favorite share g+ share fb share tw.

I've been trying for the past week to find a decent resource on floating point arithmetic for x86 assembly using AT&T syntax. Ideally, a list of the opcodes, what they do, and where the floats are stored. I am familiar with IEEE 754 representation.

I am not familiar with the floating point stack, and any assembly referring to floating point arithmetic. It's strange how difficult this is to find. EDIT: I've been looking at gcc -S output for the past month learning the assembly.

That's how I figured out everything except floating point arithmetic. Even after going through dozens of small programs compiled without optimizations, I still can't figure out much about the floating point opcodes and the stack. I've only found trivial examples online.

Assembly floating-point x86 link|improve this question edited Oct 10 '10 at 22:41 asked Oct 10 '10 at 22:22Kizaru1,0141215 100% accept rate.

Re edit: So, follow the suggestion to read libm, and read the Intel manuals. I'm sorry, you have no alternative. There are no decent AT&T-syntax-based resources, because nobody serious about x86 assembly programming uses it.

– Chris Jester-Young Oct 10 '10 at 22:42 1 Okay, so I was a little too harsh about saying that nobody serious uses AT&T syntax. Anyway, if you Google for "devpro-libm", you can download the libm code used in OpenSolaris. This may be a more lightweight download than glibc.

Then, look in the usr/src/libm/src/i386/common directory---it's a goldmine of hardcore floating-point assembly, all written in AT&T syntax. – Chris Jester-Young Oct 11 '10 at 1:09 1 I was actually just about to download that. Thanks :) I also dislike the AT&T syntax and it has some serious inconsistencies--but I have to use what I have to use.

Despite being Intel syntax, this is a concise guide similar to what I was looking for. The changes to accommodate AT&T syntax are easy. – Kizaru Oct 11 '10 at 1:31 +1 Wow, that's a pretty comprehensive guide, at least at a brief glance (I know x86 FP, so didn't feel the need to read through it in detail ;-)).

Yep, hopefully between that and the libm code, you'll be all sorted. The latter is actually very well-commented, it's not just a big bunch of magic spells. :-P – Chris Jester-Young Oct 11 '10 at 1:41 Yep, I should be set now.

Well, after a week of making sure my compiler spits out somewhat decent code that works. Thanks for all the help. – Kizaru Oct 11 '10 at 2:05.

Okay. Start with Intel syntax first, because most x86 assembly coders use it. Intel's manuals are a great resource for learning about how the x86 handles floating-point stuff.

After you learn x86 assembly in general, AT&T syntax isn't so hard to learn. The main things to note are: registers are prefixed by %; numeric constants are prefixed by $ register order is swapped for most two-operand instructions (i.e. , source first, target last) instruction names specify the size; so instead of mov dword ptr ebx, 1337, you'd say movl $1337, (%ebx).

I can't use intel syntax. This is for a compiler project and we're using AT&T syntax so it works with gcc. – Kizaru Oct 10 '10 at 22:30 2 @Kizaru: I know you can't use it for your project.

But you should learn with it first. Use nasm as your assembler, initially. Then, once you get the hang of x86 assembly programming, then use AT&T syntax.

Have your project be able to output to both formats, initially targeting nasm, if you want. – Chris Jester-Young Oct 10 '10 at 22:34 I have the compiler fully set for everything except floats at the moment. It's the one thing holding me back.

This is a project for a course. – Kizaru Oct 10 '10 at 22:36 @Kizaru: Okay. Other suggestions for you, then: 1.

Look at the libm source code; much of it is written in x86 assembly, and yes, in AT&T syntax. (On GNU/Linux, this comes as part of glibc. ) 2.

Compile some floating-point code in GCC, and look at its assembly output. – Chris Jester-Young Oct 10 '10 at 22:38 1 Suggestion: Write some floating point code in C and compile it with gcc -S. This will quickly show you what you need to know to deal with FP from AT&T syntax.

In general, flip the operands of any two-instruction Intel-syntax instruction; there are a few exceptions, but they're very few and far between. – Cody Brocious Oct 10 '10 at 22:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions