asm rlc versus c shift<<

Thread Starter

embedtechnology

Joined Dec 25, 2015
42
I want to rotate a variable through another variable so that D7 bit of variable 0 will enter into bit D0 position of
variable 1 ( like ASM: rlc variable 0, rlc variable 1 ) . But in c variable0<<=1 loads 0 into D0 position of variable0
and removes bit D7. I am using mikroc compiler.Actually I want to develop a project which is nothing but a led massage
display,in which row scanning technology is taken into consideration. The syntax is needed for scrolling function.
Any idea please.
 

Attachments

dannyf

Joined Sep 13, 2015
2,197
Left shift variable 1.
Set or clear variable 1 lsb based on variable 0 msb.
Left shift variable 0.

Fancier ways to do it also exist.
 

NorthGuy

Joined Jun 28, 2014
611
In C, you would probably define a 16-bit variable then do

C:
int x;
x <<= 1;
You can get the result of the shift from the high byte of the variable. In C it is:

C:
char y;
y = x >> 8;
It may look like a long shift, but most compilers will know that it only means taking the high byte.
 
Top