; Listing3-11.asm ; ; A program that demonstrates caling the math_sin ; and math_sec functions. 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 (In Unicode): align word ttlStr byte "Listing 3-11", 0 .data align 16 aVal real8 ? mtwo real8 -2.0 aResult real8 0.0 piBy16 real8 16.0 .code ; External definitions for C/C++ sin function externdef sin:proc ; Here is the main assembly language function. public asmMain asmMain proc push rbx sub rsp, 64 ;Shadow storage + alignment fldpi ;Set aVal to pi/2 fld mtwo fdivp fstp aVal fldpi fld piBy16 fdivp fstp piBy16 call print byte "(x)=(ASM.sin(x),ASM.sec(x)); (C.sin(x),C.sec(x))", nl, 0 ; Repeat for aVal = -pi/2 to +pi/2 by pi/32: mov rbx, 17 pgmLoop: ; Compute the assembly language cos result: math(sin) aVal fstp aResult mov rdx, aVal mov r8, aResult call print byte "(%4.1f)=(%10.3e,", 0 ; Compute the assembly language csc result: math(sec) aVal fstp aResult mov rdx, aResult call print byte "%10.3e);", 0 ; Use C++ sin: movsd xmm0, aVal call sin movsd aResult, xmm0 ; Print the C sin result: mov rdx, aResult call print byte " (%10.3e,", 0 ; Compute and display C sec result; fld aResult fld1 fdivrp fstp aResult mov rdx, aResult call print byte "%10.3e)", nl, 0 nextIteration: fld piBy16 fld aVal faddp fstp aVal dec rbx jnz pgmLoop allDone: add rsp, 64 pop rbx ret ;Returns to caller asmMain endp end