📄 ac15-2.s
字号:
.module ac15-2.c
.area lit(rom, con, rel)
_str0::
.byte 45,'T,'i,'m,'e,32,32,32,58,32,32,58,32,32,45,45
.byte 0
.dbfile d:\MYDOCU~1\ac15-2\ac15-2.c
.dbsym e str0 _str0 A[17:17]kc
_str1::
.byte 45,'A,'T,'i,'m,'e,32,32,32,58,32,32,58,32,45,45
.byte 0
.dbsym e str1 _str1 A[17:17]kc
.area text(rom, con, rel)
.dbfile d:\MYDOCU~1\ac15-2\ac15-2.c
.dbfunc e ePutstr _ePutstr fV
; l -> R20
; i -> R22
; ptr -> R10,R11
; y -> R12
; x -> R14
.even
_ePutstr::
xcall push_gset5
mov R12,R18
mov R14,R16
sbiw R28,1
ldd R10,y+11
ldd R11,y+12
.dbline -1
.dbline 43
; #include <iom16v.h>
; #include <macros.h>
; //-----------------------------------------------
; #define uchar unsigned char
; #define uint unsigned int
; //-------------------引脚电平的宏定义---------
; #define LCM_RS_1 PORTB|=BIT(PB0)
; #define LCM_RS_0 PORTB&=~BIT(PB0)
; #define LCM_RW_1 PORTB|=BIT(PB1)
; #define LCM_RW_0 PORTB&=~BIT(PB1)
; #define LCM_EN_1 PORTB|=BIT(PB2)
; #define LCM_EN_0 PORTB&=~BIT(PB2)
; #define SCL_1 PORTC|=BIT(PC0)
; #define SCL_0 PORTC&=~BIT(PC0)
; #define SDA_1 PORTC|=BIT(PC1)
; #define SDA_0 PORTC&=~BIT(PC1)
; #define LED_1 PORTB|=BIT(PB7)
; #define LED_0 PORTB&=~BIT(PB7)
; //======================================
; #define PIN_SDA (PINC&0x02)
; #define DataPort PORTA
; #define Busy 0x80
; #define xtal 8
; #define Some_NOP(); _NOP();_NOP();_NOP();_NOP();_NOP();_NOP();_NOP();_NOP();
; //======================================
; const uchar str0[]={"-Time : : --"};//待显字符串
; const uchar str1[]={"-ATime : : --"};//待显字符串
; //========函数声明=========
; void Delay_1ms(void);
; void Delay_nms(uint n);
; void WaitForEnable(void);
; void LcdWriteData(uchar W);
; void LcdWriteCommand(uchar CMD,uchar Attribc);
; void InitLcd(void);
; void Display(uchar dd);
; void DisplayOneChar(uchar x,uchar y,uchar Wdata);
; void ePutstr(uchar x,uchar y,uchar const *ptr);
; void port_init(void);
; void init_devices(void);
; void timer1_init(void);
; //**********************显示指定座标的一串字符子函数**************
; void ePutstr(uchar x,uchar y,uchar const *ptr)
; {
.dbline 44
; uchar i,l=0;
clr R20
xjmp L3
L2:
.dbline 45
.dbline 45
inc R20
.dbline 45
L3:
.dbline 45
; while(ptr[l]>31){l++;}
mov R30,R20
clr R31
add R30,R10
adc R31,R11
lpm R30,Z
ldi R24,31
cp R24,R30
brlo L2
.dbline 46
clr R22
xjmp L8
L5:
.dbline 46
; for(i=0;i<l;i++){
.dbline 47
; DisplayOneChar(x++,y,ptr[i]);
mov R30,R22
clr R31
add R30,R10
adc R31,R11
lpm R30,Z
std y+0,R30
mov R18,R12
mov R2,R14
mov R24,R2
subi R24,255 ; addi 1
mov R14,R24
mov R16,R2
xcall _DisplayOneChar
.dbline 48
; if(x==16){
mov R24,R14
cpi R24,16
brne L9
.dbline 48
.dbline 49
; x=0;y^=1;
clr R14
.dbline 49
ldi R24,1
eor R12,R24
.dbline 50
; }
L9:
.dbline 51
L6:
.dbline 46
inc R22
L8:
.dbline 46
cp R22,R20
brlo L5
.dbline -2
L1:
adiw R28,1
xcall pop_gset5
.dbline 0 ; func end
ret
.dbsym r l 20 c
.dbsym r i 22 c
.dbsym r ptr 10 pkc
.dbsym r y 12 c
.dbsym r x 14 c
.dbend
.dbfunc e LocateXY _LocateXY fV
; temp -> R20
; posy -> R22
; posx -> R10
.even
_LocateXY::
xcall push_gset3
mov R22,R18
mov R10,R16
.dbline -1
.dbline 55
; }
; }
; //*******************显示光标定位子函数******************
; void LocateXY(char posx,char posy)
; {
.dbline 57
; uchar temp;
; temp&=0x7f;
andi R20,127
.dbline 58
; temp=posx&0x0f;
mov R20,R10
andi R20,15
.dbline 59
; posy&=0x01;
andi R22,1
.dbline 60
; if(posy)temp|=0x40;
breq L12
.dbline 60
ori R20,64
L12:
.dbline 61
; temp|=0x80;
ori R20,128
.dbline 62
; LcdWriteCommand(temp,0);
clr R18
mov R16,R20
xcall _LcdWriteCommand
.dbline -2
L11:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r temp 20 c
.dbsym r posy 22 c
.dbsym r posx 10 c
.dbend
.dbfunc e DisplayOneChar _DisplayOneChar fV
; Wdata -> y+4
; y -> R22
; x -> R20
.even
_DisplayOneChar::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 66
; }
; //*******************显示指定座标的一个字符子函数*******************
; void DisplayOneChar(uchar x,uchar y,uchar Wdata)
; {
.dbline 67
; LocateXY(x,y);
mov R18,R22
mov R16,R20
xcall _LocateXY
.dbline 68
; LcdWriteData(Wdata);
ldd R16,y+4
xcall _LcdWriteData
.dbline -2
L14:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym l Wdata 4 c
.dbsym r y 22 c
.dbsym r x 20 c
.dbend
.dbfunc e InitLcd _InitLcd fV
.even
_InitLcd::
.dbline -1
.dbline 72
; }
; //*******************LCD初始化子函数*********************
; void InitLcd(void)
; {
.dbline 73
; LcdWriteCommand(0x38,0);
clr R18
ldi R16,56
xcall _LcdWriteCommand
.dbline 74
; Delay_nms(5);
ldi R16,5
ldi R17,0
xcall _Delay_nms
.dbline 75
; LcdWriteCommand(0x38,0);
clr R18
ldi R16,56
xcall _LcdWriteCommand
.dbline 76
; Delay_nms(5);
ldi R16,5
ldi R17,0
xcall _Delay_nms
.dbline 77
; LcdWriteCommand(0x38,0);
clr R18
ldi R16,56
xcall _LcdWriteCommand
.dbline 78
; Delay_nms(5);
ldi R16,5
ldi R17,0
xcall _Delay_nms
.dbline 79
; LcdWriteCommand(0x38,1);
ldi R18,1
ldi R16,56
xcall _LcdWriteCommand
.dbline 80
; LcdWriteCommand(0x08,1);
ldi R18,1
ldi R16,8
xcall _LcdWriteCommand
.dbline 81
; LcdWriteCommand(0x01,1);
ldi R18,1
ldi R16,1
xcall _LcdWriteCommand
.dbline 82
; LcdWriteCommand(0x06,1);
ldi R18,1
ldi R16,6
xcall _LcdWriteCommand
.dbline 83
; LcdWriteCommand(0x0c,1);
ldi R18,1
ldi R16,12
xcall _LcdWriteCommand
.dbline -2
L15:
.dbline 0 ; func end
ret
.dbend
.dbfunc e LcdWriteCommand _LcdWriteCommand fV
; Attribc -> R22
; CMD -> R20
.even
_LcdWriteCommand::
xcall push_gset2
mov R22,R18
mov R20,R16
.dbline -1
.dbline 87
; }
; //********************写命令到LCM子函数********************
; void LcdWriteCommand(uchar CMD,uchar Attribc)
; {
.dbline 88
; if(Attribc)WaitForEnable();
tst R22
breq L17
.dbline 88
xcall _WaitForEnable
L17:
.dbline 89
; LCM_RS_0;LCM_RW_0;_NOP();
cbi 0x18,0
.dbline 89
cbi 0x18,1
.dbline 89
nop
.dbline 90
; DataPort=CMD;_NOP();
out 0x1b,R20
.dbline 90
nop
.dbline 91
; LCM_EN_1;_NOP();_NOP();LCM_EN_0;
sbi 0x18,2
.dbline 91
nop
.dbline 91
nop
.dbline 91
cbi 0x18,2
.dbline -2
L16:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r Attribc 22 c
.dbsym r CMD 20 c
.dbend
.dbfunc e LcdWriteData _LcdWriteData fV
; dataW -> R20
.even
_LcdWriteData::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 95
; }
; //*******************写数据到LCM子函数********************
; void LcdWriteData(uchar dataW)
; {
.dbline 96
; WaitForEnable();
xcall _WaitForEnable
.dbline 97
; LCM_RS_1;LCM_RW_0;_NOP();
sbi 0x18,0
.dbline 97
cbi 0x18,1
.dbline 97
nop
.dbline 98
; DataPort=dataW;_NOP();
out 0x1b,R20
.dbline 98
nop
.dbline 99
; LCM_EN_1;_NOP();_NOP();LCM_EN_0;
sbi 0x18,2
.dbline 99
nop
.dbline 99
nop
.dbline 99
cbi 0x18,2
.dbline -2
L19:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r dataW 20 c
.dbend
.dbfunc e WaitForEnable _WaitForEnable fV
; val -> R16
.even
_WaitForEnable::
.dbline -1
.dbline 103
; }
; //*******************检测LCD忙信号子函数*********************
; void WaitForEnable(void)
; {
.dbline 105
; uchar val;
; DataPort=0xff;
ldi R24,255
out 0x1b,R24
.dbline 106
; LCM_RS_0;LCM_RW_1;_NOP();
cbi 0x18,0
.dbline 106
sbi 0x18,1
.dbline 106
nop
.dbline 107
; LCM_EN_1;_NOP();_NOP();
sbi 0x18,2
.dbline 107
nop
.dbline 107
nop
.dbline 108
; DDRA=0x00;
clr R2
out 0x1a,R2
.dbline 109
; val=PINA;
in R16,0x19
xjmp L22
L21:
.dbline 110
in R16,0x19
L22:
.dbline 110
; while(val&Busy)val=PINA;
sbrc R16,7
rjmp L21
.dbline 111
; LCM_EN_0;
cbi 0x18,2
.dbline 112
; DDRA=0xff;
ldi R24,255
out 0x1a,R24
.dbline -2
L20:
.dbline 0 ; func end
ret
.dbsym r val 16 c
.dbend
.dbfunc e Delay_1ms _Delay_1ms fV
; i -> R16,R17
.even
_Delay_1ms::
.dbline -1
.dbline 116
; }
; //****************************************
; void Delay_1ms(void) //1mS延时子函数
; { uint i;
.dbline 117
; for(i=1;i<(uint)(xtal*143-2);i++)
ldi R16,1
ldi R17,0
xjmp L28
L25:
.dbline 118
L26:
.dbline 117
subi R16,255 ; offset = 1
sbci R17,255
L28:
.dbline 117
cpi R16,118
ldi R30,4
cpc R17,R30
brlo L25
.dbline -2
L24:
.dbline 0 ; func end
ret
.dbsym r i 16 i
.dbend
.dbfunc e Delay_nms _Delay_nms fV
; i -> R20,R21
; n -> R22,R23
.even
_Delay_nms::
xcall push_gset2
movw R22,R16
.dbline -1
.dbline 122
; ;
; }
; //====================================
; void Delay_nms(uint n) //n*1mS延时子函数
; {
.dbline 123
; uint i=0;
clr R20
clr R21
xjmp L31
L30:
.dbline 125
.dbline 125
xcall _Delay_1ms
.dbline 126
subi R20,255 ; offset = 1
sbci R21,255
.dbline 127
L31:
.dbline 124
; while(i<n)
cp R20,R22
cpc R21,R23
brlo L30
.dbline -2
L29:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r n 22 i
.dbend
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 140
; {Delay_1ms();
; i++;
; }
; }
; /*******************定义结构体变量time1,time2*******************/
; struct date
; {
; uchar hour;
; uchar min;
; uchar sec;
; uchar dida;
; }time1,time2;
;
; /*******************端口初始化*******************/
; void port_init(void)
; {
.dbline 141
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 142
; DDRA = 0xFF;
ldi R24,255
out 0x1a,R24
.dbline 143
; PORTB = 0x00;
out 0x18,R2
.dbline 144
; DDRB = 0xFF;
out 0x17,R24
.dbline 145
; PORTC = 0x00;
out 0x15,R2
.dbline 146
; DDRC = 0x03;
ldi R24,3
out 0x14,R24
.dbline 147
; PORTD = 0xFF;
ldi R24,255
out 0x12,R24
.dbline 148
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L33:
.dbline 0 ; func end
ret
.dbend
.dbfunc e scan_key _scan_key fc
; temp -> R16
.even
_scan_key::
.dbline -1
.dbline 158
; }
; /*************************************/
; char com_data;
; uchar cnt;
; void delay_iic(int n);
; uchar rd_24c01(char a);
; void wr_24c01(char a,char b);
; /******************扫描按键***************/
; uchar scan_key(void)
; {
.dbline 160
; uchar temp;
; temp=PIND;
in R16,0x10
.dbline 161
; return temp;
.dbline -2
L34:
.dbline 0 ; func end
ret
.dbsym r temp 16 c
.dbend
.dbfunc e delay _delay fV
; i -> R20,R21
; j -> R22,R23
; k -> R16,R17
.even
_delay::
xcall push_gset2
.dbline -1
.dbline 165
; }
; /***************延时子函数******************/
; void delay(uint k)
; {
.dbline 167
; uint i,j;
; for(i=0;i<k;i++)
clr R20
clr R21
xjmp L39
L36:
.dbline 168
; {for(j=0;j<121;j++)
.dbline 168
clr R22
clr R23
xjmp L43
L40:
.dbline 169
.dbline 169
.dbline 169
L41:
.dbline 168
subi R22,255 ; offset = 1
sbci R23,255
L43:
.dbline 168
cpi R22,121
ldi R30,0
cpc R23,R30
brlo L40
.dbline 169
L37:
.dbline 167
subi R20,255 ; offset = 1
sbci R21,255
L39:
.dbline 167
cp R20,R16
cpc R21,R17
brlo L36
.dbline -2
L35:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r j 22 i
.dbsym r k 16 i
.dbend
.dbfunc e start _start fV
.even
_start::
.dbline -1
.dbline 174
; {;}}
; }
;
; /*****************启动读写时序子函数******************/
; void start(void)
; {DDRC=0x03;
.dbline 174
ldi R24,3
out 0x14,R24
.dbline 175
; SDA_1;Some_NOP();
sbi 0x15,1
.dbline 175
.dbline 175
nop
.dbline 175
nop
.dbline 175
nop
.dbline 175
nop
.dbline 175
nop
.dbline 175
nop
.dbline 175
nop
.dbline 175
nop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -