📄 main.s
字号:
.module main.c
.area text(rom, con, rel)
.dbfile H:\ICC_Test\EC1602/inc/idelay.c
.dbfunc e DelayUs _DelayUs fV
; i -> R20
; Xus -> R16
.even
_DelayUs::
xcall push_gset1
.dbline -1
.dbline 5
; // Use SPLC780D for EG1602
; #include <iom16v.h>
; #include "inc/macros.h"
; #include "inc/datatype.h"
; #include "inc/idelay.h"
xjmp L3
L2:
.dbline 8
; #include "inc/convert.h"
; #include "inc/780.h"
; void main(void)
clr R20
xjmp L8
L5:
.dbline 9
L6:
.dbline 8
inc R20
L8:
.dbline 8
cpi R20,65
brlo L5
L3:
.dbline 7
mov R24,R16
subi R24,1
mov R16,R24
tst R24
brne L2
.dbline -2
L1:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r Xus 16 c
.dbend
.dbfunc e DelayMs _DelayMs fV
; i -> R20,R21
; Xms -> R16,R17
.even
_DelayMs::
xcall push_gset1
.dbline -1
.dbline 15
; {
; SET_buzzer;
; LCD_Initial();
; CLR_buzzer;
; FillCGRAM();
; while(1)
; {
xjmp L11
L10:
.dbline 18
; Gotoxy(2,5);
; SendStr("Welcome!");
; wait_and_clear();
clr R20
clr R21
xjmp L16
L13:
.dbline 19
L14:
.dbline 18
subi R20,255 ; offset = 1
sbci R21,255
L16:
.dbline 18
cpi R20,143
ldi R30,2
cpc R21,R30
brlo L13
L11:
.dbline 17
movw R24,R16
sbiw R24,1
movw R16,R24
cpi R16,0
cpc R16,R17
brne L10
X0:
.dbline -2
L9:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r Xms 16 i
.dbend
.dbfunc e delay100ms _delay100ms fV
; i -> R20
.even
_delay100ms::
xcall push_gset1
.dbline -1
.dbline 24
;
;
; ShowCGRAM();
; CallBultinChar();
; Gotoxy(2,7);
; SendStr("OK");
.dbline 26
; wait_and_clear();
; }
clr R20
xjmp L21
L18:
.dbline 27
.dbline 28
ldi R16,20
ldi R17,0
xcall _DelayMs
.dbline 29
L19:
.dbline 26
inc R20
L21:
.dbline 26
cpi R20,5
brlo L18
.dbline -2
L17:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e delay500ms _delay500ms fV
; i -> R20
.even
_delay500ms::
xcall push_gset1
.dbline -1
.dbline 33
; //return 0;
; }
; }
; }
; }
; }
; }
.dbline 35
; }
; }
clr R20
xjmp L26
L23:
.dbline 36
.dbline 37
xcall _delay100ms
.dbline 38
L24:
.dbline 35
inc R20
L26:
.dbline 35
cpi R20,5
brlo L23
.dbline -2
L22:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e delay1s _delay1s fV
.even
_delay1s::
.dbline -1
.dbline 42
; }
; }
; }
; }
; }
; }
; }
.dbline 43
; }
ldi R16,1000
ldi R17,3
xcall _DelayMs
.dbline -2
L27:
.dbline 0 ; func end
ret
.dbend
.dbfile H:\ICC_Test\EC1602/inc/convert.c
.dbfunc e RvsByte _RvsByte fc
; tmp -> R20
; i -> R22
; dByte -> R10
.even
_RvsByte::
xcall push_gset3
mov R10,R16
.dbline -1
.dbline 7
.dbline 9
clr R20
.dbline 10
clr R22
xjmp L32
L29:
.dbline 11
.dbline 12
mov R16,R10
mov R17,R22
xcall lsr8
mov R24,R16
andi R24,1
mov R2,R20
lsl R2
or R2,R24
mov R20,R2
.dbline 13
L30:
.dbline 10
inc R22
L32:
.dbline 10
cpi R22,8
brlo L29
.dbline 14
mov R16,R20
.dbline -2
L28:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r tmp 20 c
.dbsym r i 22 c
.dbsym r dByte 10 c
.dbend
.area bss(ram, con, rel)
.dbfile H:\ICC_Test\EC1602/inc/convert.c
L34:
.blkb 3
.area text(rom, con, rel)
.dbfile H:\ICC_Test\EC1602/inc/convert.c
.dbfunc e NumberToChar _NumberToChar fpc
.dbsym s Dest L34 A[3:3]c
; Number -> R20
.even
_NumberToChar::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 19
.dbline 22
ldi R17,100
mov R16,R20
xcall div8u
mov R24,R16
subi R24,208 ; addi 48
sts L34,R24
.dbline 23
ldi R17,100
mov R16,R20
xcall mod8u
ldi R17,10
xcall div8u
mov R24,R16
subi R24,208 ; addi 48
sts L34+1,R24
.dbline 24
ldi R17,100
mov R16,R20
xcall mod8u
ldi R17,10
xcall mod8u
mov R24,R16
subi R24,208 ; addi 48
sts L34+2,R24
.dbline 25
ldi R16,<L34
ldi R17,>L34
.dbline -2
L33:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r Number 20 c
.dbend
.area lit(rom, con, rel)
_CGRAM::
.byte 255,255
.byte 255,255
.byte 255,255
.byte 255,255
.byte 0,0
.byte 0,0
.byte 0,0
.byte 0,0
.byte 'U,'U
.byte 'U,'U
.byte 'U,'U
.byte 'U,'U
.byte 170,170
.byte 170,170
.byte 170,170
.byte 170,170
.byte 255,0
.byte 255,0
.byte 255,0
.byte 255,0
.byte 0,255
.byte 0,255
.byte 0,255
.byte 0,255
.byte 'U,170
.byte 'U,170
.byte 'U,170
.byte 'U,170
.byte 255,17
.byte 17,17
.byte 17,17
.byte 17,255
.dbfile H:\ICC_Test\EC1602/inc/780.h
.dbsym e CGRAM _CGRAM A[64:64]kc
.area text(rom, con, rel)
.dbfile H:\ICC_Test\EC1602/inc/780.h
.dbfile H:\ICC_Test\EC1602/inc/780.c
.dbfunc e CheckBusy _CheckBusy fV
.even
_CheckBusy::
.dbline -1
.dbline 14
.dbline 16
clr R2
out 0x11,R2
.dbline 17
ldi R16,7
ldi R17,0
xcall _DelayMs
.dbline 18
ldi R24,255
out 0x12,R24
.dbline 19
cbi 0x18,0
.dbline 20
sbi 0x18,1
.dbline 21
sbi 0x18,2
L38:
.dbline 22
L39:
.dbline 22
in R2,0x10
clr R3
sbrc R2,7
rjmp L38
.dbline 23
cbi 0x18,2
.dbline 27
ldi R24,255
out 0x11,R24
.dbline -2
L37:
.dbline 0 ; func end
ret
.dbend
.dbfunc e SendByte _SendByte fV
; dByte -> R20
; DatCmd -> R22
.even
_SendByte::
xcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 31
.dbline 32
xcall _CheckBusy
.dbline 35
tst R22
brne L42
.dbline 36
cbi 0x18,0
xjmp L43
L42:
.dbline 38
sbi 0x18,0
L43:
.dbline 39
cbi 0x18,1
.dbline 48
; }
; }
; }
; }
; }
sbi 0x18,2
.dbline 49
; }
out 0x12,R20
.dbline 50
; }
cbi 0x18,2
.dbline -2
L41:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r dByte 20 c
.dbsym r DatCmd 22 c
.dbend
.dbfunc e SendStr _SendStr fV
; ptString -> R20,R21
.even
_SendStr::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 56
; }
; }
; }
; }
; }
; }
xjmp L46
L45:
.dbline 58
.dbline 59
movw R30,R20
ld R18,Z+
movw R20,R30
ldi R16,1
xcall _SendByte
.dbline 60
L46:
.dbline 57
; }
movw R30,R20
ldd R2,z+0
tst R2
brne L45
.dbline -2
L44:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r ptString 20 pc
.dbend
.dbfunc e SendNbr _SendNbr fV
; temp -> R20,R21
; Number -> R20
.even
_SendNbr::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 65
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 67
; }
; }
mov R16,R20
xcall _NumberToChar
movw R20,R16
.dbline 68
; }
movw R30,R20
ld R18,Z+
movw R20,R30
ldi R16,1
xcall _SendByte
.dbline 69
; }
movw R30,R20
ld R18,Z+
movw R20,R30
ldi R16,1
xcall _SendByte
.dbline 70
; }
movw R30,R20
ldd R18,z+0
ldi R16,1
xcall _SendByte
.dbline -2
L48:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r temp 20 pc
.dbsym r Number 20 c
.dbend
.dbfunc e Move _Move fV
; dir -> R20
.even
_Move::
xcall push_gset1
mov R20,R16
.dbline -1
.dbline 74
; }
; }
; }
; }
.dbline 75
; }
mov R18,R20
clr R16
xcall _SendByte
.dbline -2
L49:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r dir 20 c
.dbend
.dbfunc e Gotoxy _Gotoxy fV
; Col -> R20
; Row -> R22
.even
_Gotoxy::
xcall push_gset2
mov R20,R18
mov R22,R16
.dbline -1
.dbline 80
; }
; }
; }
; }
; }
.dbline 82
; }
; }
clr R23
cpi R22,2
ldi R30,0
cpc R23,R30
breq L54
xjmp L51
X1:
.dbline 83
; }
L54:
.dbline 86
; }
; }
; }
mov R18,R20
subi R18,64 ; addi 192
clr R16
xcall _SendByte
.dbline 86
xjmp L52
L51:
.dbline 97
mov R18,R20
subi R18,128 ; addi 128
clr R16
xcall _SendByte
.dbline 97
L52:
.dbline -2
L50:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r Col 20 c
.dbsym r Row 22 c
.dbend
.dbfunc e Clear _Clear fV
.even
_Clear::
.dbline -1
.dbline 103
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 104
; }
ldi R18,1
clr R16
xcall _SendByte
.dbline -2
L55:
.dbline 0 ; func end
ret
.dbend
.dbfunc e wait_and_clear _wait_and_clear fV
.even
_wait_and_clear::
.dbline -1
.dbline 111
; }
; }
; }
; }
; }
; }
; }
.dbline 112
; }
ldi R16,3000
ldi R17,11
xcall _DelayMs
.dbline 113
; }
xcall _Clear
.dbline -2
L56:
.dbline 0 ; func end
ret
.dbend
.dbfunc e FillCGRAM _FillCGRAM fV
; i -> R20
.even
_FillCGRAM::
xcall push_gset1
.dbline -1
.dbline 118
; }
; }
; }
; }
; }
.dbline 120
; }
; }
ldi R18,64
clr R16
xcall _SendByte
.dbline 121
; }
clr R20
xjmp L61
L58:
.dbline 122
.dbline 123
ldi R24,<_CGRAM
ldi R25,>_CGRAM
mov R30,R20
clr R31
add R30,R24
adc R31,R25
lpm R18,Z
ldi R16,1
xcall _SendByte
.dbline 124
L59:
.dbline 121
inc R20
L61:
.dbline 121
cpi R20,64
brlo L58
.dbline -2
L57:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbend
.dbfunc e ShowCGRAM _ShowCGRAM fV
; i -> R20
; k -> R22
.even
_ShowCGRAM::
xcall push_gset3
.dbline -1
.dbline 129
; }
; }
; }
; }
; }
; }
; }
; }
.dbline 131
; }
; }
clr R20
xjmp L66
L63:
.dbline 132
; }
.dbline 133
; }
ldi R18,128
clr R16
xcall _SendByte
.dbline 134
; }
clr R22
xjmp L70
L67:
.dbline 135
; }
.dbline 137
; }
; }
mov R10,R22
clr R11
movw R24,R10
cpi R24,20
ldi R30,0
cpc R25,R30
breq L74
xjmp L72
X2:
.dbline 138
; }
L74:
.dbline 140
; }
; }
ldi R18,192
clr R16
xcall _SendByte
.dbline 140
.dbline 150
; }
; }
; }
; }
; }
; }
; }
; }
; }
; }
L72:
.dbline 153
mov R18,R20
ldi R16,1
xcall _SendByte
.dbline 154
L68:
.dbline 134
inc R22
L70:
.dbline 134
cpi R22,40
brlo L67
.dbline 155
xcall _wait_and_clear
.dbline 156
L64:
.dbline 131
inc R20
L66:
.dbline 131
cpi R20,8
brlo L63
.dbline -2
L62:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r k 22 c
.dbend
.dbfunc e CallBultinChar _CallBultinChar fV
; i -> R20
; k -> R22
.even
_CallBultinChar::
xcall push_gset3
.dbline -1
.dbline 161
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
.dbline 163
; 鼍A
; 鼍A
clr R20
xjmp L79
L76:
.dbline 164
; 鼍A
.dbline 165
; 鼍A
ldi R18,128
clr R16
xcall _SendByte
.dbline 166
; 鼍A
clr R22
xjmp L83
L80:
.dbline 167
; 鼍A
.dbline 169
; 鼍A
; 鼍A
mov R10,R22
clr R11
movw R24,R10
cpi R24,20
ldi R30,0
cpc R25,R30
breq L87
xjmp L85
X3:
.dbline 170
; 鼍A
L87:
.dbline 172
; 鼍A
; 鼍A
ldi R18,192
clr R16
xcall _SendByte
.dbline 172
.dbline 182
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
L85:
.dbline 185
ldi R24,20
mul R24,R20
mov R18,R22
add R18,R0
ldi R16,1
xcall _SendByte
.dbline 186
L81:
.dbline 166
inc R22
L83:
.dbline 166
cpi R22,40
brlo L80
.dbline 187
xcall _wait_and_clear
.dbline 188
L77:
.dbline 163
subi R20,254 ; addi 2
L79:
.dbline 163
cpi R20,20
brlo L76
.dbline -2
L75:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r k 22 c
.dbend
.dbfunc e LCD_Initial _LCD_Initial fV
.even
_LCD_Initial::
.dbline -1
.dbline 192
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
.dbline 193
; 鼍A
xcall _delay100ms
.dbline 196
; 鼍A
; 鼍A
; 鼍A
ldi R24,15
out 0x17,R24
.dbline 223
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
ldi R18,56
clr R16
xcall _SendByte
.dbline 225
; 鼍A
; 鼍A
ldi R18,12
clr R16
xcall _SendByte
.dbline 227
; 鼍A
; 鼍A
xcall _Clear
.dbline 228
; 鼍A
ldi R18,6
clr R16
xcall _SendByte
.dbline 235
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
; 鼍A
ldi R18,4
ldi R16,1
xcall _Gotoxy
.dbline 236
; 鼍A
ldi R16,<L89
ldi R17,>L89
xcall _SendStr
.dbline 239
; 鼍A
; 鼍A
; 鼍A
ldi R18,1
ldi R16,2
xcall _Gotoxy
.dbline 240
; 鼍A
ldi R16,<L90
ldi R17,>L90
xcall _SendStr
.dbline 241
; 鼍A
ldi R16,20
xcall _SendNbr
.dbline 242
; 鼍A
xcall _wait_and_clear
.dbline 243
; 鼍A
ldi R18,1
ldi R16,1
xcall _Gotoxy
.dbline 244
; 鼍A
ldi R16,<L91
ldi R17,>L91
xcall _SendStr
.dbline 245
; 鼍A
ldi R16,2
xcall _SendNbr
.dbline 246
; 鼍A
ldi R18,1
ldi R16,2
xcall _Gotoxy
.dbline 247
; 鼍A
ldi R16,<L92
ldi R17,>L92
xcall _SendStr
.dbline 248
; 鼍A
ldi R16,40
xcall _SendNbr
.dbline 249
; 鼍A
xcall _wait_and_clear
.dbline -2
L88:
.dbline 0 ; func end
ret
.dbend
.dbfile H:\ICC_Test\EC1602\main.c
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 9
.dbline 10
sbi 0x18,3
.dbline 11
xcall _LCD_Initial
.dbline 12
cbi 0x18,3
.dbline 13
xcall _FillCGRAM
xjmp L95
L94:
.dbline 15
.dbline 16
ldi R18,5
ldi R16,2
xcall _Gotoxy
.dbline 17
ldi R16,<L97
ldi R17,>L97
xcall _SendStr
.dbline 18
xcall _wait_and_clear
.dbline 21
xcall _ShowCGRAM
.dbline 22
xcall _CallBultinChar
.dbline 23
ldi R18,7
ldi R16,2
xcall _Gotoxy
.dbline 24
ldi R16,<L98
ldi R17,>L98
xcall _SendStr
.dbline 25
xcall _wait_and_clear
.dbline 26
L95:
.dbline 14
xjmp L94
X4:
.dbline -2
L93:
.dbline 0 ; func end
ret
.dbend
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
L98:
.blkb 3
.area idata
.byte 'O,'K,0
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
L97:
.blkb 9
.area idata
.byte 'W,'e,'l,'c,'o,'m,'e,33,0
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
L92:
.blkb 11
.area idata
.byte 'L,'C,'D,95,'C,'H,'A,'R,58,32,0
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
L91:
.blkb 11
.area idata
.byte 'L,'C,'D,95,'R,'O,'W,'S,58,32,0
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
L90:
.blkb 11
.area idata
.byte 'L,'C,'D,95,'C,'O,'L,'S,58,32,0
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
L89:
.blkb 9
.area idata
.byte 'L,'C,'D,95,56,'B,'I,'T,0
.area data(ram, con, rel)
.dbfile H:\ICC_Test\EC1602\main.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -