Adding Numbers Using Pointers
Explore how to add numbers using pointers by analyzing C/C++ expressions alongside ARM64 assembly instructions. Understand the steps for memory access, register usage, and GDB disassembly output to debug and trace pointer arithmetic at the assembly level.
We'll cover the following...
We'll cover the following...
Pointers to add numbers
Now, we’ll look at the next pseudocode statement:
[x1] <- [x1] + [x0]
Recall that [x0] and [x1] are the contents of memory cells whose addresses (locations) are stored in x0 and x1 CPU registers.
We look at how we add numbers by using pointers in the following languages:
In the C/C++ language
The expression [x1] <- [x1] + [x0] is equivalent to the following C/C++ language expression:
*pb = *pb + *pa;
In this expression, the * operator is an instruction to retrieve memory contents pointed to by the pointers pa or pb (also called pointer ...