Assembly 如何在Virtualbox中启动我的操作系统?
这是我的密码:Assembly 如何在Virtualbox中启动我的操作系统?,assembly,x86,nasm,osdev,Assembly,X86,Nasm,Osdev,这是我的密码: section .text ;section declaration ;we must export the entry point to the ELF linker or global _start ;loader. They conventionally recognize _start as their
section .text ;section declaration
;we must export the entry point to the ELF linker or
global _start ;loader. They conventionally recognize _start as their
;entry point. Use ld -e foo to override the default.
_start:
;write our string to stdout
mov edx,len ;third argument: message length
mov ecx,msg ;second argument: pointer to message to write
mov ebx,1 ;first argument: file handle (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
;and exit
mov ebx,0 ;first syscall argument: exit code
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data ;section declaration
msg db "Hello, world!",0xa ;our dear string
len equ $ - msg ;length of our dear string
这是NASM的hello world代码
然后,我尝试用nasm编译它
nasm hello.nasm -o hello.bin
然后,我尝试将其转换为iso文件
mkisofs -o hello.iso hello.bin
最后,我在VirtualBox上用CD Iso文件hello.Iso创建了一个新的虚拟机,但是。。。机器不显示我的操作系统
为什么?
我有:
FATAL:找不到可引导媒体。系统暂停。
您的代码只是Netwide程序集中的一个简单的你好,World
如果你想创建一个引导扇区,你必须写一些东西
如果你想创建一个ISO映像,请参考这个(很棒) 您正在使用
Linux程序集
。您可以理解,操作系统需要特殊的基本编程(x86
)。看看有没有什么帮助
另外,我建议您从软盘开始。CD-ROM对初学者来说很难
这里有一些东西可以让你开始
BITS 16
org 0x7C00
; This is a comment
mov ah, 0eh ; Function<br>
mov al, 'A' ; Prints the letter A<br>
int 10h
times 510-($-$$) db 0<br>
dw 0xAA55
然后,为
Virtualbox
选择软盘控制器并启动虚拟机。您将看到一个A
。编写操作系统需要BIOS中断。这只是开始。您可能需要启动签名(dw 0xaa55
)。您需要为16位实模式编写代码,因为MBR的引导序列以这种方式启动您的代码(我假设您使用的是传统BIOS,但EFI的情况不同)int 0x80
是一个Linux系统调用,在启动时不可用。
nasm -f bin boot.asm -o boot.img