本文參考《orange's 一個操作系統(tǒng)的實現(xiàn)一書》。
操作環(huán)境:
macbook pro
準備:
- virtualbox虛擬機軟件下載。下載地址:https://www.virtualbox.org/。
- 第一個操作系統(tǒng)代碼:
? cat first.asm
org 07c00h
mov ax, cs
mov ds, ax
mov es, ax
call DispStr
jmp $
DispStr:
mov ax, BootMessage
mov bp, ax
mov cx, 16
mov ax, 01301h
mov bx, 000ch
mov dl, 0
int 10h
ret
BootMessage: db "hello, OS world"
times 510-($-$$) db 0
dw 0xaa55
- asm編譯軟件:
nasm。 - 編譯asm為img。
nasm first.asm -o boot.img
步驟:
-
virtualbox新建虛擬機,類型other,版本other/unknown。
image.png -
內(nèi)存選擇64MB。
image.png -
不添加虛擬硬盤。
image.png -
設置虛擬機存儲,刪除IDE,添加軟盤控制器。
image.png
選擇注冊,選中我們編譯好的boot.img文件。
image.png
image.png -
啟動虛擬機,即可看見打印的
hello, OS world。
image.png






