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

working with right shift operators in C

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?

Parents
  • "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!

Reply
  • "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!

Children
No data