📄 led.s
字号:
.module LED.c
.area lit(rom, con, rel)
_Char_I::
.byte 0,0
.byte 130,254
.byte 130,0
.byte 0,0
.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\LED大屏幕显示系统设计\LED.c
.dbsym e Char_I _Char_I A[8:8]kc
_Char_L::
.byte 0,0
.byte 254,2
.byte 2,2
.byte 0,0
.dbsym e Char_L _Char_L A[8:8]kc
_Char_V::
.byte 0,240
.byte 8,4
.byte 4,8
.byte 240,0
.dbsym e Char_V _Char_V A[8:8]kc
_Char_E::
.byte 0,0
.byte 254,146
.byte 146,130
.byte 0,0
.dbsym e Char_E _Char_E A[8:8]kc
_Char_Y::
.byte 0,192
.byte 32,30
.byte 32,192
.byte 0,0
.dbsym e Char_Y _Char_Y A[8:8]kc
_Char_O::
.byte 0,0
.byte 254,130
.byte 130,254
.byte 0,0
.dbsym e Char_O _Char_O A[8:8]kc
_Char_U::
.byte 0,0
.byte 252,2
.byte 2,252
.byte 0,0
.dbsym e Char_U _Char_U A[8:8]kc
_Space::
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.dbsym e Space _Space A[8:8]kc
_DataBaseIndexList::
.byte 73
.word _Char_I
.byte 76
.word _Char_L
.byte 79
.word _Char_O
.byte 86
.word _Char_V
.byte 69
.word _Char_E
.byte 89
.word _Char_Y
.byte 85
.word _Char_U
.byte 0
.word 0
.dbsym e DataBaseIndexList _DataBaseIndexList A[24:8]kX
_String1::
.byte 'I,'L,'O,'V,'E,'Y,'O,'U,0
.dbsym e String1 _String1 A[9:9]kc
.area text(rom, con, rel)
.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\LED大屏幕显示系统设计\LED.c
.dbfunc e Display_Init _Display_Init fV
; Index -> R20
.even
_Display_Init::
xcall push_gset1
.dbline -1
.dbline 58
; //***************************************************************
; // File Name : LED.c
; // Author : Steaven
; // Created : 2008-07-26
; // Modified :
; // Revision : V0.0
; //***************************************************************
;
; #include "iom16v.h"
; #include "DataType.h"
; #include "app.h"
; #include "LED.h"
;
; //constant definition
; const INT8U Char_I[] = {0x00,0x00,0x82,0xFE,0x82,0x00,0x00,0x00};/*"I",0*/
; const INT8U Char_L[] = {0x00,0x00,0xFE,0x02,0x02,0x02,0x00,0x00};/*"L",0*/
; const INT8U Char_V[] = {0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,0x00};/*"V",0*/
; const INT8U Char_E[] = {0x00,0x00,0xFE,0x92,0x92,0x82,0x00,0x00};/*"E",0*/
; const INT8U Char_Y[] = {0x00,0xC0,0x20,0x1E,0x20,0xC0,0x00,0x00};/*"Y",0*/
; const INT8U Char_O[] = {0x00,0x00,0xFE,0x82,0x82,0xFE,0x00,0x00};/*"O",0*/
; const INT8U Char_U[] = {0x00,0x00,0xFC,0x02,0x02,0xFC,0x00,0x00};/*"U",0*/
; const INT8U Space[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};/*" ",0*/
;
; //struct definition
; struct DataBaseIndex
; {
; INT8U Code;
; const INT8U *Ptr;
; };
;
; //char code database list
; const struct DataBaseIndex DataBaseIndexList[] =
; {
; 'I', Char_I,
; 'L', Char_L,
; 'O', Char_O,
; 'V', Char_V,
; 'E', Char_E,
; 'Y', Char_Y,
; 'U', Char_U,
; 0 , 0
; };
;
; //global variables definition
; const INT8U *pBufStr; //字符指针
; const char String1[] = {"ILOVEYOU"}; //字符串
; INT8U DisplayCnt; //显示计数器
; INT8U Buffer[8]; //显示缓冲区
; INT8U Length_of_DataBase; //字符数据库长度
;
; //***************************************************************
; // Function : Display_Init
; // Input : none
; // Output : none
; // Description : Display Initialization
; //***************************************************************
; void Display_Init(void)
; {
.dbline 59
; INT8U Index = 0;
clr R20
.dbline 60
; for(Index = 0;Index < 8;Index++)
xjmp L5
L2:
.dbline 61
.dbline 62
ldi R24,<_Buffer
ldi R25,>_Buffer
mov R30,R20
clr R31
add R30,R24
adc R31,R25
clr R2
std z+0,R2
.dbline 63
L3:
.dbline 60
inc R20
L5:
.dbline 60
cpi R20,8
brlo L2
.dbline 64
; {
; Buffer[Index] = 0;
; }
; pBufStr = String1;
ldi R24,<_String1
ldi R25,>_String1
sts _pBufStr+1,R25
sts _pBufStr,R24
.dbline 65
; DisplayCnt = 0;
clr R2
sts _DisplayCnt,R2
.dbline 66
; Length_of_DataBase = Search_DataBase_Length();
xcall _Search_DataBase_Length
sts _Length_of_DataBase,R16
.dbline -2
.dbline 67
; }
L1:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r Index 20 c
.dbend
.dbfunc e Buffer_IN _Buffer_IN fV
; pdata -> R20,R21
; Count -> R22
; Index -> R10
.even
_Buffer_IN::
xcall push_gset3
mov R10,R16
.dbline -1
.dbline 76
;
; //***************************************************************
; // Function : DotTest
; // Input : none
; // Output : none
; // Description : LED Display Test
; //***************************************************************
; void Buffer_IN(INT8U Index)
; {
.dbline 78
; const INT8U *pdata;
; INT8U Count = 0;
clr R22
.dbline 79
; pdata = SearchCharIndex(*pBufStr);
lds R30,_pBufStr
lds R31,_pBufStr+1
lpm R16,Z
xcall _SearchCharIndex
movw R20,R16
.dbline 80
; if(pdata != (INT8U *)0)
cpi R16,0
cpc R16,R17
breq L7
X0:
.dbline 81
; {
.dbline 82
; for(Count = 0;Count < 7;Count++)
clr R22
xjmp L12
L9:
.dbline 83
.dbline 84
ldi R24,<_Buffer+1
ldi R25,>_Buffer+1
mov R30,R22
clr R31
add R30,R24
adc R31,R25
ldd R2,z+0
ldi R24,<_Buffer
ldi R25,>_Buffer
mov R30,R22
clr R31
add R30,R24
adc R31,R25
std z+0,R2
.dbline 85
L10:
.dbline 82
inc R22
L12:
.dbline 82
cpi R22,7
brlo L9
.dbline 86
mov R30,R10
clr R31
add R30,R20
adc R31,R21
lpm R30,Z
sts _Buffer+7,R30
.dbline 87
L7:
.dbline -2
.dbline 88
; {
; Buffer[Count] = Buffer[Count+1];
; }
; Buffer[7] = *(pdata + Index);
; }
; }
L6:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r pdata 20 pkc
.dbsym r Count 22 c
.dbsym r Index 10 c
.dbend
.dbfunc e SearchCharIndex _SearchCharIndex fpkc
; pDataBasePtr -> R20,R21
; Index -> R22
; CharCode -> R16
.even
_SearchCharIndex::
xcall push_gset2
.dbline -1
.dbline 97
;
; //***************************************************************
; // Function : SearchCharIndex
; // Input : CharCode - Char to be displayed
; // Output : Pointer to the display code of the input char
; // Description : Get the pointer of the display char code
; //***************************************************************
; const INT8U *SearchCharIndex(INT8U CharCode)
; {
.dbline 100
; INT8U Index;
; const struct DataBaseIndex *pDataBasePtr;
; pDataBasePtr = DataBaseIndexList;
ldi R20,<_DataBaseIndexList
ldi R21,>_DataBaseIndexList
.dbline 101
; for(Index = 0;Index <= Length_of_DataBase;Index++)
clr R22
xjmp L19
L16:
.dbline 102
; {
.dbline 103
; if(pDataBasePtr->Code == CharCode)
movw R30,R20
lpm R30,Z
cp R30,R16
brne L20
.dbline 104
; {
.dbline 105
; return(pDataBasePtr->Ptr);
movw R30,R20
adiw R30,1
lpm R16,Z+
lpm R17,Z
xjmp L15
L20:
.dbline 108
.dbline 109
subi R20,253 ; offset = 3
sbci R21,255
.dbline 110
.dbline 111
L17:
.dbline 101
inc R22
L19:
.dbline 101
lds R2,_Length_of_DataBase
cp R2,R22
brsh L16
.dbline 112
; }
; else
; {
; pDataBasePtr++ ;
; }
; }
; return(0);
clr R16
clr R17
.dbline -2
L15:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r pDataBasePtr 20 pkX
.dbsym r Index 22 c
.dbsym r CharCode 16 c
.dbend
.dbfunc e Search_DataBase_Length _Search_DataBase_Length fc
; Index -> R16
; pDataBasePtr -> R18,R19
.even
_Search_DataBase_Length::
.dbline -1
.dbline 122
; }
;
; //***************************************************************
; // Function : Search_DataBase_Length
; // Input : none
; // Output : Length of database list
; // Description : Search DataBase Length
; //***************************************************************
; INT8U Search_DataBase_Length(void)
; {
.dbline 123
; INT8U Index = 0;
clr R16
.dbline 125
; const struct DataBaseIndex *pDataBasePtr;
; pDataBasePtr = DataBaseIndexList;
ldi R18,<_DataBaseIndexList
ldi R19,>_DataBaseIndexList
xjmp L24
L23:
.dbline 127
.dbline 128
inc R16
.dbline 129
subi R18,253 ; offset = 3
sbci R19,255
.dbline 130
L24:
.dbline 126
; while(pDataBasePtr->Code != 0)
movw R30,R18
lpm R30,Z
tst R30
brne L23
.dbline 131
; {
; Index++;
; pDataBasePtr++;
; }
; return(Index);
.dbline -2
L22:
.dbline 0 ; func end
ret
.dbsym r Index 16 c
.dbsym r pDataBasePtr 18 pkX
.dbend
.dbfunc e DotTest _DotTest fV
; Select -> R10
; Index -> R12
; wDelayCnt -> y+0
.even
_DotTest::
xcall push_gset4
sbiw R28,4
.dbline -1
.dbline 141
; }
;
; //***************************************************************
; // Function : DotTest
; // Input : none
; // Output : none
; // Description : LED Display Test
; //***************************************************************
; void DotTest(void)
; {
.dbline 142
; INT8U Select = 0;
clr R10
.dbline 143
; INT8U Index = 0;
clr R12
.dbline 144
; INT32U wDelayCnt = 0;
ldi R20,0
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
.dbline 145
; for(Select = 0;Select < 8;Select++)
xjmp L30
L27:
.dbline 146
; {
.dbline 147
; for(Index = 0;Index < 8;Index++)
clr R12
xjmp L34
L31:
.dbline 148
; {
.dbline 149
; PORTA = 1 << Index;
ldi R16,1
mov R17,R12
xcall lsl8
out 0x1b,R16
.dbline 150
; PORTD = ~(1 << Select);
ldi R16,1
mov R17,R10
xcall lsl8
mov R2,R16
com R2
out 0x12,R2
.dbline 151
ldi R20,0
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 L38
L35:
.dbline 151
.dbline 151
.dbline 151
L36:
.dbline 151
ldi R20,1
ldi R21,0
ldi R22,0
ldi R23,0
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
add R2,R20
adc R3,R21
adc R4,R22
adc R5,R23
movw R30,R28
std z+0,R2
std z+1,R3
std z+2,R4
std z+3,R5
L38:
.dbline 151
ldi R20,144
ldi R21,95
ldi R22,1
ldi R23,0
movw R30,R28
ldd R2,z+0
ldd R3,z+1
ldd R4,z+2
ldd R5,z+3
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
brlo L35
.dbline 152
L32:
.dbline 147
inc R12
L34:
.dbline 147
mov R24,R12
cpi R24,8
brsh X1
xjmp L31
X1:
.dbline 153
L28:
.dbline 145
inc R10
L30:
.dbline 145
mov R24,R10
cpi R24,8
brsh X2
xjmp L27
X2:
.dbline -2
.dbline 154
; for(wDelayCnt = 0;wDelayCnt < 90000;wDelayCnt++) {;}
; }
; }
; }
L26:
adiw R28,4
xcall pop_gset4
.dbline 0 ; func end
ret
.dbsym r Select 10 c
.dbsym r Index 12 c
.dbsym l wDelayCnt 0 l
.dbend
.area bss(ram, con, rel)
.dbfile E:\Steaven2000\AVR\AVR_Book\PROGRA~1\SOURCE~1\Code\LED大屏幕显示系统设计\LED.c
_Length_of_DataBase::
.blkb 1
.dbsym e Length_of_DataBase _Length_of_DataBase c
_Buffer::
.blkb 8
.dbsym e Buffer _Buffer A[8:8]c
_DisplayCnt::
.blkb 1
.dbsym e DisplayCnt _DisplayCnt c
_pBufStr::
.blkb 2
.dbsym e pBufStr _pBufStr pkc
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -