📄 键盘.s
字号:
.module _键盘.c
.area text(rom, con, rel)
.dbfile C:\DOCUME~1\user\MYDOCU~1\李智(正)\键盘\键盘.c
.dbfunc e delay _delay fV
; i -> R20
; t -> R16,R17
.even
_delay::
xcall push_gset1
.dbline -1
.dbline 11
; #include <iom128v.h>
; #define req asm("sbi 0x03,6")
; #define cl_req asm("cbi 0x03,6")
; #define dat asm("sbi 0x18,0")
; #define cl_dat asm("cbi 0x18,0")
; #define cl_reset asm("cbi 0x15,3")
; #define set_reset asm("sbi 0x15,3")
; #define LCD 0x9000
;
; void delay (unsigned int t)
; {
.dbline 13
ldi R20,1
xjmp L5
L2:
.dbline 13
L3:
.dbline 13
inc R20
L5:
.dbline 13
; unsigned char i;
; for (i=1;i<t;i++);
mov R2,R20
clr R3
cp R2,R16
cpc R3,R17
brlo L2
.dbline -2
L1:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r t 16 i
.dbend
.dbfunc e delay_1ms _delay_1ms fV
; i -> R16,R17
.even
_delay_1ms::
.dbline -1
.dbline 16
; }
; void delay_1ms(void)
; {
.dbline 18
clr R16
clr R17
xjmp L10
L7:
.dbline 18
L8:
.dbline 18
subi R16,255 ; offset = 1
sbci R17,255
L10:
.dbline 18
; unsigned int i;
; for (i=0;i<2286;i++);
cpi R16,238
ldi R30,8
cpc R17,R30
brlo L7
.dbline -2
L6:
.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 21
; }
; void delay_nms(unsigned int n)
; {
.dbline 22
; unsigned int i=0;
clr R20
clr R21
.dbline 23
; for (i=0;i<n;i++)
xjmp L15
L12:
.dbline 24
xcall _delay_1ms
L13:
.dbline 23
subi R20,255 ; offset = 1
sbci R21,255
L15:
.dbline 23
cp R20,R22
cpc R21,R23
brlo L12
.dbline -2
L11:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 i
.dbsym r n 22 i
.dbend
.dbfunc e l_delay _l_delay fV
; i -> R16
.even
_l_delay::
.dbline -1
.dbline 28
; delay_1ms();
; }
;
; void l_delay() /* 延时 */
; {
.dbline 29
; unsigned char i=33;
ldi R16,33
xjmp L18
L17:
.dbline 32
.dbline 33
dec R16
.dbline 34
L18:
.dbline 31
;
; while(i!=0)
tst R16
brne L17
.dbline -2
L16:
.dbline 0 ; func end
ret
.dbsym r i 16 c
.dbend
.dbfunc e s_delay _s_delay fV
; i -> R16
.even
_s_delay::
.dbline -1
.dbline 38
; {
; i--;
; }
; }
;
; void s_delay() /* 延时 */
; {
.dbline 39
; unsigned char i=11;
ldi R16,11
xjmp L22
L21:
.dbline 42
.dbline 43
dec R16
.dbline 44
L22:
.dbline 41
;
; while(i!=0)
tst R16
brne L21
.dbline -2
L20:
.dbline 0 ; func end
ret
.dbsym r i 16 c
.dbend
.dbfunc e move _move fV
; i -> R20,R21
.even
_move::
xcall push_gset1
.dbline -1
.dbline 48
; {
; i--;
; }
; }
;
; void move()
; {int i;
.dbline 49
; for(i=0;i<128;i++)
clr R20
clr R21
L25:
.dbline 50
.dbline 50
ldi R16,248
ldi R17,0
xcall _lcd_w
.dbline 51
ldi R16,2
ldi R17,0
xcall _delay_nms
.dbline 51
L26:
.dbline 49
subi R20,255 ; offset = 1
sbci R21,255
.dbline 49
cpi R20,128
ldi R30,0
cpc R21,R30
brlt L25
.dbline -2
L24:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbend
.dbfunc e move1 _move1 fV
; i -> R20,R21
.even
_move1::
xcall push_gset1
.dbline -1
.dbline 55
; {lcd_w(0xf8);
; delay_nms(2);}
; }
;
; void move1()
; {int i;
.dbline 56
; for(i=0;i<64;i++)
clr R20
clr R21
L30:
.dbline 57
.dbline 57
ldi R16,246
ldi R17,0
xcall _lcd_w
.dbline 58
ldi R16,2
ldi R17,0
xcall _delay_nms
.dbline 58
L31:
.dbline 56
subi R20,255 ; offset = 1
sbci R21,255
.dbline 56
cpi R20,64
ldi R30,0
cpc R21,R30
brlt L30
.dbline -2
L29:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbend
.dbfunc e lcd_w _lcd_w fV
; p -> R20,R21
; data -> R16
.even
_lcd_w::
xcall push_gset1
.dbline -1
.dbline 61
; {lcd_w(0xf6);
; delay_nms(2);}
; }
; void lcd_w(unsigned char data)
; {unsigned char *p=(unsigned char *)(LCD);
.dbline 61
ldi R20,36864
ldi R21,144
L35:
.dbline 62
L36:
.dbline 62
; while((PINE&0x80)!=0x00);
in R24,0x1
andi R24,128
brne L35
.dbline 63
; dat;
sbi 0x18,0
.dbline 64
; *p=data;
movw R30,R20
std z+0,R16
.dbline 65
; cl_dat;
cbi 0x18,0
.dbline 66
; ;;
.dbline 66
.dbline 67
; req;
sbi 0x03,6
.dbline 68
; ;;
.dbline 68
L38:
.dbline 69
L39:
.dbline 69
; while((PINE&0x80)==0x00);
in R24,0x1
andi R24,128
breq L38
.dbline 70
; cl_req;
cbi 0x03,6
.dbline -2
L34:
xcall pop_gset1
.dbline 0 ; func end
ret
.dbsym r p 20 pc
.dbsym r data 16 c
.dbend
.dbfunc e lcd_init _lcd_init fV
.even
_lcd_init::
.dbline -1
.dbline 73
; }
; void lcd_init (void)
; {
.dbline 74
; MCUCR=MCUCR|0x80;
in R24,0x35
ori R24,128
out 0x35,R24
.dbline 75
; DDRB|=0x01;
sbi 0x17,0
.dbline 76
; PORTB&=0xfe;
in R24,0x18
andi R24,254
out 0x18,R24
.dbline 77
; DDRE=0x40;
ldi R24,64
out 0x2,R24
.dbline 78
; PORTE=0xff;
ldi R24,255
out 0x3,R24
.dbline 79
; cl_reset;
cbi 0x15,3
.dbline 80
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline 81
; set_reset;
sbi 0x15,3
.dbline 82
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline 83
; cl_req;
cbi 0x03,6
.dbline 84
; delay(10);
ldi R16,10
ldi R17,0
xcall _delay
.dbline -2
L41:
.dbline 0 ; func end
ret
.dbend
.dbfunc e lcd_clear _lcd_clear fV
.even
_lcd_clear::
.dbline -1
.dbline 87
; }
; void lcd_clear (void)
; {
.dbline 88
; lcd_w(0xf4);
ldi R16,244
xcall _lcd_w
.dbline -2
L42:
.dbline 0 ; func end
ret
.dbend
.dbfunc e lcd_putsc _lcd_putsc fV
; ch -> R20,R21
; y -> R22
; x -> R10
.even
_lcd_putsc::
xcall push_gset3
mov R22,R18
mov R10,R16
ldd R20,y+6
ldd R21,y+7
.dbline -1
.dbline 93
; }
;
;
; void lcd_putsc (unsigned char x,unsigned char y,unsigned char *ch)
; {
.dbline 94
; x+=2;
mov R24,R10
subi R24,254 ; addi 2
mov R10,R24
xjmp L45
L44:
.dbline 96
; while (*ch!=0)
; {
.dbline 97
; lcd_w(0xf0);
ldi R16,240
xcall _lcd_w
.dbline 98
; lcd_w(x);
mov R16,R10
xcall _lcd_w
.dbline 99
; lcd_w(y);
mov R16,R22
xcall _lcd_w
.dbline 100
; lcd_w(*ch-0xa0);
movw R30,R20
ldd R16,z+0
subi R16,160
xcall _lcd_w
.dbline 101
; ch++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 102
; lcd_w(*ch-0xa0);
movw R30,R20
ldd R16,z+0
subi R16,160
xcall _lcd_w
.dbline 103
; ch++;
subi R20,255 ; offset = 1
sbci R21,255
.dbline 104
; if (x>=0x09)
mov R24,R10
cpi R24,9
brlo L47
.dbline 105
; {
.dbline 106
; x=2;
ldi R24,2
mov R10,R24
.dbline 107
; y+=1;
inc R22
.dbline 108
; }
xjmp L48
L47:
.dbline 110
; else
; x++;
inc R10
L48:
.dbline 111
L45:
.dbline 95
movw R30,R20
ldd R2,z+0
tst R2
brne L44
.dbline -2
L43:
xcall pop_gset3
.dbline 0 ; func end
ret
.dbsym r ch 20 pc
.dbsym r y 22 c
.dbsym r x 10 c
.dbend
.dbfunc e lcd_putsm _lcd_putsm fV
; i -> R20,R21
; ch -> R22,R23
; y -> R10
; x -> R12
.even
_lcd_putsm::
xcall push_gset4
mov R10,R18
mov R12,R16
ldd R22,y+8
ldd R23,y+9
.dbline -1
.dbline 115
; }
; }
;
; void lcd_putsm(unsigned char x,unsigned char y,unsigned char *ch)
; {int i;
.dbline 116
; x+=2;
mov R24,R12
subi R24,254 ; addi 2
mov R12,R24
xjmp L51
L50:
.dbline 118
; while (*ch!=0)
; {
.dbline 119
; lcd_w(0xf0);
ldi R16,240
xcall _lcd_w
.dbline 120
; lcd_w(x);
mov R16,R12
xcall _lcd_w
.dbline 121
; lcd_w(y);
mov R16,R10
xcall _lcd_w
.dbline 122
; lcd_w(*ch-0xa0);
movw R30,R22
ldd R16,z+0
subi R16,160
xcall _lcd_w
.dbline 123
; ch++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -