I am facing a problem in using the right shift operator in C with keil. The instruction is:for(i=0;i<=8;i++) { j=sum>>i; } where sum= 32 bit no. the instruction is not executed if the syntax is as shown above. but if i write a numerical value instead of using the variable name 'sum' then the instruction is easily executed. i need to use the variable name only. how do i fix this problem?
These are Linker warnings.
It'll be because you've used the SRC directive.
The SRC directive causes the compiler to convert 'C' source to assember source; it is then the assembler that converts this to object files.
Therefore, all the Linker sees is a load of assembler-generated objects; Because the Linker sees only assembler-generated objects, it doesn't automatically include the C runtime libraries - which is why you get these errors.
As has already been noted, you don't need inline assembler for any of this.
Therefore, re-write your code fully in 'C', and remove the SRC directive!
http://www.keil.com/support/docs/1980.htm
thank you so much!!!!!!! i did not have to rewrite the whole code in 'c'. the link you sent in your message provided the solution. i just had to add a file called 'C51S.LIB' to the source group and now the compiler is showing 0 errors and 0 warnings and my code is running successfully. thank you for all your help and time.
"i did not have to rewrite the whole code in 'c'"
True, but it would be wise to do so!
Using inline assembler and the SRC directive brings a number of issues - you have seen just one of them.
So, unless you really need it, do not use inline assembler and the SRC directive.
In general, if you need to use assembler it's far better to write a separate assembler module and call it from 'C'.
"Let your 'C' be 'C' and your Assembler be Assembler"
In your case, as already noted, there is no reason at all to use assembler - let alone inline assembler!