EmbeddedRelated.com
Forums

Using assembler

Started by poonam_k_m2003 January 14, 2004
Hi,
  i've just started to program in assembly with MSP430.i'm facing 
certain problems....

the error i'm encountering while compiling an assemply program in MSP 
IDE:
Error[e46]: Undefined external "main" referred in ?cstartup ( 
C:\Program Files\IAR Systems\Embedded Workbench Evaluation 3.2\

what are the initializations need to be made when its an assembly 
level program?
how do i include the preprocessor directive and library files as done 
in C.

Rgds,
Poonam


Beginning Microcontrollers with the MSP430

"poonam_k_m2003" <poonam_k_m2003@poon...> writes:

> Hi,
>   i've just started to program in assembly with MSP430.i'm facing

> certain problems....
> 

> the error i'm encountering while compiling an
assemply program in MSP 
> IDE:
> Error[e46]: Undefined external "main" referred in ?cstartup ( 
> C:\Program Files\IAR Systems\Embedded Workbench Evaluation 3.2\

The cstartup module in the librar is used by default, unless the
"ignore cstartup" checkbox is checked.  The cstartup contains
initialization code used by the C and C++ run-time enviroment.  The
cstartup assumes that the application contains a function named "main"
and calls it.

You can solve this in two different ways:

* Implementa a public label in your asssembler program named "main"
  and use cstartup to initialize things (e.g. stack) for you.

* Check the "ignore cstartup" box and write everything yourself,
  including the reset vector.


> what are the initializations need to be made when
its an assembly
> level program?

Minimal initialization is setting up the stack pointer.  Turning off
the watchdog could also be a good idea.

Apart from that you could initalize memory and hardware peripherals.


> how do i include the preprocessor directive and
library files as done
> in C.

Preprocessor directives are provided in the assembler stright out of
the box.

It is possible to call functions in other modules, just as in C.  In
fact, you can use the entire C standard library from assembler (if you
are aware of how C passes parameters).

To define a module, just do:

    NAME foo
    RSEG CODE:CODE:NOROOT(1)
    PUBLIC foo

foo:
    // Do something
    RET
    ENDMOD


And to use that function:

    ...
    EXTERN foo
    call foo
    ...

    -- Anders Lindgren, IAR Systems
-- 
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.

I have just uploaded SHELL.ZIP to the ftp site. It contains a reasonably 
complex shell for the MSP430F149, showing all the assembler basics. It 
includes my slightly modified header files, my own header file, my IO 
definition file, ADC initialisation, and has code for a graphics panel 
using the SED1330/5 controller. basically a bit of everything.

Al

poonam_k_m2003 wrote:

> Hi,
>   i've just started to program in assembly with MSP430.i'm facing

> certain problems....
> 
> the error i'm encountering while compiling an assemply program in MSP 
> IDE:
> Error[e46]: Undefined external "main" referred in ?cstartup ( 
> C:\Program Files\IAR Systems\Embedded Workbench Evaluation 3.2\
> 
> what are the initializations need to be made when its an assembly 
> level program?
> how do i include the preprocessor directive and library files as done 
> in C.
> 
> Rgds,
> Poonam
> 
> 
> .
> 
>  
> 
> 
>  
> 
> 
>