Assembly Language for Beginners

(Jeff_L) #1

1.19. FLOATING-POINT UNIT
92 es 0x7b 123
93 fs 0x0 0
94 gs 0x33 51
95 (gdb) ni
96 0x080484ae in d_max ()
97 (gdb) info float
98 R7: Valid 0x4000d999999999999800 +3.399999999999999911
99 =>R6: Valid 0x4000d999999999999800 +3.399999999999999911
100 R5: Empty 0x00000000000000000000
101 R4: Empty 0x00000000000000000000
102 R3: Empty 0x00000000000000000000
103 R2: Empty 0x00000000000000000000
104 R1: Empty 0x00000000000000000000
105 R0: Empty 0x00000000000000000000
106
107 Status Word: 0x3000
108 TOP: 6
109 Control Word: 0x037f IM DM ZM OM UM PM
110 PC: Extended Precision (64-bits)
111 RC: Round to nearest
112 Tag Word: 0x0fff
113 Instruction Pointer: 0x73:0x080484ac
114 Operand Pointer: 0x7b:0xbffff118
115 Opcode: 0x0000
116 (gdb) disas $eip
117 Dump of assembler code for function d_max:
118 0x080484a0 <+0>: fldl 0x4(%esp)
119 0x080484a4 <+4>: fldl 0xc(%esp)
120 0x080484a8 <+8>: fxch %st(1)
121 0x080484aa <+10>: fucomi %st(1),%st
122 0x080484ac <+12>: fcmovbe %st(1),%st
123 => 0x080484ae <+14>: fstp %st(1)
124 0x080484b0 <+16>: ret
125 End of assembler dump.
126 (gdb) ni
127 0x080484b0 in d_max ()
128 (gdb) info float
129 =>R7: Valid 0x4000d999999999999800 +3.399999999999999911
130 R6: Empty 0x4000d999999999999800
131 R5: Empty 0x00000000000000000000
132 R4: Empty 0x00000000000000000000
133 R3: Empty 0x00000000000000000000
134 R2: Empty 0x00000000000000000000
135 R1: Empty 0x00000000000000000000
136 R0: Empty 0x00000000000000000000
137
138 Status Word: 0x3800
139 TOP: 7
140 Control Word: 0x037f IM DM ZM OM UM PM
141 PC: Extended Precision (64-bits)
142 RC: Round to nearest
143 Tag Word: 0x3fff
144 Instruction Pointer: 0x73:0x080484ae
145 Operand Pointer: 0x7b:0xbffff118
146 Opcode: 0x0000
147 (gdb) quit
148 A debugging session is active.
149
150 Inferior 1 [process 30194] will be killed.
151
152 Quit anyway? (y or n) y
153 dennis@ubuntuvm:~/polygon$


Using “ni”, let’s execute the first twoFLDinstructions.

Let’s examine the FPU registers (line 33).

As it was mentioned before, the FPU registers set is a circular buffer rather than a stack (1.19.5 on
page 225). And GDB doesn’t showSTxregisters, but internal the FPU registers (Rx). The arrow (at line
35) points to the current top of the stack.
Free download pdf