Проясните момент

Тема в разделе "WASM.ASSEMBLER", создана пользователем Vladislav, 16 июл 2009.

  1. Vladislav

    Vladislav New Member

    Публикаций:
    0
    Регистрация:
    16 июл 2009
    Сообщения:
    4
    В ассемблере не очень понимаю, но нужно было дизассемблировать dll. Вот есть такой участок:
    Код (Text):
    1. text:10001049                 fld     [esp+0D0h+arg_C]
    2. text:10001050                 fmul    [esp+0D0h+arg_10]
    3. text:10001057                 fstp    [esp+0D0h+var_D0]
    4. text:1000105A                 fld     [esp+0D0h+var_D0]
    Первая понятно, но вот что делает вторая строчка? Не пойму зачем здесь умножение.
    На С++ было написано следующий код:
    Код (Text):
    1. b1 = b;
    2. c1 = c;
     
  2. Microedition

    Microedition Active Member

    Публикаций:
    0
    Регистрация:
    5 июн 2008
    Сообщения:
    814
    А они, случайно, не перегружены?
     
  3. Vladislav

    Vladislav New Member

    Публикаций:
    0
    Регистрация:
    16 июл 2009
    Сообщения:
    4
    Нет, параметры b и c типа float и передаются функции как параметры.
     
  4. GoldFinch

    GoldFinch New Member

    Публикаций:
    0
    Регистрация:
    29 мар 2008
    Сообщения:
    1.775
    Vladislav
    полный код приведи
     
  5. Vladislav

    Vladislav New Member

    Публикаций:
    0
    Регистрация:
    16 июл 2009
    Сообщения:
    4
    Код (Text):
    1. extern "C" __declspec (dllexport) int CALLBACK MyFunc2( int a, char *str, char str2[100], float b, float c, double d, asd e )
    2. {
    3.     int a1;
    4.     char str3[200],str4[200];
    5.     float b1, c1, z;
    6.     double d1;
    7.     asd e1;
    8.     a1 = a;
    9.     a1 = a1 * 2;
    10.     d1 = d;
    11.     d1 = d1 + 1;
    12.     e1 = e;
    13.     e1.a = e1.a + 1;
    14.     a1 = d1 + e1.a;
    15.  
    16.     strcpy(str3,str);
    17.     strcpy(str4, str2);
    18.     b1 = b;
    19.     c1 = c;
    20.     z = b1 * c1;
    21.     if(z > 0)
    22.         return a1;
    23.     else
    24.         return (a1*-1);
    25. }
    Код (Text):
    1. .text:10001010 ; int __stdcall MyFunc2(int, int, int, float, float, double, int, int, int)
    2. .text:10001010                 public _MyFunc2@40
    3. .text:10001010 _MyFunc2@40     proc near
    4. .text:10001010
    5. .text:10001010 var_D0          = dword ptr -0D0h
    6. .text:10001010 var_4           = dword ptr -4
    7. .text:10001010 arg_4           = dword ptr  8
    8. .text:10001010 arg_8           = dword ptr  0Ch
    9. .text:10001010 arg_C           = dword ptr  10h
    10. .text:10001010 arg_10          = dword ptr  14h
    11. .text:10001010 arg_14          = qword ptr  18h
    12. .text:10001010 arg_1C          = dword ptr  20h
    13. .text:10001010
    14. .text:10001010                 sub     esp, 0D0h
    15. .text:10001016                 mov     eax, dword_10003000
    16. .text:1000101B                 xor     eax, esp
    17. .text:1000101D                 mov     [esp+0D0h+var_4], eax
    18. .text:10001024                 mov     eax, [esp+0D0h+arg_1C]
    19. .text:1000102B                 add     eax, 1
    20. .text:1000102E                 mov     [esp+0D0h+var_D0], eax
    21. .text:10001031                 fild    [esp+0D0h+var_D0]
    22. .text:10001034                 push    esi
    23. .text:10001035                 fld     [esp+0D4h+arg_14]
    24. .text:1000103C                 fadd    ds:dbl_100020F8
    25. .text:10001042                 faddp   st(1), st
    26. .text:10001044                 call    __ftol2_sse
    27. .text:10001049                 mov     esi, eax
    28. .text:1000104B                 mov     eax, [esp+0D4h+arg_4]
    29. .text:10001052
    30. .text:10001052 loc_10001052:                           ; CODE XREF: MyFunc2(x,x,x,x,x,x,x,x,x,x)+49j
    31. .text:10001052                 mov     cl, [eax]
    32. .text:10001054                 add     eax, 1
    33. .text:10001057                 test    cl, cl
    34. .text:10001059                 jnz     short loc_10001052
    35. .text:1000105B                 mov     eax, [esp+0D4h+arg_8]
    36. .text:10001062
    37. .text:10001062 loc_10001062:                           ; CODE XREF: MyFunc2(x,x,x,x,x,x,x,x,x,x)+59j
    38. .text:10001062                 mov     cl, [eax]
    39. .text:10001064                 add     eax, 1
    40. .text:10001067                 test    cl, cl
    41. .text:10001069                 jnz     short loc_10001062
    42. .text:1000106B                 fld     [esp+0D4h+arg_C]
    43. .text:10001072                 fmul    [esp+0D4h+arg_10]
    44. .text:10001079                 fstp    [esp+0D4h+var_D0]
    45. .text:1000107D                 fld     [esp+0D4h+var_D0]
    46. .text:10001081                 fcomp   ds:flt_100020F0
    47. .text:10001087                 fnstsw  ax
    48. .text:10001089                 test    ah, 41h
    49. .text:1000108C                 mov     eax, esi
    50. .text:1000108E                 jz      short loc_10001092
    51. .text:10001090                 neg     eax
    52. .text:10001092
    53. .text:10001092 loc_10001092:                           ; CODE XREF: MyFunc2(x,x,x,x,x,x,x,x,x,x)+7Ej
    54. .text:10001092                 mov     ecx, [esp+0D4h+var_4]
    55. .text:10001099                 pop     esi
    56. .text:1000109A                 xor     ecx, esp
    57. .text:1000109C                 call    sub_10001523
    58. .text:100010A1                 add     esp, 0D0h
    59. .text:100010A7                 retn    28h
    60. .text:100010A7 _MyFunc2@40     endp
     
  6. FatMoon

    FatMoon New Member

    Публикаций:
    0
    Регистрация:
    28 ноя 2002
    Сообщения:
    954
    Адрес:
    Russia
    И чего удивительного? Вот их и перемножило. b1 и c1 более нигде не используются, так что и переменные компилятор не создал. Сразу перемножает аргументы, и сохраняет в z.
     
  7. Vladislav

    Vladislav New Member

    Публикаций:
    0
    Регистрация:
    16 июл 2009
    Сообщения:
    4
    Спасибо, туплю(