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?
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!