Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Thu Aug 01, 2013 8:54 am |
|
|
An inefficient way of getting the high byte of a value.
Inefficient, since 'make8', can do the same in a single machine cycle, while this takes dozens....
It takes the address of the variable 'x' (&x). Treats this as if the variable was an int8 (int8 *), increments it by one (to get the address of the next byte '+1'), and then returns the contents of this address (*......).
Indirect addressing is inefficient on the PIC in general, taking several instructions to setup. Modern use is almost certainly is the result of somebody not 'knowing this', and porting code over from a chip where this doesn't apply, or from an example that pre-dates CCS adding the 'make8' instruction (which does this as efficiently as possibly
Unfortunately, some of the CCS examples, date from before this, so use this form.....
It is 'standard C'.
Best Wishes |
|