2

ASM を作成してからしばらく経ちましたが、qemu でテストして、もう一度小さなブートローダーを作成してみることにしました。私の問題は割り込み 13 にあります。何らかの理由でキャリー フラグが設定されているため、読み取りが失敗しています。現在、私のディスク イメージは次のようになっています。

512バイトのBootLoader <-これは(私が知る限り)LBAのブロック0です

主な機能<- これはブロック 1 になります

基本的に、BIOS がメモリにロードする 512 バイトを使用して、同じドライブから次の 512 バイトをロードしたいと考えています。しかし、何が問題なのかわかりません。十分な情報を提供したことを願っています。

コードは次のとおりです。問題は、0x7E00 にジャンプする直前の 2 番目の 0x13 割り込みにあります。

[bits 16]
[org 0x7C00]

; Prepare Stack Segment
;-----------------------------------------------------------------
    mov sp, 0x7A00              ; 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
    xor ax, ax
    add ax, 1                   ; Clear Carry Bit

    mov si, DAPS                ; Load DAPS Struct to DS:SI
    mov ah, 0x42                ; Read Functions (AL Ignored)
    mov dl, 0x80                ; Active Boot Drive (Commented Out Due to Line 24)
    int 0x13
    jc short unsupported        ; If something goes wrong...
    jmp 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

    success:
    pop dx                      ; Pop Original Drive Identifier
    jmp $

; Fill Out Rest of Bootloader
;-----------------------------------------------------------------
times 494-($-$$) db 0

; 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
          db 1                  ; Number of Sectors to Read (1x512)
          db 0                  ; Always 0 
          dw 0x7E00             ; Target Location for Reading To
          dw 0                  ; Page Table (0, Disabled)
          dd 1                  ; Read from Second Block
          dd 0                  ; Large LBAs, ignore

    db 0x55, 0xAA               ; Add Boot Record Signature

main:
    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

    jmp $
4

1 に答える 1

2

問題は単純になり、コードは正しかった。しかし、最終的なイメージが 512 バイトの倍数ではなく 525 バイトだったため、読み取りが中断されました。画像サイズを 1024B にするために、画像を 0 で埋めて、読み取りで 512 バイトすべてを取得できるようにする必要がありました。

(明らかに、このようなフォーマットされていない小さなディスクを持たない方がはるかに良い考えですが、学習目的では、これが本当に必要なすべてです)

于 2009-11-25T06:45:09.313 に答える