<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Feature of using the BYTEALIGN directive</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/14802/feature-of-using-the-bytealign-directive</link><description> I need to use pointer on structure that may start on byte boundaries. Therefore I write: 
 
#pragma pack(1) 
#pragma BYTEALIGN 
 
typedef struct TLG 
{ 
 unsigned int a0; 
 unsigned char a1; 
 unsigned int a2; 
 unsigned char a3; 
 unsigned char a4;</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Feature of using the BYTEALIGN directive</title><link>https://community.arm.com/thread/38091?ContentTypeID=1</link><pubDate>Fri, 30 Nov 2001 09:14:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b1cacce5-ad11-45a0-9eb5-d21ff6cb6dba</guid><dc:creator>Keil  Support Intl.</dc:creator><description>&lt;p&gt;It should be enough to use just the #pragma pack (1) directive in your case.&lt;br /&gt;
&lt;br /&gt;
BYTEALIGN is required when you have int pointers that may point to a int that is un-aligned.  This seems to be not the case in your example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feature of using the BYTEALIGN directive</title><link>https://community.arm.com/thread/38092?ContentTypeID=1</link><pubDate>Fri, 30 Nov 2001 04:59:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c6919c14-905c-4f9e-a638-4db0ae3f908e</guid><dc:creator>Mik Kleshov</dc:creator><description>&lt;p&gt;I tried that too and got the same result. It seems that with the BYTEALIGN directive the compiler always uses byte-wide access to memory.&lt;br /&gt;
The only thing I can think of is that for 16-bit access you need to write your own assembler routine:&lt;br /&gt;
&lt;pre&gt;
unsigned ReadB0(void)
{
#pragma asm
	EXTS	#8, #1
	MOV	R4, 2
#pragma endasm
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>