📄 main.ls
字号:
4711 0372 7b02 ld a,(OFST+0,sp)
4712 0374 ab30 add a,#48
4713 0376 1e03 ldw x,(OFST+1,sp)
4714 0378 f7 ld (x),a
4715 0379 2023 jra L3372
4716 037b L5662:
4717 ; 158 tmp = hex & 0x000F;
4719 037b 7b07 ld a,(OFST+5,sp)
4720 037d 97 ld xl,a
4721 037e 7b08 ld a,(OFST+6,sp)
4722 0380 a40f and a,#15
4723 0382 5f clrw x
4724 0383 02 rlwa x,a
4725 0384 1f01 ldw (OFST-1,sp),x
4726 0386 01 rrwa x,a
4727 ; 159 if(tmp > 9) *str = tmp + ('A' - 10);
4729 0387 1e01 ldw x,(OFST-1,sp)
4730 0389 a3000a cpw x,#10
4731 038c 2509 jrult L1572
4734 038e 7b02 ld a,(OFST+0,sp)
4735 0390 ab37 add a,#55
4736 0392 1e03 ldw x,(OFST+1,sp)
4737 0394 f7 ld (x),a
4739 0395 2007 jra L3372
4740 0397 L1572:
4741 ; 160 else *str = tmp + '0';
4743 0397 7b02 ld a,(OFST+0,sp)
4744 0399 ab30 add a,#48
4745 039b 1e03 ldw x,(OFST+1,sp)
4746 039d f7 ld (x),a
4747 039e L3372:
4748 ; 165 width--;
4750 039e 0a09 dec (OFST+7,sp)
4751 ; 166 str++;
4753 03a0 1e03 ldw x,(OFST+1,sp)
4754 03a2 1c0001 addw x,#1
4755 03a5 1f03 ldw (OFST+1,sp),x
4756 03a7 L5272:
4757 ; 131 while(width)
4759 03a7 0d09 tnz (OFST+7,sp)
4760 03a9 2703 jreq L27
4761 03ab cc02f1 jp L3272
4762 03ae L27:
4763 ; 168 }
4766 03ae 5b04 addw sp,#4
4767 03b0 81 ret
4860 ; 170 void showLine(const u8 x,const u8 y,u8* lcd_stack,char * str,...)
4860 ; 171 {
4861 switch .text
4862 03b1 _showLine:
4864 03b1 89 pushw x
4865 03b2 5204 subw sp,#4
4866 00000004 OFST: set 4
4869 ; 172 u8 coordinate = 16 * y + x;
4871 03b4 9f ld a,xl
4872 03b5 97 ld xl,a
4873 03b6 a610 ld a,#16
4874 03b8 42 mul x,a
4875 03b9 9f ld a,xl
4876 03ba 1b05 add a,(OFST+1,sp)
4877 03bc 6b04 ld (OFST+0,sp),a
4878 ; 175 va_start(marker,str); // Initialize variable arguments.
4880 03be 96 ldw x,sp
4881 03bf 1c000d addw x,#OFST+9
4882 03c2 1f02 ldw (OFST-2,sp),x
4883 ; 176 for(i=0;i<64;i++)
4885 03c4 0f01 clr (OFST-3,sp)
4886 03c6 L3203:
4889 03c6 0c01 inc (OFST-3,sp)
4892 03c8 7b01 ld a,(OFST-3,sp)
4893 03ca a140 cp a,#64
4894 03cc 25f8 jrult L3203
4896 03ce acdc04dc jpf L3303
4897 03d2 L1303:
4898 ; 182 if(coordinate > 64) break; //防止堆栈溢出
4900 03d2 7b04 ld a,(OFST+0,sp)
4901 03d4 a141 cp a,#65
4902 03d6 2503 jrult L7303
4904 03d8 L5303:
4905 ; 217 va_end( marker ); // Reset variable arguments.
4907 ; 218 }
4910 03d8 5b06 addw sp,#6
4911 03da 81 ret
4912 03db L7303:
4913 ; 184 if(*str == '\\')
4915 03db 1e0b ldw x,(OFST+7,sp)
4916 03dd f6 ld a,(x)
4917 03de a15c cp a,#92
4918 03e0 261b jrne L1403
4919 ; 186 str++;
4921 03e2 1e0b ldw x,(OFST+7,sp)
4922 03e4 1c0001 addw x,#1
4923 03e7 1f0b ldw (OFST+7,sp),x
4924 ; 187 lcd_stack[coordinate] = *str;
4926 03e9 7b09 ld a,(OFST+5,sp)
4927 03eb 97 ld xl,a
4928 03ec 7b0a ld a,(OFST+6,sp)
4929 03ee 1b04 add a,(OFST+0,sp)
4930 03f0 2401 jrnc L67
4931 03f2 5c incw x
4932 03f3 L67:
4933 03f3 02 rlwa x,a
4934 03f4 160b ldw y,(OFST+7,sp)
4935 03f6 90f6 ld a,(y)
4936 03f8 f7 ld (x),a
4938 03f9 acd304d3 jpf L3403
4939 03fd L1403:
4940 ; 189 else if(*str == '%')
4942 03fd 1e0b ldw x,(OFST+7,sp)
4943 03ff f6 ld a,(x)
4944 0400 a125 cp a,#37
4945 0402 2703 jreq L011
4946 0404 cc04c3 jp L5403
4947 0407 L011:
4948 ; 191 str++;
4950 0407 1e0b ldw x,(OFST+7,sp)
4951 0409 1c0001 addw x,#1
4952 040c 1f0b ldw (OFST+7,sp),x
4953 ; 192 if (*str == 'd' || *str == 'D')
4955 040e 1e0b ldw x,(OFST+7,sp)
4956 0410 f6 ld a,(x)
4957 0411 a164 cp a,#100
4958 0413 2707 jreq L1503
4960 0415 1e0b ldw x,(OFST+7,sp)
4961 0417 f6 ld a,(x)
4962 0418 a144 cp a,#68
4963 041a 2637 jrne L7403
4964 041c L1503:
4965 ; 194 str++;
4967 041c 1e0b ldw x,(OFST+7,sp)
4968 041e 1c0001 addw x,#1
4969 0421 1f0b ldw (OFST+7,sp),x
4970 ; 195 decToAscii(&lcd_stack[coordinate],va_arg(marker,u16),(*str-'0'));
4972 0423 1e0b ldw x,(OFST+7,sp)
4973 0425 f6 ld a,(x)
4974 0426 a030 sub a,#48
4975 0428 88 push a
4976 0429 1e03 ldw x,(OFST-1,sp)
4977 042b 1c0002 addw x,#2
4978 042e 1f03 ldw (OFST-1,sp),x
4979 0430 1e03 ldw x,(OFST-1,sp)
4980 0432 5a decw x
4981 0433 5a decw x
4982 0434 fe ldw x,(x)
4983 0435 89 pushw x
4984 0436 7b0c ld a,(OFST+8,sp)
4985 0438 97 ld xl,a
4986 0439 7b0d ld a,(OFST+9,sp)
4987 043b 1b07 add a,(OFST+3,sp)
4988 043d 2401 jrnc L001
4989 043f 5c incw x
4990 0440 L001:
4991 0440 02 rlwa x,a
4992 0441 cd0242 call _decToAscii
4994 0444 5b03 addw sp,#3
4995 ; 196 coordinate += (*str-'0'-1);
4997 0446 1e0b ldw x,(OFST+7,sp)
4998 0448 f6 ld a,(x)
4999 0449 a031 sub a,#49
5000 044b 1b04 add a,(OFST+0,sp)
5001 044d 6b04 ld (OFST+0,sp),a
5003 044f acd304d3 jpf L3403
5004 0453 L7403:
5005 ; 198 else if(*str == 'c' || *str == 'C')
5007 0453 1e0b ldw x,(OFST+7,sp)
5008 0455 f6 ld a,(x)
5009 0456 a163 cp a,#99
5010 0458 2707 jreq L7503
5012 045a 1e0b ldw x,(OFST+7,sp)
5013 045c f6 ld a,(x)
5014 045d a143 cp a,#67
5015 045f 261f jrne L5503
5016 0461 L7503:
5017 ; 200 lcd_stack[coordinate] = va_arg(marker,u16);
5019 0461 7b09 ld a,(OFST+5,sp)
5020 0463 97 ld xl,a
5021 0464 7b0a ld a,(OFST+6,sp)
5022 0466 1b04 add a,(OFST+0,sp)
5023 0468 2401 jrnc L201
5024 046a 5c incw x
5025 046b L201:
5026 046b 02 rlwa x,a
5027 046c 1602 ldw y,(OFST-2,sp)
5028 046e 72a90002 addw y,#2
5029 0472 1702 ldw (OFST-2,sp),y
5030 0474 1602 ldw y,(OFST-2,sp)
5031 0476 905a decw y
5032 0478 905a decw y
5033 047a 90e601 ld a,(1,y)
5034 047d f7 ld (x),a
5036 047e 2053 jra L3403
5037 0480 L5503:
5038 ; 202 else if(*str == 'x' || *str == 'X')
5040 0480 1e0b ldw x,(OFST+7,sp)
5041 0482 f6 ld a,(x)
5042 0483 a178 cp a,#120
5043 0485 2707 jreq L5603
5045 0487 1e0b ldw x,(OFST+7,sp)
5046 0489 f6 ld a,(x)
5047 048a a158 cp a,#88
5048 048c 2645 jrne L3403
5049 048e L5603:
5050 ; 204 str++;
5052 048e 1e0b ldw x,(OFST+7,sp)
5053 0490 1c0001 addw x,#1
5054 0493 1f0b ldw (OFST+7,sp),x
5055 ; 205 hexToAscii(&lcd_stack[coordinate],va_arg(marker,u16),(*str - '0'));
5057 0495 1e0b ldw x,(OFST+7,sp)
5058 0497 f6 ld a,(x)
5059 0498 a030 sub a,#48
5060 049a 88 push a
5061 049b 1e03 ldw x,(OFST-1,sp)
5062 049d 1c0002 addw x,#2
5063 04a0 1f03 ldw (OFST-1,sp),x
5064 04a2 1e03 ldw x,(OFST-1,sp)
5065 04a4 5a decw x
5066 04a5 5a decw x
5067 04a6 fe ldw x,(x)
5068 04a7 89 pushw x
5069 04a8 7b0c ld a,(OFST+8,sp)
5070 04aa 97 ld xl,a
5071 04ab 7b0d ld a,(OFST+9,sp)
5072 04ad 1b07 add a,(OFST+3,sp)
5073 04af 2401 jrnc L401
5074 04b1 5c incw x
5075 04b2 L401:
5076 04b2 02 rlwa x,a
5077 04b3 cd02eb call _hexToAscii
5079 04b6 5b03 addw sp,#3
5080 ; 206 coordinate += (*str - '0' - 1);
5082 04b8 1e0b ldw x,(OFST+7,sp)
5083 04ba f6 ld a,(x)
5084 04bb a031 sub a,#49
5085 04bd 1b04 add a,(OFST+0,sp)
5086 04bf 6b04 ld (OFST+0,sp),a
5087 04c1 2010 jra L3403
5088 04c3 L5403:
5089 ; 212 lcd_stack[coordinate] = *str;
5091 04c3 7b09 ld a,(OFST+5,sp)
5092 04c5 97 ld xl,a
5093 04c6 7b0a ld a,(OFST+6,sp)
5094 04c8 1b04 add a,(OFST+0,sp)
5095 04ca 2401 jrnc L601
5096 04cc 5c incw x
5097 04cd L601:
5098 04cd 02 rlwa x,a
5099 04ce 160b ldw y,(OFST+7,sp)
5100 04d0 90f6 ld a,(y)
5101 04d2 f7 ld (x),a
5102 04d3 L3403:
5103 ; 214 str++;
5105 04d3 1e0b ldw x,(OFST+7,sp)
5106 04d5 1c0001 addw x,#1
5107 04d8 1f0b ldw (OFST+7,sp),x
5108 ; 215 coordinate++;
5110 04da 0c04 inc (OFST+0,sp)
5111 04dc L3303:
5112 ; 180 while(*str != '\0')
5114 04dc 1e0b ldw x,(OFST+7,sp)
5115 04de 7d tnz (x)
5116 04df 2703 jreq L211
5117 04e1 cc03d2 jp L1303
5118 04e4 L211:
5119 04e4 acd803d8 jpf L5303
5214 ; 20 main()
5214 ; 21 {
5215 switch .text
5216 04e8 _main:
5218 04e8 89 pushw x
5219 00000002 OFST: set 2
5222 ; 22 u8 pGetDat,tmp=0;
5224 04e9 0f01 clr (OFST-1,sp)
5225 ; 23 I2C_Init();
5227 04eb cd004c call _I2C_Init
5229 ; 24 st7920LcdInit(); /*LCD初始化*/
5231 04ee cd0138 call _st7920LcdInit
5233 ; 25 showLine(0,0,lcd_buffer,"PCF8591 Example");
5235 04f1 ae0011 ldw x,#L5313
5236 04f4 89 pushw x
5237 04f5 ae0000 ldw x,#_lcd_buffer
5238 04f8 89 pushw x
5239 04f9 5f clrw x
5240 04fa 4f clr a
5241 04fb 95 ld xh,a
5242 04fc cd03b1 call _showLine
5244 04ff 5b04 addw sp,#4
5245 ; 26 showLine(0,1,lcd_buffer,"AD Values:");
5247 0501 ae0006 ldw x,#L7313
5248 0504 89 pushw x
5249 0505 ae0000 ldw x,#_lcd_buffer
5250 0508 89 pushw x
5251 0509 ae0001 ldw x,#1
5252 050c 4f clr a
5253 050d 95 ld xh,a
5254 050e cd03b1 call _showLine
5256 0511 5b04 addw sp,#4
5257 ; 27 refreshLCD(lcd_buffer); /*刷新LCD*/
5259 0513 ae0000 ldw x,#_lcd_buffer
5260 0516 cd01d2 call _refreshLCD
5262 0519 L1413:
5263 ; 30 PCF8591_getAD(MODE0,CHNL0,&pGetDat);
5265 0519 96 ldw x,sp
5266 051a 1c0002 addw x,#OFST+0
5267 051d 89 pushw x
5268 051e 5f clrw x
5269 051f 4f clr a
5270 0520 95 ld xh,a
5271 0521 cd00f5 call _PCF8591_getAD
5273 0524 85 popw x
5274 ; 31 if(pGetDat!=tmp)
5276 0525 7b02 ld a,(OFST+0,sp)
5277 0527 1101 cp a,(OFST-1,sp)
5278 0529 27ee jreq L1413
5279 ; 33 showLine(11,1,lcd_buffer,"0x%x2",(u16)pGetDat);
5281 052b 7b02 ld a,(OFST+0,sp)
5282 052d 5f clrw x
5283 052e 97 ld xl,a
5284 052f 89 pushw x
5285 0530 ae0000 ldw x,#L7413
5286 0533 89 pushw x
5287 0534 ae0000 ldw x,#_lcd_buffer
5288 0537 89 pushw x
5289 0538 ae0001 ldw x,#1
5290 053b a60b ld a,#11
5291 053d 95 ld xh,a
5292 053e cd03b1 call _showLine
5294 0541 5b06 addw sp,#6
5295 ; 34 refreshLCD(lcd_buffer); /*刷新LCD*/
5297 0543 ae0000 ldw x,#_lcd_buffer
5298 0546 cd01d2 call _refreshLCD
5300 ; 35 tmp=pGetDat;
5302 0549 7b02 ld a,(OFST+0,sp)
5303 054b 6b01 ld (OFST-1,sp),a
5304 054d 20ca jra L1413
5317 xdef _main
5318 xdef _SPI_rechar
5319 xdef _SPI_sendchar
5320 xdef _SPI_Init
5321 switch .ubsct
5322 0000 _lcd_buffer:
5323 0000 000000000000 ds.b 64
5324 xdef _lcd_buffer
5325 xdef _showLine
5326 xdef _hexToAscii
5327 xdef _decToAscii
5328 xdef _refreshLCD
5329 xdef _st7920LcdInit
5330 xdef _sendDataST7920
5331 xdef _sendCodeST7920
5332 xdef _PCF8591_getAD
5333 xdef _PCF8591_ReadAByte
5334 xdef _PCF8591_WriteAByte
5335 xdef _I2C_RcvDat
5336 xdef _I2C_SendDat
5337 xdef _I2C_SendDAdr
5338 xdef _I2C_Start
5339 xdef _I2C_Init
5340 xdef _delay_us
5341 xdef _delay_ms
5342 .const: section .text
5343 0000 L7413:
5344 0000 307825783200 dc.b "0x%x2",0
5345 0006 L7313:
5346 0006 41442056616c dc.b "AD Values:",0
5347 0011 L5313:
5348 0011 504346383539 dc.b "PCF8591 Example",0
5368 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -