1

What the difference between loading the address of a string (or any address) in the following two different ways (absolute and PC-relative) ?
Is there any advantage of using one over the other ? Which is the recommended way to do these kind of operations ?

.data
format:
  .asciz    "%d\n"
.text

.global main

main:
  pushq     %rbp
  movq      %rsp, %rbp

  movq      $format, %rdi        # <---- 1
  lea       format(%rip), %rdi   # <---- 2

  movl      $1, %esi
  xorl      %eax, %eax
  call      printf

  movq      %rbp, %rsp
  popq      %rbp
  ret

arka
  • 418
  • 2
  • 9

0 Answers0