The first variant is the correct approach, because SDCC does not currently support the second variant, even though it is valid C.
I have no idea what is going on with the ASlink warning. It is possible that you found a bug.
If the array is a global variable, you could omit the explicit zero-initialization as a workaround, because global variables are implicitly zeroed.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, the first one should work. The error message "?ASlink-Warning-Undefined Global 'FF' referenced by module 'keypad_ledarray'" looks like it is about an unrelated issue. Can you provide a compile- and linkable code sample to reproduce that problem?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think the FF about which the linker complains must be here:
void delay(void) {
__asm
mov R7, #FF
Instead of #FF there should be either #0xFF or #255, as in this assembler # just means something like "the number argument of the assembly instruction follows" and 0x is a prefix for hexadecimal numbers.
Last edit: Janko Stamenović 2024-07-20
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#0xff or #0xFF would be the number 0xff. #FF is the value of the symbol FF (i.e a symbol named FF which would get assigned a value by the linker), but since there is no symbol FF, you get an error message at link time.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think this are not bug, since SDCC is a free and open source software, it should trade in-between feature and cost, so what's important is knowing what is can and what it can not, and for those it can, also know how it does them.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When I declared as this:
It was prompted:
and, when I declared as this:
it was prompted:
So, how to declare a 2-D array in SDCC ?
Last edit: Mian Qi 2024-07-19
The first variant is the correct approach, because SDCC does not currently support the second variant, even though it is valid C.
I have no idea what is going on with the ASlink warning. It is possible that you found a bug.
If the array is a global variable, you could omit the explicit zero-initialization as a workaround, because global variables are implicitly zeroed.
Yes, the first one should work. The error message "?ASlink-Warning-Undefined Global 'FF' referenced by module 'keypad_ledarray'" looks like it is about an unrelated issue. Can you provide a compile- and linkable code sample to reproduce that problem?
Hier:
This works.
I think the FF about which the linker complains must be here:
Instead of
#FF
there should be either#0xFF
or#255
, as in this assembler#
just means something like "the number argument of the assembly instruction follows" and0x
is a prefix for hexadecimal numbers.Last edit: Janko Stamenović 2024-07-20
Yes.
#0xff
or#0xFF
would be the number 0xff.#FF
is the value of the symbol FF (i.e a symbol named FF which would get assigned a value by the linker), but since there is no symbol FF, you get an error message at link time.Thanks, when I modified "0xFF", neither of the 2 errors is shown. And, I found
was OK, and
would trigger "error 69: struct/union/array '': initialization needs curly braces".
I attached this feature description here, maybe it is useful for someone else.
Last edit: Mian Qi 2024-07-24
The intriguing aspect of the next two lines is that they follow C23 syntax correctly but SDCC only initialize the first element:
bug?
I think this are not bug, since SDCC is a free and open source software, it should trade in-between feature and cost, so what's important is knowing what is can and what it can not, and for those it can, also know how it does them.