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

📄 led-8-2.s

📁 16个单片机c语言实验程序
💻 S
📖 第 1 页 / 共 2 页
字号:
	.module led-8-2.c
	.area text(rom, con, rel)
	.dbfile E:\16实验程序\数码管显示2\led-8-2.c
	.dbfile E:\16实验程序\数码管显示2\encoder.h
	.dbfunc e encoder _encoder fc
;           code -> R20
;            num -> R16
	.even
_encoder::
	xcall push_xgsetF000
	.dbline -1
	.dbline 3
; //数码管显示程序
; #define uchar unsigned char 
; #define uint unsigned int 
	.dbline 5
; #include<iom16v.h>
; //7段译码
	mov R22,R16
	clr R23
	cpi R22,0
	cpc R22,R23
	breq L5
X0:
	cpi R22,1
	ldi R30,0
	cpc R23,R30
	breq L6
X1:
	cpi R22,2
	ldi R30,0
	cpc R23,R30
	breq L7
X2:
	cpi R22,3
	ldi R30,0
	cpc R23,R30
	breq L8
X3:
	cpi R22,4
	ldi R30,0
	cpc R23,R30
	breq L9
X4:
	cpi R22,5
	ldi R30,0
	cpc R23,R30
	breq L10
X5:
	cpi R22,6
	ldi R30,0
	cpc R23,R30
	breq L11
X6:
	cpi R22,7
	ldi R30,0
	cpc R23,R30
	breq L12
X7:
	cpi R22,8
	ldi R30,0
	cpc R23,R30
	breq L13
X8:
	cpi R22,9
	ldi R30,0
	cpc R23,R30
	breq L14
X9:
	xjmp L2
L5:
	.dbline 8
; #include"encoder.h"    
; //写74hc595
; #include"ch595.h"
	ldi R20,192
	.dbline 8
	xjmp L3
L6:
	.dbline 10
; #define ls138a 7
; #define ls138b 6
	ldi R20,249
	.dbline 10
	xjmp L3
L7:
	.dbline 12
; #define ls138c 5
; #define ls138en 4
	ldi R20,164
	.dbline 12
	xjmp L3
L8:
	.dbline 14
; 
; unsigned long a1,a2,a3,a4,a5,a6,a7,a8;
	ldi R20,176
	.dbline 14
	xjmp L3
L9:
	.dbline 16
; 
; //按10进制分解各个位
	ldi R20,153
	.dbline 16
	xjmp L3
L10:
	.dbline 18
; void disa(unsigned long data)
; {
	ldi R20,146
	.dbline 18
	xjmp L3
L11:
	.dbline 20
; a8=data/10000000;
; a7=(data-a8*10000000)/1000000;
	ldi R20,130
	.dbline 20
	xjmp L3
L12:
	.dbline 22
; a6=(data-a8*10000000-a7*1000000)/100000;
; a5=(data-a8*10000000-a7*1000000-a6*100000)/10000;
	ldi R20,248
	.dbline 22
	xjmp L3
L13:
	.dbline 24
; a4=(data-a8*10000000-a7*1000000-a6*100000-a5*10000)/1000;
; a3=(data-a8*10000000-a7*1000000-a6*100000-a5*10000-a4*1000)/100;
	ldi R20,128
	.dbline 24
	xjmp L3
L14:
	.dbline 26
; a2=(data-a8*10000000-a7*1000000-a6*100000-a5*10000-a4*1000-a3*100)/10;
; a1=(data-a8*10000000-a7*1000000-a6*100000-a5*10000-a4*1000-a3*100-a2*10);
	ldi R20,144
	.dbline 26
L2:
L3:
	.dbline 28
; }
; 
	mov R16,R20
	.dbline -2
L1:
	.dbline 0 ; func end
	xjmp pop_xgsetF000
	.dbsym r code 20 c
	.dbsym r num 16 c
	.dbend
	.dbfile E:\16实验程序\数码管显示2\ch595.h
	.dbfunc e s_ms _s_ms fV
;              t -> R16,R17
	.even
_s_ms::
	.dbline -1
	.dbline 8
; //ch595的数据输入
; #define clk  1
; #define rclk 2
; #define dat  3  
; 
; //延时函数
; void s_ms(unsigned int t)
; {
	.dbline 9
;     for(;t>1;t--)
	xjmp L19
L16:
	.dbline 10
;     {
	.dbline 11
;     }
L17:
	.dbline 9
	subi R16,1
	sbci R17,0
L19:
	.dbline 9
	ldi R24,1
	ldi R25,0
	cp R24,R16
	cpc R25,R17
	brlo L16
X10:
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbsym r t 16 i
	.dbend
	.dbfunc e sendbyte _sendbyte fV
;            tem -> R10
;              i -> R22
;           byte -> R20
	.even
_sendbyte::
	xcall push_xgsetF00C
	mov R20,R16
	.dbline -1
	.dbline 15
; }
; //写74hc595函数
; void sendbyte(uchar byte)
; {    
	.dbline 17
;    uchar i,tem; 
;    byte=encoder(byte);       //译码
	mov R16,R20
	xcall _encoder
	mov R20,R16
	.dbline 18
;    for(i=0;i<8;i++)          
	clr R22
	xjmp L24
L21:
	.dbline 19
;         {
	.dbline 20
;          PORTA&=~(1<<clk);
	cbi 0x1b,1
	.dbline 21
;          tem=(byte&0x80);
	mov R24,R20
	andi R24,128
	mov R10,R24
	.dbline 22
; 		 if(tem==0)
	tst R24
	brne L25
X11:
	.dbline 23
; 		   {
	.dbline 24
; 		   PORTA&=~(1<<dat);
	cbi 0x1b,3
	.dbline 25
; 		   }
	xjmp L26
L25:
	.dbline 27
; 		   else
; 		   {
	.dbline 28
; 		   PORTA|=(1<<dat);
	sbi 0x1b,3
	.dbline 29
; 		   }
L26:
	.dbline 30
;          byte=byte<<1;
	lsl R20
	.dbline 31
;          PORTA|=(1<<clk);
	sbi 0x1b,1
	.dbline 32
;          }
L22:
	.dbline 18
	inc R22
L24:
	.dbline 18
	cpi R22,8
	brlo L21
X12:
	.dbline 33
;          PORTA&=~(1<<rclk);
	cbi 0x1b,2
	.dbline 34
; 		 s_ms(100);
	ldi R16,100
	ldi R17,0
	xcall _s_ms
	.dbline 35
;          PORTA|=(1<<rclk);         
	sbi 0x1b,2
	.dbline -2
L20:
	.dbline 0 ; func end
	xjmp pop_xgsetF00C
	.dbsym r tem 10 c
	.dbsym r i 22 c
	.dbsym r byte 20 c
	.dbend
	.dbfile E:\16实验程序\数码管显示2\led-8-2.c
	.dbfunc e disa _disa fV
;           data -> y+6
	.even
_disa::
	xcall push_arg4
	xcall push_xgsetF00C
	.dbline -1
	.dbline 18
	.dbline 19
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	ldd R16,y+6
	ldd R17,y+7
	ldd R18,y+8
	ldd R19,y+9
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall div32u
	sts _a8+1,R17
	sts _a8,R16
	sts _a8+2+1,R19
	sts _a8+2,R18
	.dbline 20
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	st -y,R19
	st -y,R18
	st -y,R17
	st -y,R16
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R2,R16
	movw R4,R18
	ldd R16,y+6
	ldd R17,y+7
	ldd R18,y+8
	ldd R19,y+9
	sub R16,R2
	sbc R17,R3
	sbc R18,R4
	sbc R19,R5
	ldi R20,64
	ldi R21,66
	ldi R22,15
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	xcall div32u
	sts _a7+1,R17
	sts _a7,R16
	sts _a7+2+1,R19
	sts _a7+2,R18
	.dbline 21
	lds R4,_a8+2
	lds R5,_a8+2+1
	lds R2,_a8
	lds R3,_a8+1
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	ldd R2,y+6
	ldd R3,y+7
	ldd R4,y+8
	ldd R5,y+9
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a7+2
	lds R9,_a7+2+1
	lds R6,_a7
	lds R7,_a7+1
	ldi R20,64
	ldi R21,66
	ldi R22,15
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	ldi R20,160
	ldi R21,134
	ldi R22,1
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	sts _a6+1,R17
	sts _a6,R16
	sts _a6+2+1,R19
	sts _a6+2,R18
	.dbline 22
	lds R4,_a8+2
	lds R5,_a8+2+1
	lds R2,_a8
	lds R3,_a8+1
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	ldd R2,y+6
	ldd R3,y+7
	ldd R4,y+8
	ldd R5,y+9
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a7+2
	lds R9,_a7+2+1
	lds R6,_a7
	lds R7,_a7+1
	ldi R20,64
	ldi R21,66
	ldi R22,15
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a6+2
	lds R9,_a6+2+1
	lds R6,_a6
	lds R7,_a6+1
	ldi R20,160
	ldi R21,134
	ldi R22,1
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	ldi R20,16
	ldi R21,39
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	sts _a5+1,R17
	sts _a5,R16
	sts _a5+2+1,R19
	sts _a5+2,R18
	.dbline 23
	lds R4,_a8+2
	lds R5,_a8+2+1
	lds R2,_a8
	lds R3,_a8+1
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	ldd R2,y+6
	ldd R3,y+7
	ldd R4,y+8
	ldd R5,y+9
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a7+2
	lds R9,_a7+2+1
	lds R6,_a7
	lds R7,_a7+1
	ldi R20,64
	ldi R21,66
	ldi R22,15
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a6+2
	lds R9,_a6+2+1
	lds R6,_a6
	lds R7,_a6+1
	ldi R20,160
	ldi R21,134
	ldi R22,1
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a5+2
	lds R9,_a5+2+1
	lds R6,_a5
	lds R7,_a5+1
	ldi R20,16
	ldi R21,39
	ldi R22,0
	ldi R23,0
	st -y,R9
	st -y,R8
	st -y,R7
	st -y,R6
	movw R16,R20
	movw R18,R22
	xcall empy32u
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	ldi R20,232
	ldi R21,3
	ldi R22,0
	ldi R23,0
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall div32u
	sts _a4+1,R17
	sts _a4,R16
	sts _a4+2+1,R19
	sts _a4+2,R18
	.dbline 24
	lds R4,_a8+2
	lds R5,_a8+2+1
	lds R2,_a8
	lds R3,_a8+1
	ldi R20,128
	ldi R21,150
	ldi R22,152
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	ldd R2,y+6
	ldd R3,y+7
	ldd R4,y+8
	ldd R5,y+9
	sub R2,R16
	sbc R3,R17
	sbc R4,R18
	sbc R5,R19
	lds R8,_a7+2
	lds R9,_a7+2+1
	lds R6,_a7
	lds R7,_a7+1
	ldi R20,64
	ldi R21,66
	ldi R22,15
	ldi R23,0

⌨️ 快捷键说明

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