0
我一直試圖做一個引導程序。在我得到它的一點,但現在它不再工作。當我運行它時,它會打印出一個A和一個B.所以這意味着它實際上做了讀取,但由於某種原因,當它跳轉時,它不會執行我放在USB驅動器第二個扇區的代碼。引導程序 - 不要jmp或正確加載第二個扇區
我不知道我的地址或跳轉有問題嗎?
我包括放置在第二個扇區我的USB記憶
[bits 16]
[org 0x7C00]
jmp Start
;%include "BIOS_Parameter_Block.inc"
;%include "Extensions.inc"
;%include "Print.inc"
; Prepare Stack Segment
;-----------------------------------------------------------------
Start:
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov sp, 0x7C00 ; Move Stack into SP
mov bp, sp ; Store current Stack Base
; Print Character to Make Sure Bootloader Has Reached this Point
;-----------------------------------------------------------------
mov ah, 0x0E ; Print Character to Screen
mov bh, 0x00 ; No Page Numbering
mov bl, 0x07 ; White Text, Black Background
mov al, 65 ; Print Letter A
int 0x10
; Check if INT0x13 Extentions are Supported
;-----------------------------------------------------------------
mov ah, 0x41 ; Set Function 0x41
mov word bx, 0x55AA
push dx ; Save old Drive Identifier
mov dl, 0x80 ; Load 'Active' ID Into dl
int 0x13 ; Call Interupt
jc short unsupported ; If Extentions aren't Supported, Jump
clc ; Clear Carry Bit
; Read from the device.
;-----------------------------------------------------------------
mov si, DAPS ; Load DAPS Struct to DS:SI
mov ah, 0x42 ; Read Functions (AL Ignored)
mov dl, 0x80 ; Load 'Active' ID Into dl
int 0x13
jc short unsupported ; If something goes wrong...
mov ah, 0x0E ; Print Character to Screen
mov bh, 0x00 ; No Page Numbering
mov bl, 0x07 ; White Text, Black Background
mov al, 66 ; Print Letter B
int 0x10
; IT DOES PRINT THIS ABOVE
jmp 0x0:0x7E00 ; Jump to main
; Errors
;-----------------------------------------------------------------
unsupported:
mov ah, 0x0E ; Print Letter F, Gives Indication of Failure
mov bh, 0x00
mov bl, 0x07
mov al, 70
int 0x10
clc
hlt
; Memory Data Structures and Other Variables
;-----------------------------------------------------------------
; Disk Address Packet Structure (Used For Loading Rest of OS)
DAPS: db 0x10 ; Size of Structure (16 bytes)
db 0 ; Always 0
dw 1 ; Number of Sectors to Read (1x512)
dw 0x7E00 ; Offset to load to.
dw 0x0000 ; Segment to load to.
dq 1 ; Read from Second Block
; Fill Out Rest of Bootloader
;-----------------------------------------------------------------
times 510-($-$$) db 0
db 0x55, 0xAA ; Add Boot Record Signature
2階段的圖像
[ORG 0x7E00]
[bits 16]
mov ah, 0x0E ; Print Character to Screen
mov bh, 0x00 ; No Page Numbering
mov bl, 0x07 ; White Text, Black Background
mov al, 67 ; Print Letter C
int 0x10
cli
hlt
希望你們能幫助我!
我明白你的意思,但我怎麼知道我的USB的驅動器ID是什麼? – 2013-02-09 12:22:33
這是一個很好的問題 - 我不能馬上記住過去我是如何處理這個問題的。我懷疑它會出現在HD範圍(> 0x80),但我無法證實這一點。顯然,Windows驅動器號和BIOS驅動器ID(http://support.microsoft.com/kb/62571)之間存在_some_對應關係,並且您可能能夠使用int 0x13 AH = 0x48(http ://www.delorie.com/djgpp/doc/rbinter/id/21/7.html) – Michael 2013-02-09 12:41:04
非常感謝您的信息! – 2013-02-09 12:45:49