在32位Windows上使用NASM在程序集中创建exe文件
发布时间:2020-12-14 02:54:57 所属栏目:Windows 来源:网络整理
导读:我正在使用32位 Windows 7上的NASM以汇编语言编写一个hello world程序.我的代码是: section .text global main ;must be declared for linker (ld) main: ;tells linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1
我正在使用32位
Windows 7上的NASM以汇编语言编写一个hello world程序.我的代码是:
section .text global main ;must be declared for linker (ld) main: ;tells linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello,world!',0xa ;our dear string len equ $- msg ;length of our dear string 我把这个程序保存为hello.asm.接下来,我创建了hello.o: nasm -f elf hello.asm 现在我正在尝试使用此命令创建exe文件: ld -s -o hello hello.o 但是现在我收到了这个错误:
为什么我会收到此错误,我该如何解决? 解决方法
下载并安装Mingw.然后把nasm放在Mingw bin文件夹中.
在名为Hello的bin文件夹中创建一个文件夹.在这个文件夹中 使用以下代码创建名为main.asm的文件: extern _printf global _main section .data msg: db "Hello,world!",10,0 section .text _main: push msg call _printf add esp,4 ret 从文件夹里面打开终端并编译, D:MinGWbinHello> ..nasm -fwin32 main.asm 二,调用gcc链接: D:MinGWbinHello> ..gcc main.obj -o main.exe 最后,测试一下: D:MinGWbinHello> main.exe Hello,world! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Windows Azure应用程序所需的实例数
- windows-server-2008-r2 – 我无法在Windows Server 2008 R
- 数据绑定 – Windows应用商店应用中条件样式(或Style.Trigg
- active-directory – 使用AD主目录属性来映射主驱动器真的不
- Win10,Python 3.6环境下安装PyQt4
- windows – 使用批处理文件检查服务器是否启动?
- Windows Phone模拟器错误,Hyper-V组件未运行,Windows Azure
- windows-update – 批量Windows更新服务器
- windows-xp – 在Windows XP中自动安装软件
- MVVM Windows Phone 8 – 向地图添加图钉集合
推荐文章
站长推荐
热点阅读