This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with Keil

I need to do a multiplication in the keil and the following mistake goes out for me. It does not leave me to use MLU and MUL. Why?

error: A1477W: This register combination results in UNPREDICTABLE behaviour

Parents
  • Sorry, i need to do the next c function in asm

    ;int atoi (char *string){
    ;       int i;
    ;       int tmp;
    ;       int dato;
    ;       dato = 0;
    ;       for (i=0; i<=4; i++){
    ;               tmp=*(string+i);
    ;               if (tmp=='\0' || tmp=='\r'){
    ;                       return dato;
    ;               }
    ;               else{
    ;                       if ((tmp>=48) && (tmp<=57)){
    ;                               tmp=tmp-48;
    ;                       }
    ;                       else{
    ;                               return 0;
    ;                       }
    ;                       dato=dato*10+tmp;
    ;               }
    ;       }
    ;       return dato;
    ;}
    

    This is my implementation...

            AREA    ATOI2,CODE,READONLY
            EXPORT  ATOI
    
    ATOI    STMFD   sp!,{R4,lr}
            MOV     R1,#5
            MOV     R4,#10
            MOV     R3,#0
    INICIO  LDRB    R2,[R0],#1
            CMP     R2,#&D      ;D ==> \r
            BEQ     SALIR
            CMP     R2,#0   ;0 ==> \0
            BEQ     SALIR
            CMP     R2,#48
            BCC     SINO
            CMP     R2,#57
            BHI     SINO
            SUB     R2,R2,#48
            ;MLA    R3,R3,R4,R2   ;Keil error
            MUL     R3,R3,R4      ;Keil error
            ADD     R3,R3,R2
            SUB     R1,R1,#1
            CMP     R1,#0
            BNE     INICIO
            B       SALIR
    SINO    MOV     R3,#0
    SALIR   MOV     R0,R3
            LDMFD   sp!,{R4,pc}
            END
    


    And the error is...
    atoi.s(46): error: A1477W: This register combination results in UNPREDICTABLE behaviour

Reply
  • Sorry, i need to do the next c function in asm

    ;int atoi (char *string){
    ;       int i;
    ;       int tmp;
    ;       int dato;
    ;       dato = 0;
    ;       for (i=0; i<=4; i++){
    ;               tmp=*(string+i);
    ;               if (tmp=='\0' || tmp=='\r'){
    ;                       return dato;
    ;               }
    ;               else{
    ;                       if ((tmp>=48) && (tmp<=57)){
    ;                               tmp=tmp-48;
    ;                       }
    ;                       else{
    ;                               return 0;
    ;                       }
    ;                       dato=dato*10+tmp;
    ;               }
    ;       }
    ;       return dato;
    ;}
    

    This is my implementation...

            AREA    ATOI2,CODE,READONLY
            EXPORT  ATOI
    
    ATOI    STMFD   sp!,{R4,lr}
            MOV     R1,#5
            MOV     R4,#10
            MOV     R3,#0
    INICIO  LDRB    R2,[R0],#1
            CMP     R2,#&D      ;D ==> \r
            BEQ     SALIR
            CMP     R2,#0   ;0 ==> \0
            BEQ     SALIR
            CMP     R2,#48
            BCC     SINO
            CMP     R2,#57
            BHI     SINO
            SUB     R2,R2,#48
            ;MLA    R3,R3,R4,R2   ;Keil error
            MUL     R3,R3,R4      ;Keil error
            ADD     R3,R3,R2
            SUB     R1,R1,#1
            CMP     R1,#0
            BNE     INICIO
            B       SALIR
    SINO    MOV     R3,#0
    SALIR   MOV     R0,R3
            LDMFD   sp!,{R4,pc}
            END
    


    And the error is...
    atoi.s(46): error: A1477W: This register combination results in UNPREDICTABLE behaviour

Children