nasm: error: more than one input file specified

Asked

Viewed 207 times

2

I am trying to compile a nasm file but it is returning the following error: " nasm: error: more than one input file specified ". What is the error? boot.asm:

BITS 16 ; The mode we are running in (default for every modern computer)
ORG 0x7c00 ; the origin, the boot loader is always loaded at 7C00 by the BIOS
jmp Main ; Jump the a label called "Main"


;IN: si=string, OUT:-
Print:
lodsb ; Load string byte (Load a character that's in si into al)
cmp al, 0 ; If that character is equal to "0" jump to done
je Done

mov ah, 0eh ; Set parameters for interrupt 10
int 10h ; Call the interrupt
jmp Print ; Loop back in Print to print the next character

Done: 
ret ; return back to the place we where called

Main:
mov si, msg ; Move the data of msg into si
call Print ; Call the Print label
cli 
hlt ; Halt the system

msg db 'Hello World!',0 ; Define the variable msg to a string

times 510 - ($-$$) db 0 ; make sure the file is 512 bytes

dw 0xAA55 ; Last 2 bytes need to be AA55

I am using the following command to compile:

nasm -f boot.asm -a boot.bin
  • 1

    How’s the makefile? what syntax you use to compile?

  • 1

    I haven’t created Makefile yet, I don’t think I need to. I used the following syntax: nasm -f boot.asm -a boot.bin

  • The syntax is wrong, the -f indicates which format you want to use, for example bin (to see valid formats type: nasm -hf).

  • Could you pass me the full syntax?

  • Try it like this: nasm boot.asm -o boot.bin -f bin.

  • It worked! Comment for me to give reputation and solved.

Show 1 more comment

1 answer

2


The syntax that is used to compile is incorrect, the option -f is used to specify the output format of the file, while the option -a is used to suppress preprocessing and assume that the compiler has already done this, in this case this option is also not necessary.

To compile for binary you can do (binary is the format pattern):

nasm boot.asm -o boot.bin

To know which formats are available use the option -hf.

More information: Chapter 2: Running NASM

Browser other questions tagged

You are not signed in. Login or sign up in order to post.