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
Do you not think that it would be necessary to see your code in order to have any idea why it is causing this error??
And, before you post your code, be careful to read the instructions - immediately above the box where you type - and follow them carefully!
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
i need to do the next c function in asm
No, you don't. You may believe you need that, but you don't. You just need to compile it. That's what you have a compiler for.
Now, some highly skilled people might be able to improve over what the compiler generates for this function. But you're rather obviously not anywhere near that skill level, yet.
the poor man only wants to write a little assembly - let's help him a little!
are you using thumb mode, not ARM? if so, that might limit your access to SP. what happens if you compile this code in ARM mode? also, are you sure that you have copy-pasted the exact code you are using?
"You may believe you need that, but you don't."
Actually, he might "need" it in that his homework assignment is, "create an assembler function that performs the equivalent of the standard atoi library function".
;-)
Other than that, I agree!
have you tried to compare your implementation with the code generated via compiler optimization level 0?
"This register combination results in UNPREDICTABLE behaviour"
So, have you consulted the ARM documentation to see which register combinations are acceptable?
No, he actually specifically said that he "needs" (sic) to convert that particular piece of 'C' source into assembler - which is almost certainly not a real "need" (other than to satisfy a school assignment).
If he really "only wants to write a little assembly", then there would be far better places to start; eg, http://www.keil.com/books/armbooks.asp
Thanks for help...
I don't using Thumb mode and yes, I has consulted the ARM documentation and its say that only i don't use r15...
Looking for error in documentation says
For ARM: Warning: A1786W: This instruction using SP is deprecated in ARMv7 For Thumb: Error: A1477W: This register combination results in UNPREDICTABLE behaviour
But i use the arm mode, not thumb mode... (this is in options for target,target,code generation => ARM Mode)
this is in options for target,target,code generation => ARM Mode
And how likely, do you think, is it that this option has any effect on an assembler source file?
I do not understand your question ... I am using Microvision 4 and not let me use either the MUL or MLA instruction, anyone can tell me why?
Hans means that your code is not generated by the compiler. it is already in assembly, thus this particular setting has no effect on it.
anyone can tell me why?
It's because in contrast to your statement, you rather obviously are using Thumb mode --- otherwise you wouldn't be getting a Thumb-only error message.
It's clear you don't know how you ended up in Thumb mode, but there you are.
All of this only strengthens my argument that at least right now you need to not do this in assembly. You need to learn the tools first, and you need to learn the finer points of ARM and Thumb assembly language. By then you hopefully will have learned how to decide what should be done in assembly and what shouldn't.
So. again, you might want to visit http://www.keil.com/books/armbooks.asp and look for titles about assembler...
Real ARM programmers assemble it themselves.