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.

Compiler/TMS320F28030: $strtod(x) - how to make it work on a label than with string literal

Part Number: TMS320F28030

Tool/software: TI C/C++ Compiler

I want to use the built-in function $strtod(x). to evaluate a variable at aseemble time from a string .that is part of another structure.

My question is to use built-in functions are:

1. Where to find the complete list of ALL built-in functions as a list ? For example, there is "$pi" and that is not seen documented anywhere in spru513j.pdf. Lots of assembly time string / number processing requirements that can not be achieved from the documented built-in functions can be listed.

2. For example, specifically about, $strtod(x). 

I want to use it as $strtod(person.age). rather than $strtod("40"). 

where:

personStruct .struct

name .string 30
age .string 2
strLen .endstruct ; size = 32

person    .tag    personStruct

I evaluate like below a new label (variable ageNumber)

ageNumber:        .word     $strtod(person.age)

How to achieve what I want?

Any help?

Thanks

Sayee

  • I'm sorry, the $strtod() builtin operator doesn't support anything other than an immediate constant argument.
  • Thanks your input. Is it because it is single pass and possibly a two pass assembler can do it?

    Then can you suggest how to achieve what I want using in-built functions and macros? No working code needed here. Any pointers are sufficient.

    Also I noticed that if I write the following line:
    myAge: .string perso.age

    I am seeing "myAge" is filled with structure member's address (the structure base adrress + 30, from the sample case discussed earlier) rather than the content of the str member. How to get the contents rather than the address of the str member?

    Also help me locate the list of built-in functions and other string processing directives.

    Thanks

    Sayee
  • All of the compiler documentation is at
    processors.wiki.ti.com/.../TI_Compiler_Information

    See the C28x Assembly Language Tools User's Guide (SPRU513), section 4.9 "Built-in Functions and Operators"

    If you intend to store an age in the field person.age and read it at run time, you cannot use the $strtod operator. However, in that case, you would not need $strtod, as the value would already be an integer.

    If instead you intend to define an assembly-time constant and convert it at assembly time, you should probably use something like .asg or .equ to give a symbol the intended value. However, in that case, you would still not need $strtod; you could just use the symbol name directly, and the assembler would expand it to its definition.

    If you need to express a floating-point constant, again you probably don't need $strtod. The assembler can handle most float values directly. For example, 3.1415926 is recognized as a float constant.

    You should only use $strtod when you have a floating-point value you need to represent as an immediate constant, but you need to use it at run-time as a floating-point value, and the assembler doesn't already recognize it as a float value. For example, $strtod("INF") or $strtod("0x1.1234p56")
  • Yes, perso.age gives you an address, not the contents of that address. There are several ways to get the contents, including direct addressing:
    MOV DP, #perso.age
    MOV AL, @perso.age
    Please see the CPU instruction set for addressing modes.
  • Thanks for your information.

    I am trying to use built-in macros / functions to evaluate some configuration type of ROM data - so it is to be done in assemble time and in .econst area and not in .text area. so there will be no assembly instructions and also no runtime code and penalties! That makes few things tricky.

    Nevertheless, I achieved one of the task.

    NOW ANOTHER MAJOR REQUIREMENT WHICH IS NEEDED FOR ALL:

    Auto-increment a counter and embed it in flash...for example a product serial number.

    For every download of .out file, the serial number from the host PC should be auto-incremented and embedded in flash area . except that, the rom image is same for all.
    The method should be error-proof, fool-proof and least cumbersome.

    What is the best way to achieve it? Any suggestions?

    Thanks

    Sayee
  • Well, that's really beyond the scope of the compiler tools. You might have better luck asking on the device forum.