Reputation: 1
So I was trying to run the program below using NASM assembler. Since I wanted to tell the assembler that I wanted a plain binary file without any bells nor whistles, I used:
nasm -f -o boot.bin boot.asm Error: nasm fatal: unable to open input file 'boot.bin'
someone to please help out.Why did I get this error and how to solve it.
here is the code:
bits 16
start:
mov ax, 0x07C0 ;0x07C0 is where we are
add ax, 0x20 ;add 0x20 (when shifted 512)
mov ss,ax ;set the stack segment
mov sp, 0x1000 ; set the stack pointer
mov ax, 0x07C0 ; set data segment
mov ds, ax ;more about this later
mov si, msg ;pointer to the message in SI
mov ah, 0x0E ;print CHAR BIOS procedure
.next:
lodsb ;next byte to AL, increment SI
cmp al, 0 ;if the byte is zero
je .done ;jump do done
int 0x10 ;invoke the BIOS system call
jmp .next ;loop
.done:
jmp $ ;loop forever
msg: db 'ok',0 ;The string we want to print
times 510-($-$$) db 0 ;fill up to 510 bytes
dw 0xAA55 ;master boot record signature
Upvotes: 1
Views: 344
Reputation: 47573
You specify BINary with the -f bin
option in NASM. What you wanted was:
nasm -f bin -o boot.bin boot.asm
The default is binary if you don't specify -f
so this would have worked as well:
nasm -o boot.bin boot.asm
Upvotes: 2