Anatoly  Goryachev
Anatoly Goryachev

Reputation: 11

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:

org 0x100 
start:
mov bx, [a]
mov ax, [val]
mov cx, 8
sub sp, 8
call search
ret

search:
mov di, sp
go:
    cmp [bx], ax
    jz detected
    continue:
        add bx, 2
        dec cx
        jnz go
        ret
detected:
    add di, 2
    shl word[bx], 2
    mov dx, [bx]
    mov [di], dx
    jmp continue



a dw 1, 2, 1, 4, 1, 6, 7 , 8
val dw 1

I get this error

laber.asm:1: 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".

Upvotes: 0

Views: 4071

Answers (2)

Jesse Spears
Jesse Spears

Reputation: 136

You need to insert

section .text

at the top of your file.

Upvotes: 0

Jester
Jester

Reputation: 58802

You forgot to show the command you used to assemble, and what OS you are on, and what output format you want. Due to the org 0x100 I assume you want a DOS .com file. Now, your nasm might not default to that format, so you should try something like nasm -f bin -o laber.com laber.asm.

The error label or instruction expected isn't a terribly good message, and basically means nasm didn't recognize the org and tells you to use a label (something followed by a colon) or an instruction (I hope you know what those are ;)). Of course you could also use other things, such as a valid directive, but nasm doesn't tell you that.

Upvotes: 0

Related Questions