Windows 7 中 NASM 程序中的 I/O
我想用 NASM 汇编语言进行编程。我有 NASM 2.07 和 Borland C++ 编译器 5.0 (bcc32)。我的操作系统是Windows 7。我不知道如何在Windows平台上使用NASM进行输入和输出。请问你能帮我吗?
I want to program in NASM assembly language. I have NASM 2.07 and Borland C++ compiler 5.0 (bcc32). My OS is Windows 7. I do not know how to do input and output with NASM in Windows platform. Please can you help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
向地狱狂奔2024-08-29 09:12:55
您可以使用“C”函数“printf”和“scanf”。
为此,您需要将其声明为“外部”。
有一个简单的例子:
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 ;
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
最简单的方法是调用 Win32 函数,可以通过链接 kernel32 库 (IIRC) 来访问。
The easiest way is to call the Win32 functions, accessible by linking the kernel32 libs (IIRC).