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

📄 common.s79

📁 IAPBootLoader源程序是单片机ARM的在系统编程方法1
💻 S79
📖 第 1 页 / 共 3 页
字号:
//   89 		{
//   90 			if (inputstr[i] == '\0')
        LDRB     R0,[R3, +R2]
        CMP      R0,#+0
        BNE      ??Str2Int_18
//   91 			{
//   92 				*intnum = val;
        STR      R4,[R1, #+0]
//   93 				/* return 1; */
//   94 				res =1;
        MOV      R0,#+1
        MOVS     R12,R0
//   95 				break;
        B        ??Str2Int_17
//   96 			}
//   97 			else if ((inputstr[i] == 'k' ||inputstr[i] == 'K') && (i>0))
??Str2Int_18:
        LDRB     R0,[R3, +R2]
        CMP      R0,#+107
        BEQ      ??Str2Int_19
        LDRB     R0,[R3, +R2]
        CMP      R0,#+75
        BNE      ??Str2Int_20
??Str2Int_19:
        CMP      R3,#+0
        BEQ      ??Str2Int_20
//   98 			{
//   99 				val = val << 10;
        LSLS     R4,R4,#+10
//  100 				*intnum = val;
        STR      R4,[R1, #+0]
//  101 				res = 1;
        MOV      R0,#+1
        MOVS     R12,R0
//  102 				break;
        B        ??Str2Int_17
//  103 			}
//  104 			else if ((inputstr[i] == 'm' ||inputstr[i] == 'M') && (i>0))
??Str2Int_20:
        LDRB     R0,[R3, +R2]
        CMP      R0,#+109
        BEQ      ??Str2Int_21
        LDRB     R0,[R3, +R2]
        CMP      R0,#+77
        BNE      ??Str2Int_22
??Str2Int_21:
        CMP      R3,#+0
        BEQ      ??Str2Int_22
//  105 			{	
//  106 				
//  107 				val = val << 20;
        LSLS     R4,R4,#+20
//  108 				*intnum = val;
        STR      R4,[R1, #+0]
//  109 				res = 1;
        MOV      R0,#+1
        MOVS     R12,R0
//  110 				break;
        B        ??Str2Int_17
//  111 			}
//  112 			else if (ISVALIDDEC(inputstr[i]))
??Str2Int_22:
        LDRB     R0,[R3, +R2]
        CMP      R0,#+48
        BCC      ??Str2Int_23
        LDRB     R0,[R3, +R2]
        CMP      R0,#+58
        BCS      ??Str2Int_23
//  113 				val = val*10 + CONVERTDEC(inputstr[i]);
        MOV      R0,#+10
        LDRB     R5,[R3, +R2]
        SUBS     R5,R5,#+48
        MLA      R4,R0,R4,R5
        ADDS     R3,R3,#+1
        B        ??Str2Int_16
//  114 			else
//  115 			{
//  116 				/* return 0; Invalid input */
//  117 				res = 0;
??Str2Int_23:
        MOV      R0,#+0
        MOVS     R12,R0
//  118 				break;
//  119 			}	
//  120 		}
//  121 		if (i>=11) res = 0; /* Over 10 digit decimal --invalid */
??Str2Int_17:
        CMP      R3,#+11
        BCC      ??Str2Int_15
        MOV      R0,#+0
        MOVS     R12,R0
//  122 	}
//  123 	
//  124 	return res;
??Str2Int_15:
        MOVS     R0,R12
??Str2Int_3:
        POP      {R4,R5}
        CFI R4 SameValue
        CFI R5 SameValue
        CFI CFA R13+0
        MOV      PC,LR            ;; return
        CFI EndBlock cfiBlock1
//  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 *******************************************************************************/

        RSEG CODE_Flash:CODE:NOROOT(2)
        CFI Block cfiBlock2 Using cfiCommon0
        CFI Function GetIntegerInput
        ARM
//  133 u32 GetIntegerInput(s32 * num)
//  134 {
GetIntegerInput:
        PUSH     {R4,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R4 Frame(CFA, -8)
        CFI CFA R13+8
        SUB      SP,SP,#+16
        CFI CFA R13+24
        MOVS     R4,R0
//  135 	char inputstr[16];
//  136 
//  137 	while(1)
//  138 	{
//  139 		GetInputString(inputstr);
??GetIntegerInput_0:
        MOVS     R0,SP
        BL       GetInputString
//  140 		if (inputstr[0] == '\0') continue;
        LDRB     R0,[SP, #+0]
        CMP      R0,#+0
        BEQ      ??GetIntegerInput_0
//  141 		
//  142 		if ((inputstr[0] == 'a'||inputstr[0] == 'A')&& inputstr[1] == '\0')		
        LDRB     R0,[SP, #+0]
        CMP      R0,#+97
        BEQ      ??GetIntegerInput_1
        LDRB     R0,[SP, #+0]
        CMP      R0,#+65
        BNE      ??GetIntegerInput_2
??GetIntegerInput_1:
        LDRB     R0,[SP, #+1]
        CMP      R0,#+0
        BNE      ??GetIntegerInput_2
//  143 		{	
//  144 			SerialPutString("User Cancelled \r\n");
        LDR      R0,??GetIntegerInput_3  ;; `?<Constant "User Cancelled \\r\\n">`
        BL       SerialPutString
//  145 			return 0;
        MOV      R0,#+0
        B        ??GetIntegerInput_4
//  146 		}	
//  147 		
//  148 		if (Str2Int(inputstr,num) ==0)	
??GetIntegerInput_2:
        MOVS     R1,R4
        MOVS     R0,SP
        BL       Str2Int
        CMP      R0,#+0
        BNE      ??GetIntegerInput_5
//  149 			SerialPutString("Error, Input again: \r\n");
        LDR      R0,??GetIntegerInput_3+0x4  ;; `?<Constant "Error, Input again: \\r\\n">`
        BL       SerialPutString
        B        ??GetIntegerInput_0
//  150 		else return 1;	
??GetIntegerInput_5:
        MOV      R0,#+1
??GetIntegerInput_4:
        ADD      SP,SP,#+16       ;; stack cleaning
        CFI CFA R13+8
        POP      {R4,PC}          ;; return
        DATA
??GetIntegerInput_3:
        DC32     `?<Constant "User Cancelled \\r\\n">`
        DC32     `?<Constant "Error, Input again: \\r\\n">`
        CFI EndBlock cfiBlock2
//  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 *******************************************************************************/

        RSEG CODE_Flash:CODE:NOROOT(2)
        CFI Block cfiBlock3 Using cfiCommon0
        CFI Function SerialKeyPressed
        ARM
//  161 u32 SerialKeyPressed(char *key)
//  162 {
SerialKeyPressed:
        MOVS     R1,R0
//  163    	if (UART0->SR & UART_RxBufFull)
        MOV      R0,#-1073741804
        ORR      R0,R0,#0x4000
        LDRH     R0,[R0, #+0]
        TST      R0,#0x1
        BEQ      ??SerialKeyPressed_0
//  164    	{
//  165    		*key = (char)UART0->RxBUFR;
        MOV      R0,#-1073741816
        ORR      R0,R0,#0x4000
        LDRH     R0,[R0, #+0]
        STRB     R0,[R1, #+0]
//  166    		return 1;
        MOV      R0,#+1
        B        ??SerialKeyPressed_1
//  167    	}
//  168    	else
//  169    		return 0;
??SerialKeyPressed_0:
        MOV      R0,#+0
??SerialKeyPressed_1:
        MOV      PC,LR            ;; return
        CFI EndBlock cfiBlock3
//  170 }
//  171 /*******************************************************************************
//  172 * Function Name  : GetKey
//  173 * Description    : Get a key from the HyperTerminal
//  174 * Input          : None
//  175 * Return         : The Key Pressed
//  176 *******************************************************************************/

        RSEG CODE_Flash:CODE:NOROOT(2)
        CFI Block cfiBlock4 Using cfiCommon0
        CFI Function GetKey
        ARM
//  177 u8 GetKey(void)
//  178 {
GetKey:
        PUSH     {LR}
        CFI ?RET Frame(CFA, -4)
        CFI CFA R13+4
        SUB      SP,SP,#+4
        CFI CFA R13+8
//  179   u8 key;
//  180   /* First clear Rx buffer */
//  181   UART_FifoReset(UART0,UART_RxFIFO);
        MOV      R1,#+0
        MOV      R0,#-1073741824
        ORR      R0,R0,#0x4000
        _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:
        MOVS     R0,SP
        BL       SerialKeyPressed
        CMP      R0,#+0
        BEQ      ??GetKey_0
//  187   }
//  188   return key;
        LDRB     R0,[SP, #+0]
        ADD      SP,SP,#+4        ;; stack cleaning
        CFI CFA R13+4
        POP      {PC}             ;; return
        CFI EndBlock cfiBlock4
//  189 }
//  190 
//  191 /*******************************************************************************
//  192 * Function Name  : SerialPutChar
//  193 * Description    : Print a character on the HyperTerminal
//  194 * Input          : The character to be printed
//  195 * Return         : None
//  196 *******************************************************************************/

        RSEG CODE_Flash:CODE:NOROOT(2)
        CFI Block cfiBlock5 Using cfiCommon0
        CFI Function SerialPutChar
        ARM
//  197 void SerialPutChar(char c)
//  198 {
SerialPutChar:
        PUSH     {R0,LR}
        CFI ?RET Frame(CFA, -4)
        CFI CFA R13+8
//  199   UART_ByteSend(UART0,(u8*)&c);
        MOVS     R1,SP
        MOV      R0,#-1073741824
        ORR      R0,R0,#0x4000
        _BLF     UART_ByteSend,??UART_ByteSend??rA
//  200 }
        ADD      SP,SP,#+4        ;; stack cleaning
        CFI CFA R13+4
        POP      {PC}             ;; return
        CFI EndBlock cfiBlock5
//  201 
//  202 /*******************************************************************************
//  203 * Function Name  : SerialPutString
//  204 * Description    : Print a string on the HyperTerminal
//  205 * Input          : The string to be printed
//  206 * Return         : None
//  207 *******************************************************************************/

        RSEG CODE_Flash:CODE:NOROOT(2)
        CFI Block cfiBlock6 Using cfiCommon0
        CFI Function SerialPutString
        ARM
//  208 void SerialPutString(char *s)
//  209 {
SerialPutString:
        PUSH     {R4,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R4 Frame(CFA, -8)
        CFI CFA R13+8
        MOVS     R4,R0
//  210   while (*s != '\0')
??SerialPutString_0:
        LDRB     R0,[R4, #+0]
        CMP      R0,#+0
        BEQ      ??SerialPutString_1
//  211   {
//  212   SerialPutChar(*s);
        LDRB     R0,[R4, #+0]
        BL       SerialPutChar
//  213   s ++;
        ADDS     R4,R4,#+1
        B        ??SerialPutString_0
//  214   }
//  215 }
??SerialPutString_1:
        POP      {R4,PC}          ;; return
        CFI EndBlock cfiBlock6
//  216 
//  217 /*******************************************************************************
//  218 * Function Name  : GetInputString	
//  219 * Description    : Get Input string from the HyperTerminal
//  220 * Input          : The input string
//  221 * Return         : None
//  222 *******************************************************************************/

        RSEG CODE_Flash:CODE:NOROOT(2)
        CFI Block cfiBlock7 Using cfiCommon0
        CFI Function GetInputString
        ARM
//  223 void GetInputString (char * buffP)
//  224 {
GetInputString:
        PUSH     {R4-R6,LR}
        CFI ?RET Frame(CFA, -4)
        CFI R6 Frame(CFA, -8)
        CFI R5 Frame(CFA, -12)
        CFI R4 Frame(CFA, -16)
        CFI CFA R13+16
        MOVS     R4,R0
//  225   u32 bytes_read = 0;
        MOV      R0,#+0
        MOVS     R5,R0
//  226   char c;
//  227   do
//  228    {
//  229    c = GetKey();
??GetInputString_0:
        BL       GetKey
        MOVS     R6,R0
//  230    if (c == '\r')   	
        CMP      R6,#+13
        BNE      ??GetInputString_1
//  231      break;
//  232    if (c == '\b')	/* Backspace */
//  233      {
//  234      if (bytes_read > 0)
//  235        {
//  236        SerialPutString("\b \b");
//  237        bytes_read --;
//  238        }
//  239   continue;
//  240    }
//  241   if (bytes_read >= CMD_STRING_SIZE )
//  242     {
//  243     SerialPutString("Command string size overflow\r\n");
//  244     bytes_read = 0;
//  245     continue;
//  246     }
//  247   if (c >= 0x20 && c<= 0x7E)
//  248     {
//  249     buffP[bytes_read++] = c;
//  250     SerialPutChar(c);
//  251     }	
//  252     	
//  253   }
//  254   while (1);
//  255   SerialPutString("\n\r");
        ADR      R0,??GetInputString_2  ;; "\n\r"
        BL       SerialPutString
//  256   buffP[bytes_read] = '\0';
        MOV      R0,#+0
        STRB     R0,[R5, +R4]
//  257 }
        B        ??GetInputString_3
??GetInputString_1:
        CMP      R6,#+8
        BNE      ??GetInputString_4
        CMP      R5,#+0
        BEQ      ??GetInputString_0
        ADR      R0,??GetInputString_2+0x4  ;; "\b \b"
        BL       SerialPutString
        SUBS     R5,R5,#+1
        B        ??GetInputString_0
??GetInputString_4:
        CMP      R5,#+128
        BCC      ??GetInputString_5
        LDR      R0,??GetInputString_2+0x8  ;; `?<Constant "Command string size o...">`

⌨️ 快捷键说明

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