NASM - The Netwide Assembler

NASM Forum => Programming with NASM => Topic started by: gdawg on February 24, 2012, 08:27:51 PM

Title: asm:3: error: label or instruction expected at start of line. How to correct?
Post by: gdawg on February 24, 2012, 08:27:51 PM
Hi - I'm new to asm programming and I get the subject error while trying to run the following program:
Code: [Select]
section .text                           ;Executable code hhere.
        global_start                    ;For the linker (ld).
-start:                                 ;Where execution begins.
        mov eax, 4                      ;Kernel call no.: write.
        mov ebx, 1                      ;Where to write: stdout.
        mov ecx, message                ;Location of string.   
        mov edx, message_length         ;No. of chars to write.
        int 0x80                        ;Call the kernel!

mov eax, 1                              ;Kernel call no.: exit.
        int 0x80                        ;Call the kernel!

section .data
        message db "Assembly rules!", 10
        message_length equ $ - message

I get error message after entering: nasm -f elf32 -o myfirst.o myfirst.asm
myfirst.asm:3: error: label or instruction expected at start of line

Any help will be appreciated.

jane@gdawg-Inspiron-530s ~ $ uname -a
Linux gdawg-Inspiron-530s 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux


Title: Re: asm:3: error: label or instruction expected at start of line. How to correct
Post by: Frank Kotler on February 24, 2012, 09:56:53 PM
Easy one! "-start:" should be "_start:". You've probably already figured that out. Next question? :)

Best,
Frank

Title: Re: asm:3: error: label or instruction expected at start of line. How to correct?
Post by: gdawg on February 25, 2012, 12:08:19 AM
Thank you very much Frank Kotler. I totally missed that.