⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.lst

📁 IAPBootLoader源程序是单片机ARM的在系统编程方法1
💻 LST
📖 第 1 页 / 共 4 页
字号:
     77          			{
     78          				/* return 0; Invalid input */
     79          				res = 0;
   \                     ??Str2Int_10:
   \   00000118   0000A0E3           MOV      R0,#+0
   \   0000011C   00C0B0E1           MOVS     R12,R0
     80          				break;
     81          			}	
     82          		}	
     83          		
     84          		if (i>=11) res = 0;	/* over 8 digit hex --invalid */
   \                     ??Str2Int_5:
   \   00000120   0B0053E3           CMP      R3,#+11
   \   00000124   3900003A           BCC      ??Str2Int_15
   \   00000128   0000A0E3           MOV      R0,#+0
   \   0000012C   00C0B0E1           MOVS     R12,R0
   \   00000130   360000EA           B        ??Str2Int_15
     85          	}
     86          	else /* max 10-digit decimal input */
     87          	{
     88          		for (i=0;i<11;i++)
   \                     ??Str2Int_0:
   \   00000134   0000A0E3           MOV      R0,#+0
   \   00000138   0030B0E1           MOVS     R3,R0
   \                     ??Str2Int_16:
   \   0000013C   0B0053E3           CMP      R3,#+11
   \   00000140   2E00002A           BCS      ??Str2Int_17
     89          		{
     90          			if (inputstr[i] == '\0')
   \   00000144   0200D3E7           LDRB     R0,[R3, +R2]
   \   00000148   000050E3           CMP      R0,#+0
   \   0000014C   0300001A           BNE      ??Str2Int_18
     91          			{
     92          				*intnum = val;
   \   00000150   004081E5           STR      R4,[R1, #+0]
     93          				/* return 1; */
     94          				res =1;
   \   00000154   0100A0E3           MOV      R0,#+1
   \   00000158   00C0B0E1           MOVS     R12,R0
     95          				break;
   \   0000015C   270000EA           B        ??Str2Int_17
     96          			}
     97          			else if ((inputstr[i] == 'k' ||inputstr[i] == 'K') && (i>0))
   \                     ??Str2Int_18:
   \   00000160   0200D3E7           LDRB     R0,[R3, +R2]
   \   00000164   6B0050E3           CMP      R0,#+107
   \   00000168   0200000A           BEQ      ??Str2Int_19
   \   0000016C   0200D3E7           LDRB     R0,[R3, +R2]
   \   00000170   4B0050E3           CMP      R0,#+75
   \   00000174   0600001A           BNE      ??Str2Int_20
   \                     ??Str2Int_19:
   \   00000178   000053E3           CMP      R3,#+0
   \   0000017C   0400000A           BEQ      ??Str2Int_20
     98          			{
     99          				val = val << 10;
   \   00000180   0445B0E1           LSLS     R4,R4,#+10
    100          				*intnum = val;
   \   00000184   004081E5           STR      R4,[R1, #+0]
    101          				res = 1;
   \   00000188   0100A0E3           MOV      R0,#+1
   \   0000018C   00C0B0E1           MOVS     R12,R0
    102          				break;
   \   00000190   1A0000EA           B        ??Str2Int_17
    103          			}
    104          			else if ((inputstr[i] == 'm' ||inputstr[i] == 'M') && (i>0))
   \                     ??Str2Int_20:
   \   00000194   0200D3E7           LDRB     R0,[R3, +R2]
   \   00000198   6D0050E3           CMP      R0,#+109
   \   0000019C   0200000A           BEQ      ??Str2Int_21
   \   000001A0   0200D3E7           LDRB     R0,[R3, +R2]
   \   000001A4   4D0050E3           CMP      R0,#+77
   \   000001A8   0600001A           BNE      ??Str2Int_22
   \                     ??Str2Int_21:
   \   000001AC   000053E3           CMP      R3,#+0
   \   000001B0   0400000A           BEQ      ??Str2Int_22
    105          			{	
    106          				
    107          				val = val << 20;
   \   000001B4   044AB0E1           LSLS     R4,R4,#+20
    108          				*intnum = val;
   \   000001B8   004081E5           STR      R4,[R1, #+0]
    109          				res = 1;
   \   000001BC   0100A0E3           MOV      R0,#+1
   \   000001C0   00C0B0E1           MOVS     R12,R0
    110          				break;
   \   000001C4   0D0000EA           B        ??Str2Int_17
    111          			}
    112          			else if (ISVALIDDEC(inputstr[i]))
   \                     ??Str2Int_22:
   \   000001C8   0200D3E7           LDRB     R0,[R3, +R2]
   \   000001CC   300050E3           CMP      R0,#+48
   \   000001D0   0800003A           BCC      ??Str2Int_23
   \   000001D4   0200D3E7           LDRB     R0,[R3, +R2]
   \   000001D8   3A0050E3           CMP      R0,#+58
   \   000001DC   0500002A           BCS      ??Str2Int_23
    113          				val = val*10 + CONVERTDEC(inputstr[i]);
   \   000001E0   0A00A0E3           MOV      R0,#+10
   \   000001E4   0250D3E7           LDRB     R5,[R3, +R2]
   \   000001E8   305055E2           SUBS     R5,R5,#+48
   \   000001EC   905424E0           MLA      R4,R0,R4,R5
   \   000001F0   013093E2           ADDS     R3,R3,#+1
   \   000001F4   D0FFFFEA           B        ??Str2Int_16
    114          			else
    115          			{
    116          				/* return 0; Invalid input */
    117          				res = 0;
   \                     ??Str2Int_23:
   \   000001F8   0000A0E3           MOV      R0,#+0
   \   000001FC   00C0B0E1           MOVS     R12,R0
    118          				break;
    119          			}	
    120          		}
    121          		if (i>=11) res = 0; /* Over 10 digit decimal --invalid */
   \                     ??Str2Int_17:
   \   00000200   0B0053E3           CMP      R3,#+11
   \   00000204   0100003A           BCC      ??Str2Int_15
   \   00000208   0000A0E3           MOV      R0,#+0
   \   0000020C   00C0B0E1           MOVS     R12,R0
    122          	}
    123          	
    124          	return res;
   \                     ??Str2Int_15:
   \   00000210   0C00B0E1           MOVS     R0,R12
   \                     ??Str2Int_3:
   \   00000214   3000BDE8           POP      {R4,R5}
   \   00000218   0EF0A0E1           MOV      PC,LR            ;; return
    125          }
    126          /*******************************************************************************
    127          * Function Name  : GetIntegerInput
    128          * Description    : Get an integer from the HyperTerminal
    129          * Input          : The inetger
    130          * Return         : 1 -- Correct
    131                           : 0 -- Error
    132          *******************************************************************************/

   \                                 In segment CODE_Flash, align 4, keep-with-next
    133          u32 GetIntegerInput(s32 * num)
    134          {
   \                     GetIntegerInput:
   \   00000000   10402DE9           PUSH     {R4,LR}
   \   00000004   10D04DE2           SUB      SP,SP,#+16
   \   00000008   0040B0E1           MOVS     R4,R0
    135          	char inputstr[16];
    136          
    137          	while(1)
    138          	{
    139          		GetInputString(inputstr);
   \                     ??GetIntegerInput_0:
   \   0000000C   0D00B0E1           MOVS     R0,SP
   \   00000010   ........           BL       GetInputString
    140          		if (inputstr[0] == '\0') continue;
   \   00000014   0000DDE5           LDRB     R0,[SP, #+0]
   \   00000018   000050E3           CMP      R0,#+0
   \   0000001C   FAFFFF0A           BEQ      ??GetIntegerInput_0
    141          		
    142          		if ((inputstr[0] == 'a'||inputstr[0] == 'A')&& inputstr[1] == '\0')		
   \   00000020   0000DDE5           LDRB     R0,[SP, #+0]
   \   00000024   610050E3           CMP      R0,#+97
   \   00000028   0200000A           BEQ      ??GetIntegerInput_1
   \   0000002C   0000DDE5           LDRB     R0,[SP, #+0]
   \   00000030   410050E3           CMP      R0,#+65
   \   00000034   0600001A           BNE      ??GetIntegerInput_2
   \                     ??GetIntegerInput_1:
   \   00000038   0100DDE5           LDRB     R0,[SP, #+1]
   \   0000003C   000050E3           CMP      R0,#+0
   \   00000040   0300001A           BNE      ??GetIntegerInput_2
    143          		{	
    144          			SerialPutString("User Cancelled \r\n");
   \   00000044   34009FE5           LDR      R0,??GetIntegerInput_3  ;; `?<Constant "User Cancelled \\r\\n">`
   \   00000048   ........           BL       SerialPutString
    145          			return 0;
   \   0000004C   0000A0E3           MOV      R0,#+0
   \   00000050   080000EA           B        ??GetIntegerInput_4
    146          		}	
    147          		
    148          		if (Str2Int(inputstr,num) ==0)	
   \                     ??GetIntegerInput_2:
   \   00000054   0410B0E1           MOVS     R1,R4
   \   00000058   0D00B0E1           MOVS     R0,SP
   \   0000005C   ........           BL       Str2Int
   \   00000060   000050E3           CMP      R0,#+0
   \   00000064   0200001A           BNE      ??GetIntegerInput_5
    149          			SerialPutString("Error, Input again: \r\n");
   \   00000068   14009FE5           LDR      R0,??GetIntegerInput_3+0x4  ;; `?<Constant "Error, Input again: \\r\\n">`
   \   0000006C   ........           BL       SerialPutString
   \   00000070   E5FFFFEA           B        ??GetIntegerInput_0
    150          		else return 1;	
   \                     ??GetIntegerInput_5:
   \   00000074   0100A0E3           MOV      R0,#+1
   \                     ??GetIntegerInput_4:
   \   00000078   10D08DE2           ADD      SP,SP,#+16       ;; stack cleaning
   \   0000007C   1080BDE8           POP      {R4,PC}          ;; return
   \                     ??GetIntegerInput_3:
   \   00000080   ........           DC32     `?<Constant "User Cancelled \\r\\n">`
   \   00000084   ........           DC32     `?<Constant "Error, Input again: \\r\\n">`
    151          	}
    152          }
    153          
    154          /*******************************************************************************
    155          * Function Name  : SerialKeyPressed
    156          * Description    : Test to see if a key has been pressed on the HyperTerminal
    157          * Input          : The key pressed
    158          * Return         : 1 -- Correct
    159                           : 0 -- Error
    160          *******************************************************************************/

   \                                 In segment CODE_Flash, align 4, keep-with-next
    161          u32 SerialKeyPressed(char *key)
    162          {
   \                     SerialKeyPressed:
   \   00000000   0010B0E1           MOVS     R1,R0
    163             	if (UART0->SR & UART_RxBufFull)
   \   00000004   5301A0E3           MOV      R0,#-1073741804
   \   00000008   400C80E3           ORR      R0,R0,#0x4000
   \   0000000C   B000D0E1           LDRH     R0,[R0, #+0]
   \   00000010   010010E3           TST      R0,#0x1
   \   00000014   0500000A           BEQ      ??SerialKeyPressed_0
    164             	{
    165             		*key = (char)UART0->RxBUFR;
   \   00000018   8C02A0E3           MOV      R0,#-1073741816
   \   0000001C   400C80E3           ORR      R0,R0,#0x4000
   \   00000020   B000D0E1           LDRH     R0,[R0, #+0]
   \   00000024   0000C1E5           STRB     R0,[R1, #+0]
    166             		return 1;
   \   00000028   0100A0E3           MOV      R0,#+1
   \   0000002C   000000EA           B        ??SerialKeyPressed_1
    167             	}
    168             	else
    169             		return 0;
   \                     ??SerialKeyPressed_0:
   \   00000030   0000A0E3           MOV      R0,#+0
   \                     ??SerialKeyPressed_1:
   \   00000034   0EF0A0E1           MOV      PC,LR            ;; return
    170          }
    171          /*******************************************************************************
    172          * Function Name  : GetKey
    173          * Description    : Get a key from the HyperTerminal
    174          * Input          : None
    175          * Return         : The Key Pressed
    176          *******************************************************************************/

   \                                 In segment CODE_Flash, align 4, keep-with-next
    177          u8 GetKey(void)
    178          {
   \                     GetKey:
   \   00000000   00402DE9           PUSH     {LR}
   \   00000004   04D04DE2           SUB      SP,SP,#+4
    179            u8 key;
    180            /* First clear Rx buffer */
    181            UART_FifoReset(UART0,UART_RxFIFO);
   \   00000008   0010A0E3           MOV      R1,#+0
   \   0000000C   C004A0E3           MOV      R0,#-1073741824
   \   00000010   400C80E3           ORR      R0,R0,#0x4000
   \   00000014   ........           _BLF     UART_FifoReset,??UART_FifoReset??rA
    182          	
    183            /* Then, waiting for user input */
    184            while (1)
    185            {
    186              if (SerialKeyPressed((char*)&key)) break;
   \                     ??GetKey_0:
   \   00000018   0D00B0E1           MOVS     R0,SP
   \   0000001C   ........           BL       SerialKeyPressed
   \   00000020   000050E3           CMP      R0,#+0
   \   00000024   FBFFFF0A           BEQ      ??GetKey_0
    187            }
    188            return key;
   \   00000028   0000DDE5           LDRB     R0,[SP, #+0]
   \   0000002C   04D08DE2           ADD      SP,SP,#+4        ;; stack cleaning
   \   00000030   0080BDE8           POP      {PC}             ;; return
    189          }
    190          
    191          /*******************************************************************************

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -