📄 childpointor.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: ChildPointor.asm
// Programmer: Zhifa Lee (email: zhifa/sunnorth) (ext: 2913)
// Version: 1.0.0
// Date: 2003-5-20
// Applied body: unsp serial
// Description:
// Revision history:
// ----------------------------------------------------------------------------------------
// Version, YYYY-MM-DD-Index, File-Name: Modified By, Description
// ----------------------------------------------------------------------------------------
//
//============================================================
//======================================================
// Function Name: F_ChildPointor_AccessRootFirst
// Description: gothrough the tree by RootFirst,which be stored in linked table with child pointor.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r2,r4;
// Used: r2,r4,bp,sp;
// Stacks: 5+3*C_TreeDepth;
//======================================================
.INCLUDE ChildPointor.inc
.CODE
.PUBLIC F_ChildPointor_AccessRootFirst;
.PUBLIC _F_ChildPointor_AccessRootFirst
F_ChildPointor_AccessRootFirst:
_F_ChildPointor_AccessRootFirst: .PROC
push bp to [sp];
bp=sp+5;
r2=[bp--]; //r2=OutputBuf
bp=[bp]; //bp=InputBuf
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: r2:output pointor
// bp:current node address
// Output: None
// Destroy: r2,r4,bp;
// Used: r2,r4,bp,sp;
// Stacks: 3*C_TreeDepth;
//======================================================
F_FirstRootArithmetic:
_F_FirstRootArithmetic: .PROC
r4=[bp]; //get the root node
[r2++]=r4; //output the node
push bp to [sp]; //store the current node address
bp=[bp+CONTENT_SIZE]; //get the left child pointor
jz ?L_FindRightChildPointor;
call F_FirstRootArithmetic; //gothrough the left child tree
?L_FindRightChildPointor:
pop bp from [sp]; //get the current node address from stack
bp=[bp+CONTENT_SIZE+1]; //get the right child pointor
jz ?L_ExitFunc;
call F_FirstRootArithmetic; //gothrough the rigth child tree
?L_ExitFunc:
retf;
.ENDP
//======================================================
// Function Name: F_ChildPointor_AccessRootMid
// Description: gothrough the tree by RootMiddle,which be stored in linked table with child pointor.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r2,r4;
// Used: r2,r4,bp,sp;
// Stacks: 5+3*C_TreeDepth;;
//======================================================
.PUBLIC F_ChildPointor_AccessRootMid;
.PUBLIC _F_ChildPointor_AccessRootMid;
F_ChildPointor_AccessRootMid:
_F_ChildPointor_AccessRootMid: .PROC
push bp to [sp];
bp=sp+5;
r2=[bp--]; //r2=OutputBuf
bp=[bp]; //bp=InputBuf
call F_MidRootArithmetic; //gothrough the tree by root middle
?L_ExitFunc:
pop bp from [sp];
retf;
.ENDP
//======================================================
// Function Name: F_MidRootArithmetic
// Description: recursive function to access tree.
// Input: r2:output pointor
// bp:current node address
// Output: None
// Destroy: r2,r4;
// Used: r2,r4,bp,sp;
// Stacks: 3*C_TreeDepth;
//======================================================
F_MidRootArithmetic:
_F_MidRootArithmetic: .PROC
push bp to [sp]; //store the current node address
bp=[bp+CONTENT_SIZE]; //get the left child pointor
jz ?L_FindRightChildPointor;
call F_MidRootArithmetic; //gothrough the left child tree
?L_FindRightChildPointor:
pop bp from [sp]; //get the current node address from stack
r4=[bp];
[r2++]=r4; //output the node
bp=[bp+CONTENT_SIZE+1]; //get the right child pointor
jz ?L_ExitFunc;
call F_MidRootArithmetic; //gothrough the rigth child tree
?L_ExitFunc:
retf;
.ENDP
//======================================================
// Function Name: F_ChildPointor_AccessRootLast
// Description: gothrough the tree by RootMiddle,which be stored in linked table with child pointor.
// Input: InputBuf Address,OutputBuf Address;push the parameter in stack.
// Output: None
// Destroy: r2,r4;
// Used: r2,r4,bp,sp;
// Stacks: 5+3*C_TreeDepth;
//======================================================
.PUBLIC F_ChildPointor_AccessRootLast;
.PUBLIC _F_ChildPointor_AccessRootLast;
F_ChildPointor_AccessRootLast:
_F_ChildPointor_AccessRootLast: .PROC
push bp to [sp];
bp=sp+5;
r2=[bp--]; //r2=OutputBuf
bp=[bp]; //bp=InputBuf
call F_LastRootArithmetic; //gothrough the tree by root last
?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: r2,r4;
// Used: r2,r4,bp,sp;
// Stacks: 3*C_TreeDepth;
//======================================================
F_LastRootArithmetic:
_F_LastRootArithmetic: .PROC
push bp to [sp]; //store the current node address
bp=[bp+CONTENT_SIZE]; //get the left child pointor
jz ?L_RightChild;
call F_LastRootArithmetic; //gothrough the left child tree
?L_RightChild:
pop bp from [sp]; //get the current node address from stack
push bp to [sp]; //store the current node address
bp=[bp+CONTENT_SIZE+1]; //get the right child pointor
jz ?L_AccessCurrentNode;
call F_LastRootArithmetic; //gothrough the rigth child tree
?L_AccessCurrentNode:
pop bp from [sp]; //get the current node address from stack
r4=[bp];
[r2++]=r4; //output the node
retf;
.ENDP
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -