I saw this assignment:
u = &Binary[0][0][0][0]
in a for loop:
for (i = 0, u = &Binary[0][0][0][0]; i < MAX_ADDRESSES; i++, u++)
from this section:
#define ILLEGAL_VALUE 0xFFFF
#define MAX_MODULES 8
#define MAX_SECTORS 16
#define MAX_SYLLABLES 3
#define MAX_WORDS 256
#define MAX_ADDRESSES (MAX_MODULES * MAX_SECTORS * MAX_SYLLABLES * MAX_WORDS)
...
int i;
uint16_t *u;
// Initialize the binary as completely unused.
for (i = 0, u = &Binary[0][0][0][0]; i < MAX_ADDRESSES; i++, u++)
*u = ILLEGAL_VALUE;
for an assembler.
I am not very familiar with c (or other compiled languages), awk is somewhat similar to c.
In awk var[x]
is an array, but this seems not to be an array, or any other variable.
What is this piece of code ' &Binary[0][0][0][0]
' ?
Edit:
Indeed I found this:
typedef uint16_t
BinaryImage_t[MAX_MODULES][MAX_SECTORS][MAX_SYLLABLES][MAX_WORDS];
#define ILLEGAL_VALUE 0xFFFF
So it is an array after all !
However I am surprised by the ampersand as the first character of the array name ?
Somewhere in your code is likely a declaration for a multi-dimensional array named Binary
Most likely a 4-d array of type uint16_t
(16-bit unsigned int)
uint16_t Binary[MAX_MODULES][MAX_SECTORS][MAX_SYLLABLES][MAX_WORDS];
This expression: &Binary[0][0][0][0]
is the address of the first element in this multi-dimensional array. While the array is declared as a 4-d array, it appears the for-loop is simply enumerating over all elements in the array via pointer to initialize each with the ILLEGAL_VALUE
constant.
For what it's worth, the for-loop could likely be replaced with:
memset(Binary, 0xff, sizeof(Binary));
regarding:
u = &Binary[0][0][0][0]
this means set the contents of u
with the address of the very first entry in a 4 dimensional array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.