Adding Numbers Using Pointers
Explore how to add numbers using pointers in C/C++ and assembly language on x64 architecture. Understand pointer dereferencing, memory manipulation, and analyze GDB disassembly output to observe register and memory changes during execution.
Pointers to add numbers
The following pseudocode is an instruction to add numbers using pointers:
(rbx) + (rax) -> (rbx)
The pointers (rax)and (rbx) refer to the contents of memory cells whose addresses are stored in %RAX and %RBX CPU registers.
Add numbers in different environments
Now we’ll explore how we add numbers by using pointers in following languages:
Add numbers in C/C++ using pointers
The expression (rbx) + (rax) -> (rbx) is equivalent to the following C/C++ language expression:
*pb = *pb + *pa;
...