Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.
 
lastiku said:
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.

Latest threads

New Articles From Microcontroller Tips

Back
Top