How to use RIP Relative Addressing in a 64-bit assembly program?

前端 未结 2 884
时光说笑
时光说笑 2020-11-27 19:05

How do I use RIP Relative Addressing in a Linux assembly program for the AMD64 archtitecture? I am looking for a simple example (a Hello world program) that uses the AMD64 R

相关标签:
2条回答
  • 2020-11-27 19:26

    I believe that you want to load the address of your string into %rsi; your code attempts to load a quadword from that address rather than the address itself. You want:

    lea msg(%rip), %rsi
    

    if I'm not mistaken. I don't have a linux box to test on, however.

    0 讨论(0)
  • 2020-11-27 19:28

    Since you need the address of msg in %rsi, just replace:

    mov msg(%rip),%rsi
    

    with:

    lea msg(%rip),%rsi
    
    0 讨论(0)
提交回复
热议问题