Truncated match.
PICList
Thread
'CCS Compiler - locating an ARRAY'
1999\03\22@122256
by
Lawrence Lile
I'm using the CCS C compiler. (No "I told you so's" from Andy or other
Hitech fans)
and I'm trying to specify an array in banked ram. I think the proper syntax
is:
int arrayvariable[15];
#byte arrayvariable[0] = 0x71
This is supposed to allocate an array of 15 8-bit registers between 0x71
and 0x7F. Is this actually correct?
Lawrence Lile
1999\03\22@124823
by
Piu Cheng
Hi Lawrence,
I think it should this:
#byte arrayvariable=0x71;
ivan.
On Mon, 22 Mar 1999, Lawrence Lile wrote:
{Quote hidden}> I'm using the CCS C compiler. (No "I told you so's" from Andy or other
> Hitech fans)
>
> and I'm trying to specify an array in banked ram. I think the proper syntax
> is:
>
>
> int arrayvariable[15];
> #byte arrayvariable[0] = 0x71
>
>
> This is supposed to allocate an array of 15 8-bit registers between 0x71
> and 0x7F. Is this actually correct?
>
>
> Lawrence Lile
>
1999\03\25@112739
by
John Payson
> I'm trying to specify an array in banked ram. I think the proper syntax
> is:
>
> int arrayvariable[15];
> #byte arrayvariable[0] = 0x71
>
> This is supposed to allocate an array of 15 8-bit registers between 0x71
> and 0x7F. Is this actually correct?
|I think it should this:
|#byte arrayvariable=0x71;
Does anyone know whether there's any way to pass a constant-subscripted
array element by reference to an inline procedure (or if current CCS
allows for it?)
If I code:
void dumb_inc(char &foo)
{
foo++;
}
char bar[16];
void main(void)
{
dumb_inc(bar[0]);
dumb_inc(bar[2]);
}
My compiler produces code which increments bar[0] twice, rather than
incrementing bar[0] once and bar[2] once.
1999\03\25@181558
by
Regulus Berdin
Hi,
John Payson wrote:
> Does anyone know whether there's any way to pass a constant-subscripted
> array element by reference to an inline procedure (or if current CCS
> allows for it?)
>
> If I code:
>
> void dumb_inc(char &foo)
> {
> foo++;
> }
>
> char bar[16];
>
> void main(void)
> {
> dumb_inc(bar[0]);
> dumb_inc(bar[2]);
> }
I don't know if in your application, that the addresses to be
incremented will be placed in the array bar[] or an element in bar[].
To be C compliant, bar[0] and bar[2] should be passed as pointer:
dumb_inc(bar+0);
dumb_inc(bar+2);
because the parameter in dumb_inc() is defined as pointer. But when I
tried to test in CCS it produces a 'Different levels of indirection'
error.
Maybe a hardcoded FSR function maybe the only solution. Sorry for my
english, its not my native language :).
regards,
Reggie
--
e-mail: spam_OUTrberdinTakeThisOuT
bigfoot.com
ICQ#: 31651436
URL: http://www.bigfoot.com/~rberdin
1999\03\26@122610
by
John Payson
|
> void dumb_inc(char &foo)
> {
> foo++;
> }
>
> char bar[16];
>
> void main(void)
> {
> dumb_inc(bar[0]);
> dumb_inc(bar[2]);
> }
|I don't know if in your application, that the addresses to be
|incremented will be placed in the array bar[] or an element in bar[].
|To be C compliant, bar[0] and bar[2] should be passed as pointer:
| dumb_inc(bar+0);
| dumb_inc(bar+2);
|because the parameter in dumb_inc() is defined as pointer. But when I
|tried to test in CCS it produces a 'Different levels of indirection'
|error.
CCS offers a C++ -style pass-by-reference option for function calls
(hence the "&" before argument "foo"). If function dumb_inc is as
above and I code:
void main(void)
{
char i,j;
dumb_inc(i);
dumb_inc(j);
}
and the compiler decides to expand dumb_inc inline (which it likely
would), the code produced would simply be
movf i,w
incf i,f
movf j,w
incf j,f
which is as it should be [well, the useless movf's aren't too wonderful,
but...] The problem is that CCS does not properly compute the array
addresses when using pass-by-reference. Oh well...
More... (looser matching)
- Last day of these posts
- In 1999
, 2000 only
- Today
- New search...