calc_chs.asm

来自「ADI BF DSP的CF卡的读写源码」· 汇编 代码 · 共 34 行

ASM
34
字号

/************************************************************************************************/
/*	The following routine initializes 6 8-bit register values for the compact flash card which 	*/
/*	are packed in 3 16-bit registers.  The 28-bit LBA Address (expected in R0) will be divided	*/
/*	into a Sector number (LBA7 - LBA0), a Cylinder LO number (LBA8 - LBA15), a Cylinder HI		*/
/*	number (LBA16 - LBA23), and a Head number (LBA24 - LBA27).  In addition, the Sector Count	*/
/*	register will be set to 1 and the Command register will be set to 0x20 to issue a Read		*/
/*	Sector Command.																				*/
/*															  Last Modified 02-26-03.  H. Desai */  
/************************************************************************************************/

.GLOBAL Calc_CHS;

.SECTION program;

Calc_CHS:

	R1 = R0 << 8;					//R0 holds LBA Address
	R2 = 0x0001(Z);
	R1 = R1 | R2;					//Sector Number(LBA7 - LBA0) | Sector Count
	R1.H = 0x0000;
	
	R2 = R0 >> 8;					//Cylinder HI (LBA23 - LBA16) | Cylinder LO (LBA15 - LBA8)
	R2.H = 0x0000;
	
	R3.H = 0x0F00;
	R3.L = 0x0000;
	R3 = R0 & R3;
	R3 = R3 >> 24;
	R4 = 0x20E0(Z);					//Bit 6 indicates that we are doing LBA addressing
	R3 = R3 | R4;					//Read Command | Head Number (LBA27 - LBA24)
	
	RTS;

⌨️ 快捷键说明

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