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

📄 sendrcvself.s

📁 ATmega16应用例子
💻 S
字号:
	.module SendRcvSelf.c
	.area text(rom, con, rel)
	.dbfile E:\ICCAVR_H\CmmICC.H
	.dbfunc e delay50us _delay50us fV
;              j -> R20
;              t -> R16,R17
	.even
_delay50us::
	xcall push_gset1
	.dbline -1
	.dbline 117
; //ICC-AVR application builder : 2005-6-30 17:44:36
; // Target : M16
; // Crystal: 7.3728Mhz
; 
; #include <iom16v.h>
; #include "E:\ICCAVR_H\CmmICC.H"
; 
; #define DISP_PORT PORTA
; #define DISP_DDR  DDRA
; 
; //UART0 initialisation
; // desired baud rate: 9600
; // actual: baud rate:9600 (0.0%)
; // char size: 8 bit
; // parity: Disabled
; void uart0_init(void)
; {
;  UCSRB = 0x00; //disable while setting baud rate
;  UCSRA = 0x00;
;  UCSRC = 0x86;
;  UBRRL = 47; //set baud rate lo
;  UBRRH = 0x00; //set baud rate hi
;  UCSRB = 0x98;
; }
; 
; #pragma interrupt_handler uart0_rx_isr:12
; void uart0_rx_isr(void)
; {
;  //uart has received a character in UDR
;  DISP_PORT = UDR;
; }
; 
; 
; //call this routine to initialise all peripherals
; void mcu_init(void)
; {
;  //stop errant interrupts until set up
;  CLI(); //disable all interrupts
;  uart0_init();
;  MCUCR = 0x00;
;  GICR  = 0x00;
;  TIMSK = 0x00; //timer interrupt sources
;  SEI(); //re-enable interrupts
;  //all peripherals are now initialised
; }
; 
; void main()
; {
;  uint8 counter=0;
;  mcu_init();
; 
;  DISP_DDR=0xFF;
;  
;  while(1)
;  {
;   UDR=counter++;
;    while(!(UCSRA&0x40));
;       UCSRA|=0x40;
;    delay50ms(4);
;  }
;  
; }
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 119
; 
; 
	xjmp L5
L2:
	.dbline 120
; 
	clr R20
	xjmp L9
L6:
	.dbline 121
L7:
	.dbline 120
	inc R20
L9:
	.dbline 120
	cpi R20,70
	brlo L6
L3:
	.dbline 119
	subi R16,1
	sbci R17,0
L5:
	.dbline 119
	clr R2
	clr R3
	cp R2,R16
	cpc R3,R17
	brlt L2
	.dbline -2
	.dbline 122
; 
; 
L1:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r j 20 c
	.dbsym r t 16 I
	.dbend
	.dbfunc e delay50ms _delay50ms fV
;              i -> R20,R21
;              t -> R16,R17
	.even
_delay50ms::
	xcall push_gset1
	.dbline -1
	.dbline 132
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 134
; 
; 
	xjmp L14
L11:
	.dbline 135
; 
	clr R20
	clr R21
	xjmp L18
L15:
	.dbline 136
L16:
	.dbline 135
	subi R20,255  ; offset = 1
	sbci R21,255
L18:
	.dbline 135
	cpi R20,162
	ldi R30,205
	cpc R21,R30
	brlo L15
L12:
	.dbline 134
	subi R16,1
	sbci R17,0
L14:
	.dbline 134
	clr R2
	clr R3
	cp R2,R16
	cpc R3,R17
	brlt L11
	.dbline -2
	.dbline 137
; 
; 
L10:
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r t 16 I
	.dbend
	.dbfunc e speaData _speaData fV
;              y -> y+4
;              j -> y+0
;              i -> R10
;              C -> R12
;              D -> y+16
	.even
_speaData::
	xcall push_arg4
	xcall push_gset4
	sbiw R28,8
	ldd R12,y+20
	.dbline -1
	.dbline 148
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 151
; 
; 
; 
	clr R10
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	std z+0,R20
	std z+1,R21
	std z+2,R22
	std z+3,R23
	xjmp L23
L20:
	.dbline 152
	.dbline 153
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	movw R30,R28
	ldd R6,z+16
	ldd R7,z+17
	ldd R8,z+18
	ldd R9,z+19
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R6
	movw R18,R8
	xcall div32u
	movw R30,R28
	std z+4,R16
	std z+5,R17
	std z+6,R18
	std z+7,R19
	.dbline 154
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	movw R30,R28
	ldd R2,z+4
	ldd R3,z+5
	ldd R4,z+6
	ldd R5,z+7
	st -y,R23
	st -y,R22
	st -y,R21
	st -y,R20
	movw R16,R2
	movw R18,R4
	xcall mod32u
	ldi R24,<_dataElem
	ldi R25,>_dataElem
	mov R30,R10
	clr R31
	add R30,R24
	adc R31,R25
	std z+0,R16
	.dbline 155
	movw R30,R28
	ldd R2,z+0
	ldd R3,z+1
	ldd R4,z+2
	ldd R5,z+3
	ldi R20,10
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	movw R30,R28
	std z+0,R16
	std z+1,R17
	std z+2,R18
	std z+3,R19
	.dbline 156
L21:
	.dbline 151
	inc R10
L23:
	.dbline 151
	cp R10,R12
	brsh X0
	xjmp L20
X0:
	.dbline -2
	.dbline 157
; 
; 
; 
; 
; 
; 
L19:
	adiw R28,8
	xcall pop_gset4
	adiw R28,4
	.dbline 0 ; func end
	ret
	.dbsym l y 4 l
	.dbsym l j 0 l
	.dbsym r i 10 c
	.dbsym r C 12 c
	.dbsym l D 16 l
	.dbend
	.dbfunc e changeDToH _changeDToH fc
;            hex -> R20
;              t -> y+0
;            dec -> R20
	.even
_changeDToH::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 167
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 170
; 
; 
; 
	ldi R17,10
	mov R16,R20
	xcall div8u
	std y+1,R16
	.dbline 171
; 
	ldi R17,10
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 172
; 
	ldd R2,y+1
	ldi R24,16
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 173
; 
	mov R16,R20
	.dbline -2
L24:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r hex 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r dec 20 c
	.dbend
	.dbfunc e converseDToH _converseDToH fc
;            hex -> R20
;              t -> y+0
;            dec -> R20
	.even
_converseDToH::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 184
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 187
; 
; 
; 
	mov R24,R20
	swap R24
	andi R24,#0x0F
	std y+1,R24
	.dbline 188
; 
	ldi R17,16
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 189
; 
	ldd R2,y+1
	ldi R24,16
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 190
; 
	mov R16,R20
	.dbline -2
L27:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r hex 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r dec 20 c
	.dbend
	.dbfunc e changeHToD _changeHToD fc
;            dec -> R20
;              t -> y+0
;            hex -> R20
	.even
_changeHToD::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 201
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 204
; 
; 
; 
	mov R24,R20
	swap R24
	andi R24,#0x0F
	std y+1,R24
	.dbline 205
; 
	ldi R17,16
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 206
; 
	ldd R2,y+1
	ldi R24,10
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 207
; 
	mov R16,R20
	.dbline -2
L30:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r dec 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r hex 20 c
	.dbend
	.dbfunc e converseHToD _converseHToD fc
;            dec -> R20
;              t -> y+0
;            hex -> R20
	.even
_converseHToD::
	xcall push_gset1
	mov R20,R16
	sbiw R28,2
	.dbline -1
	.dbline 218
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
; 
	.dbline 221
; 
; 
; 
	ldi R17,10
	mov R16,R20
	xcall div8u
	std y+1,R16
	.dbline 222
; 
	ldi R17,10
	mov R16,R20
	xcall mod8u
	std y+0,R16
	.dbline 223
; 
	ldd R2,y+1
	ldi R24,16
	mul R24,R2
	mov R20,R0
	add R20,R16
	.dbline 224
; 
	mov R16,R20
	.dbline -2
L33:
	adiw R28,2
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r dec 20 c
	.dbsym l t 0 A[2:2]c
	.dbsym r hex 20 c
	.dbend
	.dbfile E:\ProductPro\M16SD\ICCAVR\UART\SendRcvSelf\SendRcvSelf.c
	.dbfunc e uart0_init _uart0_init fV
	.even
_uart0_init::
	.dbline -1
	.dbline 17
	.dbline 18
	clr R2
	out 0xa,R2
	.dbline 19
	out 0xb,R2
	.dbline 20
	ldi R24,134
	out 0x20,R24
	.dbline 21
	ldi R24,47
	out 0x9,R24
	.dbline 22
	out 0x20,R2
	.dbline 23
	ldi R24,152
	out 0xa,R24
	.dbline -2
	.dbline 24
L36:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 44
	jmp _uart0_rx_isr
	.area text(rom, con, rel)
	.dbfile E:\ProductPro\M16SD\ICCAVR\UART\SendRcvSelf\SendRcvSelf.c
	.dbfunc e uart0_rx_isr _uart0_rx_isr fV
	.even
_uart0_rx_isr::
	st -y,R2
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 28
	.dbline 30
	in R2,0xc
	out 0x1b,R2
	.dbline -2
	.dbline 31
L37:
	ld R2,y+
	out 0x3f,R2
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e mcu_init _mcu_init fV
	.even
_mcu_init::
	.dbline -1
	.dbline 36
	.dbline 38
	cli
	.dbline 39
	xcall _uart0_init
	.dbline 40
	clr R2
	out 0x35,R2
	.dbline 41
	out 0x3b,R2
	.dbline 42
	out 0x39,R2
	.dbline 43
	sei
	.dbline -2
	.dbline 45
L38:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e main _main fV
;        counter -> R20
	.even
_main::
	.dbline -1
	.dbline 48
	.dbline 49
	clr R20
	.dbline 50
	xcall _mcu_init
	.dbline 52
	ldi R24,255
	out 0x1a,R24
	xjmp L41
L40:
	.dbline 55
	.dbline 56
	mov R2,R20
	subi R20,255    ; addi 1
	out 0xc,R2
L43:
	.dbline 57
L44:
	.dbline 57
	sbis 0xb,6
	rjmp L43
	.dbline 58
	sbi 0xb,6
	.dbline 59
	ldi R16,4
	ldi R17,0
	xcall _delay50ms
	.dbline 60
L41:
	.dbline 54
	xjmp L40
X1:
	.dbline -2
	.dbline 62
L39:
	.dbline 0 ; func end
	ret
	.dbsym r counter 20 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\ProductPro\M16SD\ICCAVR\UART\SendRcvSelf\SendRcvSelf.c
_dataElem::
	.blkb 6
	.dbfile E:\ICCAVR_H\CmmICC.H
	.dbsym e dataElem _dataElem A[6:6]c

⌨️ 快捷键说明

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