0

今回,os自作入門のharibote osをusbから起動できるように改造したいのですが、下記のmbrを使い、os本体を0x8000後に移動させる事に成功しました。しかし、肝心のos本体は起動してくれません。メモリを変えてくれないって感じですね。真っ黒の画面にはいってしまいます。理由はなんでしょうか?

[bits 16]
[ORG 0x7c00]
        ;; BPB Structure                                                                                                                     
JMP     entry           ;BS_jmpBoot                                                                                                  
BS_OEMName      DB "HARIBOTE"
BPB_BytsPerSec  DW 0x0200
BPB_SecPerClus  DB 0x01
BPB_RsvdSecCnt  DW 0x0020
BPB_NumFATs     DB 0x02
BPB_RootEntCnt  DW 0x0000
BPB_TotSec16    DW 0x0000
BPB_Media       DB 0xf8
BPB_FATSz16     DW 0x0000
BPB_SecPerTrk   DW 0x0001
BPB_NumHeads    DW 0x0001
BPB_HiDDSec     DD 0x00000000
BPB_TotSec32    DD 0x00ee5000
BPB_FATSz32     DD 0x00000020
BPB_ExtFlags    DW 0x0000
BPB_FSVer       DW 0x0000
BPB_RootClus    DD 0x00000002
BPB_FSInfo      DW 0x0001
BPB_BkBootSec   DW 0x0006
        times   12      DB 0    ;BPB_Reserverd                                                                                               
BS_DrvNum       DB 0x80
BS_Reserved1    DB 0x00
BS_BootSig      DB 0x29
BS_VolID        DD 0xa0a615c
BS_VolLab       DB "ISHIHA BOOT"
BS_FileSysType  DB "FAT32   "

entry:  

        MOV AX, 0 
        MOV DS, AX   
        MOV ES, AX
        MOV BX, AX
    MOV CX, 0
    MOV SP, 0x7c00

prepare:
    mov ah, 0x41                ; Set Function 0x41
        mov word bx, 0x55AA          
        push dx                     ; Save old Drive Identifier
        mov dl, 0x80                ; Load 'Active' ID Into dl, commented out to keep bios setting of dl (should be active drive)
        int 0x13                    ; Call Interupt
        jc unsupported        ; If Extentions aren't Supported, Jump
        xor ax, ax
        add ax, 1                   ; clear carry flag
    XOR EDI, EDI
loop:
    MOV CL, 0
retry:
        MOV DL, 0x80
        MOV AH, 0x42
        MOV SI, DAPS 
        INT 0x13
        JNC next
        ADD CL, 1
        MOV DL, 0x80 
        MOV AH, 0x00
        INT 0x13
        CMP CL, 6
        JAE error
        JMP retry
next:

    XOR EAX, EAX
    XOR ECX, ECX

    ADD EDI, 1
    MOV ECX, lba0
    MOV [ECX], EDI

    XOR EAX, EAX
    XOR ECX, ECX
    XOR EBP, EBP
    XOR EBP, EBP

    MOV AX, [addr]
    MOV ECX, addr
    MOV EBX, segm
    ADD AX, 0x200
    ADC BP, 0
    SHL BP, 12
    ADD BP, [segm]
    MOV [EBX], BP

    MOV [ECX], AX
    MOV [EBX], BP

    CMP EDI, 0x169
    JB loop

        JMP 0xc200
error:
        MOV     SI,msg
putloop:
        MOV     AL,[SI]
        ADD     SI,1            
        CMP     AL,0
        JE      fin
        MOV     AH,0x0e         
        MOV     BX,15       
        INT     0x10           
        JMP     putloop
fin:
        HLT                     
        JMP     fin            
msg:
        DB      0x0a, 0x0a      
        DB      "load error"
        DB      0x0a            
        DB      0
msg1:
        DB      0x0a, 0x0a      
        DB      "not supported"
        DB      0x0a            
        DB      0

unsupported:
    MOV SI, msg1
    JMP putloop

drv:    DB     0x80
DAPS:   DB 0x10               ; Size of Structure (16 bytes, always this for DAPS)
        DB 0                  ; Always 0
        DB 1                  ; Number of Sectors to Read (1x512)
        DB 0                  ; Always 0 
addr:   DW 0x8000             ; Target Location for Reading To (0x8000 = 0x0800:0x0000)  
segm:   DW 0x0000             ; Page Table (0, Disabled)
lba0:   DD 1                  ; Read from 2nd block (code I want to load)
    DD 0                  ; Large LBAs, dunno what this does
        RESB    0x01fe-($-$$)       
        DB      0x55, 0xaa
2
  • 1
    最初に読んだ時に、「あれ前の質問と全く同じではないのか?」と思ってしまいました。できればリンクを埋め込んで関連質問を示してもらったほうがいいと思います。また、前のご質問は完了したことにして新たに質問を起こすのであれば、前のご質問に「承認」の操作をお願いします。
    – OOPer
    2018年4月13日 13:33
  • 承認しました。これで全部です。 2018年4月13日 16:54

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。