If a 16 bit value is stored (in a pic microcontroller) as a High byte and Low byte, how do you go about dividing them by 2? How can a 16 bit number be rotated right?
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Dividing a 16-bit number by two is equivalent to shifting the number right by a single bit*. Clear the carry flag, rotate the higher byte right through the carry, and then rotate the lower byte right through the carry. You can find code for it here:
* Of course this is an integer division: when odd numbers are divided by two, the
0.5is truncated.