main.lst
来自「本程序是以前程序的升级」· LST 代码 · 共 1,161 行 · 第 1/5 页
LST
1,161 行
354 //------------------------------------------------------------------------------
355 //my functions ****************************************************************
356 /*
357 Calculates the CRC32 by looping through each of the bytes in sData.
358
359 Note: For Example usage example, see FileCRC().
360 */
\ In section .text, align 4, keep-with-next
361 void PartialCRC(unsigned long* ulCRC, const unsigned char *sData,unsigned long ulDataLength)
362 {
\ PartialCRC:
\ 00000000 01402DE9 PUSH {R0,LR}
\ 00000004 000052E3 CMP R2,#+0
\ 00000008 0A00000A BEQ ??PartialCRC_0
\ ??PartialCRC_1:
\ 0000000C 012042E2 SUB R2,R2,#+1
363 while(ulDataLength--)
364 {
365 *ulCRC = ((*ulCRC) >>8)
366 ^crc32_table[((*ulCRC)&0xFF)^*sData++];
\ 00000010 003090E5 LDR R3,[R0, #+0]
\ 00000014 FFC003E2 AND R12,R3,#0xFF
\ 00000018 01E0D1E4 LDRB LR,[R1], #+1
\ 0000001C 0CC02EE0 EOR R12,LR,R12
\ 00000020 ........ LDR LR,??DataTable14 ;; crc32_table
\ 00000024 0CC19EE7 LDR R12,[LR, +R12, LSL #+2]
\ 00000028 23342CE0 EOR R3,R12,R3, LSR #+8
\ 0000002C 003080E5 STR R3,[R0, #+0]
367 }
\ 00000030 000052E3 CMP R2,#+0
\ 00000034 F4FFFF1A BNE ??PartialCRC_1
368
369 }
\ ??PartialCRC_0:
\ 00000038 0050BDE8 POP {R12,LR}
\ 0000003C 1EFF2FE1 BX LR ;; return
370
371 /*
372 Reflection is a requirement for the official CRC-32 standard.
373 You can create CRCs without it, but they won't conform to the standard.
374 */
375
\ In section .text, align 4, keep-with-next
376 unsigned long Reflect(unsigned long ulReflect, const char cChar)
377 {
\ Reflect:
\ 00000000 01402DE9 PUSH {R0,LR}
378 unsigned long ulValue = 0;
\ 00000004 0020A0E3 MOV R2,#+0
379 int iPos;
380 for(iPos = 1; iPos < (cChar +1); iPos ++)
\ 00000008 0130A0E3 MOV R3,#+1
\ 0000000C 01C081E2 ADD R12,R1,#+1
\ 00000010 0CC8A0E1 MOV R12,R12, LSL #+16
\ 00000014 2CC8A0E1 MOV R12,R12, LSR #+16
\ 00000018 02005CE3 CMP R12,#+2
\ 0000001C 0800003A BCC ??Reflect_0
381 {
382 if(ulReflect &1)
\ ??Reflect_1:
\ 00000020 010010E3 TST R0,#0x1
383 {
384 ulValue |=(1 << (cChar-iPos));
\ 00000024 01C0A013 MOVNE R12,#+1
\ 00000028 03E04110 SUBNE LR,R1,R3
\ 0000002C 1C2E8211 ORRNE R2,R2,R12, LSL LR
385 }
386 ulReflect >>= 1;
\ 00000030 A000A0E1 LSR R0,R0,#+1
387 }
\ 00000034 013083E2 ADD R3,R3,#+1
\ 00000038 01C081E2 ADD R12,R1,#+1
\ 0000003C 0C0053E1 CMP R3,R12
\ 00000040 F6FFFFBA BLT ??Reflect_1
388 return ulValue;
\ ??Reflect_0:
\ 00000044 0200A0E1 MOV R0,R2
\ 00000048 0050BDE8 POP {R12,LR}
\ 0000004C 1EFF2FE1 BX LR ;; return
389 }
390
391 /*
392 This function initializes "CRC Lookup Table". You only need to call it once to
393 initalize the table before using any of the other CRC32 calculation functions.
394 */
\ In section .text, align 4, keep-with-next
395 void Initialize(void)
396 {
\ Initialize:
\ 00000000 31402DE9 PUSH {R0,R4,R5,LR}
397 unsigned long ulPolynomial = 0x04C11DB7;
398 int iCodes;
399 int iPos;
400 for(iCodes =0; iCodes<=0xFF; iCodes++)
\ 00000004 0040A0E3 MOV R4,#+0
\ 00000008 ........ LDR R5,??DataTable14 ;; crc32_table
401 {
402 crc32_table[iCodes] = Reflect(iCodes,8) << 24;
\ ??Initialize_0:
\ 0000000C 0810A0E3 MOV R1,#+8
\ 00000010 0400A0E1 MOV R0,R4
\ 00000014 ........ BL Reflect
\ 00000018 000CA0E1 LSL R0,R0,#+24
\ 0000001C 000085E5 STR R0,[R5, #+0]
403 for(iPos =0; iPos<8;iPos++)
\ 00000020 0800A0E3 MOV R0,#+8
404 {
405 crc32_table[iCodes] = (crc32_table[iCodes] << 1)
406 ^((crc32_table[iCodes] & (unsigned long)(1 << 31))?ulPolynomial:0);
\ ??Initialize_1:
\ 00000024 001095E5 LDR R1,[R5, #+0]
\ 00000028 800411E3 TST R1,#0x80000000
\ 0000002C 38109F15 LDRNE R1,??Initialize_2 ;; 0x4c11db7
\ 00000030 0010A003 MOVEQ R1,#+0
\ 00000034 002095E5 LDR R2,[R5, #+0]
\ 00000038 821021E0 EOR R1,R1,R2, LSL #+1
\ 0000003C 001085E5 STR R1,[R5, #+0]
407 }
\ 00000040 010050E2 SUBS R0,R0,#+1
\ 00000044 F6FFFF1A BNE ??Initialize_1
408 crc32_table[iCodes] = Reflect(crc32_table[iCodes],32);
\ 00000048 2010A0E3 MOV R1,#+32
\ 0000004C 000095E5 LDR R0,[R5, #+0]
\ 00000050 ........ BL Reflect
\ 00000054 040085E4 STR R0,[R5], #+4
409 }
\ 00000058 014084E2 ADD R4,R4,#+1
\ 0000005C 400F54E3 CMP R4,#+256
\ 00000060 E9FFFFBA BLT ??Initialize_0
410 }
\ 00000064 3840BDE8 POP {R3-R5,LR}
\ 00000068 1EFF2FE1 BX LR ;; return
\ ??Initialize_2:
\ 0000006C B71DC104 DC32 0x4c11db7
411
412 /*
413 Returns the calculated CRC32 (through ulOutCRC) for the given string.
414 */
\ In section .text, align 4, keep-with-next
415 unsigned long FullCRC(const unsigned char *sData, unsigned long ulDataLength)
416 {
\ FullCRC:
\ 00000000 01402DE9 PUSH {R0,LR}
417 unsigned long ulCRC = 0xffffffff; //Initilaize the CRC.
\ 00000004 0030E0E3 MVN R3,#+0
\ 00000008 00308DE5 STR R3,[SP, #+0]
418 PartialCRC(&ulCRC, sData, ulDataLength);
\ 0000000C 0120A0E1 MOV R2,R1
\ 00000010 0010A0E1 MOV R1,R0
\ 00000014 0D00A0E1 MOV R0,SP
\ 00000018 ........ BL PartialCRC
419 return ulCRC ;
\ 0000001C 00009DE5 LDR R0,[SP, #+0]
\ 00000020 0050BDE8 POP {R12,LR}
\ 00000024 1EFF2FE1 BX LR ;; return
420 //Finalize the CRC and return.
421 }
422
423 //------------------------------------------------------------------------------
424 // The function to test whether the dataflash has datas
425 //if the dataflash is empty return a value, or return 0.
426 //------------------------------------------------------------------------------
\ In section .text, align 4, keep-with-next
427 static unsigned int WhetherEmpty()
428 {
429 unsigned int i,j;
430 unsigned char *tmp;
431 tmp = SdCodeAddr;
\ WhetherEmpty:
\ 00000000 ........ LDR R0,??DataTable65 ;; SdCodeAddr
\ 00000004 000090E5 LDR R0,[R0, #+0]
432 j=0;
\ 00000008 0010A0E3 MOV R1,#+0
433 for(i = 0; i < 16; i++)
\ 0000000C 1020A0E3 MOV R2,#+16
434 {
435 if(*tmp == 0xFF)
\ ??WhetherEmpty_0:
\ 00000010 0030D0E5 LDRB R3,[R0, #+0]
\ 00000014 FF0053E3 CMP R3,#+255
436 {
437 j++;
\ 00000018 01108102 ADDEQ R1,R1,#+1
438 tmp++;
439 }
440 else
441 {
442
443 j=j;
444 tmp++;
\ 0000001C 010080E2 ADD R0,R0,#+1
445 continue;
446 }
447 }
\ 00000020 012052E2 SUBS R2,R2,#+1
\ 00000024 F9FFFF1A BNE ??WhetherEmpty_0
448 if(j==16)
\ 00000028 100051E3 CMP R1,#+16
\ 0000002C 0000A013 MOVNE R0,#+0
449 {
450 return 1;
\ 00000030 0100A003 MOVEQ R0,#+1
\ 00000034 1EFF2FE1 BX LR
451 }
452 else
453 {
454 return 0;
455 }
456 }
457 //------------------------------------------------------------------------------
458 //------------------------------------------------------------------------------
459 /// LeadApp() function was used to copy the code in dataflash to sdram
460 //------------------------------------------------------------------------------
461
\ In section .text, align 4, keep-with-next
462 static unsigned int LeadAPP(void)
463 {
\ LeadAPP:
\ 00000000 F1402DE9 PUSH {R0,R4-R7,LR}
464 unsigned int page,i;
465 unsigned char *tmp;
466 unsigned int time;
467 tmp = SdCodeAddr;
\ 00000004 ........ LDR R0,??DataTable65 ;; SdCodeAddr
\ 00000008 005090E5 LDR R5,[R0, #+0]
468 time = timestamp;
\ 0000000C ........ LDR R0,??DataTable64 ;; timestamp
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?