We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Trying to determine the behavior of the C51 compiler when performing a '>>' on a negative integer.
The C90 indicates that this is compiler implementation dependent.
Will the compiler shift the sign, or does it insert 0's?
Thanks in advance for any replies.
stevea said:C90 indicates that this is compiler implementation dependent
Indeed.
Seems Keil forgot to include the details in the manual:
http://www.keil.com/support/man/docs/c51/c51_xa_behavior.htm
:(
But, surely, you could easily determine this empirically?
You wouldn't even need a real target - the Simulator would do ...
Unfortunately I don't have access to the compiler. The code was written a number of years ago, and the algorithm has since been ported (re-written) to another design. I am not responsible for either design, but am trying to understand why the two systems give different results. I just noticed in the original source that a right shift was being applied to an integer and wanted to confirm it was working as intended.
stevea said:I don't have access to the compiler
Of course you do:
https://www.keil.com/c51/demo/eval/c51.htm
Andy, unfortunately I cannot install any software on my work machine, it all has to be done through our IT department. I was hoping that the question could be answered more quickly by using this forum.
You seem to asking a lot of questions like this, all of which would benefit from having the tools installed.
If it's part of your job, shouldn't your employer be providing appropriate tools ?
EDIT
Sorry - it wasn't you! It was somebody else, but saying a very similar thing.