32-bit memory I/O on 32-bit boundary only?

32-bit memory I/O on 32-bit boundary only?

Post by Luis Pari » Tue, 08 Jul 2003 10:00:53



Can a PocketPC application read/write 32-bit variables that are not 32-bit
aligned in memory? This is not a problem when variables from primitive
datatypes are declared. However, when I try to access a 32-bit structure
field that is not 32-bit aligned in memory, the application misteriously
hangs. Has anyone seen this problem before? The application runs on a
Toshiba PocketPC, processor Intel PXA250 (ARM).
Thanks,
Luis
 
 
 

32-bit memory I/O on 32-bit boundary only?

Post by Grant Richins [MS » Wed, 09 Jul 2003 01:54:30


Yes and no.  If you try and read unaligned data you will get an alignment
exception.  However you can use the UNALIGNED macro that modifies a pointer
to instruct the C/C++ compiler to generate code to access the memory in a
manner that won't cause the alignment fault.  It's slower this way, but it's
better than a crash.  The best solution is to make sure your data structures
are properly aligned and padded is necessary.

--
--Grant
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:> Can a PocketPC application read/write 32-bit variables that are not 32-bit
> aligned in memory? This is not a problem when variables from primitive
> datatypes are declared. However, when I try to access a 32-bit structure
> field that is not 32-bit aligned in memory, the application misteriously
> hangs. Has anyone seen this problem before? The application runs on a
> Toshiba PocketPC, processor Intel PXA250 (ARM).
> Thanks,
> Luis


 
 
 

32-bit memory I/O on 32-bit boundary only?

Post by Luis Pari » Wed, 09 Jul 2003 06:08:44


Thanks for this information. The problem arose while parsing an external
.WAV file whose headers depend on previous size fields. In this situation,
proper alignment cannot be guaranteed. One particular .WAV was, in fact,
unaligned, which doesn't mean it has bad format. The OS should probably
display a MessageBox about the alignment exception, or some error number, it
would make debugging less painful :).
Luis



> Yes and no.  If you try and read unaligned data you will get an alignment
> exception.  However you can use the UNALIGNED macro that modifies a
pointer
> to instruct the C/C++ compiler to generate code to access the memory in a
> manner that won't cause the alignment fault.  It's slower this way, but
it's
> better than a crash.  The best solution is to make sure your data
structures
> are properly aligned and padded is necessary.

> --
> --Grant
> This posting is provided "AS IS" with no warranties, and confers no
rights.



> > Can a PocketPC application read/write 32-bit variables that are not
32-bit
> > aligned in memory? This is not a problem when variables from primitive
> > datatypes are declared. However, when I try to access a 32-bit structure
> > field that is not 32-bit aligned in memory, the application misteriously
> > hangs. Has anyone seen this problem before? The application runs on a
> > Toshiba PocketPC, processor Intel PXA250 (ARM).
> > Thanks,
> > Luis

 
 
 

1. Formating storage card at 16 bit or 32 bit?

I noticed with the various storage card utilities one can format the card
with 32 bit rather than the default 16 bit. Is there any reason to use one
over the other? I know 32 bit is more secure and uses space more
efficiently, but is there some incompatibility or other issue that one needs
to consider in making the choice?

jmf

2. Downloaded MIDI files -- Why is the end chopped off?

3. 32-bit Carbus support on the Pocket PC

4. Who to contact at Apple about Technical Hardware information

5. 32 bit Cardbus Cards on the IPAQ

6. SmartandFriendly CD TurboWriter RW(SCSI) problems with ISO's

7. iPAQ PC CARD expansion sleeve and 32 bit CARDBUS

8. Stupid question, Ipaq memory 32 or 64 mb

9. Problems with more that 32 Mb memory in PPC2

10. E330 vs the 32 Meg.Axim

11. Unhandled Exception on Pocket PC with More Than 32 MB of System RAM

12. FAT 16 or FAT 32 for MMC card in iPAQ?