Hi, my 1st post, I've been programming in assembly for the last 4 - 5 months, I started it because I wanted to use the SSE registers and as long as I was playing around with those it was fine, now I'm trying some more "complex" stuff (if you can say that...) I'm still using inline assembler via C++ for some small functions... I was curious about 2 things mainly

FPU Register Stack

The contents of the register stacks are persistent across function calls?  as in... the stack is not implicitly cleared?... I made a function in a loop and the third call started giving me 1#IND on the stack... then I used FFREE to clear all the registers I previously used... is that "The way" to do it? is there a better way? or it's about taking care and using store commands that pop the stack?

MMX Registers

I was reading some book and I saw a comment about MMX registers, and I started looking for the commands I thought "Cool, 8 more registers" I wrote a few things and then I was debugging a code that used the FPU and I saw in the registers debug window something weird, sometimes when I pushed something into the the FPU stack some MMX registers (usually between 4/7) changed it's value O_O

Any clues?

And any recommended bibliography?

I started by PCASM by paul carter then I've read
Write Great Code Volume 1: Understanding the machine
Write Great Code Volume 2: Thinking low level writting high level
and I read a little of WROX professional assembly language...
I'm going to buy The Art Of Assembly programming sometime, but, is there anything else?
I was wondering about that "Assembly Language for Intel-Based Computers" anyone read that?
and also "32/64-bit 80x86 Assembly Language Architecture" (anyone?)

Thanks alot
Posted on 2008-11-01 18:41:58 by Melanikus
MMX registers are just aliases for existing FPU registers. Therefore when you played around with FPU the variables in the MMX registers got modified.
Posted on 2008-11-01 21:09:44 by roticv
True. If you want to mix FPU/MMX instructions, you have to be careful because mmx registers use the same register space as fpu registers. That's why you have to execute the emms/femms instruction before any fpu instruction following an mmx instruction. Otherwise the fpu calculations will be incorrect.

Forget about FPU and switch to SSE. Cleaner, nicer, better :) And they have their own 8 128-bit registers ^^ So you can mix MMX and SSE together. FPU instructions are kinda ancient these days.
Posted on 2008-11-02 07:43:51 by ti_mo_n
:shock: I thought FPU was still the default...maybe Compilers just use FPU in case there's no SSE...
Is SSE faster? I mean appart from the parallelization side of things if I'm using just the 1st 32 bits to do math,  Is it still faster? and MMX is "ok" ? =P People still use it?

Thanks alot
Posted on 2008-11-02 16:24:24 by Melanikus
People still use MMX; yes. I would rather use SSEII and SSEIII though. They are much better. You can read more about them in Intel Manuals. 3D NOW is the equivalent of MMX/SSE I guess by AMD.
Posted on 2008-11-02 18:15:16 by XCHG
Hi Melanikus,

Welcome on board. If you are ever really interested in using the FPU, you must know first how it works. The following should give you a pretty good idea and prevent you from falling into its numerous pitfalls.


and MMX is "ok" ? =P People still use it?

Unfortunately, some of the MS programmers fell in love with those MMX instructions when they wrote WinXP (or maybe some earlier OS after Win98). They used them in numerous functions wherever they needed to perform some computation, even if it was only 2+2 probably. Therefore those functions trash the FPU registers and it would be your responsibility to save any important data in those registers before calling such Windows APIs. Don't expect to find any information from MS regarding which APIs use MMX instructions.
Posted on 2008-11-02 19:48:51 by Raymond