views:

39

answers:

2

Hi,

I have a sample piece of code that writes the value of the xmm6 register into a memory location. The code is in NASM:

value:
    dd 0

movq [value], xmm6

However I am getting the error when I tried to compile it to macho64 format:

64-bit format does not support 32-bit absolute addresses.

Is there a way to resolve this? I am new to x86_64 assembly so any help would be appreciated.

+1  A: 

I seem to have solved by own question:

value:
    dd 0

default rel
movq [value], xmm6

Is this valid?

Alex
Yes and no! Because now you have the default pointed size 8-byte what is not very smart in 32 bit (4-byte) assembler.
GJ
+2  A: 

You must to tell assembler that you wont to point to 8-byte memory location:

movq qword[value], xmm6
GJ
Is this because xmm6 has a size of qword so I must put qword to balance it?
Alex
No, you wont to operate with 64-bit variable named value. The xmm registers are 128-bit size if you wont to copy 128-bits to memory then use "movdqa dqword [value]".
GJ
I've declared value as dd (32-bit) though, so I should use word then.
Alex
No, word is 16 bit dword is 32 bit.
GJ
But with movq instructions you can move only qword.
GJ
Use: movd dword[value], xmm6
GJ