⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 next_cluster.asm

📁 ADI BF DSP的CF卡的读写源码
💻 ASM
字号:


/************************************************************************************************/
/*	This routine updates the current cluster number with the next cluster number from the		*/
/*	cluster buffer.  The cluster buffer is read from the FAT16 table and is of size 512 (size	*/
/*	of a sector).  When the last cluster is read from the cluster buffer, the					*/
/*	Get_Sector_of_Clusters routine reloads the cluster buffer with the next set of clusters		*/
/*	from the FAT16 table.  If we reach the end of the MP3 song, the routine jumps to the next	*/
/*	MP3 starting cluster.																		*/
/*															  Last Modified 02-26-03.  H. Desai */
/************************************************************************************************/

#include "Boot_Sector_Parameters.h"

.GLOBAL Get_Next_Cluster;
.GLOBAL Get_Sector_of_Clusters;
.EXTERN Current_Cluster;
.EXTERN Paramters;
.EXTERN Boot_Sector;
.EXTERN Calc_CHS;
.EXTERN Clusters;
.EXTERN Parameters;
.EXTERN Read_Sector_CF;
.EXTERN Save_IMASK;
.EXTERN Next_MP3;
.EXTERN Sectors_Left;

.SECTION program;

Get_Sector_of_Clusters:
R7 = RETS;
P0.H = Current_Cluster;
P0.L = Current_Cluster;
R0 = W[P0](Z);						//Get Current Cluster #
P0.H = Boot_Sector;
P0.L = Boot_Sector;
R1 = B[P0+RESV_SEC_COUNT];
R2 = B[P0+RESV_SEC_COUNT+1];
R2 = R2 << 8;
R1 = R1 | R2;						//R1 = Start of FAT1
P1.H = Parameters;
P1.L = Parameters;
R2 = [P1+0xC];						//R2 = # of Hidden Sectors
R1 = R1 + R2;						//R1 = Offset of FAT1 plus Hidden Sectors

R0 = R0 >> 8;						//Divide Cluster # by 256 (256 Clusters per Sector)

R0 = R0 + R1;						//Cluster Sector

CALL Calc_CHS;

I0.H = Clusters;
I0.L = Clusters;
L0 = 0x200;
B0 = I0;

Call Read_Sector_CF;

RETS = R7;
RTS;

Get_Next_Cluster:
R5 = RETS;
P0.H = Current_Cluster;
P0.L = Current_Cluster;
R0 = W[P0](Z);						//Current Cluster #

P3.H = Parameters;
P3.L = Parameters;
R1 = [P3+0x14];
P3.H = Sectors_Left;
P3.L = Sectors_Left;
W[P3] = R1;							//Initialize Sectors_Left to # of sectors per cluster (for use with large CFs)

R1 = 0xFF(Z);
R1 = R0 & R1;						//Extract lower 16 bits from Cluster #
R1 <<= 1;							//Multiply by 2 because each Cluster # occupies 2 bytes (FAT16)
P1 = R1;							//P1 = offset in Clusters[] Buffer

P2.H = Clusters;
P2.L = Clusters;
P1 = P1 + P2;
R3 = W[P1](Z);						//Next Cluster #

R2 = 0xFFFF(Z);						//R2 = End Of File
cc = R3 == R2;
IF !cc JUMP Update_Cluster;

EOF:
JUMP Next_MP3;

Update_Cluster:
W[P0] = R3;							//Update Current Cluster #

R0 >>= 8;
R3 >>= 8;

cc = R0 == R3;						//Check if next Cluster is in same FAT Sector
IF cc JUMP Same_FAT_Sector;

CALL Get_Sector_of_Clusters;		//If not, update Clusters[] buffer

Same_FAT_Sector:
RETS = R5;
RTS;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -