Hi,
was trying to reverse a lua function and had problems because of some floating-point instruction which aren't listed in my reference and I have problems to find a explaination of them. Never worked with fpi before.
Here is the complete function:
Code:
.text:004F3460 ; =============== S U B R O U T I N E =======================================
.text:004F3460
.text:004F3460 ; Attributes: bp-based frame
.text:004F3460
.text:004F3460 lua_HasNewMail proc near ; DATA XREF: .data:01040224o
.text:004F3460
.text:004F3460 var_8 = qword ptr -8
.text:004F3460 arg_0 = dword ptr 8
.text:004F3460
.text:004F3460 push ebp
.text:004F3461 mov ebp, esp
.text:004F3463 fld flt_1040124
.text:004F3469 fabs
.text:004F346B fcomp ds:flt_9A0C58
.text:004F3471 fnstsw ax
.text:004F3473 test ah, 5
.text:004F3476 jp short loc_4F3493
.text:004F3478 fld1
.text:004F347A mov eax, [ebp+arg_0]
.text:004F347D sub esp, 8
.text:004F3480 fstp [esp+8+var_8]
.text:004F3483 push eax ; int
.text:004F3484 call lua_pushNumber
.text:004F3489 add esp, 0Ch
.text:004F348C mov eax, 1
.text:004F3491 pop ebp
.text:004F3492 retn
.text:004F3493 ; ---------------------------------------------------------------------------
.text:004F3493
.text:004F3493 loc_4F3493: ; CODE XREF: lua_HasNewMail+16j
.text:004F3493 mov ecx, [ebp+arg_0]
.text:004F3496 push ecx
.text:004F3497 call lua_pushnil
.text:004F349C add esp, 4
.text:004F349F mov eax, 1
.text:004F34A4 pop ebp
.text:004F34A5 retn
.text:004F34A5 lua_HasNewMail endp
.text:004F34A5
.text:004F34A5 ; ---------------------------------------------------------------------------
This is where I have my problems, thats how I understand it:
fld flt_1040124
Ok, loading a value.
fabs
Casting it to an unsigned number
fcomp ds:flt_9A0C58
Comparing it to another value
fnstsw ax
Not listed in my reference
test ah, 5
Higher bits of ax are compared to 5
jp short loc_4F3493
Jump if parity flag set
Can please someone explain that piece of code a bit? Too bad I don't have the new HexRays with FPU-Support, makes everything clearer I think.