0

Is there any equivalent mov instruction for floating point numbers (for register like %xmm and %ymm) like those for integer types (for register like %rax, %rcx). If exists, any technical explanation is appreciated.

I have written a demo assembly code (AT&T syntax).

.data

radius:
  .long 357
pi:
  .double 3.14

.text

.global main

main:
  pushq   %rbp
  movq    %rsp, %rbp

  # print msg1
  movq    $0, %rax
  movq    $fmtstr, %rdi
  movq    $msg1, %rsi
  call    printf

  # print msg2
  movq    $0, %rax
  movq    $fmtstr, %rdi
  movq    $msg2, %rsi
  call    printf

  # print radius
  movq    $0, %rax
  movq    $fmtint, %rdi
  movl    radius, %esi
  call    printf

  # print pi
  movq    $1, %rax
  movq    $fmtflt, %rdi
          pi, %xmm0       # Any equivalent mov instruction
  call    printf


  movq    %rbp, %rsp
  popq    %rbp
  ret


msg1:
  .asciz  "Hello World"
msg2:
  .asciz  "Alive and Kicking"
fmtstr:
  .asciz  "%s\n"
fmtint:
  .asciz  "%d\n"
fmtflt:
  .asciz  "%f\n"
arka
  • 418
  • 2
  • 9
  • 6
    Yes, `movsd`. Consult instruction set reference and the basic architecture manual chapter _11.4.1.1 Data Movement Instructions_. – Jester Oct 30 '22 at 11:14

0 Answers0