Data Types
Here I am introducing different data types in assembly. Read the comments to know more.
After assembling and linking the code, we can dissect this in GDB and check what is happening.
Here, we can see using "info variables" our variables are initialized
In GDB, we can use "x" to examine these. Use help x to display what commands can be used. So, x/x means examine in hex. Then add if you want to see bytes or whatever in x/<size>x<keyword> REGISTER_NAME format
We can also examine repeat_buffer (that times initialized with 128 0xaa) and buffer that initializes 64 bytes unreserved (assembler by default assigns it with 0x00)
We should run this and set a breakpoint on lines where I am assigning [var4] and var4 to rax to see how registers are behaving when RIP reaches there
Upon hitting breakpoint 2, we can observe that the memory address of variable 4 (var4) is not yet loaded in the rax register. Using "nexti" I can make the RIP jump one point and make it execute the next intstruction.
When I do nexti, I hit breakpoint3. This is the breakpoint where memory address of var4 has been set to rax but "mov rax [var4] is yet to be set. At that point, we can see registers and conclude var4's memory address has been set.
Now, we can examine the memory address in RAX right now and confirm that it is infact the var4 (same string). With "nexti" I jump RIP to next instruction and at that moment, "mov rax [var4]" has been executed and RAX assigned with the 8 byte string.
We can use disas command to see where RIP is at the moment. (notice arrow on the left)
Last updated