简体   繁体   English

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

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

Hello I am very new to assembly(just started today) and ran into this problem when doing exactly what is said in this tutorial . 您好,我是汇编语言的新手(今天才刚刚开始),在执行本教程中所说的内容时遇到了这个问题。 I made an asm file with this text: 我用以下文本制作了一个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

and in my folder with the asm file I have a copy of nasm and nasmpath, I also have a shortcut to bochs. 在带有asm文件的文件夹中,我有nasm和nasmpath的副本,我也有boch的快捷方式。 what I am trying to do is convert it into a bin file. 我正在尝试将其转换为bin文件。 when I put this command: 当我输入以下命令时:

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

I get this error 我得到这个错误

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

I am wondering if this is a bad tutorial or am I typing something wrong. 我想知道这是一个不好的教程还是我输入的错误。 also I would like to know what it means by "label or instruction". 我也想知道“标签或说明”的含义。

You also should put colon after Main and cls 您还应该在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     

You use a comment in line 5. To mark a line as comment you need a semicolon. 您在第5行中使用注释。要将行标记为注释,您需要使用分号。 "label or instruction" means, that each line have to be an instruction(an opcode like mov,add,...) or it have to be a label(like Print:) or a label followed by an instruction. “标签或指令”是指每行必须是一条指令(如mov,add,...等操作码),也必须是标签(如Print :)或后跟指令的标签。

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

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