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

📄 main.ls

📁 STM8全部资料
💻 LS
📖 第 1 页 / 共 2 页
字号:
   1                     ; C Compiler for STM8 (COSMIC Software)
   2                     ; Parser V4.8.32.1 - 30 Mar 2010
   3                     ; Generator V4.3.4 - 23 Mar 2010
2823                     ; 52 void delay_ms(u16 ms)
2823                     ; 53 {
2825                     	switch	.text
2826  0000               _delay_ms:
2828  0000 89            	pushw	x
2829  0001 88            	push	a
2830       00000001      OFST:	set	1
2833  0002 201b          	jra	L1102
2834  0004               L7002:
2835                     ; 57 				for(i=0;i<250;i++)
2837  0004 0f01          	clr	(OFST+0,sp)
2838  0006               L5102:
2841  0006 0c01          	inc	(OFST+0,sp)
2844  0008 7b01          	ld	a,(OFST+0,sp)
2845  000a a1fa          	cp	a,#250
2846  000c 25f8          	jrult	L5102
2847                     ; 59 				for(i=0;i<75;i++)
2849  000e 0f01          	clr	(OFST+0,sp)
2850  0010               L3202:
2853  0010 0c01          	inc	(OFST+0,sp)
2856  0012 7b01          	ld	a,(OFST+0,sp)
2857  0014 a14b          	cp	a,#75
2858  0016 25f8          	jrult	L3202
2859                     ; 61 				ms--;
2861  0018 1e02          	ldw	x,(OFST+1,sp)
2862  001a 1d0001        	subw	x,#1
2863  001d 1f02          	ldw	(OFST+1,sp),x
2864  001f               L1102:
2865                     ; 55 			while(ms!=0)
2867  001f 1e02          	ldw	x,(OFST+1,sp)
2868  0021 26e1          	jrne	L7002
2869                     ; 63 }
2872  0023 5b03          	addw	sp,#3
2873  0025 81            	ret
2916                     ; 65 void delay_us(u16 us)
2916                     ; 66 {
2917                     	switch	.text
2918  0026               _delay_us:
2920  0026 89            	pushw	x
2921  0027 88            	push	a
2922       00000001      OFST:	set	1
2925  0028 201b          	jra	L5502
2926  002a               L3502:
2927                     ; 70 				for(i=0;i<25;i++)
2929  002a 0f01          	clr	(OFST+0,sp)
2930  002c               L1602:
2933  002c 0c01          	inc	(OFST+0,sp)
2936  002e 7b01          	ld	a,(OFST+0,sp)
2937  0030 a119          	cp	a,#25
2938  0032 25f8          	jrult	L1602
2939                     ; 72 				for(i=0;i<7;i++)
2941  0034 0f01          	clr	(OFST+0,sp)
2942  0036               L7602:
2945  0036 0c01          	inc	(OFST+0,sp)
2948  0038 7b01          	ld	a,(OFST+0,sp)
2949  003a a107          	cp	a,#7
2950  003c 25f8          	jrult	L7602
2951                     ; 74 				us--;
2953  003e 1e02          	ldw	x,(OFST+1,sp)
2954  0040 1d0001        	subw	x,#1
2955  0043 1f02          	ldw	(OFST+1,sp),x
2956  0045               L5502:
2957                     ; 68 			while(us!=0)
2959  0045 1e02          	ldw	x,(OFST+1,sp)
2960  0047 26e1          	jrne	L3502
2961                     ; 76 }
2964  0049 5b03          	addw	sp,#3
2965  004b 81            	ret
3034                     ; 32 void delay(u8 z) 
3034                     ; 33 { 
3035                     	switch	.text
3036  004c               _delay:
3038  004c 89            	pushw	x
3039       00000002      OFST:	set	2
3042                     ; 35 	for(x=z;x>0;x--) 
3044  004d 6b01          	ld	(OFST-1,sp),a
3046  004f 200c          	jra	L5312
3047  0051               L1312:
3048                     ; 36 		for(y=110;y>0;y--); 
3050  0051 a66e          	ld	a,#110
3051  0053 6b02          	ld	(OFST+0,sp),a
3052  0055               L1412:
3056  0055 0a02          	dec	(OFST+0,sp)
3059  0057 0d02          	tnz	(OFST+0,sp)
3060  0059 26fa          	jrne	L1412
3061                     ; 35 	for(x=z;x>0;x--) 
3063  005b 0a01          	dec	(OFST-1,sp)
3064  005d               L5312:
3067  005d 0d01          	tnz	(OFST-1,sp)
3068  005f 26f0          	jrne	L1312
3069                     ; 37 }  
3072  0061 85            	popw	x
3073  0062 81            	ret
3127                     ; 18 _Bool lcd1602_busy(void)
3127                     ; 19 {
3128                     	switch	.text
3129  0063               _lcd1602_busy:
3131  0063 88            	push	a
3132       00000001      OFST:	set	1
3135                     ; 21 	RS_CLR;
3137  0064 721a5016      	bset	_PE_DDR,#5
3140  0068 721a5017      	bset	_PE_CR1,#5
3143  006c 721b5014      	bres	_PE_ODR,#5
3144                     ; 22 	RW_SET;
3147  0070 721c500c      	bset	_PC_DDR,#6
3150  0074 721c500d      	bset	_PC_CR1,#6
3153  0078 721c500a      	bset	_PC_ODR,#6
3154                     ; 23 	EN_SET;
3157  007c 721a500c      	bset	_PC_DDR,#5
3160  0080 721a500d      	bset	_PC_CR1,#5
3163  0084 721a500a      	bset	_PC_ODR,#5
3164                     ; 24 	delay(5);
3167  0088 a605          	ld	a,#5
3168  008a adc0          	call	_delay
3170                     ; 25 	PORT_busy;
3172  008c 725f5011      	clr	_PD_DDR
3175  0090 35ff5012      	mov	_PD_CR1,#255
3176                     ; 26 	result=(busy & 0x80);
3179  0094 c65010        	ld	a,_PD_IDR
3180  0097 a580          	bcp	a,#128
3181  0099 2705          	jreq	L41
3182  009b ae0001        	ldw	x,#1
3183  009e 2001          	jra	L61
3184  00a0               L41:
3185  00a0 5f            	clrw	x
3186  00a1               L61:
3187  00a1 9f            	ld	a,xl
3188  00a2 6b01          	ld	(OFST+0,sp),a
3189                     ; 27 	EN_CLR;
3191  00a4 721a500c      	bset	_PC_DDR,#5
3194  00a8 721a500d      	bset	_PC_CR1,#5
3197  00ac 721b500a      	bres	_PC_ODR,#5
3198                     ; 28 	return result;
3201  00b0 0d01          	tnz	(OFST+0,sp)
3202  00b2 2704          	jreq	L02
3203  00b4 a601          	ld	a,#1
3204  00b6 2001          	jra	L22
3205  00b8               L02:
3206  00b8 4f            	clr	a
3207  00b9               L22:
3210  00b9 5b01          	addw	sp,#1
3211  00bb 81            	ret
3256                     ; 31 void lcd1602_write_com(u8 com)
3256                     ; 32 {
3257                     	switch	.text
3258  00bc               _lcd1602_write_com:
3260  00bc 88            	push	a
3261       00000000      OFST:	set	0
3264  00bd               L3122:
3265                     ; 33 	while(lcd1602_busy());
3267  00bd ada4          	call	_lcd1602_busy
3269  00bf 4d            	tnz	a
3270  00c0 26fb          	jrne	L3122
3271                     ; 34 	RS_CLR;
3273  00c2 721a5016      	bset	_PE_DDR,#5
3276  00c6 721a5017      	bset	_PE_CR1,#5
3279  00ca 721b5014      	bres	_PE_ODR,#5
3280                     ; 35 	RW_CLR;
3283  00ce 721c500c      	bset	_PC_DDR,#6
3286  00d2 721c500d      	bset	_PC_CR1,#6
3289  00d6 721d500a      	bres	_PC_ODR,#6
3290                     ; 36 	EN_CLR;
3293  00da 721a500c      	bset	_PC_DDR,#5
3296  00de 721a500d      	bset	_PC_CR1,#5
3299  00e2 721b500a      	bres	_PC_ODR,#5
3300                     ; 37 	PORT_OUT;
3303  00e6 35ff5011      	mov	_PD_DDR,#255
3306  00ea 35ff5012      	mov	_PD_CR1,#255
3307                     ; 38 	PORT=com;
3310  00ee 7b01          	ld	a,(OFST+1,sp)
3311  00f0 c7500f        	ld	_PD_ODR,a
3312                     ; 39 	EN_SET;
3314  00f3 721a500c      	bset	_PC_DDR,#5
3317  00f7 721a500d      	bset	_PC_CR1,#5
3320  00fb 721a500a      	bset	_PC_ODR,#5
3321                     ; 40 	delay(5);
3324  00ff a605          	ld	a,#5
3325  0101 cd004c        	call	_delay
3327                     ; 41 	EN_CLR;
3329  0104 721a500c      	bset	_PC_DDR,#5
3332  0108 721a500d      	bset	_PC_CR1,#5
3335  010c 721b500a      	bres	_PC_ODR,#5
3336                     ; 42 }
3340  0110 84            	pop	a
3341  0111 81            	ret
3386                     ; 44 void lcd1602_write_data(u8 dat)
3386                     ; 45 {
3387                     	switch	.text
3388  0112               _lcd1602_write_data:
3390  0112 88            	push	a
3391       00000000      OFST:	set	0
3394  0113               L7322:
3395                     ; 46 	while(lcd1602_busy());
3397  0113 cd0063        	call	_lcd1602_busy
3399  0116 4d            	tnz	a
3400  0117 26fa          	jrne	L7322
3401                     ; 47 	RS_SET;
3403  0119 721a5016      	bset	_PE_DDR,#5
3406  011d 721a5017      	bset	_PE_CR1,#5
3409  0121 721a5014      	bset	_PE_ODR,#5
3410                     ; 48 	RW_CLR;
3413  0125 721c500c      	bset	_PC_DDR,#6
3416  0129 721c500d      	bset	_PC_CR1,#6
3419  012d 721d500a      	bres	_PC_ODR,#6
3420                     ; 49 	EN_CLR;
3423  0131 721a500c      	bset	_PC_DDR,#5
3426  0135 721a500d      	bset	_PC_CR1,#5
3429  0139 721b500a      	bres	_PC_ODR,#5
3430                     ; 50 	PORT_OUT;
3433  013d 35ff5011      	mov	_PD_DDR,#255
3436  0141 35ff5012      	mov	_PD_CR1,#255
3437                     ; 51 	PORT=dat;
3440  0145 7b01          	ld	a,(OFST+1,sp)
3441  0147 c7500f        	ld	_PD_ODR,a
3442                     ; 52 	EN_SET;
3444  014a 721a500c      	bset	_PC_DDR,#5
3447  014e 721a500d      	bset	_PC_CR1,#5
3450  0152 721a500a      	bset	_PC_ODR,#5
3451                     ; 53 	delay(5);
3454  0156 a605          	ld	a,#5
3455  0158 cd004c        	call	_delay
3457                     ; 54 	EN_CLR;
3459  015b 721a500c      	bset	_PC_DDR,#5
3462  015f 721a500d      	bset	_PC_CR1,#5
3465  0163 721b500a      	bres	_PC_ODR,#5
3466                     ; 55 }
3470  0167 84            	pop	a
3471  0168 81            	ret
3524                     ; 57 void lcd1602_gotoxy(u8 x,u8 y)
3524                     ; 58 {
3525                     	switch	.text
3526  0169               _lcd1602_gotoxy:
3528  0169 89            	pushw	x
3529  016a 88            	push	a
3530       00000001      OFST:	set	1
3533                     ; 60 	if(y==0)
3535  016b 9f            	ld	a,xl
3536  016c 4d            	tnz	a
3537  016d 2607          	jrne	L1722
3538                     ; 61 		add=0x80+x;
3540  016f 9e            	ld	a,xh
3541  0170 ab80          	add	a,#128
3542  0172 6b01          	ld	(OFST+0,sp),a
3544  0174 2006          	jra	L3722
3545  0176               L1722:
3546                     ; 63 		add=0xc0+x;
3548  0176 7b02          	ld	a,(OFST+1,sp)
3549  0178 abc0          	add	a,#192
3550  017a 6b01          	ld	(OFST+0,sp),a
3551  017c               L3722:
3552                     ; 64 	lcd1602_write_com(add);
3554  017c 7b01          	ld	a,(OFST+0,sp)
3555  017e cd00bc        	call	_lcd1602_write_com
3557                     ; 66 }
3560  0181 5b03          	addw	sp,#3
3561  0183 81            	ret
3586                     ; 68 void lcd1602_init(void)
3586                     ; 69 {
3587                     	switch	.text
3588  0184               _lcd1602_init:
3592                     ; 70 	delay(100);
3594  0184 a664          	ld	a,#100
3595  0186 cd004c        	call	_delay
3597                     ; 71 	lcd1602_write_com(0x38);

⌨️ 快捷键说明

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