- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
The bellow given code on NIOS results to var=0x0201, but it shoud result in var=0x0302. I have tried various combinations with __attribute__ ((align(1)), but with no success. Can I somehow set NIOS gcc compiler to produce byte aligned data access? unsigned[/B][/B] char[/B][/B] mmm[3]={0x01,0x02,0x03}; unsigned[/B][/B] short[/B][/B] var; int[/B][/B] main() { var=*((unsigned[/B][/B] short[/B][/B]*)(mmm+1)); }Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Nios requires aligned data. If you want to store a 16 bit or 32 bit value at an odd address, you'll need to handle it manually, byte-by-byte, for both reads & writes. Writing your code without any underlying alignment assumptions will make it much more portable.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page