我正在尝试为我的boot.bin和kernel.bin文件创建一个可引导的软盘驱动器。我的引导。Asm代码为:
bits 16
section .text
start:
JMP MAIN
WAIT_FOR_KEY:
MOV AH, 00H
INT 16H
RET
CLEAR:
MOV AH, 0H ;CHANGING THE VIDEO MODE TO CLEAR THE SCREEN
MOV AL, 03H ;VIDEO MODE COD
INT 10H
RET
LOG_TO_HTS:
PUSH BX
PUSH AX
MOV BX, AX
MOV DX, 0
DIV WORD[ALL_SECTORS]
ADD DL, 01H
MOV CL, DL
MOV AX, BX
MOV DX, 0
DIV WORD [ALL_SECTORS]
MOV DX, 0
DIV WORD[FACES]
MOV DH, DL
MOV CH, AL
POP AX
POP BX
MOV DL, BYTE [BOOT_DEVICE]
RET
ECHO: ;-=-=-=PRINTING FUNCTION =-=-=-;
LODSB ;MOV ONE CHAR FROM SI TO AL AND DELETE IT FROM SI
CMP AL, 0 ;CHECK IF THE VALUE IN AL=0, IF ITS ZERO THEN WE
JE DONE ;WE ARE DONE PRINTING, AND JUMP BACK TO THE MAIN FUNCTION
CMP AL, 59
JE NEWLINE
MOV AH, 0EH ;THE FUNCTION CODE FOR PRINTING (TELETYPE PRINTING)
INT 10H ;BIOS CALL
JMP ECHO ;IF WE ARRIVED TO THIS LINE THATS MEAN WE ARE NOT DONE WITH
;PRINTING THE WHOLE STREING SO JUMP BACK AND COMPLETE THE PROCESS
DONE: ;LABEL CONTAINS ONE INSTRUCTION TO JUMP BACK TO THE LINE
RET ;WHERE WE CALLED THE ECHO FUNCTION
NEWLINE:
PUSHA
MOV AH, 0EH
MOV AL, 13
INT 10H
MOV AL, 10
INT 10H
POPA
RET
RESET_DRIVE: ;RESET FLOPPY DRIVE FUNCTION
MOV AX, 0 ;THE FUNCTION CODE TO RESET DRIVE
MOV DL, BYTE [BOOT_DEVICE] ;DRIVE ID TO RESET
INT 13H
RET
MAIN: ;THE MAIN FUNCTION LABEL
;TO BEGIN LOADING EXTERNAL FILE LIKE KERNEL SOME THINGS MUST BE DONE LIKE :
;1- SETTING UP THE STACK
;2- SETTING UP THE SEGMENTS
;3- SPECIFY THE BOOT DRIVE
;SETTING UP THE STACK
CLI ;CLEAR INTERRUPTS TO SET THE SEGMENT
XOR AX, AX ;SET THE BOTTOM OF THE STACK
MOV SS, AX
MOV SP, 0XFFFF ;SET THE TOP OF THE STACK
STI ;RESTORE THE INTERRUPTS
;SETTING UP THE SEGMENTS
MOV AX, 07C0H
MOV DS, AX
MOV ES, AX
;AFTER SETTING UP SEGMENTS AND STACK, YOU ARE FREE TO CODE WHAT EVER YOU WANT
;THE CPU WILL RECOGNISE YOUR CODE AS A BOOTLOADER
CALL CLEAR
;MOV SI, WELCOME_MSG
;CALL ECHO
MOV [BOOT_DEVICE], DL ;SAVE THE DRIVE ID TO USE IT LATER
;WE WILL USE IN 13H TO LOAD ROOT DIR. THAT WE NEED TO LOAD THE FIRST SECTOR OF THE KERNEL
;THEN WE WILL LOAD FAT TO LOAD THE WHOLE KERNEL SINCE THE FILE LOAD PROCESS CONSISTS OF 3 STEPS
;1- LOAD THE FISRT SECTOR OF THE FILE
;2- LOAD THE WHOLE FILE AND COPY IT INTO RAM
;3- EXCUTE THE FILE
;THE ROOT DIR. AND FAT ARE LOCATED IN SOMEWHERE ON THE FLOPPY DRIVE AS FOLLOWS
;1- SETTING UP AND LOADING THE ROOT DIR.
MOV AH, 02H ;THE FUNCTION CODE FOR LOADING ROOT DIR.
MOV AL, 14 ;THE SIZE OF THE ROOT DIR. THE ROOT DIR. = 14 AND WE WANT TO LOAD IT ALL SO AL=14
MOV BX, TEMP ;THE TEMP STORAGE FOR THE DATA WILL BE READED OR LOADED
MOV CH, 0 ;TRACK WE WANT TO LOAD, ITS TRACK 0 BEACUSE THE ROOT DIR. LOCATED THERE (CYLINDER)
MOV CL, 2 ;SECTOR WE WANT TO LOAD, ITS SECTOR 2 BEACUSE THE ROOT DIR. LOCATED THERE
MOV DH, 1 ;HEAD WE WANT TO LOAD, ITS HEAD 1 BEACUSE THE ROOT DIR. LOCATED THERE
PUSHA ;TO BE ABLE TO RETRY TO LOAD ROOT DIR. IF INT 13H FAILED
LOAD_RD:
INT 13H
JNC LOAD_RD_DONE ;IF WE ARRIVE HERE, THATS MEAN THAT THE ROOT DIR. LOADED SUCCESSFULLY
CALL RESET_DRIVE ;RESET FLOPPY FUNCTION CALL
JMP LOAD_RD ;RETRY IF INT 13H FAILED
LOAD_RD_DONE:
POPA
;NOW WE WILL SEARCH IN THE ROOT DIR. TABLE IF IT CONTAINS THE DESIRED FILE NAME WHICH IS KERNEL.BIN
;WE WILL USE CMPSB INSTRUCTION THAT COMPARES THE VALUE OF DS:SI AND ES:DI
;ES AND DS ARE ALREADY SET
;THE SEARCH WILL BE LIMITED TO SEARCH AMONG 11 BYTES BECAUSE THE FILE NAME IS 11 BYTES
MOV DI, TEMP ;THE RESULT WE GOT (THE ENTRY)
MOV CX, 224 ;THE MAX. POSSIBLE FILE NUMBER THAT WE COULD HAVE IS 224 SO WE LIMIT THE SEARCH TO IT (THE VALUE THAT WILL BE DECREASED WHILE LOOPING)
FIND_KERNEL:
PUSH CX ;PUSH CX AND DI BECAUSE THEY HELD IMPORTANT DATA THAT WE DONT WANT TO LOSE
POP DX
MOV SI, FILE_NAME ;THE VALUE THAT WE WILL COMPARE THE RESULT OF ROOT DIR. TO FIND
MOV CX, 11 ;TO REPEATE THE SEARCH PROCESS 11 TIMES(THE FILE NAME LENGTH)
REP CMPSB ;COPMARES SI WITH DI
JE FOUND_KERNEL ;IF WO GO TO THE NEXT LINE, THAT MEANS THAT THE KERNEL IS NOT FOUNDED YET
;AND SINCE DI IS POINTS TO THE FIRST ENTRY, WE NEED TO MOVE TO THE NEXT ONE BY ADDING 32
ADD AX, 32
MOV DI, TEMP
ADD DI, AX
PUSH DX
POP CX
LOOP FIND_KERNEL
;IF WE ARE HERE, THEN THE KERNEL IS NOT EXISTS
;MOV SI, FAILED_TO_LOAD_KERNEL
;CALL ECHO
CLI
INT 18H ;CRASH AND HALT THE PROCESSOR
FOUND_KERNEL: ;IF WE FOUND THE KERNEL WE WILL BE HERE
;NOW WE HAVE THE ENTRY POINT FOR THE KERNEL SAVED IN DL REGISTER
;WE GOT THE KERNEL FROM THE FIRST 11 BYTES SO WE NEED TO ADD 15 TO GET TO THE 26 BYTES
;THE FIRST SECTOR IS LOCATED AT 26 AND 27 SO WE MUST ADD 15 TO LOAD THE KERNEL IN THE FIRST SECTOR
MOV AX, WORD [DI+15] ;WORD ADDED TO COPY BOTH 26 AND 27 BYTES TO AX, THE WORD IS 2 BYTES
MOV [ENTERY_POINT], AX
;2- SETTING UP AND LOADING THE FAT
MOV AX, 1
MOV BX, TEMP ;THE TEMP STORAGE FOR THE DATA WILL BE READED OR LOADED
CALL LOG_TO_HTS
MOV AH, 2 ;THE FUNCTION CODE FOR LOADING ROOT DIR.
MOV AL, 9 ;THE SIZE OF THE ROOT DIR. THE ROOT DIR. = 14 AND WE WANT TO LOAD IT ALL SO AL=14
PUSHA ;TO BE ABLE TO RETRY TO LOAD ROOT DIR. IF INT 13H FAILED
LOAD_FAT:
INT 13H
JNC LOAD_FAT_DONE ;IF WE ARRIVE HERE, THATS MEAN THAT THE FAT LOADED SUCCESSFULLY
CALL RESET_DRIVE ;RESET FLOPPY FUNCTION CALL
JMP LOAD_FAT ;RETRY IF INT 13H FAILED
LOAD_FAT_DONE: ;IF LOADING FAT DONE SUCCESSFULLY, WE WILL BE HERE
MOV AH, 2
MOV AL, 1
PUSH AX
LOAD_SECTOR: ;ROOT DIR. GIVES US A DATA SECTOR AND WE WANT A LOGICAL SECTOR, WE WILL DO IT HERE
MOV AX, WORD [ENTERY_POINT]
ADD AX, 31 ;31 ADDED TO DONE THE CONVERTION
CALL LOG_TO_HTS ;COVERTS THE LOGICAL SECTORS INTO HEAD TRACK SECTORS
MOV AX, 2000H
MOV ES, AX
MOV BX, WORD[OFFSET_]
POP AX
PUSH AX
INT 13H
JNC GET_NEXT
CALL RESET_DRIVE
JMP LOAD_SECTOR
GET_NEXT:
MOV AX, [ENTERY_POINT]
MOV DX, 0
MOV BX, 6
MUL BX
MOV BX, 4
DIV BX
MOV SI, TEMP
ADD SI, AX
MOV AX, WORD[SI]
OR DX, DX
JZ EVEN
ODD:
SHR AX, 4
JMP SHORT COMP_SECTOR
EVEN:
AND AX, 0FFFH
COMP_SECTOR:
MOV WORD [ENTERY_POINT], AX
CMP AX, 0FF8H
JAE END
ADD WORD[OFFSET_], 512
JMP LOAD_SECTOR
END:
;MOV SI, KERNEL_LOADED_MSG
CALL ECHO
CALL WAIT_FOR_KEY
POP AX
MOV DL, BYTE[BOOT_DEVICE]
JMP 2000H:0000H
OFFSET_ DW 0
ALL_SECTORS DW 18
FACES DW 2
ENTERY_POINT DW 0
;FAILED_TO_LOAD_KERNEL DB "Error, Cannot Load The Kernel. Booting Process Aborted;",0
BOOT_DEVICE DB 0
FILE_NAME DB "KERNEL BIN"
;WELCOME_MSG DB "Litesoft bootloader Copyright (C) 2012-2016 By Mohamed El Sayed;",0
;KERNEL_LOADED_MSG DB "Kernel Loaded, Press Any Key To Continue...",0
TIMES 510 - ($-$$) DB 0 ;LOOK FOR EVERY SINGLE EMPTY BIT AND FILL IT WITH ZERO
;TILL THE BOOTLOADER SIZE BE 512 BYTE
DW 0xAA55 ;THE BOOT SIGNETUARE, ALWAYS THE SAME
TEMP: ;HERE IN BYTE 513 WE HAVE SOME MEMORY THAT WILL NOT BE EXECUTED
;AND WE CAN USE IT AS A TEMP MEMORY
我计划使用的方法是使用dd创建一个软盘映像,并将我的引导加载程序写入第一个扇区,然后挂载它并将我的内核复制到它。
我使用的命令
1- mkdosfs -C floppy.flp 1440
,该命令创建软盘映像
2—dd status=noxfer conv=notrunc if=boot.bin of=floppy.flp
,该命令将引导加载程序烧到第一个扇区
这些命令非常有效,并且在第一个扇区成功创建了带引导加载程序的软盘映像
当我尝试使用以下命令挂载软盘映像以将内核复制到它时,问题出现了
rm -rf tmp-loop
mkdir tmp-loop && mount -o loop -t vfat floppy.flp tmp-loop && cp kernel.bin tmp-loop/
每次我尝试挂载软盘映像,我得到这个错误
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
这个错误的解决方案是什么?我用的是Ubuntu 16.04
在引导加载程序开始时缺少适当的BIOS参数块(BPB)。这个结构包含了一些bios使用/更新的信息;可以被引导加载程序用来读取未分区媒体(如软盘)上的FAT文件系统;像mount
这样的软件必须存在,以确定虚拟软盘映像所代表的媒体类型。对于未分区媒体(如软盘)上的FAT12文件系统,信息存在于主引导记录的BPB中。一个常见的布局是DOS 3.4 EBPB,它看起来像这样:
start:
JMP MAIN
TIMES 3-($-$$) DB 0x90 ; Support 2 or 3 byte encoded JMPs before BPB.
; Dos 3.4 EBPB 1.44MB floppy
OEMname: db "mkfs.fat" ; mkfs.fat is what OEMname mkdosfs uses
bytesPerSector: dw 512
sectPerCluster: db 1
reservedSectors: dw 1
numFAT: db 2
numRootDirEntries: dw 224
numSectors: dw 2880
mediaType: db 0xf0
numFATsectors: dw 9
sectorsPerTrack: dw 18
numHeads: dw 2
numHiddenSectors: dd 0
numSectorsHuge: dd 0
driveNum: db 0
reserved: db 0
signature: db 0x29
volumeID: dd 0x2d7e5a1a
volumeLabel: db "NO NAME "
fileSysType: db "FAT12 "
基于上面的DOS 3.4 EBPB和您的boot.asm
代码,这个BPB表示一个类似于使用mkdosfs -C floppy.flp 1440
:
bits 16
section .text
start:
JMP MAIN
TIMES 3-($-$$) DB 0x90 ; Support 2 or 3 byte encoded JMPs before BPB.
; Dos 3.4 EBPB 1.44MB floppy
OEMname: db "mkfs.fat" ; mkfs.fat is what OEMname mkdosfs uses
bytesPerSector: dw 512
sectPerCluster: db 1
reservedSectors: dw 1
numFAT: db 2
numRootDirEntries: dw 224
numSectors: dw 2880
mediaType: db 0xf0
numFATsectors: dw 9
sectorsPerTrack: dw 18
numHeads: dw 2
numHiddenSectors: dd 0
numSectorsHuge: dd 0
driveNum: db 0
reserved: db 0
signature: db 0x29
volumeID: dd 0x2d7e5a1a
volumeLabel: db "NO NAME "
fileSysType: db "FAT12 "
WAIT_FOR_KEY:
MOV AH, 00H
INT 16H
RET
CLEAR:
MOV AH, 0H ;CHANGING THE VIDEO MODE TO CLEAR THE SCREEN
MOV AL, 03H ;VIDEO MODE COD
INT 10H
RET
LOG_TO_HTS:
PUSH BX
PUSH AX
MOV BX, AX
MOV DX, 0
DIV WORD[ALL_SECTORS]
ADD DL, 01H
MOV CL, DL
MOV AX, BX
MOV DX, 0
DIV WORD [ALL_SECTORS]
MOV DX, 0
DIV WORD[FACES]
MOV DH, DL
MOV CH, AL
POP AX
POP BX
MOV DL, BYTE [BOOT_DEVICE]
RET
ECHO: ;-=-=-=PRINTING FUNCTION =-=-=-;
LODSB ;MOV ONE CHAR FROM SI TO AL AND DELETE IT FROM SI
CMP AL, 0 ;CHECK IF THE VALUE IN AL=0, IF ITS ZERO THEN WE
JE DONE ;WE ARE DONE PRINTING, AND JUMP BACK TO THE MAIN FUNCTION
CMP AL, 59
JE NEWLINE
MOV AH, 0EH ;THE FUNCTION CODE FOR PRINTING (TELETYPE PRINTING)
INT 10H ;BIOS CALL
JMP ECHO ;IF WE ARRIVED TO THIS LINE THATS MEAN WE ARE NOT DONE WITH
;PRINTING THE WHOLE STREING SO JUMP BACK AND COMPLETE THE PROCESS
DONE: ;LABEL CONTAINS ONE INSTRUCTION TO JUMP BACK TO THE LINE
RET ;WHERE WE CALLED THE ECHO FUNCTION
NEWLINE:
PUSHA
MOV AH, 0EH
MOV AL, 13
INT 10H
MOV AL, 10
INT 10H
POPA
RET
RESET_DRIVE: ;RESET FLOPPY DRIVE FUNCTION
MOV AX, 0 ;THE FUNCTION CODE TO RESET DRIVE
MOV DL, BYTE [BOOT_DEVICE] ;DRIVE ID TO RESET
INT 13H
RET
MAIN: ;THE MAIN FUNCTION LABEL
;TO BEGIN LOADING EXTERNAL FILE LIKE KERNEL SOME THINGS MUST BE DONE LIKE :
;1- SETTING UP THE STACK
;2- SETTING UP THE SEGMENTS
;3- SPECIFY THE BOOT DRIVE
;SETTING UP THE STACK
CLI ;CLEAR INTERRUPTS TO SET THE SEGMENT
XOR AX, AX ;SET THE BOTTOM OF THE STACK
MOV SS, AX
MOV SP, 0XFFFF ;SET THE TOP OF THE STACK
STI ;RESTORE THE INTERRUPTS
;SETTING UP THE SEGMENTS
MOV AX, 07C0H
MOV DS, AX
MOV ES, AX
;AFTER SETTING UP SEGMENTS AND STACK, YOU ARE FREE TO CODE WHAT EVER YOU WANT
;THE CPU WILL RECOGNISE YOUR CODE AS A BOOTLOADER
CALL CLEAR
;MOV SI, WELCOME_MSG
;CALL ECHO
MOV [BOOT_DEVICE], DL ;SAVE THE DRIVE ID TO USE IT LATER
;WE WILL USE IN 13H TO LOAD ROOT DIR. THAT WE NEED TO LOAD THE FIRST SECTOR OF THE KERNEL
;THEN WE WILL LOAD FAT TO LOAD THE WHOLE KERNEL SINCE THE FILE LOAD PROCESS CONSISTS OF 3 STEPS
;1- LOAD THE FISRT SECTOR OF THE FILE
;2- LOAD THE WHOLE FILE AND COPY IT INTO RAM
;3- EXCUTE THE FILE
;THE ROOT DIR. AND FAT ARE LOCATED IN SOMEWHERE ON THE FLOPPY DRIVE AS FOLLOWS
;1- SETTING UP AND LOADING THE ROOT DIR.
MOV AH, 02H ;THE FUNCTION CODE FOR LOADING ROOT DIR.
MOV AL, 14 ;THE SIZE OF THE ROOT DIR. THE ROOT DIR. = 14 AND WE WANT TO LOAD IT ALL SO AL=14
MOV BX, TEMP ;THE TEMP STORAGE FOR THE DATA WILL BE READED OR LOADED
MOV CH, 0 ;TRACK WE WANT TO LOAD, ITS TRACK 0 BEACUSE THE ROOT DIR. LOCATED THERE (CYLINDER)
MOV CL, 2 ;SECTOR WE WANT TO LOAD, ITS SECTOR 2 BEACUSE THE ROOT DIR. LOCATED THERE
MOV DH, 1 ;HEAD WE WANT TO LOAD, ITS HEAD 1 BEACUSE THE ROOT DIR. LOCATED THERE
PUSHA ;TO BE ABLE TO RETRY TO LOAD ROOT DIR. IF INT 13H FAILED
LOAD_RD:
INT 13H
JNC LOAD_RD_DONE ;IF WE ARRIVE HERE, THATS MEAN THAT THE ROOT DIR. LOADED SUCCESSFULLY
CALL RESET_DRIVE ;RESET FLOPPY FUNCTION CALL
JMP LOAD_RD ;RETRY IF INT 13H FAILED
LOAD_RD_DONE:
POPA
;NOW WE WILL SEARCH IN THE ROOT DIR. TABLE IF IT CONTAINS THE DESIRED FILE NAME WHICH IS KERNEL.BIN
;WE WILL USE CMPSB INSTRUCTION THAT COMPARES THE VALUE OF DS:SI AND ES:DI
;ES AND DS ARE ALREADY SET
;THE SEARCH WILL BE LIMITED TO SEARCH AMONG 11 BYTES BECAUSE THE FILE NAME IS 11 BYTES
MOV DI, TEMP ;THE RESULT WE GOT (THE ENTRY)
MOV CX, 224 ;THE MAX. POSSIBLE FILE NUMBER THAT WE COULD HAVE IS 224 SO WE LIMIT THE SEARCH TO IT (THE VALUE THAT WILL BE DECREASED WHILE LOOPING)
FIND_KERNEL:
PUSH CX ;PUSH CX AND DI BECAUSE THEY HELD IMPORTANT DATA THAT WE DONT WANT TO LOSE
POP DX
MOV SI, FILE_NAME ;THE VALUE THAT WE WILL COMPARE THE RESULT OF ROOT DIR. TO FIND
MOV CX, 11 ;TO REPEATE THE SEARCH PROCESS 11 TIMES(THE FILE NAME LENGTH)
REP CMPSB ;COPMARES SI WITH DI
JE FOUND_KERNEL ;IF WO GO TO THE NEXT LINE, THAT MEANS THAT THE KERNEL IS NOT FOUNDED YET
;AND SINCE DI IS POINTS TO THE FIRST ENTRY, WE NEED TO MOVE TO THE NEXT ONE BY ADDING 32
ADD AX, 32
MOV DI, TEMP
ADD DI, AX
PUSH DX
POP CX
LOOP FIND_KERNEL
;IF WE ARE HERE, THEN THE KERNEL IS NOT EXISTS
;MOV SI, FAILED_TO_LOAD_KERNEL
;CALL ECHO
CLI
INT 18H ;CRASH AND HALT THE PROCESSOR
FOUND_KERNEL: ;IF WE FOUND THE KERNEL WE WILL BE HERE
;NOW WE HAVE THE ENTRY POINT FOR THE KERNEL SAVED IN DL REGISTER
;WE GOT THE KERNEL FROM THE FIRST 11 BYTES SO WE NEED TO ADD 15 TO GET TO THE 26 BYTES
;THE FIRST SECTOR IS LOCATED AT 26 AND 27 SO WE MUST ADD 15 TO LOAD THE KERNEL IN THE FIRST SECTOR
MOV AX, WORD [DI+15] ;WORD ADDED TO COPY BOTH 26 AND 27 BYTES TO AX, THE WORD IS 2 BYTES
MOV [ENTERY_POINT], AX
;2- SETTING UP AND LOADING THE FAT
MOV AX, 1
MOV BX, TEMP ;THE TEMP STORAGE FOR THE DATA WILL BE READED OR LOADED
CALL LOG_TO_HTS
MOV AH, 2 ;THE FUNCTION CODE FOR LOADING ROOT DIR.
MOV AL, 9 ;THE SIZE OF THE ROOT DIR. THE ROOT DIR. = 14 AND WE WANT TO LOAD IT ALL SO AL=14
PUSHA ;TO BE ABLE TO RETRY TO LOAD ROOT DIR. IF INT 13H FAILED
LOAD_FAT:
INT 13H
JNC LOAD_FAT_DONE ;IF WE ARRIVE HERE, THATS MEAN THAT THE FAT LOADED SUCCESSFULLY
CALL RESET_DRIVE ;RESET FLOPPY FUNCTION CALL
JMP LOAD_FAT ;RETRY IF INT 13H FAILED
LOAD_FAT_DONE: ;IF LOADING FAT DONE SUCCESSFULLY, WE WILL BE HERE
MOV AH, 2
MOV AL, 1
PUSH AX
LOAD_SECTOR: ;ROOT DIR. GIVES US A DATA SECTOR AND WE WANT A LOGICAL SECTOR, WE WILL DO IT HERE
MOV AX, WORD [ENTERY_POINT]
ADD AX, 31 ;31 ADDED TO DONE THE CONVERTION
CALL LOG_TO_HTS ;COVERTS THE LOGICAL SECTORS INTO HEAD TRACK SECTORS
MOV AX, 2000H
MOV ES, AX
MOV BX, WORD[OFFSET_]
POP AX
PUSH AX
INT 13H
JNC GET_NEXT
CALL RESET_DRIVE
JMP LOAD_SECTOR
GET_NEXT:
MOV AX, [ENTERY_POINT]
MOV DX, 0
MOV BX, 6
MUL BX
MOV BX, 4
DIV BX
MOV SI, TEMP
ADD SI, AX
MOV AX, WORD[SI]
OR DX, DX
JZ EVEN
ODD:
SHR AX, 4
JMP SHORT COMP_SECTOR
EVEN:
AND AX, 0FFFH
COMP_SECTOR:
MOV WORD [ENTERY_POINT], AX
CMP AX, 0FF8H
JAE END
ADD WORD[OFFSET_], 512
JMP LOAD_SECTOR
END:
;MOV SI, KERNEL_LOADED_MSG
CALL ECHO
CALL WAIT_FOR_KEY
POP AX
MOV DL, BYTE[BOOT_DEVICE]
JMP 2000H:0000H
OFFSET_ DW 0
ALL_SECTORS DW 18
FACES DW 2
ENTERY_POINT DW 0
;FAILED_TO_LOAD_KERNEL DB "Error, Cannot Load The Kernel. Booting Process Aborted;",0
BOOT_DEVICE DB 0
FILE_NAME DB "KERNEL BIN"
;WELCOME_MSG DB "Litesoft bootloader Copyright (C) 2012-2016 By Mohamed El Sayed;",0
;KERNEL_LOADED_MSG DB "Kernel Loaded, Press Any Key To Continue...",0
TIMES 510 - ($-$$) DB 0 ;LOOK FOR EVERY SINGLE EMPTY BIT AND FILL IT WITH ZERO
;TILL THE BOOTLOADER SIZE BE 512 BYTE
DW 0xAA55 ;THE BOOT SIGNETUARE, ALWAYS THE SAME
TEMP: ;HERE IN BYTE 513 WE HAVE SOME MEMORY THAT WILL NOT BE EXECUTED
;AND WE CAN USE IT AS A TEMP MEMORY
如果从这段代码生成boot.bin
并将其放在软盘映像中,并使用命令显示文件类型信息:
file floppy.flp
如果它工作了,它应该产生如下内容:
软盘。flp:,代码偏移0x99+3, OEM-ID"mkfs"。"fat",根条目224,扇区2880(卷<=32 MB),扇区/fat 9,扇区/磁道18,序列号0x2d7e5a1a,未标记,fat(12位),后面跟着fat
如果您得到类似的输出,则应该可以使用mount
命令挂载。
您可能已经注意到,EBPB/BPB中的数据可用于在FAT12文件系统上导航。