This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM: about passing parameters.

The following code is from a project compiled and run very well under Realview Debuger platform.But when transplanted to Keil uVision3, it can be successfully compiled and booted, but overflowed in many function calling. For example:

UInt32 FC_EvalCorr(unsigned char *psliceref,unsigned char *pslicenew, short x, short y)
{
        register UInt8  *imr, *imn;
        register UInt32 sumcorr = 0;
        register Int32  diff;
        register UInt16 i;

        imr = psliceref + ((XSLICE-WCORR)>>1);
        imn = pslicenew + ((XSLICE-WCORR)>>1) + x + y * XSLICE;

        for (i = 0; i < WCORR; i++)
        {
                diff     = imn[i] - imr[i];
                sumcorr += abs(diff) * abs(diff);
        }

        return (sumcorr);
}

its Dissembly Window is like this:

0x20003C18  E0811002  ADD       R1,R1,R2
0x20003C1C  E3A02023  MOV       R2,#0x00000023
0x20003C20  E1620283  ???
   201: {
   202:         register UInt8  *imr, *imn;
   203:         register UInt32 sumcorr = 0;
   204:         register Int32  diff;
   205:         register UInt16 i;
   206:
   207:
   208:         imr = psliceref + ((XSLICE-WCORR)>>1);
0x20003C24  E1A0C000  MOV       R12,R0
   209:         imn = pslicenew + ((XSLICE-WCORR)>>1) + x + y * XSLICE;

0x20003C28  E0811182  ADD       R1,R1,R2,LSL #3
   201: {
   202:         register UInt8  *imr, *imn;
0x20003C2C  E52DE004  STR       R14,[R13,#-0x0004]!
   203:         register UInt32 sumcorr = 0;    // to compute correlation
   204:         register Int32  diff;
   205:         register UInt16 i;
   206:
   207:
   208:         imr = psliceref + ((XSLICE-WCORR)>>1); //reference
0x20003C30  E3A00000  MOV       R0,#comm_t(0x00000000)
   209:         imn = pslicenew + ((XSLICE-WCORR)>>1) + x + y * XSLICE;

0x20003C34  E281E04C  ADD       R14,R1,#0x0000004C
   208:         imr = psliceref + ((XSLICE-WCORR)>>1); //reference
   209:         imn = pslicenew + ((XSLICE-WCORR)>>1) + x + y * XSLICE;

0x20003C38  E28CC04C  ADD       R12,R12,#0x0000004C
   231:         for (i = 0; i < WCORR; i++)
   232:         {
0x20003C3C  E1A01000  MOV       R1,R0
   233:                 diff     = imn[i] - imr[i];
0x20003C40  E7DE2001  LDRB      R2,[R14,R1]
0x20003C44  E7DC3001  LDRB      R3,[R12,R1]
0x20003C48  E2811001  ADD       R1,R1,#0x00000001
0x20003C4C  E3C11801  BIC       R1,R1,#0x00010000
0x20003C50  E0522003  SUBS      R2,R2,R3
   234:                 sumcorr += abs(diff) * abs(diff);
   235:         }
   236:
   237:         return (sumcorr);
0x20003C54  42622000  RSBMI     R2,R2,#comm_t(0x00000000)
0x20003C58  E0200292  MLA       R0,R2,R2,R0
   231:         for (i = 0; i < WCORR; i++)
   232:         {
   233:                 diff     = imn[i] - imr[i];
   234:                 sumcorr += abs(diff) * abs(diff);
   235:         }
   236:
   237:         return (sumcorr);
0x20003C5C  E3510080  CMP       R1,#0x00000080
0x20003C60  3AFFFFF6  BCC       0x20003C40
   238: }

Three questions:
1.what does the "???" means?

2.if there are no abs functions, it should also work correctly, but in fact the same error as 1 will emerge.

3.the C code is very simple. why does its corresponding asm code seem to repeat so many times?

0