0
votes

I am doing my school project: dynamic MASM assembler library in Visual Studio, that implements CaesarCipher's method. Everything worked fine, when I was using console application. When I created Windows Forms UI, MMX functions started to cause errors.

MMX functions - the problem of my project. I see no point of usage it in my project, but one of things I have to do is to use MMX code, even though its useless.

In console that worked fine:

movq mm1, mm0

In Forms Application it causes generic error.

1
Did you forget to emms? - harold
What do you mean? I don't really understand. - user1678401

1 Answers

5
votes

Using an MMX instruction will cause the FPU to switch to MMX mode (sort of, it's not really a mode), which means that all 8 FPU registers will become valid and ready for use by MMX instructions. Using an x87 instruction while in this state can easily fail, all the FPU stack slots are filled so loading anything will cause an FPU stack overflow. In a console program it can easily be the case that no x87 instructions were used at all, so it wasn't a big problem to leave the FPU in that state, but windows forms uses some x87 instructions and they assumed there would be space on the FPU stack as usual.

You can empty the FPU stack after using MMX by using the emms instruction.