📄 insertvalue.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: chazhi.asm
// Programmer: Zhifa Lee (email: zhifa/sunnorth) (ext: 2913)
// Version: 1.0.0
// Date: 2003-5-30
// Applied body: unsp serial
// Description:
// Revision history:
// ----------------------------------------------------------------------------------------
// Version, YYYY-MM-DD-Index, File-Name: Modified By, Description
// ----------------------------------------------------------------------------------------
//
//============================================================
.include chazhi.inc
.external __subf2;
.external __divf2;
.external __addf2;
.external __mulf2;
.code
//======================================================
// 程序名称: F_LinearInsert
// 功能描述: 计算(x-x0)x(y1-y0)/(x1-x0)+y0,实现线性插值算法.
// 输入: 浮点数x0,y0,x1,y1,x
// 输出: 浮点数y->r1,r2
// 破坏: r1,r2,r3,r4;
// 使用: r1,r2,r3,r4,bp,sp;
// 占用堆栈: 14;
//======================================================
.public F_LinearInsert;
.public _F_LinearInsert;
.code
F_LinearInsert:
_F_LinearInsert: .proc
push bp to [sp];
bp=sp;
bp+=4; //bp指向参数x0
M_GetValue 0; //取x0
push r3,r4 to [sp];
M_GetValue 4; //取x
push r3,r4 to [sp];
call __subf2; //计算x-x0
sp+=4;
M_StoreValue 4; //x-x0存入参数x
M_GetValue 1; //取 y0
push r3,r4 to [sp];
M_GetValue 3; //取 y1
push r3,r4 to [sp];
call __subf2; //计算y1-y0
sp+=4;
M_StoreValue 3; //y1-y0存入参数y1
M_GetValue 0; //取 x0
push r3,r4 to [sp];
M_GetValue 2; //取 x1
push r3,r4 to [sp];
call __subf2; //计算x1-x0
sp+=4;
M_StoreValue 2; //x1-x0存入参数x1
M_GetValue 4; //取 x,即x-x0
push r3,r4 to [sp];
M_GetValue 3; //取 y1,即y1-y0
push r3,r4 to [sp];
call __mulf2; //计算(x-x0)x(y1-y0)
sp+=4;
M_StoreValue 4; //(x-x0)x(y1-y0)存入参数x
M_GetValue 2; //取 x1,即x1-x0
push r3,r4 to [sp];
M_GetValue 4; //取 x,即(x-x0)x(y1-y0)
push r3,r4 to [sp];
call __divf2; //计算(x-x0)x(y1-y0)/(x1-x0)
sp+=4;
push r1,r2 to [sp];
M_GetValue 1; //取 y0
push r3,r4 to [sp];
call __addf2; //计算(x-x0)x(y1-y0)/(x1-x0)+y0
sp+=4;
pop bp from [sp];
retf;
.endp
//======================================================
// 程序名称: F_QuadraticInsert
// 功能描述: 实现逐次线性插值算法:
// 1、计算L01=y0+(y1-y0)(x-x0)/(x1-x0)
// 2、计算L02=y0+(y2-y0)(x-x0)/(x2-x0)
// 3、计算L012=L01+(L02-L01)(x-x1)/(x2-x1)
// 输入: 浮点数x0,y0,x1,y1,x2,y2,x
// 输出: 浮点数y->r1,r2
// 破坏: r1,r2,r3,r4;
// 使用: r1,r2,r3,r4,bp,sp;
// 占用堆栈: 28;
//======================================================
.public F_QuadraticInsert;
.public _F_QuadraticInsert;
F_QuadraticInsert:
_F_QuadraticInsert: .proc
push bp to [sp];
bp=sp+4; //bp指向参数x0
M_GetValue 6; //取 x
push r3,r4 to [sp];
M_GetValue 3; //取 y1
push r3,r4 to [sp];
M_GetValue 2; //取 x1
push r3,r4 to [sp];
M_GetValue 1; //取 y0
push r3,r4 to [sp];
M_GetValue 0; //取 x0
push r3,r4 to [sp];
call F_LinearInsert; //计算 L01
sp+=10;
M_StoreValue 3; //L01存入y1
M_GetValue 6; //取 x
push r3,r4 to [sp];
M_GetValue 5; //取 y2
push r3,r4 to [sp];
M_GetValue 4; //取 x2
push r3,r4 to [sp];
M_GetValue 1; //取 y0
push r3,r4 to [sp];
M_GetValue 0; //取 x0
push r3,r4 to [sp];
call F_LinearInsert; //计算 L02
sp+=10;
M_StoreValue 5; //L02存入y2
M_GetValue 6; //取 x
push r3,r4 to [sp];
M_GetValue 5; //取 L02
push r3,r4 to [sp];
M_GetValue 4; //取 x2
push r3,r4 to [sp];
M_GetValue 3; //取 L01
push r3,r4 to [sp];
M_GetValue 2; //取 x1
push r3,r4 to [sp];
call F_LinearInsert; //计算 L012
sp+=10;
pop bp from [sp];
retf;
.endp
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -