"Hello, world" in VC

Тема в разделе "WASM.BEGINNERS", создана пользователем Raman, 22 май 2010.

  1. Raman

    Raman New Member

    Публикаций:
    0
    Регистрация:
    16 ноя 2009
    Сообщения:
    6
    Пытаюсь писать в Visual Studio 2008. В проекте из main вызывает asm-функция clear:

    Код (Text):
    1. .586              ;Target processor.  Use instructions for Pentium class machines
    2. .MODEL FLAT, C    ;Use the flat memory model. Use C calling conventions
    3. .STACK            ;Define a stack segment of 1KB (Not required for this example)
    4. .DATA             ;Create a near data segment.  Local variables are declared after
    5.                   ;this directive (Not required for this example)
    6. .CODE             ;Indicates the start of a code segment.
    7. clear PROC
    8.    xor eax, eax
    9.    xor ebx, ebx
    10.    ret
    11. clear ENDP
    12. END
    помогите, пожалуйста, добавить в этот код вывод строки ("hello, world"). Желательно, используя вызов функцию printf стандартной библиотека stdio.h. Заранее благодарен.
     
  2. Raman

    Raman New Member

    Публикаций:
    0
    Регистрация:
    16 ноя 2009
    Сообщения:
    6
    Всем спасибо за внимание, извините, что побеспокоил))) оказалось всё просто))))

    Код (Text):
    1. .586              ;Target processor.  Use instructions for Pentium class machines
    2. .MODEL FLAT, C    ;Use the flat memory model. Use C calling conventions
    3. .STACK            ;Define a stack segment of 1KB (Not required for this example)
    4. .DATA             ;Create a near data segment.  Local variables are declared after
    5.                   ;this directive (Not required for this example)
    6.     msg db "hello, world!"
    7. .CODE             ;Indicates the start of a code segment.
    8.   EXTERN printf:near
    9. clear PROC
    10.    xor eax, eax
    11.    xor ebx, ebx
    12.    push offset msg
    13.    call printf
    14.    pop eax
    15.    ret
    16. clear ENDP
    17. END
     
  3. ohne

    ohne New Member

    Публикаций:
    0
    Регистрация:
    28 фев 2009
    Сообщения:
    431
    Код (Text):
    1.    push offset msg
    2.    call printf
    3.    pop eax
    http://en.wikipedia.org/wiki/X86_calling_conventions#cdecl