I just started learning about assembly language in Kali Linux in VMware. I have a Ryzen 5 CPU. In the below code snippet, I have a few things I don't understand.
- What is the meaning of
lea rax, [rip ± 0xeb3]
at <main + 17>? I understand whatlea
does, but what is the meaning of ±? - And what is the purpose of RDI after getting updated?
(gdb) list
1 #include<stdio.h>
2
3 int main(){
4 int i;
5 for(i = 0 ; i < 10 ; i++){
6 printf("Hello World!\n");
7 }
8 return 0;
9 }
(gdb) disassemble main
Dump of assembler code for function main:
0x0000000000001139 <+0>: push rbp
0x000000000000113a <+1>: mov rbp,rsp
0x000000000000113d <+4>: sub rsp,0x10
0x0000000000001141 <+8>: mov DWORD PTR [rbp-0x4],0x0
0x0000000000001148 <+15>: jmp 0x115d <main+36>
0x000000000000114a <+17>: lea rax,[rip±0xeb3] # 0x2004
0x0000000000001151 <+24>: mov rdi,rax
0x0000000000001154 <+27>: call 0x1030 <puts@plt>
0x0000000000001159 <+32>: add DWORD PTR [rbp-0x4],0x1
0x000000000000115d <+36>: cmp DWORD PTR [rbp-0x4],0x9
0x0000000000001161 <+40>: jle 0x114a <main+17>
0x0000000000001163 <+42>: mov eax,0x0
0x0000000000001168 <+47>: leave
0x0000000000001169 <+48>: ret
End of assembler dump.
(gdb)
Edit:
gdb -v
GNU gdb (Debian 12.1-3) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.