Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

in HTC , how to shift PORTB bits to left or right?

Status
Not open for further replies.

vinodstanur

Advanced Member level 3
Advanced Member level 3
Joined
Oct 31, 2009
Messages
751
Helped
114
Reputation
234
Reaction score
114
Trophy points
1,333
Location
Kerala (INDIA)
Activity points
7,054
in a HTC compiler, how can I shift the bits of a port ,say PORTB , to left?
now I follow ;


int a;
(a=1);
PORTB=a*2;

but I think, the above procedure will not work when 8-bit PORTB value exceeds 255 (decimal).
so, as in 8086 instruction set, there is SHL,SHR,ROR etc, how could i use similar instructions in C (for HTC compiler).
 

To shift right you can use >> bit shift operator
For example:
11010111>>2 would give the result 00110101

Similarly, you can left shift using << bit shift operator
For example:
11010111<<3 would give the result 10111000
 

after right shift if i use left shift then could i get the old data?

---------- Post added at 20:00 ---------- Previous post was at 19:53 ----------

actually i am trying to make a scrolling message display on 8*10 dot matrix display. Am using pic16f84a.
Pls give some ideas for this . I tried << and its working. But any one pls give me some ideas about scrolling text display. I had already made it to display letters but i cant make them scroll in continuous manner . My ideas will consume much memory of the PIC.
 

after right shift if i use left shift then could i get the old data?

bhattaroshan already gave you the answer. all you need to do is to understand his examples and apply them to your own question.

But any one pls give me some ideas about scrolling text display.

doesn't that depend on how you display the text?
 

if you are using c language why do you want to use bit shift operators.There are many other ways that is more easy. I don't mean to say that we cannot perform this task using bit operators but you could use other library functions either.If you want some examples then please reply the post i will suggest you.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top