Question

Not sure why...but at line 113 I create the number 400000000 then move it to edi but it doesn't move? I multiplied by a variable .int is that the problem?

113                 mull %ecx                #Create number
(gdb) info registers
eax            0x17d78400   400000000
ecx            0x5f5e100    100000000
edx            0x0  0
ebx            0x0  0
esp            0xbffff3a4   0xbffff3a4
ebp            0x0  0x0
esi            0xa  10
edi            0x19cd8f78   432902008
eip            0x8048107    0x8048107 <_output+48>
eflags         0x206    [ PF IF ]
cs             0x73 115
ss             0x7b 123
ds             0x7b 123
es             0x7b 123
fs             0x0  0
gs             0x0  0
(gdb) s
115                 mov %eax, %edi           #move low
(gdb) s
116                 mov %edx, %esi            #move high
(gdb) info registers
eax            0xbf040000   -1090256896
ecx            0x5f5e100    100000000
edx            0x8e1bc9 9313225
ebx            0x0  0
esp            0xbffff3a4   0xbffff3a4
ebp            0x0  0x0
esi            0xa  10
edi            0xbf040000   -1090256896
eip            0x804810b    0x804810b <_output+52>
eflags         0xa87    [ CF PF SF IF OF ]
cs             0x73 115
ss             0x7b 123
ds             0x7b 123
es             0x7b 123
fs             0x0  0
gs             0x0  0
Was it helpful?

Solution

After the mull the product of EAX times ECX is in EDX:EAX, in your case

factors:

eax            0x17d78400   400000000
ecx            0x5f5e100    100000000

product:

eax            0xbf040000   -1090256896
edx            0x8e1bc9 9313225

So the 64-bit product is

0x8e1bc9bf040000

Which in decimal is

40,000,000,000,000,000

So the product is correct, and in the correct place.

You move EAX to EDI, which is only the lower 32-bits of the product. The next instruction, which you didn't step, is a move of EDX to ESI (the upper 32-bits of the product).

enter image description here

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top