This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

64-bit integer arithmetic does not work

Other Parts Discussed in Thread: CC1310

64-bit arithmetic does not seem to work on TI compiler for CC1310 (ARM Cortex M-3). In particular, in the following code v remain always zero (x gets correct values):

#include <stdint.h>
...
uint64_t getUint64(const uint8_t* field, uint16_t len) {

  uint64_t v = 0;  
  uint64_t x;
  uint16_t i;
  uint8_t shift = 0;
  for (i=0; i<len; i++) {
  System_printf("%02x\n",field[i]);
    x = field[i];
    x <<= shift;
    v = v | x; 
    System_printf("%02x %08x %08x\n",field[i],x,v);
    shift += 8;
  }
  System_printf("get64 %d\n",v);
  return v;
}

v remains zero throughout. The values of x seem fine (byte values shifted to the left). When I change both v and x to uint32_t, v gets the correct value (when fed from exactly the same data).

Is this just broken or is there a compiler switch that enables 64-bit arithmetic?

Thanks, Sivan Toledo

  • What version of the compiler (not CCS) do you use?  Please show the build options exactly as the compiler sees them.  Please show the array and length you pass as arguments to this function.

    Thanks and regards,

    -George

  • George, the compilation command invoked by CCS is

    'Invoking: ARM Compiler'
    "C:/Programs/TI2/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/bin/armcl" -mv7M3 --code_state=16 --float_support=vfplib --abi=eabi -me -O2 --include_path="C:/Programs/TI2/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/include" --include_path="C:/files/atlas/tags-cc1310" --include_path="C:/Programs/TI2/tirtos_cc13xx_cc26xx_2_20_00_06/products/cc13xxware_2_04_02_17240" -g --define=DEBUG --define=VH_TAG_FIRMWARE --define=ccs --display_error_number --diag_warning=225 --diag_warning=255 --diag_wrap=off --gen_func_subsections=on --preproc_with_compile --preproc_dependency="vildehaye.pp" --cmd_file="configPkg/compiler.opt" "../vildehaye.c"
    "../vildehaye.c", line 263: warning #225-D: function "tag_sessionSeqno" declared implicitly
    "../vildehaye.c", line 305: warning #225-D: function "radioSetup_configureFromBuffer" declared implicitly
    "../vildehaye.c", line 310: warning #169-D: argument of type "const uint8_t *" is incompatible with parameter of type "uint8_t *"
    'Finished building: ../vildehaye.c'

    The build number seems to be 5.2.5, but I'm pasting below the full output of -version.

    The length of the input array is 4 and the array itself held the number 2000002 in little endian (I got similar results for other values), or 0x82, 0x84, 0x1e, 0x00.

    Sivan

    /Programs/TI2/ccsv6/tools/compiler/ti-cgt-arm_5.2.5/bin/armcl -version
    TI ARM C/C++ Compiler v5.2.5
    Build Number 1PGTM-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V

    TI ARM C/C++ Parser v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM EABI C/C++ Parser v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM C/C++ File Merge v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM C/C++ Optimizer v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM C/C++ Codegen v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Assembler v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Embed Utility v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM C Source Interlister v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Linker v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Absolute Lister v5.2.5
    Build Number 1PGTM-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Strip Utility v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM XREF Utility v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM C++ Demangler v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Hex Converter v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Name Utility v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Object File Display v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
    TI ARM Archiver v5.2.5
    Build Number 1PGTN-0QYXQUZU-RTARQ-RAQ-ZAZE_V_S_V
  • You can't use format %x to print a 64-bit integer. You need to use %llx, but I don't think System_printf supports this format. It does support %lx, as shown at rtsc.eclipse.org/.../System.html
    You could do this:
    System_printf("x = %08lx %08lx\n", (uint32_t)(x >> 32), (uint32_t)x);
  • OK, so the arithmetic is done right and the problem was in my printf statements. Got it, thanks a lot.