直接上源代碼了。
org 0x7c00
start:
mov ax, cs ;; 實模式 cs 爲 零
mov ss, ax ;;
mov ds, ax
mov es, ax
mov si, msg ;; 指到字符串位置
print:
mov al, [si]
add si, 1 ;;
cmp al, 0x00
je last
mov ah, 0x0e
mov bx, 0x0f
int 0x10
jmp print
last:
hlt ;;
jmp last
msg:
db 0x0a, 0x0a ;; 換行
db "Simple OS."
db 0x0a, 0x0a ;;
times 510-($-$$) db 0x00 ;; 填零操作
db 0x5, 0xaa ;; 引導程序結束符
;; 編譯 boot.asm
;; nasm boot.asm -o boot.bin
;; 製作虛擬軟盤
;; bximage a.img -q -fd -size=1.44
;; boot.bin 寫入虛擬軟盤
;; dd if=boot.bin of=a.img bs=512 count=1 conv=notrunc
;; vm 創建虛擬機,設置 虛擬軟盤文件爲 a.img 即可