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.

.define errors

Other Parts Discussed in Thread: MSP430G2231, CC430F5123

I'm trying to build an assembler-only program in CCS v5.1 and I'm running into trouble with my definitions.

I want to create several constants which are located at specific, sequencial locations in RAM which I would like to define.  I also want to initialize these addresses with values.

The code I have written is:

.cdecls C,LIST, 

"msp430g2231.h"

BIN  .equ 200h                                                           illegal mneumonic specified

.define 0x0202,EmergencyFlag                              

.define 0x0204,OpenValveTimer                            

.define 0x0206,Divisor

.define 0x0208,FullMeasurement

;------------------------------------------------------------------------------

           

.text                           ; Progam Start          

.global INITIALIZE           ; define entry point

;------------------------------------------------------------------------------

INITIALIZE 

mov.w   #0280h,SP               ; Initialize stackpointer

StopWDT    

mov.w   #WDTPW+WDTHOLD,&WDTCTL ; Stop WDT

mov.w #TASSEL_2+MC_2,&TACTL ; Initialize the Timer A contol Register and set it to continuous mode with the Sub-Master Clock

;------------------------------------------------------------------------------

; Definitions set up specifically for Multi-Tasking Routine

;------------------------------------------------------------------------------

clr.w Bin                                                                                            illegal, un-relocatable operand

clr.w EmergencyFlag                                                                        illegal, un-relocatable operand

clr.w OpenValveTImer                                                                      undefined symbol

clr.w Divisor                                                                                         illegal, un-relocatable operand

clr.w FullMeasurement                                                                        illegal, un-relocatable operand

I have noted the error messages beside the code.  Any idea how to fix this issue?

Also, when using ".define" is the value given the address of the symbol, or the value of the symbol?

 

Thanks for any help

Joanna

  • Put & in front of the operand. For example ...

    clr.w &Bin

    Thanks and regards,

    -George

  • Thanks for the response.

    I added the '&' as suggested.  This gets rid of the error, but doesn't entirely solve my problem.

    I'm using these variables later on in my code.  I would like to see them changing in the debugger as I use them (just as you can do with the working registers), but they are not listed in the variables section.

    I suppose a better way of phrasing my question would be how do you define and initialize variables in assembly using CCS 5.1?

    I wrote some very simple C-code which initialized variables in an attempt to see this in the 'disassembler', but found that all the variables were automatically written to the working registers.  I would like to write my variables to RAM.

     

    Joanna

  • It is easy enough to define data variables in assembly.  The key directive is .usect.  Read about it in the Assembly Language Tools book.  Define the variables in a section you name.  Then, in the link command file, allocate that section to a specific address.

    But, you also want to see these variables in CCS just like variables defined in C.  That is difficult.  The compiler uses a series of non-trivial debug directives (they all start with ".dw") to encode all of the Dwarf debug information for a variable.  Reproducing that in hand-coded assembly is not practical.  So far, I have no thought of a solution to this part of your problem.

    Thanks and regards,

    -George

  • So, just so I ensure I understand what your saying:

    If I have an assembly program which contains a file register called LoopCounter in RAM, I cannot view what the value of that register is if I step through the program in CCS?  But i can in C?  When programming PICs in assembler, we commonly had 100+ such named registers. 

     

    Also, where is the link command file located, and how am I to modify it?  I've been through that Tools book already, but found it hard to follow.  What would really be helpful is an example!  Is there no examples that show such things?  (I was already pointed to those listed on the ti website, but they are short and do not include much useful code).

  • Joanna Boetzkes said:
    If I have an assembly program which contains a file register called LoopCounter in RAM, I cannot view what the value of that register is if I step through the program in CCS?  But i can in C?  When programming PICs in assembler, we commonly had 100+ such named registers.

    I'm not sure what you mean by a "file register" in RAM.  You can certainly see ordinary CPU registers in CCS.  But such registers, and their visibility in CCS, is all built-in.  I presume you are talking about a piece of memory allocated and given a name by the user.  For such variables, the memory allocation step is straightforward.  The difficulty is associating the name and type with that chunk of memory so that CCS knows how to display it.  That information is encoded in Dwarf debug format with non-trivial assembler directives.  

    Joanna Boetzkes said:
    where is the link command file located, and how am I to modify it?

    This best shown by example.  In CCS create a new project.  The menu item is Project -> New CCS Project.  Name the project.  Then under Project templates and examples, choose the Blink The Led project.  Click Finish.  (BTW, these selections may be a bit different depending on which CCS version you use.)  Expand the project in the Project Explorer view.  You will see a file with a name similar to lnk_cc430f5123.cmd.  Double-click to edit it.  This is a linker command file.  Even for an assembly only project, you should probably use the link command file appropriate for your device.

    Thanks and regards,

    -George