📄 sequentialstore.asm
字号:
//======================================================
// The information contained herein is the exclusive property of
// Sunnnorth Technology Co. And shall not be distributed, reproduced,
// or disclosed in whole in part without prior written permission.
// (C) COPYRIGHT 2003 SUNNORTH TECHNOLOGY CO.
// ALL RIGHTS RESERVED
// The entire notice above must be reproduced on all authorized copies.
//========================================================
//========================================================
// Filename: SequentialStore.asm
// Programmer: Zhifa Lee (email: zhifa/sunnorth) (ext: 2913)
// Version: 1.0.0
// Date: 2003-5-19
// Applied body: unsp serial
// Description:
// Revision history:
// ----------------------------------------------------------------------------------------
// Version, YYYY-MM-DD-Index, File-Name: Modified By, Description
// ----------------------------------------------------------------------------------------
//
//============================================================
.INCLUDE SequentialStore.inc
.CONST C_TreeDepth =5;
.CODE
//======================================================
// Function Name: F_SequentStore_AccessByOrder
// Description: gothrough the tree by order,which be stored in sequential RAM.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r1,r2,r3,r4;
// Used: r1,r2,r3,r4,bp,sp;
// Stacks: 5;
//======================================================
.PUBLIC F_SequentStore_AccessByOrder;
.PUBLIC _F_SequentStore_AccessByOrder;
_F_SequentStore_AccessByOrder: //input parameter:word InputBuf,word OutputBuf
F_SequentStore_AccessByOrder: .PROC
push bp to [sp];
bp=sp+4;
r1=[bp++]; //r1=InputBuf
r2=[bp]; //r2=OutputBuf
r3=[r1++]; //r3=Node Number
jz ?L_ExitFunc;
[r2++]=r3; //output the node number
?L_NextNode:
r4=[r1++]; //Get the Node
jz ?L_NextNode; //Jump the Null Node
[r2++]=r4; //Output the Nonull node
r3-=1; //node Number decrease
jz ?L_ExitFunc;
jmp ?L_NextNode; //get the next node
?L_ExitFunc:
pop bp from [sp];
retf;
.ENDP
//======================================================
// Function Name: F_SequentStore_AccessRootFirst
// Description: gothrough the tree by RootFirst,which be stored in sequential RAM.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r1,r2,r3,r4;
// Used: r1,r2,r3,r4,bp,sp;
// Stacks: 5;
//======================================================
.PUBLIC F_SequentStore_AccessRootFirst;
.PUBLIC _F_SequentStore_AccessRootFirst
F_SequentStore_AccessRootFirst:
_F_SequentStore_AccessRootFirst: .PROC
push bp to [sp];
bp=sp+5;
r2=[bp--]; //r2=OutputBuf
bp=[bp]; //bp=InputBuf
r3=[bp]; //r3=Node Number
jz ?L_ExitFunc;
[r2++]=r3; //output the node number
r1=1; //point to tree root
call F_FirstRootArithmetic; //gothrough the tree by root first
?L_ExitFunc:
pop bp from [sp];
retf;
.ENDP
//======================================================
// Function Name: F_FirstRootArithmetic
// Description: recursive function to access tree.
// Input: r1:current node number
// r2:output pointor
// bp:start address of whole tree
// Output: None
// Destroy: r1,r2,r4;
// Used: r1,r2,r4,bp,sp;
// Stacks: 3*C_TreeDepth;
//======================================================
F_FirstRootArithmetic:
_F_FirstRootArithmetic: .PROC
r4=bp;
r4+=r1;
r4=[r4]; //get the root node
jz ?L_ExitFunc; //Null node,exit
[r2++]=r4; //output the node
M_DegreeNumberCheck C_TreeDepth,r1; //is leaf node?
jae ?L_ExitFunc; //if leaf node,exit
push r1 to [sp]; //store the current node number
r1=r1 lsl 1; //get the left child number
call F_FirstRootArithmetic; //gothrough the left child tree
pop r1 from [sp]; //get the current node number from stack
r1=r1 lsl 1;
r1+=1; //get the right child number
call F_FirstRootArithmetic; //gothrough the rigth child tree
?L_ExitFunc:
retf;
.ENDP
//======================================================
// Function Name: F_SequentStore_AccessRootMid
// Description: gothrough the tree by RootMiddle,which be stored in sequential RAM.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r1,r2,r3,r4;
// Used: r1,r2,r3,r4,bp,sp;
// Stacks: 5;
//======================================================
.PUBLIC F_SequentStore_AccessRootMid;
.PUBLIC _F_SequentStore_AccessRootMid;
F_SequentStore_AccessRootMid:
_F_SequentStore_AccessRootMid: .PROC
push bp to [sp];
bp=sp+5;
r2=[bp--]; //r2=OutputBuf
bp=[bp]; //bp=InputBuf
r3=[bp]; //r3=Node Number
jz ?L_ExitFunc;
[r2++]=r3; //output the node number
r1=1; //point to tree root
call F_MidRootArithmetic; //gothrough the tree by root first
?L_ExitFunc:
pop bp from [sp];
retf;
.ENDP
//======================================================
// Function Name: F_MidRootArithmetic
// Description: recursive function to access tree.
// Input: r1:current node number
// r2:output pointor
// bp:start address of whole tree
// Output: None
// Destroy: r1,r2,r4;
// Used: r1,r2,r4,bp,sp;
// Stacks: 3*C_TreeDepth;
//======================================================
F_MidRootArithmetic:
_F_MidRootArithmetic: .PROC
r4=bp;
r4+=r1;
r4=[r4]; //get the root node
jz ?L_AccessCurrentNode; //Null node,exit
M_DegreeNumberCheck C_TreeDepth,r1; //is leaf node?
jae ?L_AccessCurrentNode; //if leaf node,exit
push r1 to [sp]; //store the current node number
r1=r1 lsl 1; //get the left child number
call F_MidRootArithmetic; //gothrough the left child tree
pop r1 from [sp]; //get the current node number from stack
?L_AccessCurrentNode:
r4=bp;
r4+=r1;
r4=[r4];
[r2++]=r4; //output the node
M_DegreeNumberCheck C_TreeDepth,r1; //is leaf node?
jae ?L_ExitFunc; //if leaf node,exit
r1=r1 lsl 1;
r1+=1; //get the right child number
call F_MidRootArithmetic; //gothrough the rigth child tree
?L_ExitFunc:
retf;
.ENDP
//======================================================
// Function Name: F_SequentStore_AccessRootLast
// Description: gothrough the tree by RootMiddle,which be stored in sequential RAM.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r1,r2,r3,r4;
// Used: r1,r2,r3,r4,bp,sp;
// Stacks: 5;
//======================================================
.PUBLIC F_SequentStore_AccessRootLast;
.PUBLIC _F_SequentStore_AccessRootLast;
F_SequentStore_AccessRootLast:
_F_SequentStore_AccessRootLast: .PROC
push bp to [sp];
bp=sp+5;
r2=[bp--]; //r2=OutputBuf
bp=[bp]; //bp=InputBuf
r3=[bp]; //r3=Node Number
jz ?L_ExitFunc;
[r2++]=r3; //output the node number
r1=1; //point to tree root
call F_LastRootArithmetic; //gothrough the tree by root first
?L_ExitFunc:
pop bp from [sp];
retf;
.ENDP
//======================================================
// Function Name: F_LastRootArithmetic
// Description: recursive function to access tree.
// Input: r1:current node number
// r2:output pointor
// bp:start address of whole tree
// Output: None
// Destroy: r1,r2,r4;
// Used: r1,r2,r4,bp,sp;
// Stacks: 3*C_TreeDepth;
//======================================================
F_LastRootArithmetic:
_F_LastRootArithmetic: .PROC
r4=bp;
r4+=r1;
r4=[r4]; //get the root node
jz ?L_AccessCurrentNode; //Null node,exit
M_DegreeNumberCheck C_TreeDepth,r1; //is leaf node?
jae ?L_AccessCurrentNode; //if leaf node,exit
push r1 to [sp]; //store the current node number
r1=r1 lsl 1; //get the left child number
call F_LastRootArithmetic; //gothrough the left child tree
pop r1 from [sp]; //get the current node number from stack
push r1 to [sp]; //store the current node number
r1=r1 lsl 1;
r1+=1; //get the right child number
call F_LastRootArithmetic; //gothrough the rigth child tree
pop r1 from [sp]; //get the current node number from stack
?L_AccessCurrentNode:
r4=bp;
r4+=r1;
r4=[r4];
[r2++]=r4; //output the node
?L_ExitFunc:
retf;
.ENDP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -