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

missing code for C instruction

The line /***/ below doesn't generate any code, how to fix? using MSP432p401R

//a tree is similar to an inverted 'V' with two branches (left and right) of equal length.
//it's assumed lightCount % 4 == 0
//typedef struct tree
//{
//    char        eyeCatcher[4];    "TREE"
//    uint32_t *  pData;            points to left branch leaf
//    uint32_t    size;
//
//} Tree;

//return zero if failed malloc
Tree *  growTree(uint32_t  treeSize)
{
    Tree *  result = calloc(sizeof(Tree) + treeSize * sizeof(uint32_t), sizeof(uint8_t));
    if (NULL != result)
    {
        memcpy(result->eyeCatcher, "TREE", 4);
        result->pData = (uint32_t*)((uint8_t*)result + sizeof(Tree));
/***/   result->size = treeSize;
    }
    return result;
}

disassembly:
    73: {
0x000006E4 B510      PUSH          {r4,lr}
0x000006E6 4604      MOV           r4,r0
    74:     Tree *  result = calloc(sizeof(Tree) + treeSize * sizeof(uint32_t), sizeof(uint8_t));
0x000006E8 200C      MOVS          r0,#0x0C
0x000006EA EB000084  ADD           r0,r0,r4,LSL #2
0x000006EE 2101      MOVS          r1,#0x01
0x000006F0 F7FFFDF2  BL.W          calloc (0x000002D8)
    75:     if (NULL != result)
    76:     {
0x000006F4 2800      CMP           r0,#0x00
0x000006F6 D006      BEQ           0x00000706
    77:         memcpy(result->eyeCatcher, "TREE", 4);
0x000006F8 A103      ADR           r1,{pc}+0x10  ; @0x00000708
0x000006FA 6809      LDR           r1,[r1,#0x00]
    78:         result->pData = (uint32_t*)((uint8_t*)result + sizeof(Tree));
    79:         result->size = treeSize;
    80:     }
    81:     return result;
0x000006FC 6001      STR           r1,[r0,#0x00]
0x000006FE F100010C  ADD           r1,r0,#0x0C
0x00000702 E9C01401  STRD          r1,r4,[r0,#0x04]
    82: }

Build output:
*** Using Compiler 'V5.06 update 3 (build 300)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'timer32_periodic_mode_led_toggle'
compiling timer32_periodic_mode_led_toggle.c...
assembling ledDriver.s...
compiling changeTree.c...
assembling startup_msp432p401r_uvision.s...
compiling system_msp432p401r.c...
linking...
Program Size: Code=1908 RO-data=356 RW-data=4 ZI-data=4708
After Build - User command #1: fromelf --bin --output .\Build\timer32_periodic_mode_led_toggle.bin .\Build\timer32_periodic_mode_led_toggle.axf
".\Build\timer32_periodic_mode_led_toggle.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed:  00:00:03
Load "C:\\Keil_v5\\projects\\lightTreeV4\\driverlib\\examples\\MSP432P4xx\\timer32\\timer32_periodic_mode_led_toggle\\keil\\Build\\timer32_periodic_mode_led_toggle.axf"
Erase Done.
Programming Done.
Verify OK.
Flash Load finished at 11:56:18

Thanks, Morris

Parents Reply Children