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

📄 spline.s

📁 ssd1325控制器液晶的驱动程序
💻 S
📖 第 1 页 / 共 4 页
字号:
	.module spline.c
	.area text(rom, con, rel)
	.dbfile G:\IccPro\mega128_lcd\ZLG_GUI\spline.c
	.dbfunc e max _max fI
;              b -> R18,R19
;              a -> R16,R17
	.even
_max::
	.dbline -1
	.dbline 19
; /****************************************************************************************
; * 文件名:SPLINE.C
; * 功能:二次参数样条曲线生成程序。
; * 作者:黄绍斌
; * 日期:2003.09.09
; ****************************************************************************************/
; #include  "config.h"
; #include  "math.h"
; 
; 
; /****************************************************************************
; * 名称:max()
; * 功能:求两个整数中最大的整数值。
; * 入口参数:a			整数1
; *          b		整数2
; * 出口参数:返回最大的整数值
; ****************************************************************************/
; int  max(int a, int b)
; {  if(a>b) return(a);
	.dbline 19
	cp R18,R16
	cpc R19,R17
	brge L8
	.dbline 19
	xjmp L7
L8:
	.dbline 20
;      else  return(b);
	movw R16,R18
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbsym r b 18 I
	.dbsym r a 16 I
	.dbend
	.dbfunc e abs _abs fI
;              a -> R16,R17
	.even
_abs::
	.dbline -1
	.dbline 30
; }
; 
; /****************************************************************************
; * 名称:abs()
; * 功能:求一个整数的绝对值。
; * 入口参数:a			取绝对值的数据
; * 出口参数:返回a的绝对值
; ****************************************************************************/
; int  abs(int a)
; {  if(a>0) return(a);
	.dbline 30
	clr R2
	clr R3
	cp R2,R16
	cpc R3,R17
	brge L11
	.dbline 30
	xjmp L10
L11:
	.dbline 31
;      else  return(-a);
	com R16
	com R17
	subi R16,0xFF
	sbci R17,0xFF
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbsym r a 16 I
	.dbend
	.dbfunc e CURVE_SetCurve _CURVE_SetCurve fV
;             cy -> y+22
;             cx -> y+18
;             by -> y+14
;             bx -> y+10
;             ay -> y+6
;             ax -> y+2
;             cl -> R20,R21
	.even
_CURVE_SetCurve::
	st -y,r19
	st -y,r18
	xcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 63
; }
; 
; 
; 
; /* 曲线类变量及相关函数 */
; typedef  struct
; {  float  	Ax, Ay;			// 定义A、B、C点坐标变量
;    float  	Bx, By;
;    float  	Cx, Cy;
;    
;    int    	Ndiv;			// 定义曲线平滑参数变量     
; } CURVE;  
; 
; #define  DIV_FACTOR 		8.0				/* 平滑控制参数 */
; /****************************************************************************
; * 名称:CURVE_SetCurve()
; * 功能:设置三点曲线参数。
; * 入口参数:	cl		要操作的曲线对象,CURVE结构
; *           ax		a点x坐标值
; *           ay		a点y坐标值
; *			bx		b点x坐标值
; *           by		b点y坐标值
; *			cx		c点x坐标值
; *           cy		c点y坐标值
; * 出口参数:无
; * 说明:
; ****************************************************************************/
; void  CURVE_SetCurve(CURVE *cl,
;                      float ax, float ay, 
;                		 float bx, float by,
;                		 float cx, float cy) 
; {  cl->Ax = ax;
	.dbline 63
	movw R30,R28
	ldd R2,z+2
	ldd R3,z+3
	ldd R4,z+4
	ldd R5,z+5
	movw R30,R20
	std z+0,R2
	std z+1,R3
	std z+2,R4
	std z+3,R5
	.dbline 64
;    cl->Ay = ay;
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	movw R30,R20
	std z+4,R2
	std z+5,R3
	std z+6,R4
	std z+7,R5
	.dbline 65
;    cl->Bx = bx; 
	movw R30,R28
	ldd R2,z+10
	ldd R3,z+11
	ldd R4,z+12
	ldd R5,z+13
	movw R30,R20
	std z+8,R2
	std z+9,R3
	std z+10,R4
	std z+11,R5
	.dbline 66
;    cl->By = by;
	movw R30,R28
	ldd R2,z+14
	ldd R3,z+15
	ldd R4,z+16
	ldd R5,z+17
	movw R30,R20
	std z+12,R2
	std z+13,R3
	std z+14,R4
	std z+15,R5
	.dbline 67
;    cl->Cx = cx; 
	movw R30,R28
	ldd R2,z+18
	ldd R3,z+19
	ldd R4,z+20
	ldd R5,z+21
	movw R30,R20
	std z+16,R2
	std z+17,R3
	std z+18,R4
	std z+19,R5
	.dbline 68
;    cl->Cy = cy;
	movw R30,R28
	ldd R2,z+22
	ldd R3,z+23
	ldd R4,z+24
	ldd R5,z+25
	movw R30,R20
	std z+20,R2
	std z+21,R3
	std z+22,R4
	std z+23,R5
	.dbline 70
;    
;    cl->Ndiv = (int)(max( abs((int)ax), abs((int)ay) ) / DIV_FACTOR);
	movw R30,R28
	ldd R16,z+2
	ldd R17,z+3
	ldd R18,z+4
	ldd R19,z+5
	xcall fp2int
	xcall _abs
	movw R2,R16
	movw R30,R28
	ldd R16,z+6
	ldd R17,z+7
	ldd R18,z+8
	ldd R19,z+9
	xcall fp2int
	push R2
	push R3
	xcall _abs
	pop R3
	pop R2
	movw R18,R16
	movw R16,R2
	xcall _max
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	ldi R16,<L15
	ldi R17,>L15
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32f
	xcall fp2int
	movw R30,R20
	std z+25,R17
	std z+24,R16
	.dbline -2
L14:
	xcall pop_gset1
	adiw R28,2
	.dbline 0 ; func end
	ret
	.dbsym l cy 22 D
	.dbsym l cx 18 D
	.dbsym l by 14 D
	.dbsym l bx 10 D
	.dbsym l ay 6 D
	.dbsym l ax 2 D
	.dbsym r cl 20 pX
	.dbend
	.dbfunc e CURVE_GetCount _CURVE_GetCount fI
;             cl -> R16,R17
	.even
_CURVE_GetCount::
	.dbline -1
	.dbline 82
; }
; 
; 
; /****************************************************************************
; * 名称:CURVE_GetCount()
; * 功能:取出平滑参数Ndiv+1的值。
; * 入口参数:cl		要操作的曲线对象,CURVE结构
; * 出口参数:返回Ndiv+1的值
; * 说明:若Ndiv为0,则先设置其为1。
; ****************************************************************************/
; int  CURVE_GetCount(CURVE *cl)
; {  if(0 == cl->Ndiv) cl->Ndiv=1;
	.dbline 82
	movw R30,R16
	ldd R2,z+24
	ldd R3,z+25
	tst R2
	brne L17
	tst R3
	brne L17
X0:
	.dbline 82
	ldi R24,1
	ldi R25,0
	movw R30,R16
	std z+25,R25
	std z+24,R24
L17:
	.dbline 84
; 
;    return(cl->Ndiv+1);
	movw R30,R16
	ldd R16,z+24
	ldd R17,z+25
	subi R16,255  ; offset = 1
	sbci R17,255
	.dbline -2
L16:
	.dbline 0 ; func end
	ret
	.dbsym r cl 16 pX
	.dbend
	.dbfunc e CURVE_GetCurve _CURVE_GetCurve fV
;              Y -> R10,R11
;              X -> R12,R13
;              h -> y+12
;              g -> y+8
;              f -> y+4
;              i -> R14,R15
;              t -> y+0
;     PointCount -> R20,R21
;         points -> R22,R23
;              y -> y+34
;              x -> y+30
;             cl -> R6,R7
	.even
_CURVE_GetCurve::
	st -y,r19
	st -y,r18
	xcall push_gset5
	movw R6,R16
	sbiw R28,20
	ldd R22,y+38
	ldd R23,y+39
	ldd R20,y+40
	ldd R21,y+41
	.dbline -1
	.dbline 100
; }
; 
; 
; /****************************************************************************
; * 名称:CURVE_GetCurve()
; * 功能:增加曲线点到points。
; * 入口参数:cl			要操作的曲线对象,CURVE结构
; *          x			新增点的x坐标值
; *		   y 			新增点的y坐标值
; *		   points		曲线点缓冲区
; *          PointCount	缓冲区的当前指针
; * 出口参数:无
; * 说明:
; ****************************************************************************/
; void  CURVE_GetCurve(CURVE *cl, float x, float y, PointXY points[], int *PointCount)
; {  int    X, Y;
	.dbline 104
;    float  t, f, g, h;
;    int    i;
; 
;    if(cl->Ndiv==0)  cl->Ndiv = 1;
	movw R30,R6
	ldd R2,z+24
	ldd R3,z+25
	tst R2
	brne L20
	tst R3
	brne L20
X1:
	.dbline 104
	ldi R24,1
	ldi R25,0
	movw R30,R6
	std z+25,R25
	std z+24,R24
L20:
	.dbline 107
; 
;     /* 新增一个点到结构 */
; 	X = (int)x; 
	movw R30,R28
	ldd R16,z+30
	ldd R17,z+31
	ldd R18,z+32
	ldd R19,z+33
	xcall fp2int
	movw R12,R16
	.dbline 108
; 	Y = (int)y;
	movw R30,R28
	ldd R16,z+34
	ldd R17,z+35
	ldd R18,z+36
	ldd R19,z+37
	xcall fp2int
	movw R10,R16
	.dbline 109
; 	points[*PointCount].x = X;
	movw R30,R20
	ldd R18,z+0
	ldd R19,z+1
	ldi R16,4
	ldi R17,0
	xcall empy16s
	movw R30,R16
	add R30,R22
	adc R31,R23
	std z+1,R13
	std z+0,R12
	.dbline 110
; 	points[*PointCount].y = Y;
	movw R30,R20
	ldd R18,z+0
	ldd R19,z+1
	ldi R16,4
	ldi R17,0
	xcall empy16s
	movw R30,R16
	add R30,R22
	adc R31,R23
	std z+3,R11
	std z+2,R10
	.dbline 111
; 	(*PointCount)++;
	movw R30,R20
	ldd R24,z+0
	ldd R25,z+1
	adiw R24,1
	std z+1,R25
	std z+0,R24
	.dbline 114
; 
;     /* 变换出ndiv个点 */
; 	for(i=1; i<=cl->Ndiv; i++)
	ldi R24,1
	ldi R25,0
	movw R14,R24
	xjmp L25
L22:
	.dbline 115
	.dbline 115
	ldi R16,<L26
	ldi R17,>L26
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R30,R6
	ldd R16,z+24
	ldd R17,z+25
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall div32fs
	movw R16,R14
	xcall int2fp
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall empy32f
	movw R30,R28
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	.dbline 116
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 4
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	ldi R16,<L27
	ldi R17,>L27
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	ldi R16,<L28
	ldi R17,>L28
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R30,R28
 ; stack offset 12
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall sub32fs
	xcall empy32f
	movw R30,R28
	std z+4,R16
	std z+5,R17
	std z+6,R18
	std z+7,R19
	.dbline 117
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L26
	ldi R17,>L26
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32f
	movw R30,R28
	std z+16,R16
	std z+17,R17
	std z+18,R18
	std z+19,R19
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 4
	ldd R2,z+20
	ldd R3,z+21
	ldd R4,z+22
	ldd R5,z+23
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	movw R30,R28
 ; stack offset 4
	ldd R2,z+20
	ldd R3,z+21
	ldd R4,z+22
	ldd R5,z+23
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32f
	movw R30,R28
	std z+8,R16
	std z+9,R17
	std z+10,R18
	std z+11,R19
	.dbline 118
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 4
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	movw R30,R28
 ; stack offset 4
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	ldi R16,<L26
	ldi R17,>L26
	xcall lpm32
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	xcall sub32fs
	xcall empy32f
	movw R30,R28
	std z+12,R16
	std z+13,R17
	std z+14,R18
	std z+15,R19
	.dbline 120
	movw R30,R28
	ldd R2,z+30
	ldd R3,z+31
	ldd R4,z+32
	ldd R5,z+33
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R6
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32fs
	movw R30,R6
	ldd R2,z+8
	ldd R3,z+9
	ldd R4,z+10
	ldd R5,z+11
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32fs
	movw R30,R6
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+20
	ldd R3,z+21
	ldd R4,z+22
	ldd R5,z+23
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32f
	xcall fp2int
	movw R12,R16
	.dbline 121
	movw R30,R28
	ldd R2,z+34
	ldd R3,z+35
	ldd R4,z+36
	ldd R5,z+37
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R6
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32fs
	movw R30,R6
	ldd R2,z+12
	ldd R3,z+13
	ldd R4,z+14
	ldd R5,z+15
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+16
	ldd R3,z+17
	ldd R4,z+18
	ldd R5,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32fs
	movw R30,R6
	ldd R2,z+20
	ldd R3,z+21
	ldd R4,z+22
	ldd R5,z+23
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R30,R28
 ; stack offset 8
	ldd R2,z+20
	ldd R3,z+21
	ldd R4,z+22
	ldd R5,z+23
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32fs
	xcall add32f
	xcall fp2int
	movw R10,R16
	.dbline 123
	movw R30,R20
	ldd R18,z+0
	ldd R19,z+1
	ldi R16,4
	ldi R17,0
	xcall empy16s
	movw R30,R16
	add R30,R22
	adc R31,R23
	std z+1,R13
	std z+0,R12
	.dbline 124
	movw R30,R20
	ldd R18,z+0
	ldd R19,z+1
	ldi R16,4
	ldi R17,0
	xcall empy16s
	movw R30,R16
	add R30,R22
	adc R31,R23
	std z+3,R11
	std z+2,R10
	.dbline 125
	movw R30,R20

⌨️ 快捷键说明

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