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

📄 main.s

📁 工控计数器ICCAVR的MAGE8程序LED数码显示+4键
💻 S
字号:
	.module main.c
	.area data(ram, con, rel)
_ticnt::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.dbsym e ticnt _ticnt i
_keytime::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.dbsym e keytime _keytime i
	.area vector(rom, abs)
	.org 2
	rjmp _Key_Init
	.area data(ram, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.area text(rom, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.dbfunc e Key_Init _Key_Init fV
;              j -> R10
;              x -> R10
	.even
_Key_Init::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R4
	st -y,R5
	st -y,R6
	st -y,R7
	st -y,R8
	st -y,R9
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R24
	st -y,R25
	st -y,R30
	st -y,R31
	in R0,0x3f
	st -y,R0
	rcall push_gset3
	.dbline -1
	.dbline 16
; #define MAIN_C
; #include "main.h"
; #define    ds            0
; #define    cp            1
; #define    sh_cp       2
; long                                Contdata,timeset[3];
; unsigned    int                 ti[3],ticnt =0;
; unsigned    int                 keytime=0;
; unsigned    char              kt[3],keybit;
; extern        long                    tempcnt;
; extern        unsigned char     trdata_x[ ];
; extern        unsigned char     inmtemp;
; //--------------------------------------------------------------------
; #pragma interrupt_handler Key_Init:2
; void Key_Init(void)    
; {
	.dbline 18
;     unsigned char j,x;
;      j=ACSR&0X20; 
	in R24,0x30
	andi R24,32
	mov R10,R24
	.dbline 19
	lds R2,_inmtemp
	tst R2
	breq L2
	.dbline 19
	.dbline 19
	tst R24
	brne L4
	.dbline 19
	ldi R24,32
	mov R10,R24
	rjmp L5
L4:
	.dbline 19
	clr R10
L5:
	.dbline 19
; 	if( inmtemp!=0)   { if(j==0)   j=0x20;    else      j=0;   }
L2:
	.dbline 20
; 	if  (j==0)           {  Contdata++;}
	tst R10
	brne L6
	.dbline 20
	.dbline 20
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	lds R4,_Contdata+2
	lds R5,_Contdata+2+1
	lds R2,_Contdata
	lds R3,_Contdata+1
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	sts _Contdata+1,R3
	sts _Contdata,R2
	sts _Contdata+2+1,R5
	sts _Contdata+2,R4
	.dbline 20
	rjmp L7
L6:
	.dbline 21
; 	else                  {   Contdata--;}
	.dbline 21
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	lds R4,_Contdata+2
	lds R5,_Contdata+2+1
	lds R2,_Contdata
	lds R3,_Contdata+1
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	sts _Contdata+1,R3
	sts _Contdata,R2
	sts _Contdata+2+1,R5
	sts _Contdata+2,R4
	.dbline 21
L7:
	.dbline 22
;     for (x=0; x<3;x++)  
	clr R10
	rjmp L11
L8:
	.dbline 23
; 	{
	.dbline 24
;     if(tempcnt>=timeset[x])	
	ldi R24,4
	mul R24,R10
	movw R30,R0
	ldi R24,<_timeset
	ldi R25,>_timeset
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	lds R8,_tempcnt+2
	lds R9,_tempcnt+2+1
	lds R6,_tempcnt
	lds R7,_tempcnt+1
	cp R6,R2
	cpc R7,R3
	cpc R8,R4
	cpc R9,R5
	brge X0
	rjmp L12
X0:
	.dbline 25
; 	       {
	.dbline 26
; 	        if(kt[x]==0) 
	ldi R24,<_kt
	ldi R25,>_kt
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	tst R2
	brne L14
	.dbline 27
; 			{
	.dbline 28
; 			if(trdata_x[x]!=0) {PORTC|=BIT(x+3);}
	ldi R24,<_trdata_x
	ldi R25,>_trdata_x
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	ldd R2,z+0
	tst R2
	breq L16
	.dbline 28
	.dbline 28
	mov R17,R10
	subi R17,253    ; addi 3
	ldi R16,1
	rcall lsl8
	in R2,0x8
	or R2,R16
	out 0x8,R2
	.dbline 28
L16:
	.dbline 29
; 			ti[x]=ticnt;
	ldi R24,2
	mul R24,R10
	movw R30,R0
	ldi R24,<_ti
	ldi R25,>_ti
	add R30,R24
	adc R31,R25
	lds R2,_ticnt
	lds R3,_ticnt+1
	std z+1,R3
	std z+0,R2
	.dbline 30
; 			kt[x]=1;
	ldi R24,<_kt
	ldi R25,>_kt
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	ldi R24,1
	std z+0,R24
	.dbline 31
; 		   }
L14:
	.dbline 32
; 		 }
L12:
	.dbline 33
L9:
	.dbline 22
	inc R10
L11:
	.dbline 22
	mov R24,R10
	cpi R24,3
	brsh X1
	rjmp L8
X1:
	.dbline -2
L1:
	rcall pop_gset3
	ld R0,y+
	out 0x3f,R0
	ld R31,y+
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R9,y+
	ld R8,y+
	ld R7,y+
	ld R6,y+
	ld R5,y+
	ld R4,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	.dbline 0 ; func end
	reti
	.dbsym r j 10 c
	.dbsym r x 10 c
	.dbend
	.area vector(rom, abs)
	.org 4
	rjmp _bakcnt
	.area text(rom, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.dbfunc e bakcnt _bakcnt fV
	.even
_bakcnt::
	rcall push_lset
	.dbline -1
	.dbline 38
;      }												    
; }
; //--------------------------------------------------------------------
; #pragma interrupt_handler bakcnt:3
; void    bakcnt(void)   
; {   
	.dbline 39
;  CLI( );
	cli
	.dbline 40
;  powersave();
	rcall _powersave
	.dbline -2
L18:
	rcall pop_lset
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 26
	rjmp _timer1_ovf_isr
	.area text(rom, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
	.even
_timer1_ovf_isr::
	st -y,R2
	st -y,R3
	st -y,R24
	st -y,R25
	st -y,R30
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 45
; }
; //---------------------------------------------------------------------
; #pragma interrupt_handler timer1_ovf_isr:14
; void timer1_ovf_isr(void)
; {
	.dbline 46
;  TCNT1H = 0xFD; //reload counter high value
	ldi R24,253
	sts 133,R24
	.dbline 47
;  TCNT1L = 0x8F; //reload counter low value
	ldi R24,143
	sts 132,R24
	.dbline 48
;  if(ticnt<60000)                {ticnt++; keytime++;}
	lds R24,_ticnt
	lds R25,_ticnt+1
	cpi R24,96
	ldi R30,234
	cpc R25,R30
	brsh L20
	.dbline 48
	.dbline 48
	adiw R24,1
	sts _ticnt+1,R25
	sts _ticnt,R24
	.dbline 48
	lds R24,_keytime
	lds R25,_keytime+1
	adiw R24,1
	sts _keytime+1,R25
	sts _keytime,R24
	.dbline 48
	rjmp L21
L20:
	.dbline 49
;  else                               ticnt=0; 
	clr R2
	clr R3
	sts _ticnt+1,R3
	sts _ticnt,R2
L21:
	.dbline 50
;  if(keytime>1000)              keybit=0xf7;
	ldi R24,1000
	ldi R25,3
	lds R2,_keytime
	lds R3,_keytime+1
	cp R24,R2
	cpc R25,R3
	brsh L22
	.dbline 50
	ldi R24,247
	sts _keybit,R24
L22:
	.dbline 51
	in R24,0x3
	andi R24,15
	cpi R24,15
	breq L24
	.dbline 51
	clr R2
	clr R3
	sts _keytime+1,R3
	sts _keytime,R2
L24:
	.dbline -2
L19:
	ld R2,y+
	out 0x3f,R2
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R3,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.area vector(rom, abs)
	.org 6
	rjmp _int_clr
	.area text(rom, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
	.dbfunc e int_clr _int_clr fV
;              m -> R10
	.even
_int_clr::
	st -y,R0
	st -y,R1
	st -y,R2
	st -y,R3
	st -y,R16
	st -y,R17
	st -y,R18
	st -y,R24
	st -y,R25
	st -y,R30
	st -y,R31
	in R0,0x3f
	st -y,R0
	rcall push_gset3
	.dbline -1
	.dbline 56
;  if((PINB&0X0f)!=0x0f)       keytime=0;
; }
; //-----------------------------------------------------------------------
; #pragma interrupt_handler int_clr:4
; void int_clr(void)
; {
	.dbline 58
;  unsigned char m;
;  CLI( );
	cli
	.dbline 59
;  Contdata=0;
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	sts _Contdata+1,R21
	sts _Contdata,R20
	sts _Contdata+2+1,R23
	sts _Contdata+2,R22
	.dbline 60
;  tempcnt=0;
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	sts _tempcnt+1,R21
	sts _tempcnt,R20
	sts _tempcnt+2+1,R23
	sts _tempcnt+2,R22
	.dbline 61
;  for (m=0; m<3;m++)
	clr R10
	rjmp L30
L27:
	.dbline 62
	.dbline 63
	mov R17,R10
	subi R17,253    ; addi 3
	ldi R16,1
	rcall lsl8
	mov R2,R16
	com R2
	in R3,0x8
	and R3,R2
	out 0x8,R3
	.dbline 64
	ldi R24,2
	mul R24,R10
	movw R30,R0
	ldi R24,<_ti
	ldi R25,>_ti
	add R30,R24
	adc R31,R25
	clr R2
	clr R3
	std z+1,R3
	std z+0,R2
	.dbline 65
	ldi R24,<_kt
	ldi R25,>_kt
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	std z+0,R2
	.dbline 66
L28:
	.dbline 61
	inc R10
L30:
	.dbline 61
	mov R24,R10
	cpi R24,3
	brlo L27
	.dbline 67
;    {
;     PORTC&=~BIT(m+3);	
;   	ti[m]=0;    
; 	kt[m]=0;
;     }
;  SEI( );
	sei
	.dbline -2
L26:
	rcall pop_gset3
	ld R0,y+
	out 0x3f,R0
	ld R31,y+
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R18,y+
	ld R17,y+
	ld R16,y+
	ld R3,y+
	ld R2,y+
	ld R1,y+
	ld R0,y+
	.dbline 0 ; func end
	reti
	.dbsym r m 10 c
	.dbend
	.dbfunc e powersave _powersave fV
;              m -> R20
	.even
_powersave::
	rcall push_gset1
	sbiw R28,2
	.dbline -1
	.dbline 71
; }
; //------
; void   powersave(void)
; {
	.dbline 72
;        unsigned char    m=0;
	clr R20
	.dbline 73
;        WDR();
	wdr
	.dbline 74
; 	   PORTC&=~BIT(cp);
	cbi 0x8,1
	.dbline 75
; 	   for(m=0;m<24;m++)
	rjmp L35
L32:
	.dbline 76
	.dbline 77
	cbi 0x8,2
	.dbline 78
	sbi 0x8,0
	.dbline 79
	sbi 0x8,2
	.dbline 80
L33:
	.dbline 75
	inc R20
L35:
	.dbline 75
	cpi R20,24
	brlo L32
	.dbline 81
; 	   {
; 	   PORTC&=~BIT(sh_cp);
;        PORTC|=BIT(ds);
; 	   PORTC|= BIT(sh_cp);
;        }
;        PORTC|=BIT(cp);
	sbi 0x8,1
	.dbline 82
; 	   DDRC=0x00;
	clr R2
	out 0x7,R2
	.dbline 83
; 	   EEPROMwrite(0xb0,kt[0]);  
	lds R18,_kt
	ldi R16,176
	ldi R17,0
	rcall _EEPROMwrite_extIO
	.dbline 84
;        EEPROM_WRITE(0x93, Contdata);
	ldi R24,4
	ldi R25,0
	std y+1,R25
	std y+0,R24
	ldi R18,<_Contdata
	ldi R19,>_Contdata
	ldi R16,147
	ldi R17,0
	rcall _EEPROMWriteBytes_extIO
L36:
	.dbline 85
L37:
	.dbline 85
	rjmp L36
X2:
	.dbline -2
L31:
	adiw R28,2
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r m 20 c
	.dbend
	.dbfunc e main _main fV
	.even
_main::
	.dbline -1
	.dbline 89
;        while(1);
; }
; //------------------------------------------------------------------------
; void main(void)
; {   
	.dbline 90
; InitIo();
	rcall _InitIo
	rjmp L41
L40:
	.dbline 92
; while(1)
;    {
	.dbline 93
;     menu();
	rcall _menu
L43:
	.dbline 95
; loop:		
;     if((PINB&0X0f)==0x07) goto   loop;
	in R24,0x3
	andi R24,15
	cpi R24,7
	brne L44
	.dbline 95
	rjmp L43
L44:
	.dbline 96
;     if((PINB&0X0f)==0x17) goto   loop;
	in R24,0x3
	andi R24,15
	cpi R24,23
	brne L46
	.dbline 96
	rjmp L43
L46:
	.dbline 97
	rcall _cntplay
	.dbline 98
L41:
	.dbline 91
	rjmp L40
X3:
	.dbline -2
L39:
	.dbline 0 ; func end
	ret
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\NumberDisplay\cfile\main.c
_keybit::
	.blkb 1
	.dbsym e keybit _keybit c
_kt::
	.blkb 3
	.dbsym e kt _kt A[3:3]c
_ti::
	.blkb 6
	.dbsym e ti _ti A[6:3]i
_timeset::
	.blkb 12
	.dbsym e timeset _timeset A[12:3]L
_Contdata::
	.blkb 4
	.dbsym e Contdata _Contdata L

⌨️ 快捷键说明

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