2

NASM アセンブリ言語でプログラミングしたい。NASM 2.07 と Borland C++ コンパイラ 5.0 (bcc32) を使用しています。私の OS は Windows 7 です。Windows プラットフォームで NASM を使用して入出力を行う方法がわかりません。助けてくれますか?

4

2 に答える 2

2

The easiest way is to call the Win32 functions, accessible by linking the kernel32 libs (IIRC).

于 2010-02-24T16:27:40.247 に答える
0

「C」関数「printf」および「scanf」を使用できます。そのためには、「extern」として宣言する必要があります。簡単な例があります:

section .data
    input_string   db 0
    format         db "%s", 0
    output_string1 db "type something", 10, 0 ; "type something\n"
    output_string2 db "you wrote: %s", 0

extern _printf
extern _scanf

section .text
global _main
_main:                  ; int main()

    push output_string1 ;
    call _printf        ; printf(string1);
    add  esp, 4         ;

    push output_string1 ;
    push format         ;
    call _scanf         ; scanf(format, string1);
    add  esp, 8         ;


    push input_string   ;
    push output_string2 ;
    call _printf        ; printf(output_string2, input_string);
    add  esp, 8         ;

    xor  eax, eax       ; return 0;
    ret                 ;
于 2014-11-20T17:46:39.607 に答える