所以我试图使用NASM汇编程序运行下面的程序。由于我想告诉汇编程序我想要一个没有任何铃声或口哨声的纯二进制文件,所以我使用了:
nasm-f-o boot.bin boot.asm错误:nasm致命:无法打开输入文件'boot.bin'
请某人帮忙。我为什么会出现这个错误,以及如何解决它。
这是代码:
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
您使用NASM中的-f bin
选项指定BINary。你想要的是:
nasm -f bin -o boot.bin boot.asm
如果你不指定-f
,默认值是二进制的,所以这也会起作用:
nasm -o boot.bin boot.asm