Accessing Control Registers
3-21
For ZDCC the macro is:
disable_cbuf(CBUF_ID);
There are special macros defined within
cbuf.h
to access the elements
in a circular buffer. These macros are the same for all compilers.
load_int_cbuf(
dst
,
pt
,
inc
)
store_int_cbuf(
src
,
pt
,
inc
)
load_long_cbuf(
dst
,
pt
,
inc
)
store_long_cbuf(
src
,
pt
,
inc
)
The
inc
parameter determines the number of elements to increment the
pointer
pt
. The
inc
parameter must be a constant rather than a variable.
For
load_int_cbuf
and
store_int_cbuf
,
inc
must be in the range
1–50. For
load_long_cbuf
and
store_long_cbuf
,
inc
must be in the
range 1–25.
It is legal to access a value pointed to by
pt
using
*pt
, so an increment
value of 0 is not needed.
The
dst
and
src
parameters are variables used for the destination and
source values, respectively. Note that these parameters are not pointers
to a location where the destination/source will be stored/accessed, but to
the variables that will actually be stored/accessed.
Note:
You must disable circular-buffer arithmetic immediately after
the final use of
pt
, because the compiler may reuse the
register containing
pt
for other purposes. The code
generated in this case would not expect the register to have
circular arithmetic.
Because the registers supporting circular-buffer functionality are not
saved and restored by function calls/returns, circular buffers should not
be used with code containing function calls.
3.7 Accessing Control Registers
Macros have been defined in the header file <creg.h> to simplify
accessing control registers.