【发布时间】:2011-09-22 14:40:42
【问题描述】:
x86 汇编编程初学者。我有一个简单的 asm 文件,我使用 nasm 版本组装 - NASM 版本 2.10rc6 于 2011 年 6 月 6 日编译,用于 windows(我的 windows 是 Windowa-7 64 位)。 NASM 是从here (nasm-2.10rc6-win32.zip) 下载的。
ORG 100
USE16
mov ah, 09
mov dx, msg
int 21h
mov ah, 01
int 21h
mov ah, 4ch
int 21h
msg db 'Hello assembly', 0Ah, '$'
然后我使用命令组装 -
nasm -f bin hello.asm -o hello.com
然后我使用 Dosbox(用于 64 位操作系统 Windows-7 的 Dos 模拟器)运行生成的可执行文件 hello.com。 当它运行时,控制台上的输出输出有我的字符串'Hello assembly'加上一些垃圾字符/控制字符在它之前打印,如下所示:
这是什么原因。代码有什么问题吗?
我需要做什么来解决这个问题?
编辑:当我尝试为 nasm 提供选项 -f 以生成特定类型的可执行输出时,例如Win32 或 Win64 输出我不断收到错误提示:
nasm -f win64 hello.asm -o hello.com
hello.asm:1: error: parser: instruction expected
它在期待什么?如何使用 nasm 生成 win32/win64 可执行文件?或者就此而言,nasm 表示它支持的任何其他可执行文件(如 elf32/coff)?
【问题讨论】: