我想用 NASM 汇编语言编程。我有 NASM 2.07 和 Borland C++ 编译器 5.0 (bcc32)。我的操作系统是 Windows 7。我不知道如何在 Windows 平台上使用 NASM 进行输入和输出。请问你能帮我吗?
1294 次
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 回答