gpt4 book ai didi

assembly - 在VirtualBox上运行操作系统

转载 作者:行者123 更新时间:2023-12-04 17:11:34 24 4
gpt4 key购买 nike

我在Windows 7上使用VirtualBox 4.1.14,并且试图使其在我的测试操作系统上运行。我正在使用下面的汇编代码,并使用

nasm -f bin -o boot.bin boot.asm

我试图将生成的bin文件转换为VB4.1.14可以使用的ISO(我不想付钱或试用程序没有限制)。我曾尝试下载不同的转换器(如bin2iso),但是每当我尝试在其中打开生成的ISO(如VERR_NOT_SUPPORTED等)时,VB都会出现不同的错误。

我希望该解决方案成为命令行工具,因此我可以在批处理脚本中使用它来加快测试速度。

BITS 16

start:
mov ax, 07C0h ; Set up 4K stack space after this bootloader
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096

mov ax, 07C0h ; Set data segment to where we're loaded
mov ds, ax


mov si, text_string ; Put string position into SI
call print_string ; Call our string-printing routine

jmp $ ; Jump here - infinite loop!


text_string db 'This is my cool new OS!', 0


print_string: ; Routine: output string in SI to screen
mov ah, 0Eh ; int 10h 'print char' function

.repeat:
lodsb ; Get character from string
cmp al, 0
je .done ; If char is zero, end of string
int 10h ; Otherwise, print it
jmp .repeat

.done:
ret


times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
dw 0xAA55 ; The standard PC boot signature

最佳答案

您可以使用dd(对于Windows搜索dd)来创建用于启动器的软盘。二进制文件仅写入1440 kib文件的前256个字节。

dd if=/dev/zero of=floppy.img ibs=1k count=1440
dd if=boot.img of=floppy.img conv=notrunc

现在我们开始:

关于assembly - 在VirtualBox上运行操作系统,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10571771/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com