📄 main.ls
字号:
4425 039d L3752:
4426 ; 198 else if(*str == 'c' || *str == 'C')
4428 039d 1e0b ldw x,(OFST+7,sp)
4429 039f f6 ld a,(x)
4430 03a0 a163 cp a,#99
4431 03a2 2707 jreq L3062
4433 03a4 1e0b ldw x,(OFST+7,sp)
4434 03a6 f6 ld a,(x)
4435 03a7 a143 cp a,#67
4436 03a9 261f jrne L1062
4437 03ab L3062:
4438 ; 200 lcd_stack[coordinate] = va_arg(marker,u16);
4440 03ab 7b09 ld a,(OFST+5,sp)
4441 03ad 97 ld xl,a
4442 03ae 7b0a ld a,(OFST+6,sp)
4443 03b0 1b04 add a,(OFST+0,sp)
4444 03b2 2401 jrnc L26
4445 03b4 5c incw x
4446 03b5 L26:
4447 03b5 02 rlwa x,a
4448 03b6 1602 ldw y,(OFST-2,sp)
4449 03b8 72a90002 addw y,#2
4450 03bc 1702 ldw (OFST-2,sp),y
4451 03be 1602 ldw y,(OFST-2,sp)
4452 03c0 905a decw y
4453 03c2 905a decw y
4454 03c4 90e601 ld a,(1,y)
4455 03c7 f7 ld (x),a
4457 03c8 2053 jra L7652
4458 03ca L1062:
4459 ; 202 else if(*str == 'x' || *str == 'X')
4461 03ca 1e0b ldw x,(OFST+7,sp)
4462 03cc f6 ld a,(x)
4463 03cd a178 cp a,#120
4464 03cf 2707 jreq L1162
4466 03d1 1e0b ldw x,(OFST+7,sp)
4467 03d3 f6 ld a,(x)
4468 03d4 a158 cp a,#88
4469 03d6 2645 jrne L7652
4470 03d8 L1162:
4471 ; 204 str++;
4473 03d8 1e0b ldw x,(OFST+7,sp)
4474 03da 1c0001 addw x,#1
4475 03dd 1f0b ldw (OFST+7,sp),x
4476 ; 205 hexToAscii(&lcd_stack[coordinate],va_arg(marker,u16),(*str - '0'));
4478 03df 1e0b ldw x,(OFST+7,sp)
4479 03e1 f6 ld a,(x)
4480 03e2 a030 sub a,#48
4481 03e4 88 push a
4482 03e5 1e03 ldw x,(OFST-1,sp)
4483 03e7 1c0002 addw x,#2
4484 03ea 1f03 ldw (OFST-1,sp),x
4485 03ec 1e03 ldw x,(OFST-1,sp)
4486 03ee 5a decw x
4487 03ef 5a decw x
4488 03f0 fe ldw x,(x)
4489 03f1 89 pushw x
4490 03f2 7b0c ld a,(OFST+8,sp)
4491 03f4 97 ld xl,a
4492 03f5 7b0d ld a,(OFST+9,sp)
4493 03f7 1b07 add a,(OFST+3,sp)
4494 03f9 2401 jrnc L46
4495 03fb 5c incw x
4496 03fc L46:
4497 03fc 02 rlwa x,a
4498 03fd cd0235 call _hexToAscii
4500 0400 5b03 addw sp,#3
4501 ; 206 coordinate += (*str - '0' - 1);
4503 0402 1e0b ldw x,(OFST+7,sp)
4504 0404 f6 ld a,(x)
4505 0405 a031 sub a,#49
4506 0407 1b04 add a,(OFST+0,sp)
4507 0409 6b04 ld (OFST+0,sp),a
4508 040b 2010 jra L7652
4509 040d L1752:
4510 ; 212 lcd_stack[coordinate] = *str;
4512 040d 7b09 ld a,(OFST+5,sp)
4513 040f 97 ld xl,a
4514 0410 7b0a ld a,(OFST+6,sp)
4515 0412 1b04 add a,(OFST+0,sp)
4516 0414 2401 jrnc L66
4517 0416 5c incw x
4518 0417 L66:
4519 0417 02 rlwa x,a
4520 0418 160b ldw y,(OFST+7,sp)
4521 041a 90f6 ld a,(y)
4522 041c f7 ld (x),a
4523 041d L7652:
4524 ; 214 str++;
4526 041d 1e0b ldw x,(OFST+7,sp)
4527 041f 1c0001 addw x,#1
4528 0422 1f0b ldw (OFST+7,sp),x
4529 ; 215 coordinate++;
4531 0424 0c04 inc (OFST+0,sp)
4532 0426 L7552:
4533 ; 180 while(*str != '\0')
4535 0426 1e0b ldw x,(OFST+7,sp)
4536 0428 7d tnz (x)
4537 0429 2703 jreq L27
4538 042b cc031c jp L5552
4539 042e L27:
4540 042e ac220322 jpf L1652
4620 ; 18 void _delay_us(u8 us)
4620 ; 19 {
4621 switch .text
4622 0432 __delay_us:
4624 0432 88 push a
4625 00000000 OFST: set 0
4628 0433 L7562:
4629 ; 20 while(--us);
4631 0433 0a01 dec (OFST+1,sp)
4632 0435 26fc jrne L7562
4633 ; 21 }
4636 0437 84 pop a
4637 0438 81 ret
4664 ; 24 void resetOnewire(void)
4664 ; 25 {
4665 switch .text
4666 0439 _resetOnewire:
4670 ; 26 OUT_DQ();
4672 0439 7214500c bset _PC_DDR,#2
4673 ; 27 CLR_DQ();
4675 043d 7215500a bres _PC_ODR,#2
4676 ; 28 _delay_us(750);
4678 0441 a6ee ld a,#238
4679 0443 aded call __delay_us
4681 ; 29 SET_DQ();
4683 0445 7214500a bset _PC_ODR,#2
4684 ; 30 _delay_us(100);
4686 0449 a664 ld a,#100
4687 044b ade5 call __delay_us
4689 ; 31 IN_DQ();
4691 044d 7215500c bres _PC_DDR,#2
4693 0451 L5762:
4694 ; 33 while(!(GET_DQ()));
4696 0451 c6500b ld a,_PC_IDR
4697 0454 a504 bcp a,#4
4698 0456 27f9 jreq L5762
4699 ; 34 SET_DQ();
4701 0458 7214500a bset _PC_ODR,#2
4702 ; 35 }
4705 045c 81 ret
4752 ; 38 u8 rOnewire(void)
4752 ; 39 {
4753 switch .text
4754 045d _rOnewire:
4756 045d 89 pushw x
4757 00000002 OFST: set 2
4760 ; 40 u8 data=0,i=0;
4762 045e 0f02 clr (OFST+0,sp)
4765 ; 41 for(i=0;i<8;i++)
4767 0460 0f01 clr (OFST-1,sp)
4768 0462 L3272:
4769 ; 43 data=data>>1;
4771 0462 0402 srl (OFST+0,sp)
4772 ; 44 OUT_DQ();
4774 0464 7214500c bset _PC_DDR,#2
4775 ; 45 CLR_DQ();
4777 0468 7215500a bres _PC_ODR,#2
4778 ; 46 IN_DQ();
4780 046c 7215500c bres _PC_DDR,#2
4781 ; 47 if(GET_DQ()) data|=0x80;
4783 0470 c6500b ld a,_PC_IDR
4784 0473 a504 bcp a,#4
4785 0475 2708 jreq L7372
4788 0477 7b02 ld a,(OFST+0,sp)
4789 0479 aa80 or a,#128
4790 047b 6b02 ld (OFST+0,sp),a
4792 047d 2007 jra L3372
4793 047f L7372:
4794 ; 48 else while(!(GET_DQ()));
4796 047f c6500b ld a,_PC_IDR
4797 0482 a504 bcp a,#4
4798 0484 27f9 jreq L7372
4799 0486 L3372:
4800 ; 49 _delay_us(60);
4802 0486 a63c ld a,#60
4803 0488 ada8 call __delay_us
4805 ; 41 for(i=0;i<8;i++)
4807 048a 0c01 inc (OFST-1,sp)
4810 048c 7b01 ld a,(OFST-1,sp)
4811 048e a108 cp a,#8
4812 0490 25d0 jrult L3272
4813 ; 51 return(data);
4815 0492 7b02 ld a,(OFST+0,sp)
4818 0494 85 popw x
4819 0495 81 ret
4865 ; 54 void wOnewire(u8 data)
4865 ; 55 {
4866 switch .text
4867 0496 _wOnewire:
4869 0496 88 push a
4870 0497 88 push a
4871 00000001 OFST: set 1
4874 ; 56 u8 i=0;
4876 ; 57 OUT_DQ();
4878 0498 7214500c bset _PC_DDR,#2
4879 ; 58 for(i=0;i<8;i++)
4881 049c 0f01 clr (OFST+0,sp)
4882 049e L5672:
4883 ; 60 CLR_DQ();
4885 049e 7215500a bres _PC_ODR,#2
4886 ; 61 if(data&0x01)
4888 04a2 7b02 ld a,(OFST+1,sp)
4889 04a4 a501 bcp a,#1
4890 04a6 2706 jreq L3772
4891 ; 63 SET_DQ();
4893 04a8 7214500a bset _PC_ODR,#2
4895 04ac 2004 jra L5772
4896 04ae L3772:
4897 ; 67 CLR_DQ();
4899 04ae 7215500a bres _PC_ODR,#2
4900 04b2 L5772:
4901 ; 69 data=data>>1;
4903 04b2 0402 srl (OFST+1,sp)
4904 ; 70 _delay_us(60); //65
4906 04b4 a63c ld a,#60
4907 04b6 cd0432 call __delay_us
4909 ; 71 SET_DQ();
4911 04b9 7214500a bset _PC_ODR,#2
4912 ; 58 for(i=0;i<8;i++)
4914 04bd 0c01 inc (OFST+0,sp)
4917 04bf 7b01 ld a,(OFST+0,sp)
4918 04c1 a108 cp a,#8
4919 04c3 25d9 jrult L5672
4920 ; 73 }
4923 04c5 85 popw x
4924 04c6 81 ret
4988 ; 20 void getDs2401Number(u8 *tmp)
4988 ; 21 {
4989 switch .text
4990 04c7 _getDs2401Number:
4992 04c7 89 pushw x
4993 04c8 88 push a
4994 00000001 OFST: set 1
4997 ; 23 resetOnewire(); //先复位onewire
4999 04c9 cd0439 call _resetOnewire
5001 ; 24 wOnewire(0x33); //发"Read_ROM"指令
5003 04cc a633 ld a,#51
5004 04ce adc6 call _wOnewire
5006 ; 25 for(i=0;i<8;i++)
5008 04d0 0f01 clr (OFST+0,sp)
5009 04d2 L7203:
5010 ; 27 *(tmp+i)=rOnewire();
5012 04d2 7b02 ld a,(OFST+1,sp)
5013 04d4 97 ld xl,a
5014 04d5 7b03 ld a,(OFST+2,sp)
5015 04d7 1b01 add a,(OFST+0,sp)
5016 04d9 2401 jrnc L601
5017 04db 5c incw x
5018 04dc L601:
5019 04dc 02 rlwa x,a
5020 04dd 89 pushw x
5021 04de cd045d call _rOnewire
5023 04e1 85 popw x
5024 04e2 f7 ld (x),a
5025 ; 25 for(i=0;i<8;i++)
5027 04e3 0c01 inc (OFST+0,sp)
5030 04e5 7b01 ld a,(OFST+0,sp)
5031 04e7 a108 cp a,#8
5032 04e9 25e7 jrult L7203
5033 ; 29 }
5036 04eb 5b03 addw sp,#3
5037 04ed 81 ret
5103 ; 20 main()
5103 ; 21 {
5104 switch .text
5105 04ee _main:
5107 04ee 5209 subw sp,#9
5108 00000009 OFST: set 9
5111 ; 24 getDs2401Number(serial_number);
5113 04f0 96 ldw x,sp
5114 04f1 1c0001 addw x,#OFST-8
5115 04f4 add1 call _getDs2401Number
5117 ; 25 st7920LcdInit(); /*LCD初始化*/
5119 04f6 cd0082 call _st7920LcdInit
5121 ; 26 showLine(0,0,lcd_buffer,"DS2401 Example");
5123 04f9 ae0014 ldw x,#L5603
5124 04fc 89 pushw x
5125 04fd ae0000 ldw x,#_lcd_buffer
5126 0500 89 pushw x
5127 0501 5f clrw x
5128 0502 4f clr a
5129 0503 95 ld xh,a
5130 0504 cd02fb call _showLine
5132 0507 5b04 addw sp,#4
5133 ; 27 showLine(0,1,lcd_buffer,"Serial Number:");
5135 0509 ae0005 ldw x,#L7603
5136 050c 89 pushw x
5137 050d ae0000 ldw x,#_lcd_buffer
5138 0510 89 pushw x
5139 0511 ae0001 ldw x,#1
5140 0514 4f clr a
5141 0515 95 ld xh,a
5142 0516 cd02fb call _showLine
5144 0519 5b04 addw sp,#4
5145 ; 28 for(n=0;n<8;n++)
5147 051b 0f09 clr (OFST+0,sp)
5148 051d L1703:
5149 ; 30 showLine(n*4,2,lcd_buffer,"%x2H",(u16)serial_number[n]);
5151 051d 96 ldw x,sp
5152 051e 1c0001 addw x,#OFST-8
5153 0521 9f ld a,xl
5154 0522 5e swapw x
5155 0523 1b09 add a,(OFST+0,sp)
5156 0525 2401 jrnc L211
5157 0527 5c incw x
5158 0528 L211:
5159 0528 02 rlwa x,a
5160 0529 f6 ld a,(x)
5161 052a 5f clrw x
5162 052b 97 ld xl,a
5163 052c 89 pushw x
5164 052d ae0000 ldw x,#L7703
5165 0530 89 pushw x
5166 0531 ae0000 ldw x,#_lcd_buffer
5167 0534 89 pushw x
5168 0535 ae0002 ldw x,#2
5169 0538 7b0f ld a,(OFST+6,sp)
5170 053a 48 sll a
5171 053b 48 sll a
5172 053c 95 ld xh,a
5173 053d cd02fb call _showLine
5175 0540 5b06 addw sp,#6
5176 ; 28 for(n=0;n<8;n++)
5178 0542 0c09 inc (OFST+0,sp)
5181 0544 7b09 ld a,(OFST+0,sp)
5182 0546 a108 cp a,#8
5183 0548 25d3 jrult L1703
5184 ; 32 refreshLCD(lcd_buffer); /*刷新LCD*/
5186 054a ae0000 ldw x,#_lcd_buffer
5187 054d cd011c call _refreshLCD
5189 0550 L1013:
5190 ; 33 while(1);
5192 0550 20fe jra L1013
5205 xdef _main
5206 xdef _getDs2401Number
5207 xdef _wOnewire
5208 xdef _rOnewire
5209 xdef _resetOnewire
5210 xdef __delay_us
5211 xdef _SPI_rechar
5212 xdef _SPI_sendchar
5213 xdef _SPI_Init
5214 switch .ubsct
5215 0000 _lcd_buffer:
5216 0000 000000000000 ds.b 64
5217 xdef _lcd_buffer
5218 xdef _showLine
5219 xdef _hexToAscii
5220 xdef _decToAscii
5221 xdef _refreshLCD
5222 xdef _st7920LcdInit
5223 xdef _sendDataST7920
5224 xdef _sendCodeST7920
5225 xdef _delay_us
5226 xdef _delay_ms
5227 .const: section .text
5228 0000 L7703:
5229 0000 2578324800 dc.b "%x2H",0
5230 0005 L7603:
5231 0005 53657269616c dc.b "Serial Number:",0
5232 0014 L5603:
5233 0014 445332343031 dc.b "DS2401 Example",0
5253 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -