ATMEL AVR 单片机开发套件和大量C和ASM代码工程
源代码在线查看: sound.s
.module sound.c
.area text
.dbfile E:\grc\licc\例子10.3.6\sound.c
.dbfunc s delay _delay fI
; i -> R20
; j -> R22
; t -> R16
.even
_delay::
rcall push_gset2
.dbline 5{
; #include /*预处理命令 */
; #define uchar unsigned char
; #define uint unsigned int
; void delay(uchar t)
; {
.dbline 7
; uchar i,j;
; for (i=0;i clr R20
rjmp L5
L2:
.dbline 8
ldi R22,1
rjmp L9
L6:
.dbline 8
L7:
.dbline 8
inc R22
L9:
.dbline 8
cpi R22,150
brlo L6
L3:
.dbline 7
inc R20
L5:
.dbline 7
cp R20,R16
brlo L2
.dbline 9}
; for(j=1;j ; }
L1:
rcall pop_gset2
ret
.dbsym r i 20 c
.dbsym r j 22 c
.dbsym r t 16 c
.dbfunc s sound_pc0 _sound_pc0 fI
; i -> R20,R21
; t -> R22
.even
_sound_pc0::
rcall push_gset2
mov R22,R16
.dbline 11{
; void sound_pc0(uchar t)
; {
.dbline 13
; uint i;
; DDRC=0xff;
ldi R24,255
out 0x14,R24
.dbline 14
; PORTC=0xff;
out 0x15,R24
.dbline 15
; for (i=0;i clr R20
clr R21
rjmp L14
L11:
.dbline 16
.dbline 17
ldi R24,1
in R2,0x15
eor R2,R24
out 0x15,R2
.dbline 18
mov R16,R22
rcall _delay
.dbline 19
L12:
.dbline 15
subi R20,255 ; offset = 1
sbci R21,255
L14:
.dbline 15
mov R18,R22
clr R19
mov R16,R22
clr R17
rcall mpy16s
ldi R24,94
ldi R25,1
sub R24,R16
sbc R25,R17
cp R20,R24
cpc R21,R25
brlo L11
.dbline 20}
; {
; PORTC^=0x01;
; delay(t);
; }
; }
L10:
rcall pop_gset2
ret
.dbsym r i 20 i
.dbsym r t 22 c
.dbfunc s main _main fI
; dt -> R20
.even
_main::
.dbline 22{
; void main (void)
; {
.dbline 24
; uchar dt;
; for(;;)
L16:
.dbline 25
; {
.dbline 26
; for(dt=1;dt ldi R20,1
rjmp L23
L20:
.dbline 27
mov R16,R20
rcall _sound_pc0
L21:
.dbline 26
inc R20
L23:
.dbline 26
cpi R20,14
brlo L20
.dbline 28
; sound_pc0(dt);
; }
.dbline 24
.dbline 24
rjmp L16
X0:
L15:
ret
.dbline 25}
.dbsym r dt 20 c