Problems with floating point instruction menu

Shout-Out

User Tag List

Results 1 to 5 of 5
  1. #1
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with floating point instruction

    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.

    Problems with floating point instruction
  2. #2
    Oowafas's Avatar Member
    Reputation
    14
    Join Date
    Jan 2009
    Posts
    31
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    fnstsw ax stores the FPU status word in the ax register. When the upper bits are tested against 5 it's checking the C2 and C0 bits of the FPU status word. The parity flag is set if there are an odd number of bits after the bitwise and operation done by test, so if either the '4' bit or the '1' bit is set it will take the jp branch. C0 is set if st (abs(flt_1040124)) < source (flt_9A0C5. Neither bit is set if st >= source, and both are set if the operation is invalid. So the branch will only happen if C0 is set (st<source).

    Edit in response to posts below : AoA is a good asm resource also, download that in HTML.
    Last edited by Oowafas; 08-20-2009 at 01:29 AM.

  3. #3
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Get a copy of the Intel Developer Reference Manuals (or w.e they're called), they have an instruction set reference.

    Anyway, here:
    Code:
    signed int __cdecl lua_HasNewMail(int a1)
    {
      signed int result; // eax@2
    
      if ( fabs(flt_1040124) >= 0.0000002384185791015625 )
      {
        sub_801A30(a1);
        result = 1;
      }
      else
      {
        sub_801A50(a1, 1.0);
        result = 1;
      }
      return result;
    }

  4. #4
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Get a copy of the Intel Developer Reference Manuals (or w.e they're called), they have an instruction set reference.
    I second that.

    You can get it from here for free.
    Don't believe everything you think.

  5. #5
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    I second that.

    You can get it from here for free.
    I ordered hardcopies ages ago (which I still have), and I checked again recently because a friend wanted to order them and couldn't find out how. I had a look and it seems that they no longer mail out hard copies of the manuals.

    Is that still true? It seems like it based on their website....

    If anyone wants to try though, email their 'Literature department' or something (look it up, can't remember the name) and ask if they'll send you them. They did for me, but like I said, it seems that since then they've removed the SKU ordering numbers from their website.

Similar Threads

  1. Problem with mmo points.
    By zeulus in forum World of Warcraft General
    Replies: 6
    Last Post: 12-20-2009, 09:18 AM
  2. Problem with WPE
    By weedlord in forum World of Warcraft General
    Replies: 0
    Last Post: 08-14-2006, 03:35 AM
  3. Problem with BWH 1.11.2
    By gwl15 in forum World of Warcraft General
    Replies: 3
    Last Post: 08-11-2006, 05:37 PM
  4. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  5. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
All times are GMT -5. The time now is 07:12 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search