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.

ASM command lib for IAR Workbench



Hello!

I am using IAR Embedded Workbench IDE to write code in asm for MSP430.

Some of the programs are getting quite long and I am looking for a way how to make them more readable.

I use a lot of subroutine fragments as commands. It would be nice if I could save those fragments in separate file as a command library and then use them in other projects.

So, the question is how to make a command library for IAR? I have no understanding where to begin.. Could someone point me to some literature or examples?

  • I would recommend you consult IAR's own documentation as there may be particular syntax and constructs specific to their code generation tools.

    You are going to find that most examples are written in C.  There are number of reasons why that is including some of the objectives you just stated, readability, modularity, etc.

  • You could define such fragments as macros, collect all those macro definitions in a file, and include that file in you source code file whenever they are needed.

  • Thank you for advice.

     

    I mangaged to create some macros in the same file. I even managed to put one macro in a separate file. The problems start when I put multiple macros in that file. The compiler gives error: missing end-of-module.

    One other problem is that when in debugging mode, the macro commands does not execute in one go. I have to step for each command line that is in the macro. There is no difference if I use step-into, step-over or other debug commands.

    Could you post a library file with at least two macros?

    I used this to describe a macro:

                     name  command

    command macro dst

                     add  #4, dst

                     endm

  • Macros are read and expanded by the pre-processor. The assembler can only see the already expanded source code and knew nothing about the macros. The linker and debugger have no knowledge about the macros either. “name command” is useless.

    If you define macros in a file, you need to #include that file in your source code that uses these macros. You cannot include that file in your project. Macro is only kind of an illusion that helps you to hide repetition.

**Attention** This is a public forum