Part 29 – Float 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 Floating-Point variables.
A floating-point variable is different from an integer as it has a fractional value attached to which we designate with a period.
Let’s examine our code.
#include <iostream>
float main(void) {
int myNumber = 1337.1;
std::cout << myNumber << std::endl;
return 0;
}
To compile this we simply type:
g++ example6.cpp -o example6
./example6
SUCCESS! We see 1337.1 printed to the standard output or terminal!
Let’s break it down:
We assign the floating-point variable directly into the variable myNumber and then print it out to the terminal with the c++ cout function.
Thus far we have a good understanding of the ARM registers however next week we will introduce the registers within the math co-processor that work with floating-point variables. The registers you have worked with up to now only store whole numbers or integers and at the Assembly level, any fractional value must be manipulated through the math co-processor registers.
Next week we will dive into Debugging Float Variables.