至少在他/她的生活中至少有一次程序員,我正在嘗試創建我的「革命性」,即新的,唯一的操作系統。 :DAssembly - 讀取虛擬磁盤的下一個扇區
那麼,我正在使用一個虛擬仿真器(Oracle VM Virtual Box),爲此我創建一個新的unknwon操作系統,並帶有一個vmdk磁盤。我喜歡vmdk,因爲它們只是純文件,所以我可以將我的啓動加載器粘貼到虛擬硬盤的前512個字節。
現在,我正在嘗試讀取此虛擬磁盤的下一個扇區,我將在該扇區上粘貼一個顯示消息的簡單內核。
我有兩個問題:
難道我讀第二段(第一-512 bytes-由引導程序佔用)是否正確? CODE:
ReadDisk: mov bx, 0x8000 ; segment mov es, bx mov bx, 0x0000 ; offset mov ah, 0x02 ; read function mov al, 0x01 ; sectors - this might be wrong, trying to read from hd mov ch, 0x00 ; cylinder mov cl, 0x02 ; sector mov dh, 0x00 ; head mov dl, 0x80 ; drive - trying to read from hd int 0x13 ; disk int jc ReadDisk jmp [es:bx] ; buffer
在這裏,我得到錯誤信息,檢查後CF.但是,如果我使用INT 13,1來獲取最後的 狀態消息,則AL爲0 - 因此不會保存錯誤。
我粘貼我的簡單內核在vmdk裏的正確位置?我所做的是在文件的第512個字節之後粘貼它,前面的512個字節,正如我所說的,是boot-loader。 該文件是這樣的:
BE 45 7C E8 16 00 EB FE B4 0E B7 00 B3 07 CD 10 <- First sector C3 AC 08 C0 74 05 E8 EF FF EB F6 C3 B4 00 B2 80 CD 13 BE 5D 7C 72 F5 BB 00 80 8E C3 BB 00 00 B4 02 B0 06 B5 00 B1 01 B6 00 B2 07 CD 13 BE 4E 7C 72 CF 26 FF 27 57 65 6C 63 6F 6D 65 21 00 52 65 61 64 69 6E 67 20 65 72 72 6F 72 21 00 52 65 73 65 74 74 69 6E 67 20 65 72 72 6F 72 21 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA <- Boot-loader signature B4 0E B0 2E CD 10 EB FE 00 00 00 00 00 00 00 00 <- Start of the second sector 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
所以,這是我想給內核添加到第二個扇區的方式。 你認爲這是什麼錯誤?謝謝!
UPDATE
O.K.現在我沒有收到任何錯誤,但是我沒有看到正在執行的加載代碼。它應該在窗口上顯示一個點:
;--------------------------------------------
; 'load.asm'
; loaded from 'boot.asm'
[org 0x8000]
[bits 16]
;--------------------------------------------
main:
mov ah, 0x0E ; print function
mov al, '.' ; ascii char
int 0x10 ; IO int
jmp $ ; hang
你應該真的去http://osdev.org/並在那裏問它。並閱讀其wiki上的一些文章。 – Griwes