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

📄 node.c

📁 老外写的一个文件系统
💻 C
字号:
#include "Platform.h"
#include "Debug/Debug.h"
#include "FileSystem/Fat32/FileTree/Node.h"

unsigned short GetPage(FileNodeHandle h) NAKED
{
	h;
//	return (unsigned short)h;	// the compiler generates an ungodly amount of code for this simple task...
	_asm
		// input: A/B/DPH/DPL == h.  we want the bottom two bytes as the return value,
		// and they are already assigned to DPH/DPL!!!!  so just return!
		ret
	_endasm;
}

unsigned char GetIndexChar(FileNodeHandle h) NAKED
{
	h;
//	return (unsigned char)(h>>16);	// the compiler generates an ungodly amount of code for this simple task...
	_asm
		// input: A/B/DPH/DPL == h.  we want the upper two bytes casted to a char, as the return value
		mov dpl, b	// all we need to do is transfer the index (0..255) into dpl.
		ret
	_endasm;
}

unsigned short GetOffsetShort(FileNodeHandle h) NAKED
{
	h;
//	return (unsigned short)(h>>16);	// the compiler generates an ungodly amount of code for this simple task...
	_asm
		// input: A/B/DPH/DPL == h.  we want the upper two bytes casted to a char, as the return value
		mov dph, a	// all we need to do is transfer the index (0..4095) into dptr.
		mov dpl, b	// all we need to do is transfer the index (0..4095) into dptr.
		ret
	_endasm;
}

FileNodeHandle MakeHandle(DramPageIndex page, unsigned short index) NAKED
{
	page;
	index;
//	return (((unsigned long)index)<<16) | page;	// the compiler generates an ungodly amount of code for this simple task...
	_asm
		// input: DPH/DPL == page already!! All we need to do to make a complete handle is tack-on the index!
		push dph
		push dpl
		mov dptr,#_MakeHandle_PARM_2
		movx a, @dptr
		mov b, a
		inc dptr
		movx a, @dptr
		pop dpl
		pop dph
		ret
	_endasm;
}

_CONSTANT_DATA(NODE)

⌨️ 快捷键说明

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