CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Shift_left, shift_right, rotate_left, rotate_right

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Willie Erasmus
Guest







Shift_left, shift_right, rotate_left, rotate_right
PostPosted: Wed Apr 02, 2003 3:31 am     Reply with quote

<font face="Courier New" size=-1>Hi

The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"

Thanks
Willie
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13305
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Shift_left, shift_right, rotate_left, rotate_right
PostPosted: Wed Apr 02, 2003 8:53 am     Reply with quote

:=<font face="Courier New" size=-1>Hi
:=
:=The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
:=
:=Thanks
:=Willie
:=</font>


The shift functions works like a multiply or divide by 2. This requires you to specify the the size of the number you wish to perform this function on.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13309
Sherpa Doug
Guest







Re: Shift_left, shift_right, rotate_left, rotate_right
PostPosted: Wed Apr 02, 2003 9:54 am     Reply with quote

<font face="Courier New" size=-1>:=<font face="Courier New" size=-1>Hi
:=
:=The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
:=
:=Thanks
:=Willie
:=</font>

The functions all shift by one bit, "value" is a boolean. If you want it to shift a multi-byte word by one bit you must tell it how wide your word is. If you want to shift by several bits you call the function several times.

Does that help?

</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13310
Willie Erasmus
Guest







Re: Shift_left, shift_right, rotate_left, rotate_right
PostPosted: Thu Apr 03, 2003 1:03 am     Reply with quote

Thanks for your replies

If I want to shift out 6 bits, would the function look like this: shift_left(PIN_B0,1,data) (data can be anything described by 6 bits). I now only put the shift function in a for-loop calling it 6 times?

Thanks
Willie



:=<font face="Courier New" size=-1>Hi
:=
:=The CCS compiler help file says that it must be specified in these built-in functions how many bytes must be shifted or rotated. For example: shift_left(address, bytes, value). Is it possible to output any number of bits other than the 8 bits in one byte or must we stick to a "byte(s)"
:=
:=Thanks
:=Willie
:=</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13339
Sherpa Doug
Guest







Re: Shift_left, shift_right, rotate_left, rotate_right
PostPosted: Thu Apr 03, 2003 7:52 am     Reply with quote

:=Thanks for your replies
:=
:=If I want to shift out 6 bits, would the function look like this: shift_left(PIN_B0,1,data) (data can be anything described by 6 bits). I now only put the shift function in a for-loop calling it 6 times?
:=
:=Thanks
:=Willie
:=

If you want to shift out a serial stream try something like:

for(i=0;i<6;i++){
output_bit(PIN_B0,shift_left(&data,1,0));
[wait for length of bit]
}
Which should shift out 6 bits from the byte "data" to pin B0. Note that the output bit of shift_left is its returned value. On the other end of the data 0's are shifted in.

___________________________
This message was ported from CCS's old forum
Original Post ID: 13352
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group