Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

RE: [lpc2100] Problem with word / dword - access...

2004-02-10 by Jan Szymanski

Try the following instead:
 
union 
 {
 char c[256];
 short i[128];
 long l[64];
 }mydata;
otherwise you have to align 4

-----Original Message-----
From: lpc2100@... [mailto:lpc2100@...] 
Sent: Wednesday, February 11, 2004 06:58
To: lpc2100@yahoogroups.com
Subject: [lpc2100] Problem with word / dword - access...


Hello,

i have a problem with word / dword - access when the address is not even
/ devideable through 4. When i let run the below program i get the
following output:

00 01 02 03 04 05 06 07 08 09

0100 0001 0302 0003 0504 0005 0706 0007 0908 0009

03020100 00030201 01000302 02010003 07060504 04070605 05040706 06050407
0B0A090
8 080B0A09

First line is fine, because it is byte access, filled the array with
increasing numbers.

Second line: On word access all accesses on even addresses are wrong.
Why is the ARM hardware not correcting this or at least detecting it
(throwing an exception), so you know there is something wrong ?

Third line: dword (4 Bytes) seems to ignore below 2 bits, only
rotating... is it really as it should be ? 

I found it during porting a software to LPC2106, and it costs me hours
to find the wrong values. And i am still not sure if i have catched all
the problems.

Have a look at the following example: 
(Pay attention, i have cut out not relevant parts, but i hope you can
still see my problem)

int main(void)
{
    unsigned char   bytearray[256];
    unsigned char  *charptr;
    unsigned short *wordptr;
    unsigned long  *dwordptr;
    int i;

    // Init cut out here...

    for(i = 0;i < 256; i++) bytearray[i] = i;
    
    for(i = 0;i < 10; i++)
    {
        charptr = (unsigned char *)&bytearray[i];
        DebugPutString(" ");
        DebugPutBYTE(*charptr);
    }

    DebugPutString("\r\n\r\n");
    
    for(i = 0;i < 10; i++)
    {
        wordptr = (unsigned short *)&bytearray[i];
        DebugPutString(" ");
        DebugPutWORD(*wordptr);
    }
    
    DebugPutString("\r\n\r\n");
    
    for(i = 0;i < 10; i++)
    {
        dwordptr = (unsigned long *)&bytearray[i];
        DebugPutString(" ");
        DebugPutDWORD(*dwordptr);
    }
    
    while(1);
    
}


________________________________________________________________________
______
Erdbeben im Iran: Zehntausende Kinder brauchen Hilfe. UNICEF hilft den
Kindern - helfen Sie mit! https://www.unicef.de/spe/spe_03.php



  _____  

Yahoo! Groups Links


*	To visit your group on the web, go to:
http://groups.yahoo.com/group/lpc2100/
  

*	To unsubscribe from this group, send an email to:
lpc2100-unsubscribe@yahoogroups.com
<mailto:lpc2100-unsubscribe@yahoogroups.com?subject=Unsubscribe> 
  

*	Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> .

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.