PIC Assembly

Status
Not open for further replies.

lastiku

New Member
I would like someone to help me with a problem I encountered. In the source code I am currently writing I need to divide by 2 one of the variables. Can any one help me please, with an asssembly language source code?. Also I would like to know if percentage are possible to calculate using assembly language, for the Microchip PIC.
Thank you.
 

Dividing by 2 is extremely easy, all you do is shift the variable to the right one bit (to multiply by 2 you shift it left). The code looks like this:

RRF Variable, f

That's it!.

As for percentage, you can do any maths you want, it's simply a question of writing the code for it. But with any maths on a PIC it's best to avoid floating point, by careful scaling of the values you can use integer maths for most functions.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…