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

📄 led.s

📁 使用Atmel88芯片实现RS485通讯,Modbus通讯协议.在IVR_AVR环境中编译,文件完整.
💻 S
字号:
	.module led.c
	.area text(rom, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
	.dbfunc e light_0 _light_0 fV
	.even
_light_0::
	.dbline -1
	.dbline 17
; //LED device
; #include <iom48v.h>
; #include <macros.h>
; #include "main.h"
; #include "modbus.h"
; #include "timer2.h"   
; 
; static char aloneD[4];
; 
; //led
; void (*pcled[10])(void);  //定义函数指针数组.
; unsigned int LedShowLink;
; 
; // PB0  PB1  PB2  PB3  PB4  PB5  PD6  PD7
; //  A    B    C    D    E    F    G   dp
; void light_0(void)
; {
	.dbline 19
;      //0000'0011
;  	PORTB &= 0xc0;
	in R24,0x5
	andi R24,192
	out 0x5,R24
	.dbline 20
; 	PORTD |= 0x40; 
	sbi 0xb,6
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_1 _light_1 fV
	.even
_light_1::
	.dbline -1
	.dbline 24
; }
; 
; void light_1(void)
; {    //0010'0101
	.dbline 25
; 	 PORTB &= 0b11111001;
	in R24,0x5
	andi R24,249
	out 0x5,R24
	.dbline 26
;  	 PORTB |= 0b00111001;
	in R24,0x5
	ori R24,57
	out 0x5,R24
	.dbline 27
; 	 PORTD |= 0b01000000;
	sbi 0xb,6
	.dbline -2
L6:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_2 _light_2 fV
	.even
_light_2::
	.dbline -1
	.dbline 31
; }
; 
; void light_2(void)
; {    //0010'0101
	.dbline 32
;  	 PORTB &= 0b11100100;
	in R24,0x5
	andi R24,228
	out 0x5,R24
	.dbline 33
; 	 PORTB |= 0b00100100;
	in R24,0x5
	ori R24,36
	out 0x5,R24
	.dbline 34
; 	 PORTD &= 0b10111111;
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L7:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_3 _light_3 fV
	.even
_light_3::
	.dbline -1
	.dbline 38
; }
; 
; void light_3(void)
; {    //0000'1101
	.dbline 39
; 	 PORTB &= 0b11110000;
	in R24,0x5
	andi R24,240
	out 0x5,R24
	.dbline 40
; 	 PORTB |= 0b00110000;
	in R24,0x5
	ori R24,48
	out 0x5,R24
	.dbline 41
; 	 PORTD &= 0b10111111;
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L8:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_4 _light_4 fV
	.even
_light_4::
	.dbline -1
	.dbline 45
; }
; 
; void light_4(void)
; {	 //1001'1001
	.dbline 46
; 	 PORTB &= 0b11011001;
	in R24,0x5
	andi R24,217
	out 0x5,R24
	.dbline 47
; 	 PORTB |= 0b00011001;
	in R24,0x5
	ori R24,25
	out 0x5,R24
	.dbline 48
; 	 PORTD &= 0b10111111; 	 
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L9:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_5 _light_5 fV
	.even
_light_5::
	.dbline -1
	.dbline 52
; }
; 
; void light_5(void)
; {	 //01001001
	.dbline 53
;  	 PORTB &= 0b11010010;
	in R24,0x5
	andi R24,210
	out 0x5,R24
	.dbline 54
; 	 PORTB |= 0b00010010;
	in R24,0x5
	ori R24,18
	out 0x5,R24
	.dbline 55
;  	 PORTD &= 0b10111111; 	
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L10:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_6 _light_6 fV
	.even
_light_6::
	.dbline -1
	.dbline 59
; }
; 
; void light_6(void)
; {   //01000001
	.dbline 60
; 	 PORTB &= 0b11000010;
	in R24,0x5
	andi R24,194
	out 0x5,R24
	.dbline 61
; 	 PORTB |= 0b00000010;
	sbi 0x5,1
	.dbline 62
;  	 PORTD &= 0b10111111;
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_7 _light_7 fV
	.even
_light_7::
	.dbline -1
	.dbline 66
; }
; 
; void light_7(void)
; {   //00011111
	.dbline 67
; 	 PORTB &= 0b11111000;
	in R24,0x5
	andi R24,248
	out 0x5,R24
	.dbline 68
; 	 PORTB |= 0b00111000;
	in R24,0x5
	ori R24,56
	out 0x5,R24
	.dbline 69
;  	 PORTD |= 0b01000000;
	sbi 0xb,6
	.dbline -2
L12:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_8 _light_8 fV
	.even
_light_8::
	.dbline -1
	.dbline 73
; }
; 
; void light_8(void)
; {   //00000001
	.dbline 74
; 	PORTB &= 0b11000000;
	in R24,0x5
	andi R24,192
	out 0x5,R24
	.dbline 76
; 	//
;  	PORTD &= 0b10111111; 
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L13:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e light_9 _light_9 fV
	.even
_light_9::
	.dbline -1
	.dbline 80
; }
; 
; void light_9(void)
; {    //00001001
	.dbline 81
; 	 PORTB &= 0b11010000;
	in R24,0x5
	andi R24,208
	out 0x5,R24
	.dbline 82
; 	 PORTB |= 0b00010000;
	sbi 0x5,4
	.dbline 83
;  	 PORTD &= 0b10111111;
	in R24,0xb
	andi R24,191
	out 0xb,R24
	.dbline -2
L14:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e led_init _led_init fV
	.even
_led_init::
	.dbline -1
	.dbline 88
; }
; 
; 
; void led_init(void)
; {
	.dbline 90
;     //段码   1: output;  0: input.
;  	 DDRD |= 0xc0;  // 0b1100'0000
	in R24,0xa
	ori R24,192
	out 0xa,R24
	.dbline 91
; 	 DDRB |= 0x3f;  // 0b0011'1111 
	in R24,0x4
	ori R24,63
	out 0x4,R24
	.dbline 93
; //位码
; 	 DDRC |= 0x3c;  // 0b0011'1100 
	in R24,0x7
	ori R24,60
	out 0x7,R24
	.dbline 95
; //
;      PORTC &= 0b11011111;		
	in R24,0x8
	andi R24,223
	out 0x8,R24
	.dbline 96
; 	 PORTC |= 0b00100000;	
	sbi 0x8,5
	.dbline 97
; 	 PORTC &= 0b11011111;
	in R24,0x8
	andi R24,223
	out 0x8,R24
	.dbline 98
; 	 PORTC |= 0b00010000;	
	sbi 0x8,4
	.dbline 99
; 	 PORTC &= 0b11101111;			 
	in R24,0x8
	andi R24,239
	out 0x8,R24
	.dbline 101
; 	//连接
; 	pcled[0] =  light_0;
	ldi R24,<PL_light_0
	ldi R25,>PL_light_0
	sts _pcled+1,R25
	sts _pcled,R24
	.dbline 102
; 	pcled[1] =  light_1; 
	ldi R24,<PL_light_1
	ldi R25,>PL_light_1
	sts _pcled+2+1,R25
	sts _pcled+2,R24
	.dbline 103
; 	pcled[2] =  light_2; 
	ldi R24,<PL_light_2
	ldi R25,>PL_light_2
	sts _pcled+4+1,R25
	sts _pcled+4,R24
	.dbline 104
; 	pcled[3] =  light_3; 
	ldi R24,<PL_light_3
	ldi R25,>PL_light_3
	sts _pcled+6+1,R25
	sts _pcled+6,R24
	.dbline 105
; 	pcled[4] =  light_4; 
	ldi R24,<PL_light_4
	ldi R25,>PL_light_4
	sts _pcled+8+1,R25
	sts _pcled+8,R24
	.dbline 106
;    	pcled[5] =  light_5; 
	ldi R24,<PL_light_5
	ldi R25,>PL_light_5
	sts _pcled+10+1,R25
	sts _pcled+10,R24
	.dbline 107
; 	pcled[6] =  light_6; 
	ldi R24,<PL_light_6
	ldi R25,>PL_light_6
	sts _pcled+12+1,R25
	sts _pcled+12,R24
	.dbline 108
; 	pcled[7] =  light_7; 
	ldi R24,<PL_light_7
	ldi R25,>PL_light_7
	sts _pcled+14+1,R25
	sts _pcled+14,R24
	.dbline 109
; 	pcled[8] =  light_8; 
	ldi R24,<PL_light_8
	ldi R25,>PL_light_8
	sts _pcled+16+1,R25
	sts _pcled+16,R24
	.dbline 110
; 	pcled[9] =  light_9; 
	ldi R24,<PL_light_9
	ldi R25,>PL_light_9
	sts _pcled+18+1,R25
	sts _pcled+18,R24
	.dbline -2
L15:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e CalculateSub _CalculateSub fV
;       p_aloneD -> R20,R21
;          Digit -> R22,R23
	.even
_CalculateSub::
	rcall push_gset2
	movw R20,R18
	movw R22,R16
	.dbline -1
	.dbline 115
; }
; 
; //位计算.
; void CalculateSub(unsigned int Digit,char *p_aloneD)
; {
	.dbline 116
;  	*p_aloneD = (char)(Digit/1000);
	ldi R18,1000
	ldi R19,3
	movw R16,R22
	rcall div16u
	movw R30,R20
	std z+0,R16
	.dbline 117
; 	Digit -= *p_aloneD++ * 1000;
	ld R18,Z+
	movw R20,R30
	clr R19
	ldi R16,1000
	ldi R17,3
	rcall empy16s
	sub R22,R16
	sbc R23,R17
	.dbline 119
; 	
; 	*p_aloneD = (char)(Digit/100);
	ldi R18,100
	ldi R19,0
	movw R16,R22
	rcall div16u
	movw R30,R20
	std z+0,R16
	.dbline 120
; 	Digit -= *p_aloneD++ * 100;
	ld R17,Z+
	movw R20,R30
	ldi R16,100
	muls R16,R17
	sub R22,R0
	sbc R23,R1
	.dbline 122
; 	
; 	*p_aloneD = (char)(Digit/10);
	ldi R18,10
	ldi R19,0
	movw R16,R22
	rcall div16u
	movw R30,R20
	std z+0,R16
	.dbline 123
; 	Digit -= *p_aloneD++ * 10;
	ld R17,Z+
	ldi R16,10
	muls R16,R17
	sub R22,R0
	sbc R23,R1
	.dbline 125
; 
; 	*p_aloneD = (char)Digit;
	std z+0,R22
	.dbline 126
; 	p_aloneD = 0;   
	clr R20
	clr R21
	.dbline -2
L25:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r p_aloneD 20 pc
	.dbsym r Digit 22 i
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
L27:
	.blkb 2
	.area text(rom, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
	.dbfunc e sub2 _sub2 fV
	.dbsym s ShowDigit L27 I
	.even
_sub2::
	.dbline -1
	.dbline 130
; }
; 
; void sub2(void)
; {
	.dbline 132
; 	static int ShowDigit;
; 	NOP();
	nop
	.dbline 133
; 	ShowDigit =	 LedShowLink;//  0x4d2;// 
	lds R2,_LedShowLink
	lds R3,_LedShowLink+1
	sts L27+1,R3
	sts L27,R2
	.dbline 134
; 	CalculateSub(ShowDigit, &aloneD[0]);
	ldi R18,<_aloneD
	ldi R19,>_aloneD
	lds R16,L27
	lds R17,L27+1
	rcall _CalculateSub
	.dbline 135
; 	NOP();
	nop
	.dbline -2
L26:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
L29:
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
	.area text(rom, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
	.dbfunc e subled _subled fV
	.dbsym s ledbitcou L29 c
;        bytebit -> R22
;          byteT -> R20
	.even
_subled::
	rcall push_gset2
	.dbline -1
	.dbline 139
; }
; 
; void subled(void)
; {
	.dbline 142
; 	static char ledbitcou=0b00000000;
; //	static char coui ; //用作数组aloneD[]下标.
; 	char bytebit=0,byteT=0;
	clr R22
	.dbline 142
	clr R20
	.dbline 146
; 	
; //为每位扫描. 1,置一,四位都不亮;  2,清零,点亮一个位.
; 
; 	if(ledbitcou == 0)
	lds R2,L29
	tst R2
	brne L30
	.dbline 147
; 	{
	.dbline 148
; 		 bytebit = 0b11111011;
	ldi R22,251
	.dbline 149
	rjmp L31
L30:
	.dbline 149
; 	}else if(ledbitcou == 1)
	lds R24,L29
	cpi R24,1
	brne L32
	.dbline 150
; 	{
	.dbline 151
; 		 bytebit = 0b11110111;
	ldi R22,247
	.dbline 152
	rjmp L33
L32:
	.dbline 152
; 	}else if(ledbitcou == 2)
	lds R24,L29
	cpi R24,2
	brne L34
	.dbline 153
; 	{
	.dbline 154
; 		 bytebit = 0b11101111;
	ldi R22,239
	.dbline 155
	rjmp L35
L34:
	.dbline 155
; 	}else if(ledbitcou == 3)
	lds R24,L29
	cpi R24,3
	brne L36
	.dbline 156
; 	{	  
	.dbline 157
; 		 bytebit = 0b11011111;
	ldi R22,223
	.dbline 158
; 	}
L36:
L35:
L33:
L31:
	.dbline 163
	in R24,0xb
	ori R24,192
	out 0xb,R24
	.dbline 164
	in R24,0x5
	ori R24,252
	out 0x5,R24
	.dbline 166
	in R24,0x8
	ori R24,60
	out 0x8,R24
	.dbline 167
	in R2,0x8
	and R2,R22
	out 0x8,R2
	.dbline 169
	ldi R24,<_aloneD
	ldi R25,>_aloneD
	lds R30,L29
	clr R31
	add R30,R24
	adc R31,R25
	ldd R20,z+0
	.dbline 170
	ldi R24,2
	mul R24,R20
	movw R30,R0
	ldi R24,<_pcled
	ldi R25,>_pcled
	add R30,R24
	adc R31,R25
	ldd R26,z+0
	ldd R27,z+1
	movw R30,R26
	rcall xicall
	.dbline 171
	lds R24,L29
	subi R24,255    ; addi 1
	mov R2,R24
	sts L29,R2
	cpi R24,4
	brne L38
	.dbline 172
	clr R2
	sts L29,R2
L38:
	.dbline -2
L28:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r bytebit 22 c
	.dbsym r byteT 20 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile D:\ICCTES~1\1128\led.c
_LedShowLink::
	.blkb 2
	.dbsym e LedShowLink _LedShowLink i
_pcled::
	.blkb 20
	.dbsym e pcled _pcled A[20:10]pfV
_aloneD:
	.blkb 4
	.dbsym s aloneD _aloneD A[4:4]c
	.area func_lit
PL_light_9:	.word `_light_9
PL_light_8:	.word `_light_8
PL_light_7:	.word `_light_7
PL_light_6:	.word `_light_6
PL_light_5:	.word `_light_5
PL_light_4:	.word `_light_4
PL_light_3:	.word `_light_3
PL_light_2:	.word `_light_2
PL_light_1:	.word `_light_1
PL_light_0:	.word `_light_0

⌨️ 快捷键说明

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