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

📄 lcd0.s

📁 长沙理工自己的实验程序
💻 S
字号:
	.module lcd0.c
	.area text(rom, con, rel)
;              i -> R10
;              j -> R16,R17
	.even
_timeDelay::
	st -y,R10
; #include "lcd0.h"
; 
; void timeDelay(unsigned int j)                     /* 延时                  */
; {
;     unsigned char i;
; 	
; 	for(i = 0;i < j;i++);
	clr R10
	xjmp L5
L2:
L3:
	inc R10
L5:
	mov R2,R10
	clr R3
	cp R2,R16
	cpc R3,R17
	brlo L2
X0:
L1:
	.dbline 0 ; func end
	ld R10,y+
	ret
;         ucData -> R16
	.even
_lcdWrite::
; }
; 
; void lcdWrite(unsigned char ucData)
; {
L7:
;     while ((PINE & 0x80) != 0x00);                  /* ASK=1,状态为忙,不能接收数据      */
L8:
	sbic 0x1,7
	rjmp L7
X1:
; 	
; 	DATA_H;
	sbi 0x18,0
; 	PORTA = ucData;
	out 0x1b,R16
; 	DATA_L;
	cbi 0x18,0
; 	REQUEST_H;
	sbi 0x03,6
L10:
; 	
; 	while((PINE & 0x80) == 0x00);                   /* ASK=0,闲,接收数据                 */
L11:
	sbis 0x1,7
	rjmp L10
X2:
L6:
	.dbline 0 ; func end
	ret
	.even
_lcdInitiate::
; }
; 
; void lcdInitiate(void)
; {
;     DDRB  |= 0x01;                                  /* 定义PB0(LCD)口为输出            */
	sbi 0x17,0
; 	PORTB &= 0xfe;                                  /* PB0口输出为0           */                            
	in R24,0x18
	andi R24,254
	out 0x18,R24
; 	DDRE   = 0x40;                                  /* PE6为输出            */
	ldi R24,64
	out 0x2,R24
; 	PORTE  = 0xff;                                  /* PE口输出为1          */
	ldi R24,255
	out 0x3,R24
; 	timeDelay(10);
	ldi R16,10
	ldi R17,0
	xcall _timeDelay
L13:
	.dbline 0 ; func end
	ret
	.even
_lcdClear::
; }
; 
; void lcdClear(void)
; {
;     lcdWrite(0xf4);                                  /* 清屏                */
	ldi R16,244
	xcall _lcdWrite
L14:
	.dbline 0 ; func end
	ret
;        ucpData -> R20,R21
;            ucY -> R10
;            ucX -> R22
	.even
_characterDisplay::
	xcall push_xgsetF00C
	mov R10,R18
	mov R22,R16
	ldd R20,y+6
	ldd R21,y+7
; }
; 
; void characterDisplay(unsigned char ucX,unsigned char ucY,unsigned char *ucpData)
; {   
	xjmp L17
L16:
;     while (*ucpData)
;     {
;         lcdWrite(0xf1);                               /* 显示8*8 ASCLL 字符  */
	ldi R16,241
	xcall _lcdWrite
; 	    lcdWrite(ucX);                                /* X坐标               */
	mov R16,R22
	xcall _lcdWrite
; 	    lcdWrite(ucY);                                /* Y坐标               */
	mov R16,R10
	xcall _lcdWrite
; 	    lcdWrite(*ucpData);                           
	movw R30,R20
	ldd R16,z+0
	xcall _lcdWrite
; 		ucpData++;
	subi R20,255  ; offset = 1
	sbci R21,255
; 		
; 		if (ucX >= 19)                                /* 换行                */
	cpi R22,19
	brlo L19
X3:
; 		{
; 		    ucX = 0x04;
	ldi R22,4
; 			ucY += 8;
	mov R24,R10
	subi R24,248    ; addi 8
	mov R10,R24
; 		}
	xjmp L20
L19:
; 		else
; 	    {
; 		    ucX++;
	inc R22
; 		}
L20:
; 	}
L17:
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L16
X4:
L15:
	.dbline 0 ; func end
	xjmp pop_xgsetF00C
;        ucpData -> R20,R21
;            ucY -> R10
;            ucX -> R22
	.even
_chineseDisplay::
	xcall push_xgsetF00C
	mov R10,R18
	mov R22,R16
	ldd R20,y+6
	ldd R21,y+7
; }
; 
; void chineseDisplay(unsigned char ucX,unsigned char ucY,unsigned char *ucpData)
; {
	xjmp L23
L22:
;      
; 	while (*ucpData)
; 	{
; 	   lcdWrite(0xf0);                               /* 显示国标汉字         */
	ldi R16,240
	xcall _lcdWrite
; 	   lcdWrite(ucX);
	mov R16,R22
	xcall _lcdWrite
; 	   lcdWrite(ucY);
	mov R16,R10
	xcall _lcdWrite
; 	   lcdWrite(*ucpData - 0xa0); 
	movw R30,R20
	ldd R16,z+0
	subi R16,160
	xcall _lcdWrite
; 	   ucpData++;
	subi R20,255  ; offset = 1
	sbci R21,255
; 	   lcdWrite(*ucpData - 0xa0); 
	movw R30,R20
	ldd R16,z+0
	subi R16,160
	xcall _lcdWrite
; 	   ucpData++;
	subi R20,255  ; offset = 1
	sbci R21,255
; 	   if (ucX >= 9)
	cpi R22,9
	brlo L25
X5:
; 	   {
; 	       ucX = 2;
	ldi R22,2
; 		   ucY ++;
	inc R10
; 	   }else
	xjmp L26
L25:
; 	   {
; 	       ucX++;
	inc R22
; 	   }
L26:
;     }
L23:
	movw R30,R20
	ldd R2,z+0
	tst R2
	brne L22
X6:
L21:
	.dbline 0 ; func end
	xjmp pop_xgsetF00C
; }
; 	
; 	

⌨️ 快捷键说明

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