Busy learning CVAVR after many years of ASM. Not doing too bad, but this exceeds my ability...
I have an ASM program that has a lot of "structures", all of similar shape but different size defined like this (different size means different number of bytes from the 3rd byte onwards and different numbers of data bytes):
.equ DATA_BYTE = 0x00 .equ _NUL = 0x00 .equ _ESC = 0x1B .equ _DC1 = 0x11 .SET X_POS = 120 .SET Y_POS = 150 EEPROM_spi_XXX1_start: .db _DC1, (EEPROM_spi_XXX1_end - EEPROM_spi_XXX1_start - 1) .db _ESC, "Z", "F", "0", _ESC, "F", "Z", "1", "P", "Z", "L", low(X_POS),high(X_POS),low(Y_POS),high(Y_POS) EEPROM_spi_XXX1_value: .db DATA_BYTE .db DATA_BYTE .db DATA_BYTE .db DATA_BYTE EEPROM_spi_XXX1_end: .db _NUL .equ spi_XXX1_offset = EEPROM_spi_XXX1_value - EEPROM_spi_XXX1_start EEPROM_spi_XXX2_start: ...etc
The second byte is the size of the structure after the second byte. It's worked out by the assembler meaning I don't have to. Also I need to know the offset from the start of the structure data where the data bytes are so I can insert data at the right places at run time (before sending the whole stream of bytes via SPI to an external device) - the assembler also works that out for me and gives me a value(?) I can use in the code.
So how could I declare and use a similar structure in C?
(hope this makes sense - ask if it doesn't :))