NASM 中的命令行优化级别
我编写了一个汇编代码来使用字节变量添加十个数字,并且代码没有错误。
汇编代码:
; a program to add ten numbers using byte variables
[org 0x0100]
jmp start
num1: dw 10, 20, 30, 40, 50, 10, 20, 30, 40, 50
result: dw 0
start:
; initialize stuff
mov ax, 0 ; reset the accumulator
mov bx, 0 ; set the counter
outerloop:
add ax, [num1 + bx]
add bx, 2
cmp bx, 20 ; sets ZF=1 when they are equal,
;un set ZF=0, if they are not equal
jne outerloop
mov [result], ax
mov ax, 0x4c00
int 0x21
在 NASM 中汇编此代码时遇到此错误。
I have written an assembly code to add ten numbers using byte variables, and code is error free.
Assembly code:
; a program to add ten numbers using byte variables
[org 0x0100]
jmp start
num1: dw 10, 20, 30, 40, 50, 10, 20, 30, 40, 50
result: dw 0
start:
; initialize stuff
mov ax, 0 ; reset the accumulator
mov bx, 0 ; set the counter
outerloop:
add ax, [num1 + bx]
add bx, 2
cmp bx, 20 ; sets ZF=1 when they are equal,
;un set ZF=0, if they are not equal
jne outerloop
mov [result], ax
mov ax, 0x4c00
int 0x21
While assembling this code in NASM facing this error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NASM 的命令行选项区分大小写。看来您想使用
-o
选项(小写o
)指定输出文件名,以便-o C02-06.COM
将输出写入名为的文件C02-06.COM
。相反,您使用了 大写-O
< /a>,它请求优化并且(对于您的版本)需要一个额外的标志,如消息所述。因此,将命令更改为
-o C02-06.COM
,它应该可以工作。NASM's command line options are case sensitive. It looks like you wanted to use the
-o
option (lower caseo
) to specify the output file name, so that-o C02-06.COM
would write the output to a file namedC02-06.COM
. Instead you used upper-case-O
, which requests optimization and (with your version) requires an additional flag, as the message says.So change your command to
-o C02-06.COM
and it should work.