📄 bootsector.asm
字号:
/************************************************************************************************/
/* This routine extracts the following parameters from the boot sector: */
/* 1) total sectors in root directory */
/* 2) start of root directory */
/* 3) start of data region */
/* 4) total sectors in data region */
/* Last Modified 02-26-03. H. Desai */
/************************************************************************************************/
#include "Boot_Sector_Parameters.h"
.GLOBAL Get_BootSector_Info;
.EXTERN Boot_Sector;
.EXTERN Parameters;
.SECTION program;
Get_BootSector_Info:
/**Calc. Total Sectors in Root Directory**/
/** RootDirSectors = ((MaxRootEntries * 32) + (BytesPerSector - 1))/BytesPerSector**/
P0.L = Boot_Sector;
P0.H = Boot_Sector;
P1.H = Parameters;
P1.L = Parameters;
R0 = B[P0+SECTORS_PER_CLUSTER];
[P1+0x14] = R0; //Store Sectors per Cluster
R0 = B[P0+ROOT_DIR_COUNT];
R1 = B[P0+ROOT_DIR_COUNT+1];
R1 = R1 << 8;
R0 = R1 | R0;
R0 = R0 << 5; //Mult. by 32
R1 = B[P0+BYTES_PER_SECTOR];
R2 = B[P0+BYTES_PER_SECTOR+1];
R2 = R2 << 8;
R1 = R1 | R2;
R1 += -1;
R0 = R0 + R1;
R0 = R0 >> 9; //Divide by 512
[P1+8] = R0; //Number of Root Directory Sectors
/**Calc. Start of Data Region**/
/**RootDirStart = (FATcount * SectorsPerFAT) + ReservedSectors**/
/**FirstDataSector = RootDirStart + RootDirSectors**/
R1 = B[P0+NUMBER_FATS];
R2 = B[P0+FAT_SECTORS];
R3 = B[P0+FAT_SECTORS+1];
R3 = R3 << 8;
R2 = R2 | R3;
R1.L = R1.L * R2.L (IS);
R2 = B[P0+RESV_SEC_COUNT];
R3 = B[P0+RESV_SEC_COUNT+1];
R3 = R3 << 8;
R2 = R2 | R3;
R1 = R1 + R2;
[P1] = R1; //R1 = Start of Root Directory
R0 = R0 + R1;
[P1+4] = R0; //R0 = Start of Data Region
/**Calc. Total Sectors in Data Region**/
/**DataSectors = TotalSectors - FirstDataSector**/
R1 = B[P0+TOTAL_SECTORS16];
R2 = B[P0+TOTAL_SECTORS16+1];
R2 = R2 << 8;
R1 = R1 | R2;
R2 = 0x0(Z);
cc = R1 == R2;
IF !cc JUMP Calc_Data_Sec;
GT_32MB:
R1 = B[P0+TOTAL_SECTORS32_LO];
R2 = B[P0+TOTAL_SECTORS32_LO+1];
R2 = R2 << 8;
R1 = R1 | R2;
R2 = B[P0+TOTAL_SECTORS32_HI];
R2 = R2 << 16;
R3 = B[P0+TOTAL_SECTORS32_HI+1];
R3 = R3 << 24;
R2 = R2 | R3;
R1 = R1 | R2;
Calc_Data_Sec:
R0 = R1 - R0;
[P1+0x10] = R0;
R0 = B[P0+HIDDEN_SECTORS_LO];
R1 = B[P0+HIDDEN_SECTORS_LO+1];
R1 = R1 << 8;
R0 = R0 | R1;
R1 = B[P0+HIDDEN_SECTORS_HI];
R1 = R1 << 16;
R0 = R0 | R1;
R1 = B[P0+HIDDEN_SECTORS_HI+1];
R1 = R1 << 24;
R0 = R0 | R1;
[P1+0xC] = R0; //R0 = # of Hidden Sectors
RTS;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -