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.

Assembler header file problem

Other Parts Discussed in Thread: MSP430F2013

Hello,

I tried to install and use the LaunchPad and to start a small MSP430F2013-Project.
There are some questions and I kindly ask your assistance.

The program shall be a pure assembler program.

Question 1:
Of course I want to use header files but it doesn't work. Sources:

defines.asm:-------------------------------------------------
...
        .cdecls C,LIST,"msp430f2013.h"
        .global _c_int00, stack_init
        .global app, mnloop

adrOn   .equ    80h
adrOff  .equ    0
adr2SLi .equ    10h
adr4SNi .equ    20h
adr5SNi .equ    30h

        .global adrOn, adrOff, adr2SLi, adr4SNi, adr5SNi        

amin.asm:----------------------------------------------------

        .copy   "defines.asm"
...
        .sect   ".infoB"

adrQ    .byte   adrOn|2;    Restladung (default, dominant)
adrI    .byte   adrOn|2;    Entladestrom (nur Alarm)
adrBal  .byte   adr2SLi|2;  Balancing-Alarm (nur Alarm)
adrUtot .byte   adrOn|2;    Gesamt-Spannung (nur Alarm)
rQlLmit .int    2000*2;     Alarm-Grenze Restladung
dIuLmit .int    30*2;       Alarm-Grenze Entladestrom
tolBalU .int    8*2;        Alarm-Grenze Balancing
tUlLmit .int    34*2;       Alarm-Grenze Gesamt-Spannung
lParams .equ    12

Error messages:----------------------------------------------
[E0004] Invalid data size for relocation    for all 4 lines defining adrQ .. adrUtot
[E0300] The following symbols are indefined: adrOn adr2SLi
but I had already cases where nothing was listed in message E0300.

I directly copied the .equ into the main source (in fact I completely copied defines.asm) and it was assembled without message.
But this cannot be good programming style as I will have several source files.

What am I doing wrong?
The "MSP430 Assembly Language Tools v 3.3, User's Guide" (SLAU131E) gives no hints.
Ok, .equ-defined names are per se local, but when .global doesn't make them global: How shall I prepare a header file with imports, exports and defines, eventually with data structures?


Question 2:
I would like the possibility ti define data structures using .struct and .tag, especially I would like to use a C header file and let it be assembled.
So I could define data structures and constants to be used in my assembler program and also in a cooperating PC program written in C.
But, besides problems very similar than the ones described in question 1:
How can I instanciate such a structure in the information flash and preset it? The guide doesn't describe it.

The other questions are posted in seperate threads to reduce confusion.
Thank you in advance for your help and kind regards,
Helmut

  • Helmut Stettmaier said:
    What am I doing wrong?

    Change the .equ statements into

    .define 80h, symbol_name

    The .equ (same as .set) creates an actual symbol with the value 0x80.  The .byte directive does not accept such symbols as operands of expressions like sym | 2.

    A .define is different.  It does not create an actual symbol.  Instead, it creates a text equivalence.  Any instance of symbol_name is replaced by 80h.  Just like #define in C. 

    Helmut Stettmaier said:
    especially I would like to use a C header file and let it be assembled.

    Use the .cdecls directive for that.  Background on it can be found in slides 54-56 of the presentation on this Wiki page.

    Thanks and regards,

    -George

  • Hello George,
    thank you for your help.

    .define is ok.
    I suggest to list ".define" also in the "Directives Summary" of the "MSP430 Assembly Language Tools v 3.3 User's Guide" (even in version of November 2011) such that top down reading newbies find it.

    Using a C header file and .cdecl allows to declare structures (I tried it), but not to define and preset structured variables.
    As the structure variable shall be located in flash memory it must be preset.
    I simply have to learn that this is not possible with strcut{...} or .struct.

    Nevertheless you have answered my questions fully and let me say "Thank You" for it.
    Kind regards,
    Helmut