📄 main.ls
字号:
4404 037f 89 pushw x
4405 0380 7b0c ld a,(OFST+8,sp)
4406 0382 97 ld xl,a
4407 0383 7b0d ld a,(OFST+9,sp)
4408 0385 1b07 add a,(OFST+3,sp)
4409 0387 2401 jrnc L06
4410 0389 5c incw x
4411 038a L06:
4412 038a 02 rlwa x,a
4413 038b cd018c call _decToAscii
4415 038e 5b03 addw sp,#3
4416 ; 196 coordinate += (*str-'0'-1);
4418 0390 1e0b ldw x,(OFST+7,sp)
4419 0392 f6 ld a,(x)
4420 0393 a031 sub a,#49
4421 0395 1b04 add a,(OFST+0,sp)
4422 0397 6b04 ld (OFST+0,sp),a
4424 0399 ac1d041d jpf L7652
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
4615 ; 18 void I2C_Init(void)
4615 ; 19 {
4616 switch .text
4617 0432 _I2C_Init:
4621 ; 20 I2C_FREQR=0x0f; //设置频率寄存器
4623 0432 350f5212 mov _I2C_FREQR,#15
4624 ; 21 I2C_CCRH=0x00; //设置始终寄存器高位
4626 0436 725f521c clr _I2C_CCRH
4627 ; 22 I2C_CCRL=0x50; //设置始终寄存器低位
4629 043a 3550521b mov _I2C_CCRL,#80
4630 ; 23 I2C_TRISER=0x11; //设置最大SCL上升时间
4632 043e 3511521d mov _I2C_TRISER,#17
4633 ; 24 I2C_CR1|=0x01; //使能I2C模块
4635 0442 72105210 bset _I2C_CR1,#0
4636 ; 25 I2C_Ack(); //设置匹配应答
4638 0446 72145211 bset _I2C_CR2,#2
4639 ; 26 I2C_CR2|=0x08; //设置接收应答
4642 044a 72165211 bset _I2C_CR2,#3
4643 ; 27 }
4646 044e 81 ret
4672 ; 30 void I2C_Start(void)
4672 ; 31 {
4673 switch .text
4674 044f _I2C_Start:
4678 044f L1662:
4679 ; 32 I2C_busy();
4681 044f c65219 ld a,_I2C_SR3
4682 0452 a402 and a,#2
4683 0454 a101 cp a,#1
4684 0456 27f7 jreq L1662
4685 ; 33 I2C_start();
4688 0458 72105211 bset _I2C_CR2,#0
4691 045c L7662:
4692 ; 34 while(I2C_SBask==0);
4694 045c c65217 ld a,_I2C_SR1
4695 045f a501 bcp a,#1
4696 0461 27f9 jreq L7662
4697 ; 35 }
4700 0463 81 ret
4737 ; 37 void I2C_SendDAdr(u8 Add)
4737 ; 38 {
4738 switch .text
4739 0464 _I2C_SendDAdr:
4743 ; 39 I2C_writebyte(Add);
4745 0464 c75216 ld _I2C_DR,a
4748 0467 L3172:
4749 ; 40 while(I2C_addrask==0);
4751 0467 c65217 ld a,_I2C_SR1
4752 046a a502 bcp a,#2
4753 046c 27f9 jreq L3172
4755 046e L1272:
4756 ; 41 I2C_busy();
4758 046e c65219 ld a,_I2C_SR3
4759 0471 a402 and a,#2
4760 0473 a101 cp a,#1
4761 0475 27f7 jreq L1272
4762 ; 42 }
4766 0477 81 ret
4803 ; 45 void I2C_SendDat(u8 data)
4803 ; 46 {
4804 switch .text
4805 0478 _I2C_SendDat:
4809 ; 47 I2C_writebyte(data);
4811 0478 c75216 ld _I2C_DR,a
4814 047b L5472:
4815 ; 48 I2C_busy();
4817 047b c65219 ld a,_I2C_SR3
4818 047e a402 and a,#2
4819 0480 a101 cp a,#1
4820 0482 27f7 jreq L5472
4823 0484 L3572:
4824 ; 49 while(I2C_TxEask==0);
4826 0484 c65217 ld a,_I2C_SR1
4827 0487 a580 bcp a,#128
4828 0489 27f9 jreq L3572
4829 ; 50 }
4832 048b 81 ret
4868 ; 52 u8 I2C_RcvDat(void)
4868 ; 53 {
4869 switch .text
4870 048c _I2C_RcvDat:
4872 048c 88 push a
4873 00000001 OFST: set 1
4876 048d L1003:
4877 ; 55 while(I2C_RxNeask==0);
4879 048d c65217 ld a,_I2C_SR1
4880 0490 a540 bcp a,#64
4881 0492 27f9 jreq L1003
4882 0494 L7572:
4883 ; 56 abc:
4883 ; 57 if(I2C_BTF==0x04)
4885 0494 c65217 ld a,_I2C_SR1
4886 0497 a404 and a,#4
4887 0499 a104 cp a,#4
4888 049b 26f7 jrne L7572
4889 ; 58 {i=I2C_DR;}
4891 049d c65216 ld a,_I2C_DR
4892 04a0 6b01 ld (OFST+0,sp),a
4894 ; 60 if(I2C_BTF==0){}
4896 04a2 c65217 ld a,_I2C_SR1
4897 04a5 a504 bcp a,#4
4898 04a7 26eb jrne L7572
4900 ; 62 return i;
4902 04a9 7b01 ld a,(OFST+0,sp)
4905 04ab 5b01 addw sp,#1
4906 04ad 81 ret
4947 ; 20 void PCF8574_Init(void)
4947 ; 21 {
4948 switch .text
4949 04ae _PCF8574_Init:
4953 ; 22 I2C_Init();
4955 04ae ad82 call _I2C_Init
4957 ; 23 }
4960 04b0 81 ret
4998 ; 25 void PCF8574_WriteAByte(u8 data)
4998 ; 26 {
4999 switch .text
5000 04b1 _PCF8574_WriteAByte:
5002 04b1 88 push a
5003 00000000 OFST: set 0
5006 ; 27 I2C_Start();
5008 04b2 ad9b call _I2C_Start
5010 ; 28 I2C_SendDAdr(0x40);
5012 04b4 a640 ld a,#64
5013 04b6 adac call _I2C_SendDAdr
5015 ; 29 I2C_SendDat(data);
5017 04b8 7b01 ld a,(OFST+1,sp)
5018 04ba adbc call _I2C_SendDat
5020 ; 30 I2C_stop();
5022 04bc 72125211 bset _I2C_CR2,#1
5023 ; 31 }
5027 04c0 84 pop a
5028 04c1 81 ret
5086 ; 20 void main(void)
5086 ; 21 {
5087 switch .text
5088 04c2 _main:
5090 04c2 88 push a
5091 00000001 OFST: set 1
5094 ; 23 PCF8574_Init();
5096 04c3 ade9 call _PCF8574_Init
5098 ; 24 st7920LcdInit();
5100 04c5 cd0082 call _st7920LcdInit
5102 ; 25 showLine(0,0,lcd_buffer,"PCF8574 Example");
5104 04c8 ae0029 ldw x,#L5703
5105 04cb 89 pushw x
5106 04cc ae0000 ldw x,#_lcd_buffer
5107 04cf 89 pushw x
5108 04d0 5f clrw x
5109 04d1 4f clr a
5110 04d2 95 ld xh,a
5111 04d3 cd02fb call _showLine
5113 04d6 5b04 addw sp,#4
5114 ; 26 showLine(0,1,lcd_buffer,"I2C->Parallel");
5116 04d8 ae001b ldw x,#L7703
5117 04db 89 pushw x
5118 04dc ae0000 ldw x,#_lcd_buffer
5119 04df 89 pushw x
5120 04e0 ae0001 ldw x,#1
5121 04e3 4f clr a
5122 04e4 95 ld xh,a
5123 04e5 cd02fb call _showLine
5125 04e8 5b04 addw sp,#4
5126 ; 27 showLine(0,2,lcd_buffer,"Focus on LED");
5128 04ea ae000e ldw x,#L1013
5129 04ed 89 pushw x
5130 04ee ae0000 ldw x,#_lcd_buffer
5131 04f1 89 pushw x
5132 04f2 ae0002 ldw x,#2
5133 04f5 4f clr a
5134 04f6 95 ld xh,a
5135 04f7 cd02fb call _showLine
5137 04fa 5b04 addw sp,#4
5138 ; 28 refreshLCD(lcd_buffer);
5140 04fc ae0000 ldw x,#_lcd_buffer
5141 04ff cd011c call _refreshLCD
5143 0502 L3013:
5144 ; 31 showLine(0,3,lcd_buffer,"Values:0x%x2",(u16)i);
5146 0502 7b01 ld a,(OFST+0,sp)
5147 0504 5f clrw x
5148 0505 97 ld xl,a
5149 0506 89 pushw x
5150 0507 ae0000 ldw x,#L7013
5151 050a 89 pushw x
5152 050b ae0000 ldw x,#_lcd_buffer
5153 050e 89 pushw x
5154 050f ae0003 ldw x,#3
5155 0512 4f clr a
5156 0513 95 ld xh,a
5157 0514 cd02fb call _showLine
5159 0517 5b06 addw sp,#6
5160 ; 32 refreshLCD(lcd_buffer);
5162 0519 ae0000 ldw x,#_lcd_buffer
5163 051c cd011c call _refreshLCD
5165 ; 33 PCF8574_WriteAByte(i);
5167 051f 7b01 ld a,(OFST+0,sp)
5168 0521 ad8e call _PCF8574_WriteAByte
5170 ; 34 i++;
5172 0523 0c01 inc (OFST+0,sp)
5173 ; 35 delay_ms(1000);
5175 0525 ae03e8 ldw x,#1000
5176 0528 cd0000 call _delay_ms
5179 052b 20d5 jra L3013
5192 xdef _main
5193 xdef _PCF8574_WriteAByte
5194 xdef _PCF8574_Init
5195 xdef _I2C_RcvDat
5196 xdef _I2C_SendDat
5197 xdef _I2C_SendDAdr
5198 xdef _I2C_Start
5199 xdef _I2C_Init
5200 xdef _SPI_rechar
5201 xdef _SPI_sendchar
5202 xdef _SPI_Init
5203 switch .ubsct
5204 0000 _lcd_buffer:
5205 0000 000000000000 ds.b 64
5206 xdef _lcd_buffer
5207 xdef _showLine
5208 xdef _hexToAscii
5209 xdef _decToAscii
5210 xdef _refreshLCD
5211 xdef _st7920LcdInit
5212 xdef _sendDataST7920
5213 xdef _sendCodeST7920
5214 xdef _delay_us
5215 xdef _delay_ms
5216 .const: section .text
5217 0000 L7013:
5218 0000 56616c756573 dc.b "Values",163
5219 0007 ba3078257832 dc.b 186,48,120,37,120,50,0
5220 000e L1013:
5221 000e 466f63757320 dc.b "Focus on LED",0
5222 001b L7703:
5223 001b 4932432d3e50 dc.b "I2C->Parallel",0
5224 0029 L5703:
5225 0029 504346383537 dc.b "PCF8574 Example",0
5245 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -