sin и cos из msvcrt.dll

Тема в разделе "WASM.BEGINNERS", создана пользователем Adrax, 8 сен 2007.

  1. Adrax

    Adrax Алексей

    Публикаций:
    0
    Регистрация:
    14 окт 2006
    Сообщения:
    135
    Адрес:
    г. Курск
    Уважаемые программисты! Снова прошу помочь мне с сишными функциями
    Код (Text):
    1. format PE console
    2. include 'win32axp.inc'
    3. N dd ?
    4. d db '%d',0
    5. form db 'Sinus of %d is %d, cosinus of %d is %d',0
    6. string db 'Input N:',0
    7. printf dd ?
    8. scanf dd ?
    9. sin dd ?
    10. cos dd ?
    11. name1 db 'printf',0
    12. name2 db 'scanf',0
    13. name3 db 'sin',0
    14. name4 db 'cos',0
    15. dllka db 'msvcrt.dll',0
    16. sinus dd ?
    17. cosinus dd ?
    18. ex dd ?
    19. .code
    20. fuck:
    21. invoke LoadLibrary,dllka
    22. push eax
    23. push eax
    24. push eax
    25. invoke GetProcAddress,eax,name1
    26. mov [printf],eax
    27. pop eax
    28. invoke GetProcAddress,eax,name2
    29. mov [scanf],eax
    30. pop eax
    31. invoke GetProcAddress,eax,name3
    32. mov [sin],eax
    33. invoke GetProcAddress,eax,name4
    34. mov [cos],eax
    35. cinvoke printf,string
    36. cinvoke scanf,d,N
    37.  
    38. cinvoke sin,N
    39. mov [sinus],eax
    40. cinvoke cos,N
    41. mov [cosinus],eax
    42.  
    43. cinvoke printf,form,[N],[sinus],[N],[cosinus]
    44. invoke ExitProcess,0
    45. .end fuck
    Независимо от того, вызываю ли я sin,[N] или sin,N - возникает ошибка "execution 0x0"

    Дизасм:
    Код (Text):
    1.  start:                                  ; "msvcrt.dll"
    2. .text:00402000                 push    offset aMsvcrt_dll
    3. .text:00402005                 call    ds:LoadLibraryA
    4. .text:0040200B                 push    eax
    5. .text:0040200C                 push    eax
    6. .text:0040200D                 push    eax
    7. .text:0040200E                 push    offset aPrintf  ; "printf"
    8. .text:00402013                 push    eax
    9. .text:00402014                 call    ds:GetProcAddress
    10. .text:0040201A                 mov     dword_401037, eax
    11. .text:0040201F                 pop     eax
    12. .text:00402020                 push    offset aScanf   ; "scanf"
    13. .text:00402025                 push    eax
    14. .text:00402026                 call    ds:GetProcAddress
    15. .text:0040202C                 mov     dword_40103B, eax
    16. .text:00402031                 pop     eax
    17. .text:00402032                 push    offset aSin     ; "sin"
    18. .text:00402037                 push    eax
    19. .text:00402038                 call    ds:GetProcAddress
    20. .text:0040203E                 mov     dword_40103F, eax
    21. .text:00402043                 push    offset aCos     ; "cos"
    22. .text:00402048                 push    eax
    23. .text:00402049                 call    ds:GetProcAddress
    24. .text:0040204F                 mov     dword_401043, eax
    25. .text:00402054                 push    offset aInputN  ; "Input N:"
    26. .text:00402059                 call    dword_401037
    27. .text:0040205F                 add     esp, 4
    28. .text:00402062                 push    offset dword_401000
    29. .text:00402067                 push    offset byte_401004
    30. .text:0040206C                 call    dword_40103B
    31. .text:00402072                 add     esp, 8
    32. .text:00402075                 push    offset dword_401000
    33. .text:0040207A                 call    dword_40103F
    34. .text:00402080                 add     esp, 4
    35. .text:00402083                 mov     dword_401067, eax
    36. .text:00402088                 push    offset dword_401000
    37. .text:0040208D                 call    dword_401043
    38. .text:00402093                 add     esp, 4
    39. .text:00402096                 mov     dword_40106B, eax
    40. .text:0040209B                 push    dword_40106B
    41. .text:004020A1                 push    dword_401000
    42. .text:004020A7                 push    dword_401067
    43. .text:004020AD                 push    dword_401000
    44. .text:004020B3                 push    offset aSinusOfDIsDCos ; "Sinus of %d is %d, cosinus of %d is %d"
    45. .text:004020B8                 call    dword_401037
    46. .text:004020BE                 add     esp, 14h
    47. .text:004020C1                 push    0
    48. .text:004020C3                 call    ds:ExitProcess
     
  2. IceStudent

    IceStudent Active Member

    Публикаций:
    0
    Регистрация:
    2 окт 2003
    Сообщения:
    4.300
    Адрес:
    Ukraine
    Вся беда отсюда:
    А если серьёзно — посмотри, как это делает компилятор сей:
    Код (Text):
    1. proc get_sin arg
    2.    
    3.     fild    dword[arg]
    4.     fstp    [bufq]
    5.     cinvoke sin,dword[bufq],dword[bufq+4]
    6.     fstp    dword[arg]
    7.     mov     eax,[arg]
    8.     ret
    9. endp
    10.  
    11. bufq dq ?
     
  3. Adrax

    Adrax Алексей

    Публикаций:
    0
    Регистрация:
    14 окт 2006
    Сообщения:
    135
    Адрес:
    г. Курск
    Отказался от идеи сей...
    Поглядел в дизасм скомпиленного сишного кода - всё понял..