I'm doing a small program for a University course, they asked us to calculate the Golden number and then print it on the screen, we already have the calculation, now the drawback is that we do not know how to get that number from the FPU
and print it as a ASCII
, we used the FST/FIST
instruction to store it in memory but at the time of checking its value with a debugger
it changes to its representation in Hexadecimal
, which the CPU
transforms into another decimal value, if someone knows how to print it as a ASCII
or knows another way to do it, I'd appreciate it.
This is a bit of the code we are implementing:
section .bss
numero_aureo resb 1
section .data
;numeros necesarios para calcular el numero aureo
x dd 1
y dd 5.0
z dd 2
section .text
global _start
_start:
;calculo del numero aureo
finit
fld dword[y] ;carga el 5 a la FPU
fsqrt ;saca la raiz de 5
fiadd dword[x] ;suma el 1
fidiv dword[z] ;divide entre 2
fst dword[numero_aureo]
esto es lo que me da el debugger:
Breakpoint 4, 0x08048097 in t4 ()
(gdb) info float
=>R7: Valid 0x3fffcf1bbcdcbfa53e0b +1.618033988749894848
R6: Empty 0x00000000000000000000
R5: Empty 0x00000000000000000000
R4: Empty 0x00000000000000000000
R3: Empty 0x00000000000000000000
R2: Empty 0x00000000000000000000
R1: Empty 0x00000000000000000000
R0: Empty 0x00000000000000000000
Status Word: 0x3820 PE
TOP: 7
Control Word: 0x037f IM DM ZM OM UM PM
PC: Extended Precision (64-bits)
RC: Round to nearest
Tag Word: 0x3fff
Instruction Pointer: 0x00:0x00000000
Operand Pointer: 0x00:0x00000000
Opcode: 0x0000
(gdb) continue
Continuing.
Breakpoint 5, 0x0804809d in fin ()
(gdb) print numero_aureo
$1 = 1070537661
(gdb)