Author Topic: asm:3: error: label or instruction expected at start of line. How to correct?  (Read 14531 times)

Offline gdawg

  • Jr. Member
  • *
  • Posts: 2
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



Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Easy one! "-start:" should be "_start:". You've probably already figured that out. Next question? :)

Best,
Frank


Offline gdawg

  • Jr. Member
  • *
  • Posts: 2
Thank you very much Frank Kotler. I totally missed that.