© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
D. VostokovFoundations of ARM64 Linux Debugging, Disassembling, and Reversinghttps://doi.org/10.1007/978-1-4842-9082-8_2

2. Code Optimization

Dmitry Vostokov1  
(1)
Dublin, Ireland
 

“Arithmetic” Project: C/C++ Program

Let’s rewrite our “Arithmetic” program in C/C++. Corresponding assembly language instructions are put in comments:
int a, b;
int main(int argc, char* argv[])
{
      a = 1;              // adr  x0, a
                          // mov  w1, #1
                          // str  w1, [x0]
      b = 1;              // adr  x0, b
                          // mov  w1, #1
                          // str  w1, [x0]
      b = b + a;          // adr  x0, b
                          // ...

Get Foundations of ARM64 Linux Debugging, Disassembling, and Reversing: Analyze Code, Understand Stack Memory Usage, and Reconstruct Original C/C++ Code with ARM64 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.