0

I have a problem in my bootloader file.

The problem is when I attempt to compile my bootloader.asm with Nasm.

Here 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 'Bootloader for LunarOS 0.1' , 0

times 510 - ($ - $$) db 0 
dw 0xAA55

The problem is

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

Thank you in advance for any help, it is all appreciated

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
Kawjah
  • 1
  • 1
  • 1
    Aren't you missing a trailing ':' after `PrintString` – Cyclonecode May 15 '16 at 01:46
  • @Cyclone that was a problem, but it didn't fix my main problem :\ – Kawjah May 15 '16 at 01:47
  • @Cyclone Thanks, It brought up 3 more problems but I managed to fix them :P sorry for the question, im a beginner :) – Kawjah May 15 '16 at 01:51
  • 2
    @Cyclone and Kawjah do **NOT** change `:DATA` to `SECTION .DATA.` Remove `:DATA` altogether. If writing a bootloader with NASM using `-f bin` place the data in with the code (before the boot signature as is already done). If you place `SECTION .DATA` where `:DATA` is then `times 510 - ($ - $$) db 0` will compute the wrong number of bytes to pad, and the boot signature will be placed beyond bytes 511 and 512 of the file. That will generate a bootlaoder > 512 bytes with a boot signature in wrong place making it unusable by most BIOSes. Simply remove `:DATA` . – Michael Petch May 15 '16 at 02:36
  • 1
    I have some general bootload tips in the [Stackoverflow Answer](http://stackoverflow.com/a/32705076/3857942). One in particular you may wish to add to your program at the top is the explicit zeroing of the _DS_ register since you are using `[org 0x7c00]`. That can be done as the first lines of your bootloader with these instructions `xor ax, ax` `mov ds, ax` – Michael Petch May 15 '16 at 02:46

0 Answers0