繁体   English   中英

nasm-错误:应在行首输入标签或指令

[英]nasm - error: label or instruction expected at the start of line

您好,我是汇编语言的新手(今天才刚刚开始),在执行本教程中所说的内容时遇到了这个问题。 我用以下文本制作了一个asm文件:

bits    16
org     0x7c00
jmp     Main

:In=  si = string, ah = 0eh, al = char, Out= character screen
Print:
lodsb
cmp     al, 0
je      Done
mov     ah, 0eh
int     10h
jmp     Print

Done:
ret

Main
mov     si, msg
call Print

cls
hlt

msg     db  "Hello World",0

times 510 - ($-$$)      db      0

dw      0xAA55

在带有asm文件的文件夹中,我有nasm和nasmpath的副本,我也有boch的快捷方式。 我正在尝试将其转换为bin文件。 当我输入以下命令时:

nasm -f bin boot.asm -o boot.bin

我得到这个错误

boot.asm:5: error: label or instruction expected at the start of line

我想知道这是一个不好的教程还是我输入的错误。 我也想知道“标签或说明”的含义。

您还应该在Main和cl之后加上冒号

bits    16
org     0x7c00
jmp     Main

;In=  si = string, ah = 0eh, al = char, Out= character screen
Print:
lodsb
cmp     al, 0
je      Done
mov     ah, 0eh
int     10h
jmp     Print

Done:
ret

Main:
mov     si, msg
call Print

cls:
hlt

msg     db  "Hello World",0

times 510 - ($-$$)      db      0

dw      0xAA55     

您在第5行中使用注释。要将行标记为注释,您需要使用分号。 “标签或指令”是指每行必须是一条指令(如mov,add,...等操作码),也必须是标签(如Print :)或后跟指令的标签。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM