Kasra Ghassemi
Kasra Ghassemi

Reputation: 36

NASM compiler error while making bootloader

I am making a bootloader in assembly, and i got a compiler error while compiling my file in NASM. the output is:

bootloader.asm:1: error: label or instruction expected at start of line
bootloader.asm:16: warning: label alone on a line without a colon might be in error [-w+orphan-labels]
bootloader.asm:23: warning: label alone on a line without a colon might be in error [-w+orphan-labels]

can anybody help? this is my code:

[BITS 16]
[ORG 0x7C00]

MOV SI, BOOTLOADERSTR
CALL PrintString
JMP $

PrintCharacter:
MOV AH, 0x0E
MOV BH, 0x00
MOV BL, 0x07

INT 0x10
RET

PrintString
next_character:
MOV AL, [SI]
INC SI
OR AL, AL
JZ exit_function
CALL PrintCharacter
exit_function
RET

;DATA
BOOTLOADERSTR db 'it-is-OK Bootloader for OpenKasrix' , 0

TIMES 510 - ($ - $$) db 0
DW 0xAA55

Upvotes: 0

Views: 557

Answers (1)

zx485
zx485

Reputation: 29022

bootloader.asm:1: error: label or instruction expected at start of line

I cannot reproduce this first error with NASM version 2.11.08, so there must be another problem like a BOM (Byte-Order-Mark). So check if the first bytes do match one of the sequences mentioned in this article - and if so, remove them (with a Hex-Editor or Saving-Options or ...). Then this otherwise unrecognizable error should magically disappear.

The next two errors are missing a : at the end of your labels

PrintString      ; line 16
exit_function    ; line 23

Add a colon at the end and the errors will disappear. So they should look like

PrintString:     ; line 16
exit_function:   ; line 23

Upvotes: 1

Related Questions