Help with syntax for MPLAB code

Status
Not open for further replies.

Daryl69

Newbie level 2
Joined
Apr 25, 2006
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
Hi

I'm writing a program in MPLAB but there are some words I need.

In my program there is one bit where it takes a value that has been inputed i.e 1 and then it multiplies it by 2 e.g 1x2 =2

How to I write that as code in MPLAB?

Also another bit is when it takes a value i.e 2 and shifts one led to the right. can that be typed in as code?

Any help please

Daryl
 

Help with prog

Read about doing arithmatic operations on binary numbers.

A left shift operation on an 8 bit binary number has the effect of doubling the value. Read the data sheet for the PIC you are using for the details of the left shift instruction. You need to allow for the source of the 1 or 0 that gets shifted into the lowest bit.

You also need to consider the possibility of overflow in the higher level design of your program, ie if you are using a single register and the input value is above 127.

It is clear from this and your other post that you need to spend some time reading.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…