Hi anton.
At first I'm not mE guy, and my english is very bad, so Please pardon it when you do not understand my explanation.
Returned value is correct, even if those are different from your expected.
16Bit PIC can byte data even if it allocated at odd address, but can not handle word data allocated at odd address.
Maybe this is the reason why byte data in record type aligned even address.
Think about this type of record.
Code: Select all
Type
Tsomerec = record
b1: byte;
w1: word;
b2: byte;
w2: word;
end;
If this type of record is 'PACKED', w1 and w2 may be allocated at odd address.
Since record type can contain various type of data, each fields aligned on boundary. On other side array type contains single type of data, there is no need to align on word boundary. So "siaeof(arraytype)" may returns value as your expected.
Anyway sometime when I need to save ram (or EEPROM) (ex. Data logger App.) , I use cheap tricks like this.
Code: Select all
type
TSomerecord = record
W1: word;
Dummy: word;
W3: word;
var
rec: TSomerecord;
bdata1, bdata2: ^byte;
begin
bdata1 := @rec + 2;
bdata2 := @rec + 3;
bdata1^ := anybytevalue;
...
end.
Usually these kind of codings are not recommended, sometimes cause unexpected overwrite, but if use with care, very useful.