📄 main.ls
字号:
4982 03fa 5f clrw x
4983 03fb 02 rlwa x,a
4984 03fc 1f01 ldw (OFST-1,sp),x
4985 03fe 01 rrwa x,a
4986 ; 159 if(tmp > 9) *str = tmp + ('A' - 10);
4988 03ff 1e01 ldw x,(OFST-1,sp)
4989 0401 a3000a cpw x,#10
4990 0404 2509 jrult L3272
4993 0406 7b02 ld a,(OFST+0,sp)
4994 0408 ab37 add a,#55
4995 040a 1e03 ldw x,(OFST+1,sp)
4996 040c f7 ld (x),a
4998 040d 2007 jra L5072
4999 040f L3272:
5000 ; 160 else *str = tmp + '0';
5002 040f 7b02 ld a,(OFST+0,sp)
5003 0411 ab30 add a,#48
5004 0413 1e03 ldw x,(OFST+1,sp)
5005 0415 f7 ld (x),a
5006 0416 L5072:
5007 ; 165 width--;
5009 0416 0a09 dec (OFST+7,sp)
5010 ; 166 str++;
5012 0418 1e03 ldw x,(OFST+1,sp)
5013 041a 1c0001 addw x,#1
5014 041d 1f03 ldw (OFST+1,sp),x
5015 041f L7762:
5016 ; 131 while(width)
5018 041f 0d09 tnz (OFST+7,sp)
5019 0421 2703 jreq L66
5020 0423 cc0369 jp L5762
5021 0426 L66:
5022 ; 168 }
5025 0426 5b04 addw sp,#4
5026 0428 81 ret
5119 ; 170 void showLine(const u8 x,const u8 y,u8* lcd_stack,char * str,...)
5119 ; 171 {
5120 switch .text
5121 0429 _showLine:
5123 0429 89 pushw x
5124 042a 5204 subw sp,#4
5125 00000004 OFST: set 4
5128 ; 172 u8 coordinate = 16 * y + x;
5130 042c 9f ld a,xl
5131 042d 97 ld xl,a
5132 042e a610 ld a,#16
5133 0430 42 mul x,a
5134 0431 9f ld a,xl
5135 0432 1b05 add a,(OFST+1,sp)
5136 0434 6b04 ld (OFST+0,sp),a
5137 ; 175 va_start(marker,str); // Initialize variable arguments.
5139 0436 96 ldw x,sp
5140 0437 1c000d addw x,#OFST+9
5141 043a 1f02 ldw (OFST-2,sp),x
5142 ; 176 for(i=0;i<64;i++)
5144 043c 0f01 clr (OFST-3,sp)
5145 043e L5772:
5148 043e 0c01 inc (OFST-3,sp)
5151 0440 7b01 ld a,(OFST-3,sp)
5152 0442 a140 cp a,#64
5153 0444 25f8 jrult L5772
5155 0446 ac540554 jpf L5003
5156 044a L3003:
5157 ; 182 if(coordinate > 64) break; //防止堆栈溢出
5159 044a 7b04 ld a,(OFST+0,sp)
5160 044c a141 cp a,#65
5161 044e 2503 jrult L1103
5163 0450 L7003:
5164 ; 217 va_end( marker ); // Reset variable arguments.
5166 ; 218 }
5169 0450 5b06 addw sp,#6
5170 0452 81 ret
5171 0453 L1103:
5172 ; 184 if(*str == '\\')
5174 0453 1e0b ldw x,(OFST+7,sp)
5175 0455 f6 ld a,(x)
5176 0456 a15c cp a,#92
5177 0458 261b jrne L3103
5178 ; 186 str++;
5180 045a 1e0b ldw x,(OFST+7,sp)
5181 045c 1c0001 addw x,#1
5182 045f 1f0b ldw (OFST+7,sp),x
5183 ; 187 lcd_stack[coordinate] = *str;
5185 0461 7b09 ld a,(OFST+5,sp)
5186 0463 97 ld xl,a
5187 0464 7b0a ld a,(OFST+6,sp)
5188 0466 1b04 add a,(OFST+0,sp)
5189 0468 2401 jrnc L27
5190 046a 5c incw x
5191 046b L27:
5192 046b 02 rlwa x,a
5193 046c 160b ldw y,(OFST+7,sp)
5194 046e 90f6 ld a,(y)
5195 0470 f7 ld (x),a
5197 0471 ac4b054b jpf L5103
5198 0475 L3103:
5199 ; 189 else if(*str == '%')
5201 0475 1e0b ldw x,(OFST+7,sp)
5202 0477 f6 ld a,(x)
5203 0478 a125 cp a,#37
5204 047a 2703 jreq L401
5205 047c cc053b jp L7103
5206 047f L401:
5207 ; 191 str++;
5209 047f 1e0b ldw x,(OFST+7,sp)
5210 0481 1c0001 addw x,#1
5211 0484 1f0b ldw (OFST+7,sp),x
5212 ; 192 if (*str == 'd' || *str == 'D')
5214 0486 1e0b ldw x,(OFST+7,sp)
5215 0488 f6 ld a,(x)
5216 0489 a164 cp a,#100
5217 048b 2707 jreq L3203
5219 048d 1e0b ldw x,(OFST+7,sp)
5220 048f f6 ld a,(x)
5221 0490 a144 cp a,#68
5222 0492 2637 jrne L1203
5223 0494 L3203:
5224 ; 194 str++;
5226 0494 1e0b ldw x,(OFST+7,sp)
5227 0496 1c0001 addw x,#1
5228 0499 1f0b ldw (OFST+7,sp),x
5229 ; 195 decToAscii(&lcd_stack[coordinate],va_arg(marker,u16),(*str-'0'));
5231 049b 1e0b ldw x,(OFST+7,sp)
5232 049d f6 ld a,(x)
5233 049e a030 sub a,#48
5234 04a0 88 push a
5235 04a1 1e03 ldw x,(OFST-1,sp)
5236 04a3 1c0002 addw x,#2
5237 04a6 1f03 ldw (OFST-1,sp),x
5238 04a8 1e03 ldw x,(OFST-1,sp)
5239 04aa 5a decw x
5240 04ab 5a decw x
5241 04ac fe ldw x,(x)
5242 04ad 89 pushw x
5243 04ae 7b0c ld a,(OFST+8,sp)
5244 04b0 97 ld xl,a
5245 04b1 7b0d ld a,(OFST+9,sp)
5246 04b3 1b07 add a,(OFST+3,sp)
5247 04b5 2401 jrnc L47
5248 04b7 5c incw x
5249 04b8 L47:
5250 04b8 02 rlwa x,a
5251 04b9 cd02ba call _decToAscii
5253 04bc 5b03 addw sp,#3
5254 ; 196 coordinate += (*str-'0'-1);
5256 04be 1e0b ldw x,(OFST+7,sp)
5257 04c0 f6 ld a,(x)
5258 04c1 a031 sub a,#49
5259 04c3 1b04 add a,(OFST+0,sp)
5260 04c5 6b04 ld (OFST+0,sp),a
5262 04c7 ac4b054b jpf L5103
5263 04cb L1203:
5264 ; 198 else if(*str == 'c' || *str == 'C')
5266 04cb 1e0b ldw x,(OFST+7,sp)
5267 04cd f6 ld a,(x)
5268 04ce a163 cp a,#99
5269 04d0 2707 jreq L1303
5271 04d2 1e0b ldw x,(OFST+7,sp)
5272 04d4 f6 ld a,(x)
5273 04d5 a143 cp a,#67
5274 04d7 261f jrne L7203
5275 04d9 L1303:
5276 ; 200 lcd_stack[coordinate] = va_arg(marker,u16);
5278 04d9 7b09 ld a,(OFST+5,sp)
5279 04db 97 ld xl,a
5280 04dc 7b0a ld a,(OFST+6,sp)
5281 04de 1b04 add a,(OFST+0,sp)
5282 04e0 2401 jrnc L67
5283 04e2 5c incw x
5284 04e3 L67:
5285 04e3 02 rlwa x,a
5286 04e4 1602 ldw y,(OFST-2,sp)
5287 04e6 72a90002 addw y,#2
5288 04ea 1702 ldw (OFST-2,sp),y
5289 04ec 1602 ldw y,(OFST-2,sp)
5290 04ee 905a decw y
5291 04f0 905a decw y
5292 04f2 90e601 ld a,(1,y)
5293 04f5 f7 ld (x),a
5295 04f6 2053 jra L5103
5296 04f8 L7203:
5297 ; 202 else if(*str == 'x' || *str == 'X')
5299 04f8 1e0b ldw x,(OFST+7,sp)
5300 04fa f6 ld a,(x)
5301 04fb a178 cp a,#120
5302 04fd 2707 jreq L7303
5304 04ff 1e0b ldw x,(OFST+7,sp)
5305 0501 f6 ld a,(x)
5306 0502 a158 cp a,#88
5307 0504 2645 jrne L5103
5308 0506 L7303:
5309 ; 204 str++;
5311 0506 1e0b ldw x,(OFST+7,sp)
5312 0508 1c0001 addw x,#1
5313 050b 1f0b ldw (OFST+7,sp),x
5314 ; 205 hexToAscii(&lcd_stack[coordinate],va_arg(marker,u16),(*str - '0'));
5316 050d 1e0b ldw x,(OFST+7,sp)
5317 050f f6 ld a,(x)
5318 0510 a030 sub a,#48
5319 0512 88 push a
5320 0513 1e03 ldw x,(OFST-1,sp)
5321 0515 1c0002 addw x,#2
5322 0518 1f03 ldw (OFST-1,sp),x
5323 051a 1e03 ldw x,(OFST-1,sp)
5324 051c 5a decw x
5325 051d 5a decw x
5326 051e fe ldw x,(x)
5327 051f 89 pushw x
5328 0520 7b0c ld a,(OFST+8,sp)
5329 0522 97 ld xl,a
5330 0523 7b0d ld a,(OFST+9,sp)
5331 0525 1b07 add a,(OFST+3,sp)
5332 0527 2401 jrnc L001
5333 0529 5c incw x
5334 052a L001:
5335 052a 02 rlwa x,a
5336 052b cd0363 call _hexToAscii
5338 052e 5b03 addw sp,#3
5339 ; 206 coordinate += (*str - '0' - 1);
5341 0530 1e0b ldw x,(OFST+7,sp)
5342 0532 f6 ld a,(x)
5343 0533 a031 sub a,#49
5344 0535 1b04 add a,(OFST+0,sp)
5345 0537 6b04 ld (OFST+0,sp),a
5346 0539 2010 jra L5103
5347 053b L7103:
5348 ; 212 lcd_stack[coordinate] = *str;
5350 053b 7b09 ld a,(OFST+5,sp)
5351 053d 97 ld xl,a
5352 053e 7b0a ld a,(OFST+6,sp)
5353 0540 1b04 add a,(OFST+0,sp)
5354 0542 2401 jrnc L201
5355 0544 5c incw x
5356 0545 L201:
5357 0545 02 rlwa x,a
5358 0546 160b ldw y,(OFST+7,sp)
5359 0548 90f6 ld a,(y)
5360 054a f7 ld (x),a
5361 054b L5103:
5362 ; 214 str++;
5364 054b 1e0b ldw x,(OFST+7,sp)
5365 054d 1c0001 addw x,#1
5366 0550 1f0b ldw (OFST+7,sp),x
5367 ; 215 coordinate++;
5369 0552 0c04 inc (OFST+0,sp)
5370 0554 L5003:
5371 ; 180 while(*str != '\0')
5373 0554 1e0b ldw x,(OFST+7,sp)
5374 0556 7d tnz (x)
5375 0557 2703 jreq L601
5376 0559 cc044a jp L3003
5377 055c L601:
5378 055c ac500450 jpf L7003
5467 ; 21 void main(void)
5467 ; 22 {
5468 switch .text
5469 0560 _main:
5471 0560 88 push a
5472 00000001 OFST: set 1
5475 ; 25 PS2_Init();
5477 0561 cd004c call _PS2_Init
5479 ; 27 st7920LcdInit();
5481 0564 cd01b0 call _st7920LcdInit
5483 ; 28 showLine(0,0,lcd_buffer,"Keyboard Example");
5485 0567 ae0017 ldw x,#L3013
5486 056a 89 pushw x
5487 056b ae0000 ldw x,#_lcd_buffer
5488 056e 89 pushw x
5489 056f 5f clrw x
5490 0570 4f clr a
5491 0571 95 ld xh,a
5492 0572 cd0429 call _showLine
5494 0575 5b04 addw sp,#4
5495 ; 29 showLine(0,1,lcd_buffer,"Press the Keyboard:");
5497 0577 ae0003 ldw x,#L5013
5498 057a 89 pushw x
5499 057b ae0000 ldw x,#_lcd_buffer
5500 057e 89 pushw x
5501 057f ae0001 ldw x,#1
5502 0582 4f clr a
5503 0583 95 ld xh,a
5504 0584 cd0429 call _showLine
5506 0587 5b04 addw sp,#4
5507 ; 30 refreshLCD(lcd_buffer);
5509 0589 ae0000 ldw x,#_lcd_buffer
5510 058c cd024a call _refreshLCD
5512 058f L7013:
5513 ; 34 check();
5515 058f cd0065 call _check
5517 ; 35 if(rcvF)
5519 btst _rcvF
5520 0597 24f6 jruge L7013
5521 ; 37 data=keyHandle(keyVal);
5523 0599 b640 ld a,_keyVal
5524 059b cd00bc call _keyHandle
5526 059e 6b01 ld (OFST+0,sp),a
5527 ; 38 if(data!=0xff){
5529 05a0 7b01 ld a,(OFST+0,sp)
5530 05a2 a1ff cp a,#255
5531 05a4 27e9 jreq L7013
5532 ; 39 showLine(4,2,lcd_buffer,"%c",(u16)data);
5534 05a6 7b01 ld a,(OFST+0,sp)
5535 05a8 5f clrw x
5536 05a9 97 ld xl,a
5537 05aa 89 pushw x
5538 05ab ae0000 ldw x,#L7113
5539 05ae 89 pushw x
5540 05af ae0000 ldw x,#_lcd_buffer
5541 05b2 89 pushw x
5542 05b3 ae0002 ldw x,#2
5543 05b6 a604 ld a,#4
5544 05b8 95 ld xh,a
5545 05b9 cd0429 call _showLine
5547 05bc 5b06 addw sp,#6
5548 ; 40 refreshLCD(lcd_buffer);}
5550 05be ae0000 ldw x,#_lcd_buffer
5551 05c1 cd024a call _refreshLCD
5553 05c4 20c9 jra L7013
5566 xdef _main
5567 xdef _SPI_rechar
5568 xdef _SPI_sendchar
5569 xdef _SPI_Init
5570 switch .ubsct
5571 0000 _lcd_buffer:
5572 0000 000000000000 ds.b 64
5573 xdef _lcd_buffer
5574 xdef _showLine
5575 xdef _hexToAscii
5576 xdef _decToAscii
5577 xdef _refreshLCD
5578 xdef _st7920LcdInit
5579 xdef _sendDataST7920
5580 xdef _sendCodeST7920
5581 xdef _keyHandle
5582 xdef _check
5583 xdef _PS2_Init
5584 xdef _shifted
5585 xdef _unshifted
5586 0040 _keyVal:
5587 0040 00 ds.b 1
5588 xdef _keyVal
5589 xdef _rcvF
5590 xdef _delay_us
5591 xdef _delay_ms
5592 .const: section .text
5593 0000 L7113:
5594 0000 256300 dc.b "%c",0
5595 0003 L5013:
5596 0003 507265737320 dc.b "Press the Keyboard"
5597 0015 3a00 dc.b ":",0
5598 0017 L3013:
5599 0017 4b6579626f61 dc.b "Keyboard Example",0
5619 end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -