0

Using C++ Builder 6 and trying to run this code

  __int64 m64_1 = 1424115525456;
  __int64 m64_2 = 2222222222222;
  __int64 m64_3 = 1111111111111;


    __asm movq mm1, m64_1
    __asm paddd mm1, m64_2
    __asm movq m64_3, mm1

Getting and exception

but I don't execute division by zero. What about this error

keipa
  • 702
  • 1
  • 8
  • 17
  • 2
    If you MMX you must also EMMS – harold Apr 30 '16 at 21:32
  • I don't see where it shows that one of those instructions causes the exception. Why do you think it is there? – wallyk Apr 30 '16 at 21:32
  • @wallyk when i debug it. i go across __asm lines and crashed into 'Memo1->Text = "assemble"'; – keipa Apr 30 '16 at 21:37
  • @harold my task is multiply to arrays using mmx. Do you think EMMS will help me? – keipa Apr 30 '16 at 21:40
  • **Project Project1.exe raised exception calss EInvalidOp with message "Invalid floating point operation. Process stopped"** – keipa Apr 30 '16 at 21:43
  • 4
    EMMS does not help per se, but it is required in order to make subsequent code safe. Not EMMS-ing leaves the FPU stack in a state that makes almost all FPU code crash instantly. The error caused by that should really be FPU stack overflow but maybe the dialog does not distinguish – harold Apr 30 '16 at 21:46
  • @harold awesome. i typed `__asm emms` after mmx commands and it work!Thank you – keipa Apr 30 '16 at 21:52
  • You should probably use SSE2 for new code, instead of MMX. `emms` is slow-ish, and in recent CPUs (Skylake), the MMX versions of many vector instructions can't run on as many execution ports. (i.e. CPU designers don't care as much about MMX anymore, because it's obsolete.) – Peter Cordes May 02 '16 at 06:04

1 Answers1

0

just type __asm emms after your mmx commands like that:

__asm movq mm1, m64_1;
__asm paddd mm1, m64_2;
__asm movq m64_3, mm1;
__asm emms
David Hoelzer
  • 15,862
  • 4
  • 48
  • 67
keipa
  • 702
  • 1
  • 8
  • 17