assembly - 使用 nasm 汇编程序可以正常打印的引导加载程序
问题描述
所以我试图使用 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 中的选项指定BIN ary 。-f bin
你想要的是:
nasm -f bin -o boot.bin boot.asm
如果您未指定,则默认值为二进制,-f
因此这也可以:
nasm -o boot.bin boot.asm
推荐阅读
- mysql - 如何在mysql中使用csv文件上传印地语数据
- camunda - Camunda:在没有租户特定 bpm 的情况下使用 callActivity
- android - 在驾驶模式下更新谷歌地图上的方向路径
- linux - 在 Linux 上安装 Node 版本
- java - Maven:运行测试时不会拾取配置文件属性
- mapbox - 在最新的 MapBox SDK 6.7 中旋转和更改标记的位置
- jquery - jQuery 'blur' 事件不适用于文件字段
- php - 在while循环中插入数据库的PHP问题
- reactjs - 无法下载反应网页
- c++ - 带有嵌套多态模板的 c++ 动态转换