0

movaps instruction set in the documentation is as follows

MOVAPS—Move Aligned Packed Single Precision Floating-Point Values

Instruction:
MOVAPS xmm1, xmm2/m128

Description:
Move aligned packed single precision floating-point values from xmm2/mem to xmm1.

Questions 1: Why is xmm1 written instead of xmm register?

;nasm -f elf64 test.asm

section .data
        var1    dd      0.1, 0.2, 0.3, 0.4

section .text
        global _start

_start:

        movaps xmm1, var1

exit:
        mov rax,60
        mov rdi,0
        syscall

I got the error when I tried to compile the code.

test.asm:11: error: invalid combination of opcode and operands

As a result of my research from the internet, I fixed the error by replacing movaps xmm1, var1 with movaps xmm1, [var1].

Question 2: Where is the error in movaps xmm1, var1. Isn't variable name a pointer in NASM? For example:

section .data
        var1 dd 100

section .text 
        global _start

_start:
        mov eax, var1 ; put var1's pointer in eax
;eax = memory


        mov eax, dword [var1] ; put var1's value in eax
;eax = 100

exit:
        mov rax,60
        mov rdi,0
        syscall

I am using Linux and NASM.

General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • Yes, `var1` is a pointer (address). Not the pointed-to value (memory contents). See the linked duplicate. (And you can't movaps-immediate to an XMM register, as the manual shows there's no form of movaps with an immediate source operand, only memory). – Peter Cordes Apr 28 '23 at 19:58
  • @PeterCordes I don't want to put immediate in xmm register. Is the ```movaps``` instruction only used with xmm1 register? – renraelmsa Apr 28 '23 at 20:02
  • If you don't want an address as an immediate operand, put `[]` around the symbol name to "dereference" it. NASM isn't MASM. See the linked duplicate Q&A, and see your own experiment with EAX which shows the difference. – Peter Cordes Apr 28 '23 at 20:51
  • @PeterCordes You answered my second question. But you didn't answer my first question. My first question is: Is the ```movaps``` instruction only used with xmm1 register? Can I use ```movaps``` instruction with ```xmm7``` register. For example: ```movaps xmm7, [var1]```. The point I'm stuck on is why they write ```xmm1``` in the documentation. – renraelmsa Apr 28 '23 at 21:09
  • I assume you've tried it and found that it works with any xmm register. You can also see that from looking at compiler output; compilers will use it with different registers. [XMM register 0 not being used](https://stackoverflow.com/q/27772153) explains the documentation; the vol.2 manual also has info on how to read the entries, some of which is quoted in [How to read the Intel Opcode notation](https://stackoverflow.com/q/15017659) – Peter Cordes Apr 28 '23 at 21:20

0 Answers0