Re: [Tack-devel] Accessing to unaligned data in records/structures
Moved to https://github.com/davidgiven/ack
Brought to you by:
dtrg
From: David G. <dg...@co...> - 2019-06-11 16:02:37
|
EM requires word-aligned accesses (or short-aligned for shorts) (which just recently came as a nasty shock when I set the i80 alignment to 1 and everything started failing obscurely). Only architectures that don't require it you *can* get away with code like the above but it's not guaranteed to work, and the C compiler will insert padding in structures to make alignment work. To load unaligned fields you have to read bytes and then assemble a word with arithmetic. For some reason there aren't any EM instructions to do unaligned reads. On Tue, 11 Jun 2019 at 17:35, Carl Eric Codere via Tack-devel < tac...@li...> wrote: > Greetings, > I am slowly working on the em instruction testsuite, and I > am a bit stuck, when trying to test LOI from the below code, I get a bad > pointer error in the interpreter at LOI 2, because the address is not > aligned. Hence my question, how do you access the second field of this > structure? What happens in pascal if the record is declared as packed, or > is this just a problem associated with the interpreter? > > > /* Unaligned structure containing the data to read. */ > struct01 > rom 255I1 > rom -32767I2 > rom 2147483647I4 > #if EM_WSIZE >= 4 > rom 9223372036854775807I8 > #endif > > exp $_m_a_i_n > pro $_m_a_i_n, 0 > > /* Unaligned structure access */ > > 1 > lae struct01+1 /* stack address of structure */ > loi 2 /* stack data from structure */ > loc -32767 > cmi EM_WSIZE /* check if value is what is expected. */ > zeq *2 > > ldc __LINE__ > cal $fail > asp 4 > > Thanks for all your help, > Carl > > _______________________________________________ > Tack-devel mailing list > Tac...@li... > https://lists.sourceforge.net/lists/listinfo/tack-devel > -- ┌─── http://www.cowlark.com ─── │ "I have always wished for my computer to be as easy to use as my │ telephone; my wish has come true because I can no longer figure out │ how to use my telephone." --- Bjarne Stroustrup |