Page 1 of 1

Re: How to shift register?

Posted: Fri Mar 19, 2010 5:48 pm
by Benj
Hello

If your shifting a variable then you can do so inside a calculation icon as follows.

var = var >> 1

will shift one place to the right

var = var << 1

will shift one place to the left

var = var >> 1 is the same as var = var / 2
var = var >> 2 is the same as var = var / 4

A right shift can also be done as a divide.

var = var << 1 is the same as var = var * 2
var = var << 2 is the same as var = var * 4

A left shift can also be done as a multiply.

Re: How to shift register?

Posted: Mon Mar 22, 2010 9:23 am
by Benj
Hello

Instead of using this,

FCV_PORTB = FCV_PORTB << 1;
FCV_PORTB = FCV_PORTB << 2;
FCV_PORTB = FCV_PORTB << 3;

Try just using the one shift. The result is stored back in the register.

FCV_PORTB = FCV_PORTB << 1;