سؤال

I have a problem with simple logarithm computation using FPU. I am using MASM compiler integrated with Visual Studio 2012.

LOCAL log_e_120 : REAL8;

MOV     eax, 120
MOVD    mm0, eax
MOVQ    log_e_120, mm0

FINIT

FLDLN2              ; load log_e(2)
FLD     log_e_120   ; load x
FYL2X               ; compute log_e(2)*log_2(x) = log_e(x)
FSTP    log_e_120   ; store the result

nop

I set a breakpoint at NOP operation to view state of registers/locals and so one.

When the process is at NOP, I'm debugging the value of local log_e_120 in VS2010 watch. It looks like: Results of debugging

All my FLD's operaton has been assembled properly with:

fld         qword ptr [log_e_120]

The upper part of screen is for REAL8 type, and the second one at the bottom is result of debugging QWORD type.

I have also changed the type of log_e_120 to REAL8, QWORD, pretty the same effect.

Also: I cannot properly debug the values of my code.

Of course, the result should be about 4.7874917427820458 (wolframapha computation) .

هل كانت مفيدة؟

المحلول

You have to provide instructions to convert from integer representation to double

 fild local_var_120  ; where the variable is stored as integer

or you can simply use your assembler to do it for you:

 LOCAL log_e_120: REAL8 120.0
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top