Hello Frank, and thanks for the welcome-wishes! :-)
As I think all over it, i just need the printf for "seeing" my values. In fact I do not really need this written out.
But the printf-function seems to be cabaple of interpreting and displaying the packed BCD-Values.
For example I wrote a piece of code, which calculates different squareroots, which are at least partly even, without floating point. These are moved to registers, where I want to see them with a debugger. Nevertheless, I can't see my values in the register; I assume, they are BCD-packed, which I assume, printf could write them OR I find another solution. (For unpacking the packed BCD ?)
; calculates square root
; nasm -f elf64 fpu_sq_root.asm
; ld -s -o fpu_sq_root fpu_sq_root.o
[bits 64]
global _start
section .data
_msg db ' ',0ah
len_msg equ $-_msg
val1: dq 16 ;declare quad word (double precision)
val2: dq 9 ;declare quad word (double precision)
val3: dq 4 ;declare quad word (double precision)
val4: dq 1 ;declare quad word (double precision)
val5: dq 0 ;declare quad word (double precision)
val6: dq 0.25 ;declare quad word (double precision)
val7: dq 2.25 ;declare quad word (double precision)
val8: dq 6.25 ;declare quad word (double precision)
val9: dq 12.25 ;declare quad word (double precision)
section .bss
res: resq 1 ;reserve 1 quad word for result
section .text
_start:
nop
nop
nop
nop
nop
fld qword [val1] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val2] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val3] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val4] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val5] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val6] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val7] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val8] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
fld qword [val9] ;load value into st0
fsqrt ;compute square root of st0 and store in st0
fst qword [res] ;store st0 in result
mov rbx, [res]
nop
nop
nop
nop
mov rax,1
int 80h
;end program
=> Squareroots of the val's are computed and one after each stored in RBX.
If I debug the program with radare2, I see senseless numbers in RBX.
Are they packed BCD? If yes, how to unpack ?
Greetz and thanks, Andy
PS : the many "nop" are for me to be able to get orientation while debugging...