Here below are my code to boot OS from usb memory.I try using usb and my os basic is located at 0x004200(RAM).I am using int 0x13 ah=0x42 to load data from usb.My question is, wether It move the data to memory place of 0x008000?.My os is at 0x004200 as mention above, my os will load to 0x008000 + 0x004200 = 0x00c200.But when I do this , screen will refresh again and agin.How to solve the problem?
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 SP, 0x7c00
prepare:
STI ; BIOSがSTIし忘れていても大丈夫なために
MOV [drv],DL ; 起動ドライブ番号がDLに入っている(BIOSがDLに入れてからMBRを起動するので)
CMP DL,0x80
JB error ; HDD系デバイスでなければエラー
MOV AH,0x41
MOV BX,0x55aa
INT 0x13
JC error
CMP BX,0xaa55
JNE error
TEST CL,0x01
JZ error
readloop:
MOV CL, 0
retry:
MOV DL, 0x80
MOV AH, 0x42
MOV SI, packet
INT 0x13
JNC next
ADD CL, 1
MOV DL, 0x80
MOV AH, 0x00
INT 0x13
CMP CL, 6
JAE error
JMP retry
next:
MOV AX,[bufferoff]
MOV BX,bufferoff
ADD AX,0x0200
MOV [BX],AX
MOV AX,[blockNum]
MOV BX,blockNum
ADD AX,1
MOV [BX],AX
CMP AX, 361
JB readloop
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
drv: DB 0x80
packet:
packet_size: DB 0x10
reserved: DB 0
count: DW 1
bufferoff: DW 0x0820
bufferseg: DW 0
blockNum: DD 1
DD 0
RESB 0x01fe-($-$$)
DB 0x55, 0xaa
User contributions licensed under CC BY-SA 3.0