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.

[C6713] Output of 64-bit variable

Hi,

using the C6713, is there a way to display 64-bit variables (long long var) in hex style on the screen?

I've tried it in different ways, e.g.:
LOG_printf (&output, " %X ",var);
LOG_printf (&output, " %16llX ",var);

Though, no matter what I do, it always cuts of the first 32 bits and just displays the last 32 - what am I doing wrong?

 

Thanks for any helpful reply,

legear

  • The BIOS documentation doesn't show support for "long long" with LOG_printf.  As a workaround you could output two variables.  Perhaps something like this would work:

    LOG_printf(&output, "%x %x", var>>32, var);

    Let us know if that works.

  • Thanks, that's a nice workaround.

    There is a problem when the second half of "var" is starting with a "0" (The output for the second half is FFFFFFFF then).

    Seems I have to do it with two 32-Bit integers:

    LOG_printf(&output, "%x %x", int_var1, int_var2);

  • I think you mean when bit 63 is a 1 (not zero), right?  Yes, that would make sense since the '>>' operator is an ARITHMETIC shift right.  Therefore you end up with the sign being preserved.

    Since the C language does not support a logical shift right you would need an intrinsic to generate the proper instruction.  You might want to try this:

    LOG_printf(&output, "%x %x", _hill(var), var);

    The _hill intrinsic is documented in the compiler guide.  It returns the high (hi) part of a long long (ll).

  • The problem is there when bit 31 is "0"

    LOG_printf(&output, "%x %x", var>>32, var);

    -> The output for var>>32 is always correct (bit 63 is always "1" in my case) 
    -> The output for var is FFFFFFFF if bit 31 is "0"

    Strangely, it works the other way round:

    LOG_printf(&output, "%x %x", var, var>>32);

    gives correct output for both 32 bit parts (though prints the lower 32 bits first of course)

    Didn't know there are intrinsics existing for such cases - I'll have a look into the compiler guide tomorrow, maybe the _loll intrinsic can solve my problem.

  • Pardon my confusion here if my understanding is incorrect, but why are you outputting a variable using LOG_printf()? Is var a constant or does it change throughout the life of the application code?

    LOG_printf() relies on messages found within the COFF (.out) file on the host. When it encounters a LOG_printf message CCS finds the appropriate message from within the COFF file and displays it on the screen. It should not be capable of outputting dynamic values as a result of this.

  • LOG_printf does indeed allow you to pass variables at run-time.  It does so using RTA/RTDX so that you don't need to halt.  You're right that CCS grabs the string from the out file, but it will format and insert the data values that were passed from the target.

  • Touche! My mistake.