Reverse Engineering for Beginners

(avery) #1

CHAPTER 35. TEMPERATURE CONVERTING CHAPTER 35. TEMPERATURE CONVERTING


subsd xmm1, QWORD PTR real@4040000000000000 ; 32
movsd xmm0, QWORD PTR
real@c071100000000000 ; -273
mulsd xmm1, QWORD PTR real@4014000000000000 ; 5
divsd xmm1, QWORD PTR
real@4022000000000000 ; 9
comisd xmm0, xmm1
jbe SHORT $LN1@main
push OFFSET $SG4233 ; 'Error: incorrect temperature!'
call esi ; call printf()
add esp, 4
push 0
call DWORD PTR impexit
$LN10@main:
$LN1@main:
sub esp, 8
movsd QWORD PTR [esp], xmm1
push OFFSET $SG4234 ; 'Celsius: %lf'
call esi ; call printf()
add esp, 12 ; 0000000cH
; return 0 - by C99 standard
xor eax, eax
pop esi
add esp, 8
ret 0
$LN8@main:
_main ENDP


Of course,SIMDinstructions are available in x86 mode, including those working with floating point numbers. It’s somewhat
easier to use them for calculations, so the new Microsoft compiler uses them.


We can also see that the− 273 value is loaded intoXMM0register too early. And that’s OK, because the compiler may emit
instructions not in the order they are in the source code.

Free download pdf