0

This is what I am currently doing but leaq is not the correct instruction (I want to print the contents of %rax but I need the register for the syscall so I move it to %rdx) :

_printResult:
        movq %rax, %rdx
        movq $1, %rax
        movq $1, %rdi
        leaq %rdx, %rsi
        movq $3, %rdx
        syscall

Error: operand type mismatch for 'lea'

sn99
  • 843
  • 8
  • 24
leels
  • 1
  • What are you trying to do at that `leaq`? `%rdx` itself does not have an address, so taking the effective address of `%rdx` doesn't make sense. – Thomas Jager Oct 14 '20 at 13:30
  • 2
    Copy the contents of `rax` onto the stack (e.g. using a `push` instruction) and pass a pointer to that stack location to the system call. Note that even if you do this, you'll only print the literal bytes that make up `rax`. If you want to print the contents as a number, you need to write a conversion routine. – fuz Oct 14 '20 at 13:42
  • 1
    `lea` requires an addressing mode as the source. `lea (%rdx), %rsi` would be equivalent to `mov %rdx, %rsi` so is pointless. – Peter Cordes Oct 14 '20 at 14:41

0 Answers0