The following code creates some interesting asm with the following flags:
 -g -c -Os -fno-force-mem -mmcu=msp430x437

It looks like it unrolled the loop in 64 byte chunks and is instead
iterating over that.  While this is faster this would hardly ever get run so
I would rather have it small.

attached are list files with the -fno-force-mem on and off and the C file.

If I change the span it iterates over to a nonmultiple of 64 I get the
expected asm.  

My question is what does no-force-mem have to do with this and why isn't
auto increment addressing being used?  In this case it would save quite a
bit here.

-Chris    

---

#include <msp430x44x.h>

int test()
{
    unsigned int sum = 0;
    unsigned int *addr;

    for (addr = (int *)0x8000; addr != 0x0000; addr++) {
        sum += *addr;
    }

    return sum;
}

-------

    for (addr = (int *)0x8000; addr != 0x0000; addr++) {^M
   2:   3e 40 00 80     mov #-32768,r14 ;#0x8000
        sum += *addr;^M
   6:   2f 5e           add @r14,   r15 ;
   8:   1f 5e 02 00     add 2(r14), r15 ;
   c:   1f 5e 04 00     add 4(r14), r15 ;
  10:   1f 5e 06 00     add 6(r14), r15 ;
  14:   1f 5e 08 00     add 8(r14), r15 ;
  18:   1f 5e 0a 00     add 10(r14),r15 ;
  1c:   1f 5e 0c 00     add 12(r14),r15 ;
  20:   1f 5e 0e 00     add 14(r14),r15 ;
  24:   1f 5e 10 00     add 16(r14),r15 ;
  28:   1f 5e 12 00     add 18(r14),r15 ;
  2c:   1f 5e 14 00     add 20(r14),r15 ;
  30:   1f 5e 16 00     add 22(r14),r15 ;
  34:   1f 5e 18 00     add 24(r14),r15 ;
  38:   1f 5e 1a 00     add 26(r14),r15 ;
  3c:   1f 5e 1c 00     add 28(r14),r15 ;
  40:   1f 5e 1e 00     add 30(r14),r15 ;
  44:   1f 5e 20 00     add 32(r14),r15 ;
  48:   1f 5e 22 00     add 34(r14),r15 ;
  4c:   1f 5e 24 00     add 36(r14),r15 ;
  50:   1f 5e 26 00     add 38(r14),r15 ;
  54:   1f 5e 28 00     add 40(r14),r15 ;
  58:   1f 5e 2a 00     add 42(r14),r15 ;
  5c:   1f 5e 2c 00     add 44(r14),r15 ;
  60:   1f 5e 2e 00     add 46(r14),r15 ;
  64:   1f 5e 30 00     add 48(r14),r15 ;
  68:   1f 5e 32 00     add 50(r14),r15 ;
  6c:   1f 5e 34 00     add 52(r14),r15 ;
  70:   1f 5e 36 00     add 54(r14),r15 ;
  74:   1f 5e 38 00     add 56(r14),r15 ;
  78:   1f 5e 3a 00     add 58(r14),r15 ;
  7c:   1f 5e 3c 00     add 60(r14),r15 ;
  80:   1f 5e 3e 00     add 62(r14),r15 ;
  84:   3e 50 40 00     add #64,    r14 ;#0x0040
  88:   be 23           jnz $-130       ;abs 0x6
    }

Attachment: test.c
Description: Binary data

Attachment: test.lst
Description: Binary data

Attachment: test.unr.lst
Description: Binary data

Reply via email to