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

📄 main.s

📁 avr单片机与flash存储器通信程序,调试通过,希望对大家有所帮助.
💻 S
字号:
	.module main.c
	.area lit(rom, con, rel)
_Tab::
	.byte 33,249
	.byte 19,'Q
	.byte 201,'E
	.byte 5,241
	.byte 1,'A
	.byte 129,13
	.byte 39,25
	.byte 7,135
	.dbfile C:\ATMega8515\LCD/ForATmega8515.h
	.dbsym e Tab _Tab A[16:16]kc
	.area text(rom, con, rel)
	.dbfile C:\ATMega8515\LCD/ForATmega8515.h
	.dbfile C:\ATMega8515\LCD\main.c
	.dbfunc e main _main fV
;      softdelay -> R20,R21
	.even
_main::
	.dbline -1
	.dbline 12
; #include <iom8515v.h>
; #include"ForATmega8515.h"
; 
; void delay(uint ticks);
; ///////////////////////
; void writedata(uchar lcddata);//写数据到LCD
; void writecom(uchar lcddata);//写命令到LCD
; void writeline(uchar *str); //写一串数据到LCD
; void initlcd();		   //初始话LCD
; ////////////////////////////
; void main()
; { 
	.dbline 13
;  uint softdelay=1000;
	ldi R20,1000
	ldi R21,3
	.dbline 14
;  init_devices();
	rcall _init_devices
	.dbline 15
;  initlcd();
	rcall _initlcd
	rjmp L3
L2:
	.dbline 18
; 
;  while(1)
;  {
	.dbline 19
;  writeline("Hello World!");//在LCD上面显示Hello World!
	ldi R16,<L5
	ldi R17,>L5
	rcall _writeline
	rjmp L7
L6:
	.dbline 20
	ldi R16,30
	ldi R17,0
	rcall _delay
L7:
	.dbline 20
;  while(softdelay--)delay(30);softdelay=1000;//延时
	movw R2,R20
	subi R20,1
	sbci R21,0
	tst R2
	brne L6
	tst R3
	brne L6
X0:
	.dbline 20
	ldi R20,1000
	ldi R21,3
	.dbline 21
;  writecom(0x01);//清屏
	ldi R16,1
	rcall _writecom
	.dbline 22
;  writecom(0x80);//回车
	ldi R16,128
	rcall _writecom
	.dbline 23
;  writeline("ForATMega8515");//在LCD上面显示ForATMega8515
	ldi R16,<L9
	ldi R17,>L9
	rcall _writeline
	rjmp L11
L10:
	.dbline 24
	ldi R16,30
	ldi R17,0
	rcall _delay
L11:
	.dbline 24
	movw R2,R20
	subi R20,1
	sbci R21,0
	tst R2
	brne L10
	tst R3
	brne L10
X1:
	.dbline 24
	ldi R20,1000
	ldi R21,3
	.dbline 25
	ldi R16,1
	rcall _writecom
	.dbline 26
	ldi R16,128
	rcall _writecom
	.dbline 28
L3:
	.dbline 17
	rjmp L2
X2:
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r softdelay 20 i
	.dbend
	.dbfunc e delay _delay fV
;              i -> R20
;          ticks -> R16,R17
	.even
_delay::
	rcall push_gset1
	.dbline -1
	.dbline 33
;  while(softdelay--)delay(30);softdelay=1000;//延时
;  writecom(0x01);//清屏
;  writecom(0x80);//回车
; 
;  }
; }
; 
; 
; void delay(uint ticks)
; {
	.dbline 35
	rjmp L17
L14:
	.dbline 35
	ldi R20,200
	rjmp L21
L18:
	.dbline 35
L19:
	.dbline 35
	dec R20
L21:
	.dbline 35
	tst R20
	brne L18
L15:
	.dbline 35
	subi R16,1
	sbci R17,0
L17:
	.dbline 35
;  uchar i;
;  for(;ticks!=0;ticks--)for(i=200;i!=0;i--);
	cpi R16,0
	cpc R16,R17
	brne L14
X3:
	.dbline -2
L13:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 c
	.dbsym r ticks 16 i
	.dbend
	.dbfunc e writedata _writedata fV
;        lcddata -> R20
	.even
_writedata::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 42
; }
; 
; 
; 
; ///////////////////////////////
; void writedata(uchar lcddata)
; {
	.dbline 44
; // E=1;
;  PORTC|=E;
	sbi 0x15,4
	.dbline 46
; // RS=1;
;  PORTC|=RS;
	sbi 0x15,2
	.dbline 48
; // RW=0;
;  PORTA=lcddata;
	out 0x1b,R20
	.dbline 50
; // E=0;
;  PORTC&=~E;
	cbi 0x15,4
	.dbline 51
;  delay(100);
	ldi R16,100
	ldi R17,0
	rcall _delay
	.dbline -2
L22:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r lcddata 20 c
	.dbend
	.dbfunc e writecom _writecom fV
;        lcddata -> R20
	.even
_writecom::
	rcall push_gset1
	mov R20,R16
	.dbline -1
	.dbline 55
; }
; /////////////////////////////////
; void writecom(uchar lcddata)
; {
	.dbline 57
; // E=1;
;  PORTC|=E;
	sbi 0x15,4
	.dbline 59
; // RS=0;
;  PORTC&=~RS;
	cbi 0x15,2
	.dbline 61
; // RW=0;
;  PORTA=lcddata;
	out 0x1b,R20
	.dbline 63
; // E=0; 
;  PORTC&=~E;
	cbi 0x15,4
	.dbline 64
;  delay(100);
	ldi R16,100
	ldi R17,0
	rcall _delay
	.dbline -2
L23:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r lcddata 20 c
	.dbend
	.dbfunc e writeline _writeline fV
;            str -> R20,R21
	.even
_writeline::
	rcall push_gset1
	movw R20,R16
	.dbline -1
	.dbline 68
; }
; 
; void writeline(uchar *str)
; {
	rjmp L26
L25:
	.dbline 69
	movw R30,R20
	ld R16,Z+
	movw R20,R30
	rcall _writedata
L26:
	.dbline 69
;  while(*str)writedata(*str++);
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L25
	.dbline -2
L24:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r str 20 pc
	.dbend
	.dbfunc e initlcd _initlcd fV
	.even
_initlcd::
	.dbline -1
	.dbline 74
; }
; 
; ///////////////////////////////////
; void initlcd()
; {
	.dbline 76
; 
;  writecom(0x01);	//清屏
	ldi R16,1
	rcall _writecom
	.dbline 77
;  writecom(0x38);	//功能设置
	ldi R16,56
	rcall _writecom
	.dbline 78
;  writecom(0x0f);	//显示开关控制
	ldi R16,15
	rcall _writecom
	.dbline 79
;  writecom(0x06);	//设置输入模式
	ldi R16,6
	rcall _writecom
	.dbline 80
;  writecom(0x01);	//清屏
	ldi R16,1
	rcall _writecom
	.dbline 81
;  writecom(0x80);	//回车
	ldi R16,128
	rcall _writecom
	.dbline -2
L28:
	.dbline 0 ; func end
	ret
	.dbend
	.area data(ram, con, rel)
	.dbfile C:\ATMega8515\LCD\main.c
L9:
	.blkb 14
	.area idata
	.byte 'F,'o,'r,'A,'T,'M,'e,'g,'a,56,53,49,53,0
	.area data(ram, con, rel)
	.dbfile C:\ATMega8515\LCD\main.c
L5:
	.blkb 13
	.area idata
	.byte 'H,'e,'l,'l,'o,32,'W,'o,'r,'l,'d,33,0
	.area data(ram, con, rel)
	.dbfile C:\ATMega8515\LCD\main.c

⌨️ 快捷键说明

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