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

pokeyOne picture pokeyOne · Jun 16, 2014 · Viewed 12k times · Source

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:

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. what I am trying to do is convert it into a bin file. 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".

Answer

nimday picture nimday · Jun 17, 2014

You also should put colon after Main and cls

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