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

📄 din0.s

📁 这个是用AVR编写的程序
💻 S
字号:
	.module din0.c
	.area data(ram, con, rel)
_num::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\chengxu\lesson7_2\lesson7_3\din0.c
	.dbsym e num _num c
	.area code(ram, con, rel)
	.dbfile D:\chengxu\lesson7_2\lesson7_3\din0.c
	.area lit(rom, con, rel)
_table::
	.word 63
	.word 6
	.word 91
	.word 79
	.word 102
	.word 109
	.word 125
	.word 7
	.word 127
	.word 111
	.word 119
	.word 124
	.word 57
	.word 94
	.word 121
	.word 113
	.dbsym e table _table A[32:16]I
	.area vector(rom, abs)
	.org 16
	jmp _miao
	.area lit(rom, con, rel)
	.area text(rom, con, rel)
	.dbfile D:\chengxu\lesson7_2\lesson7_3\din0.c
	.dbfunc e delay _delay fV
;              x -> R20,R21
;              y -> R22,R23
;              z -> R16,R17
	.even
_delay::
	xcall push_gset2
	.dbline -1
	.dbline 12
; #include<iom16v.h>
; #include<macros.h>
; #include<stdio.h>
; #define uint unsigned int
; #define uchar unsigned char
; uchar num=0;
; #pragma data:code
;  const  table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,
;                   0x39,0x5e,0x79,0x71};
; #pragma interrupt_handler miao:5		  
; void delay(uint z)
;    {uint x,y;
	.dbline 13
;     for (x=0;x<z;x++)
	clr R20
	clr R21
	xjmp L5
L2:
	.dbline 14
	clr R22
	clr R23
	xjmp L9
L6:
	.dbline 14
L7:
	.dbline 14
	subi R22,255  ; offset = 1
	sbci R23,255
L9:
	.dbline 14
	cpi R22,80
	ldi R30,4
	cpc R23,R30
	brlo L6
L3:
	.dbline 13
	subi R20,255  ; offset = 1
	sbci R21,255
L5:
	.dbline 13
	cp R20,R16
	cpc R21,R17
	brlo L2
	.dbline -2
	.dbline 15
; 	  for(y=0;y<1104;y++);
;       }
L1:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r x 20 i
	.dbsym r y 22 i
	.dbsym r z 16 i
	.dbend
	.dbfunc e show _show fV
;              y -> R20
;              x -> R22
	.even
_show::
	xcall push_gset2
	mov R20,R18
	mov R22,R16
	.dbline -1
	.dbline 17
; 	 void show(uchar x,uchar y)
;    {DDRA|=0x18;
	.dbline 17
	in R24,0x1a
	ori R24,24
	out 0x1a,R24
	.dbline 18
;     DDRB=0xff;
	ldi R24,255
	out 0x17,R24
	.dbline 19
;     PORTB=table[x];
	ldi R24,2
	mul R24,R22
	movw R30,R0
	ldi R24,<_table
	ldi R25,>_table
	add R30,R24
	adc R31,R25
	lpm R0,Z+
	lpm R1,Z
	movw R30,R0
	out 0x18,R30
	.dbline 20
; 	PORTA|=BIT(3);
	sbi 0x1b,3
	.dbline 21
; 	PORTA&=~BIT(3);
	cbi 0x1b,3
	.dbline 22
; 	PORTB=0XFF;
	ldi R24,255
	out 0x18,R24
	.dbline 23
; 	PORTB&=~BIT(y);
	ldi R16,1
	mov R17,R20
	xcall lsl8
	mov R2,R16
	com R2
	in R3,0x18
	and R3,R2
	out 0x18,R3
	.dbline 24
; 	PORTA|=BIT(4);
	sbi 0x1b,4
	.dbline 25
; 	PORTA&=~BIT(4);
	cbi 0x1b,4
	.dbline 26
; 	delay(1);}
	ldi R16,1
	ldi R17,0
	xcall _delay
	.dbline -2
	.dbline 26
L10:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r y 20 c
	.dbsym r x 22 c
	.dbend
	.dbfunc e init _init fV
	.even
_init::
	.dbline -1
	.dbline 40
;  /* void show(uchar x,uchar y)
;    {DDRA|=0X18;
;     DDRB=0XFF;
; 	PORTB=table[x];
; 	PORTA|=BIT(3);
; 	PORTA&=~BIT(3);
; 	PORTB=0XFF;
; 	PORTB&=~BIT(y);
; 	PORTA|=BIT(4);
; 	PORTA&=~BIT(4);
; 	delay(1);
;    }*/	
;    void init() //定时器0的初始化
;     {TCNT0=0X01;
	.dbline 40
	ldi R24,1
	out 0x32,R24
	.dbline 41
; 	 TCCR0=0x05;
	ldi R24,5
	out 0x33,R24
	.dbline 42
; 	 TIMSK|=BIT(2);
	in R24,0x39
	ori R24,4
	out 0x39,R24
	.dbline 43
; 	 SREG|=BIT(7);
	bset 7
	.dbline -2
	.dbline 44
; 	 }
L11:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e miao _miao fV
	.even
_miao::
	st -y,R2
	st -y,R24
	st -y,R25
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 60
; 	 
; 	  
; 	/*   void init() //定时器2的初始化
;     {TCNT2=0X01;
; 	 TCCR2=0x05;
; 	 TIMSK|=BIT(6);
; 	 SREG|=BIT(7);
; 	 }
; 	  void miao() //中断函数2
; 	  {if(num==1000)
; 	    {num=0;}
; 	   else num++;
; 	   TCNT2=0X01;
; 	  }*/
; 	 void miao() //中断函数0
; 	  {if(num==1000)
	.dbline 60
	lds R24,_num
	cpi R24,232
	brne L13
	.dbline 61
; 	    {num=0;}
	.dbline 61
	clr R2
	sts _num,R2
	.dbline 61
	xjmp L14
L13:
	.dbline 62
; 	   else num++;
	lds R24,_num
	subi R24,255    ; addi 1
	sts _num,R24
L14:
	.dbline 63
; 	   TCNT0=0X01;
	ldi R24,1
	out 0x32,R24
	.dbline -2
	.dbline 64
; 	  }
L12:
	ld R2,y+
	out 0x3f,R2
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e main _main fV
;            fen -> R20
	.even
_main::
	.dbline -1
	.dbline 67
; 	  			  
;   void main(void)
;     {uchar fen=0;
	.dbline 67
	clr R20
	.dbline 68
; 	init();
	xcall _init
	xjmp L17
L16:
	.dbline 70
; 	while(1)
;       {
	.dbline 71
; 	  if(num==1000)
	lds R24,_num
	cpi R24,232
	brne L19
	.dbline 72
; 	  {num=0;
	.dbline 72
	clr R2
	sts _num,R2
	.dbline 73
; 	   if(fen==59)
	cpi R20,59
	brne L21
	.dbline 74
; 	   {fen=0;
	.dbline 74
	clr R20
	.dbline 75
; 	   }
	xjmp L22
L21:
	.dbline 76
; 	   else fen++;
	inc R20
L22:
	.dbline 77
; 	   }
L19:
	.dbline 78
	clr R18
	ldi R17,10
	mov R16,R20
	xcall div8u
	xcall _show
	.dbline 79
	ldi R18,1
	ldi R17,10
	mov R16,R20
	xcall mod8u
	xcall _show
	.dbline 80
L17:
	.dbline 69
	xjmp L16
X0:
	.dbline -2
	.dbline 81
; 	 show(fen/10,0);
; 	 show(fen%10,1);
; 	  }
; }	
L15:
	.dbline 0 ; func end
	ret
	.dbsym r fen 20 c
	.dbend

⌨️ 快捷键说明

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