; Listing3-10.asm ; ; A program that demonstrates how to compute ; the log of an arbitrary base. option casemap:none ; Include the aoalib (ANSI strings) and aoamath ; libraries: include aoalib.inc include math.inc includelib aoalib.lib includelib aoamath.lib .const ; Program title: align word ttlStr byte "Listing 3-10", 0 three real8 3.0 .data align 16 aVal real8 1.0 aResult real8 0.0 .code ; Here is the main assembly language function. public asmMain asmMain proc push rbx sub rsp, 64 ;Shadow storage + alignment ; Repeat for aVal = 1 to 1000 by powers of two: mov rbx, 10 pgmLoop: ; Compute the assembly language lg(x) ; (log base-2) result: fld1 fld aVal fyl2x fld1 fld three fyl2x fdivp fstp aResult mov rdx, aVal mov r8, aResult call print byte "log3(%6.1f)=(%10.3e)", nl, 0 nextIteration: fld aVal ;Double aVal fld aVal faddp fstp aVal dec rbx jnz pgmLoop allDone: add rsp, 64 pop rbx ret ;Returns to caller asmMain endp end