Searching \ for 'CCS compiler - shift Right' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=ccs+compiler+shift
Search entire site for: 'CCS compiler - shift Right'.

Truncated match.
PICList Thread
'CCS compiler - shift Right'
1999\03\24@125759 by Lawrence Lile

flavicon
face
I'm trying to divide a 16 bit variable by 32.  Instead of invoking a
cumbersome divide routine I'd like to just  shift right 5X.  CCS seems to
have a couple of functions that do something like this but I can't seem to
figure out how they work.  Anybody know a good way to do this?

1999\03\24@195837 by Regulus Berdin

picon face
Hi,

You could try inline assembly.  But I think having the code:

       long var;

       var=var/32;

will generate the shifts and not using the div function.  The function
shift_right() will shift an array or structure one bit at a time and may
not generate a tight code.

regards,
Reggie

--
e-mail: spam_OUTrberdinTakeThisOuTspambigfoot.com
ICQ#:   31651436
URL:    http://www.bigfoot.com/~rberdin

Lawrence Lile wrote:
>
> I'm trying to divide a 16 bit variable by 32.  Instead of invoking a
> cumbersome divide routine I'd like to just  shift right 5X.  CCS seems to
> have a couple of functions that do something like this but I can't seem to
> figure out how they work.  Anybody know a good way to do this?

1999\03\25@010822 by Peter Homann

picon face
Hi Lawrence,
long    data;
byte    x;

       for (x = 0; x < 5; x++)
       {
               shift_right(&data,2,0);
       }

or the normal C method.

long    data;

       data = data >>5;

is the same as

long    data;

       data >>= 5;

regards,

Peter.
---
Peter Homann    Email:  .....peterhKILLspamspam@spam@adacel.com.au
Adacel Technologies Ltd _/_/_/ _/_/_/ _/ Phone:   +61 3 9596 2991
250 Bay St, Brighton   _/  _/   _/   _/  Fax:     +61 3 9596 2960
Victoria  3186        _/_/_/   _/   _/   Home:    +61 3 9555 5603
AUSTRALIA            _/  _/   _/   _/_/_/Mobile:      0414-494578
------------------------------------------------------------------------


|{Original Message removed}

1999\03\25@012114 by Regulus Berdin

picon face
Hi Lawrence,

I tried to compile the following code in CCS:

       i = i/32;
       i >>= 5;

and got:
....................  i=i/32;
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
MOVLW  07
ANDWF  26,F
....................  i >>= 5;
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
RRF    26,F
RRF    25,F
MOVLW  07
ANDWF  26,F

which already are very efficient.

regards,
Reggie

--
e-mail: rberdinspamKILLspambigfoot.com
ICQ#:   31651436
URL:    http://www.bigfoot.com/~rberdin

Peter Homann wrote:
{Quote hidden}


'CCS compiler - shift Right'
1999\08\12@110251 by Lawrence Lile
flavicon
face
Igor,

I will start my reply by giving your several resources to answer questions
about the CCS compiler.  I am just a user  of the compiler, starting about a
year ago, and I am no expert.

1.   You can get technical support directly from CCS at

.....ccsKILLspamspam.....ccsinfo.com  .  They are very helpful.

2. You can get technical help on CCS and anything related to a PIC
microcontroller by subscribing to the PIClist.  It is a nonmoderated mailing
list devoted to PIC microcontrollers and anything remotely related (Such as
cows, jokes about Bill Gates, Optical components, homemade nuclear weapons,
and general electronics<G>.)  Joking aside, it is the BEST resource for an
electronics guy.  It also has many Spanish speaking members, and has even
spawned a Spanish list ( I don't know the contacts for this list right now.)

To subsribe send a message to  EraseMELISTSERVspam_OUTspamTakeThisOuTMITVMA.MIT.EDU   with the body of
the message stating

SUBSCRIBE PICLIST

on a line by itself with a carriage return at the end of the line.  You will
get a detailed email in return telling you how the list operates.  SAVE THIS
MESSAGE because it tells you how to get OFF the list if you so desire.

3.  Back to your question.  I have trouble with the OUTPUT_HIGH(pin_xx)
command as well.  I think it has to do with the old read-write-modify bug
(MCHIP says it is a feature???!?!?!!!???)  of the PIC microcontroller.  CCS
translates OUTPUT_HIGH(pin_xx) into BSF PORT, PIN in assembler, which is
generally NOT the correct way to change a pin in a PIC.  If there is any
capacitance on the pin it will NOT go high.  Instead, try this:  Keep a
variable called MIRROR with your pin settings in it.  If you want to raise a
pin, do this:

#ASM
           BSF MIRROR, PIN
           MOVF MIRROR, W
           MOVWF PORT
#ENDASM

Or in C,

bit_set(mirror, pin);
port = mirror;



4.  BTW - how did you find out about me?


-- Lawrwence Lile



{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...