How to load all 1 into mmx register? Why is this not working?

Could not find anything but questions regarding 64/32 bit questions when I searched.

__asm__ {
  mov rbx, 0xFFFFffffFFFFffffull
  movq mm2, rbx 
}

After these two commands, the mm2 register contains the value 0x30500004ffffffff according to my xcode debugger (this is the built-in asm in C ++). Now I am new to x86 assembly, and my assembly class was taught in MIPS, which I took forever, but I believe that this does not work, because I compile (this is part of the Photoshop plugin) in 32-bit mode and rbx (64- the bit version of ebx, bx, etc., right?) probably doesn’t technically exist. I tried other methods to get all 1, for example loading 0xfffffffful in mm2 and a different register and multiplication, but that also did not work.

I fix the optimization of my plugin with some SIMD instructions, but I can not figure it out or find any documentation that cannot hurt me. Any help is much appreciated!

+3
source share
2 answers

Although the interjay code does what you want, there is an easier way to set the MMX register (or XMM register, for that matter) for all-1 (here for mm2):

pcmpeqw mm2, mm2
+8
source

You cannot run 64-bit assembler code in a 32-bit program. You can either read the value in the MMX register from a memory location, or use something like this:

mov ebx, 0xffffffff
movd mm2, ebx       //copy value to lower 32 bits
punpckldq mm2, mm2  //copy lower 32-bits to upper 32 bits
+1
source

Source: https://habr.com/ru/post/1751618/


All Articles