Part 26 – Integer Variables

For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/Reverse-Engineering-Tutorial

The next stage in our journey is that of Integer variables.

A 32-bit register can store 2^32 different values. The range of integer values that can be stored in 32 bits depends on the integer representation used. With the two most common representations, the range is 0 through 4,294,967,295 (2^32 − 1) for representation as an (unsigned) binary number, and −2,147,483,648 (−2^31) through 2,147,483,647 (2^31 − 1) for representation as two’s complement.

Keep in mind with 32-bit memory addresses you can directly access a maximum of 4 GB of byte-addressable memory.

Let’s examine our code.

  1. #include <iostream>
  2. int main(void) {
  3. int myNumber = 777;
  4. std::cout << myNumber << std::endl;
  5. return 0;
  6. }

Part 26 – Integer Variables - 图1

To compile this we simply type:

g++ example5.cpp -o example5

./example5

Part 26 – Integer Variables - 图2

SUCCESS! We see 777 printed to the standard output or terminal!

Let’s break it down:

We assign the integer 777 directly into the variable myNumber and then print it out to the terminal with the c++ cout function.

Next week we will dive into Debugging Integer Variables.