GDB Register Display Issue

Question!

I have recently started delving deeper into Assembly, and I could not determine what is going on when I analyze the following code segment. Essentially, 0xFFFFFFFF is moved into EAX and then 0x10 is added to it. When viewing EAX within GDB, the value after execution is 0xF rather than 0x9. When I add 0x11, rather than 0x10, the proper result (0x10) is displayed. Any help would be much appreciated.

I have attached debug output below.

The first value after command execution is EAX, which is displayed using print/x $eax.


(gdb) ni
$11 = 0xffffffff
Dump of assembler code from 0x8048096 to 0x80480a0:
=> 0x08048096 <_start+22>:      add    eax,0x10
   0x08048099 <_start+25>:      mov    eax,0x0
   0x0804809e <_start+30>:      add    BYTE PTR ds:0x804910c,0x22
End of assembler dump.

0x08048096 in _start ()

(gdb) ni
$13 = 0xf
Dump of assembler code from 0x8048099 to 0x80480a3:
=> 0x08048099 <_start+25>:      mov    eax,0x0
   0x0804809e <_start+30>:      add    BYTE PTR ds:0x804910c,0x22
End of assembler dump.

0x08048099 in _start ()


Answers
You appear to expect that adding 0x10 to -1 (0xFFFFFFFF) will produce 0x9.

But 0x10 is 16 (decimal), and adding -1 to it produces 15 (decimal), which is 0xF.

So everything is working here just as it should.



This video can help you solving your question :)
By: admin