I have this makefile:
我有这个Makefile:
ASM = nasm
.PHONY: floppyimage kernel bootloader everything
goldos: everything
qemu-system-i386 -fda build/goldos.img
norun: everything
everything: floppyimage kernel bootloader build
floppyimage: build/goldos.img
build/goldos.img: build bootloader kernel
dd if=/dev/zero of=build/goldos.img bs=512 count=2880
mkfs.fat -F 12 -n "GOLDOS" build/goldos.img
dd if=build/bootloader.bin of=build/goldos.img conv=notrunc
mcopy -i build/goldos.img build/kernel.bin "::kernel.bin"
bootloader: build/bootloader.bin
build/bootloader.bin: build bootloader/bootloader.asm
$(ASM) bootloader/bootloader.asm -fbin -obuild/bootloader.bin
kernel: build/kernel.bin
build/kernel.bin: build kernel/kernel.asm
$(ASM) kernel/kernel.asm -fbin -obuild/kernel.bin
clean:
rm -r build
build:
mkdir -p build
For some stupid reason, it started saying:
出于某种愚蠢的原因,它开始说:
dd if=/dev/zero of=build/goldos.img bs=512 count=2880
2880+0 records in
2880+0 records out
1474560 bytes (1.5 MB, 1.4 MiB) copied, 0.00605087 s, 244 MB/s
mkfs.fat -F 12 -n "GOLDOS" build/goldos.img
mkfs.fat 4.2 (2021-01-31)
dd if=build/bootloader.bin of=build/goldos.img conv=notrunc
1+0 records in
1+0 records out
512 bytes copied, 5.852e-05 s, 8.7 MB/s
mcopy -i build/goldos.img build/kernel.bin "::kernel.bin"
init :: non DOS media (here, the parentesis are not part of the output)
Cannot initialize '::'
::kernel.bin: Success
make: *** [makefile:18: build/goldos.img] Error 1
bootloader.asm (on github due to over 300 lines)
i cannot run this anymore, couldn't find any info online, kernel.asm has nothing,
mcopy started acting out when I added something to that file, but i removed it.
Already tried deleting the output files, but same error.
已尝试删除输出文件,但出现相同错误。
更多回答
Show bootloader.asm source.
显示bootloader.asm源代码。
Replace jmp setup
by jmp strict short setup
followed by nop
将JMP设置替换为JMP Strong Short Setup,然后是NOP
Because there are 3 bytes that are needed before the data in the BPB. Your current jump is 2 bytes long, the nop
is a 3rd byte to ensure the BPB is in the right place. Adding the nop
shouldn't change the size of your bootloader.
因为在BPB中的数据之前需要3个字节。您当前的跳转长度为2个字节,NOP为3个字节,以确保BPB位于正确的位置。添加NOP不应该改变引导加载程序的大小。
The BPB contents must start at offset 11, and the OEM ID at offset 3. Otherwise the superblock structure doesn't match what everyone else expects. If you have no space for this single added byte you will have to re-order or optimise something. For instance, replace mov ax, 0
by xor ax, ax
. And mov si, ferror_kernel_jump_failed
is never reached so you can just drop this part.
BPB内容必须从偏移量11开始,OEM ID必须从偏移量3开始。否则,超级块结构与其他所有人的预期不符。如果没有空间容纳这个单独添加的字节,您将不得不重新排序或优化某些内容。例如,将mov ax,0替换为xor ax,ax。而mov si,FERROR_KERRINE_JUMP_FAILED永远不会到达,因此您可以直接删除此部分。
When you do int 13h
in disk_read
you do a pusha
to save all the registers before int 13h
and if there is no disk error you don't do a corresponding popa
. Your popa
should be done right after int 13h
not further down before the call disk_reset
. As a result if the disk read was successful the stack is unbalanced when the ret
is done and it goes off into memory executing memory you didn't intend.
当您在DISK_READ中执行int13h时,您在int13h之前执行了一次Pusha以保存所有寄存器,如果没有磁盘错误,则不会执行相应的POPA。您的POPA应该在int 13小时之后完成,而不是在调用DISK_RESET之前再往下。因此,如果磁盘读取成功,则当ret完成时,堆栈就会不平衡,它会进入内存,执行您不想要的内存。
Replaced jmp start
to jmp strict short start
and added nop
after that.
the BIOS expects 3 bytes before the header, and those operations are 3 bytes.
I was able to get more space by adding a call to talk
inside the fatal_reboot
, label, since every reference ran talk before fatal_reboot
.
Thanks @ecm.
将JMP启动替换为JMP严格短启动,并在此之后添加了NOP。BIOS期望在报头之前有3个字节,而这些操作是3个字节。我可以通过在FATAL_REBOOT,标签中添加一个调用Talk来获得更多空间,因为每个引用都在FATAL_REBOOT之前运行Talk。谢谢@ECM。
更多回答
我是一名优秀的程序员,十分优秀!