Archived

This topic is now archived and is closed to further replies.

Gammastrahler

Byte Alignment in VC++ 6.0

Recommended Posts

hi, i have a question concerning byte alignment. I´m programming a scripting language and my instructions should be variable-sized to keep the code small (for example, a byte-add instruction should only occupie 3 bytes, one for the byte code, and one for each of the two operands, where an longint adds would occupy 9 bytes). but the byte alignment is set by VC++ to a 8 byte boundary, to improve performance, and i have an AMD 1800XP+. Would reducing the boundary to one byte mean heavily peformance hits? I have read that the java byte code format always uses 1-byte boundary alignmemnt. Can someone give me a good advice? thanks Gammastrahler

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Just let your compiler do any kind of aligning it wants. Then when reading in the commands, read each operand/operator separately.

struct A {
char a;
int b; //don''t care about alignment
char c;
};

ifstream in(..);
A a;
in >> a.a >> a.b >> a.c;

Share this post


Link to post
Share on other sites