前面已经接管引导权了,只能玩玩,什么都不能做,接下来要做正事了!以软盘1.44M,和FAT12系统为例(为了简单些)
512B.ASM文件:
ORG 0X7C00
BS_jmpBOOT JMP NEAR BOOT_BEGIN
%INCLUDE "FAT12.ASM"
%INCLUDE "INC.ASM"
BASE_STACK_ADDR EQU 50H ;(SS)堆栈基地址,500H-900H 1K堆栈
OFFS_STACK_ADDR EQU 400H ;(SP)堆栈栈顶地址
DIR_SECTOR_NUM EQU 14 ;根目录占用扇区
DIR_SECTOR_HEAD EQU 19 ;根目录起始扇区
SECTOR_RAM_BASE_ADDR EQU 1B0H ;500H+400H+1200H=1B00H,临时区或OSLDR复制到RAM地址
SECROT_RAM_OFFS_ADDR EQU 0 ;临时区或OSLDR复制到RAM偏移地址
DEFINE_FILE_NAME DB 'OSLDR ' ;文件名
READ_FAT_BASE_ADDR EQU 90H ;FAT复制到内存基地址
READ_FAT_OFFS_ADDR EQU 0 ;FAT复制到内存偏移地址
READ_FAT_HEAD_NUM EQU 1 ;FAT表起始扇区号,INT13H
READ_FAT_SECTOR_SIZE EQU 9 ;FAT表占用扇区数
READ_FAT_DRV_NUM EQU 0 ;中断13的驱动器号
READ_FAT_SEC_PER EQU 18 ;每磁道扇区数
BOOT_BEGIN:
MOV AX,CS
MOV DS,AX
MOV ES,AX
MOV AX,BASE_STACK_ADDR
MOV SS,AX
MOV SP,OFFS_STACK_ADDR
XOR AH,AH
XOR DL,DL
INT 13H
CALL READ_FILE
CMP WORD[SCAN_FILE_NAME_VAR_DSN],0
JZ NO_BOOT_FILE
CMP WORD[SCAN_FILE_NAME_VAR_DSN],0FF7H
JZ DISK_DAMAGE
JMP SECTOR_RAM_BASE_ADDR:SECROT_RAM_OFFS_ADDR
NO_BOOT_FILE:
MOV BP,No_boot_file_disp
JMP SHORT Display_information
DISK_DAMAGE:
MOV BP,Disk_damage_disp
Display_information:
MOV AX,CS
MOV ES,AX
MOV CX,13
MOV AX,1301H
MOV BX,0CH
MOV DX,0
INT 10H
JMP SHORT $
Disk_damage_disp DB "Disk Damage. "
No_boot_file_disp DB "No Boot File."
TIMES 510-