Assembly Language for Beginners

(nextflipdebug2) #1

1.31. WORKING WITH FLOATING POINT NUMBERS USING SIMD


x86


Let’s compile this example in MSVC 2012 with optimization turned on:


Listing 1.403: Optimizing MSVC 2012 x86

_a$ = 8 ; size = 8
_b$ = 16 ; size = 8
_d_max PROC
movsd xmm0, QWORD PTR _a$[esp-4]
comisd xmm0, QWORD PTR _b$[esp-4]
jbe SHORT $LN1@d_max
fld QWORD PTR _a$[esp-4]
ret 0
$LN1@d_max:
fld QWORD PTR _b$[esp-4]
ret 0
_d_max ENDP


Almost the same, but the values ofaandbare taken from the stack and the function result is left inST(0).


IfweloadthisexampleinOllyDbg,wecanseehowtheCOMISDinstructioncomparesvaluesandsets/clears
theCFandPFflags:


Figure 1.118:OllyDbg:COMISDchangedCFandPFflags

1.31.4 Calculating machine epsilon: x64 and SIMD


Let’s revisit the “calculating machine epsilon” example fordoublelisting.1.25.2.


Now we compile it for x64:

Free download pdf