MSP 430 Dependent Features
**************************

Options
=======

-mmcu
     selects the mpu arch.  If the architecture is 430Xv2 then this also enables NOP generation unless the -mN is also specified.

-mcpu
     selects the cpu architecture.  If the architecture is 430Xv2 then this also enables NOP generation unless the -mN is also specified.

-mP
     enables polymorph instructions handler.

-mQ
     enables relaxation at assembly time. DANGEROUS!

-ml
     indicates that the input uses the large code model.

-mN
     disables the generation of a NOP instruction following any instruction that might change the interrupts enabled/disabled state.  For the 430Xv2 architecture the instructions: EINT, DINT, BIC #8, SR, BIS #8, SR and MOV.W <>, SR must be followed by a NOP instruction in order to ensure the correct processing of interrupts.  By default generation of the NOP instruction happens automatically, but this command line option disables this behaviour.  It is then up to the programmer to ensure that interrupts are enabled and disabled correctly.

Syntax
======

Macros
------

The macro syntax used on the MSP 430 is like that described in the MSP 430 Family Assembler Specification.  Normal AS macros should still work.

Additional built-in macros are:

llo(exp)
     Extracts least significant word from 32-bit expression 'exp'.

lhi(exp)
     Extracts most significant word from 32-bit expression 'exp'.

hlo(exp)
     Extracts 3rd word from 64-bit expression 'exp'.

hhi(exp)
     Extracts 4rd word from 64-bit expression 'exp'.

They normally being used as an immediate source operand.

         mov	#llo(1), r10	;	== mov	#1, r10
         mov	#lhi(1), r10	;	== mov	#0, r10

Special Characters
------------------

A semicolon (;) appearing anywhere on a line starts a comment that extends to the end of that line.

If a # appears as the first character of a line then the whole line is treated as a comment, but it can also be a logical line number directive (see Comments) or a preprocessor control command (see Preprocessing).

Multiple statements can appear on the same line provided that they are separated by the { character.

The character $ in jump instructions indicates current location and implemented only for TI syntax compatibility.

Register Names
--------------

General-purpose registers are represented by predefined symbols of the form rN (for global registers), where N represents a number between 0 and 15.  The leading letters may be in either upper or lower case; for example, r13 and R7 are both valid register names.

Register names PC, SP and SR cannot be used as register names and will be treated as variables. Use r0, r1, and r2 instead.

Assembler Extensions
--------------------

@rN
     As destination operand being treated as 0(rn)

0(rN)
     As source operand being treated as @rn

jCOND +N
     Skips next N bytes followed by jump instruction and equivalent to jCOND $+N+2

Also, there are some instructions, which cannot be found in other assemblers. These are branch instructions, which has different opcodes upon jump distance. They all got PC relative addressing mode.

beq label
     A polymorph instruction which is jeq label in case if jump distance within allowed range for cpu's jump instruction. If not, this unrolls into a sequence of

            jne $+6
            br  label

bne label
     A polymorph instruction which is jne label or jeq +4; br label

blt label
     A polymorph instruction which is jl label or jge +4; br label

bltn label
     A polymorph instruction which is jn label or jn +2; jmp +4; br label

bltu label
     A polymorph instruction which is jlo label or jhs +2; br label

bge label
     A polymorph instruction which is jge label or jl +4; br label

bgeu label
     A polymorph instruction which is jhs label or jlo +4; br label

bgt label
     A polymorph instruction which is jeq +2; jge label or jeq +6; jl  +4; br label

bgtu label
     A polymorph instruction which is jeq +2; jhs label or jeq +6; jlo +4; br label

bleu label
     A polymorph instruction which is jeq label; jlo label or jeq +2; jhs +4; br label

ble label
     A polymorph instruction which is jeq label; jl  label or jeq +2; jge +4; br label

jump label
     A polymorph instruction which is jmp label or br label

Floating Point
==============

The MSP 430 family uses IEEE 32-bit floating-point numbers.

MSP 430 Machine Directives
==========================

.file
     This directive is ignored; it is accepted for compatibility with other MSP 430 assemblers.

          Warning: in other versions of the GNU assembler, .file is used for the directive called .app-file in the MSP 430 support.

.line
     This directive is ignored; it is accepted for compatibility with other MSP 430 assemblers.

.arch
     Sets the target microcontroller in the same way as the -mmcu command line option.

.cpu
     Sets the target architecture in the same way as the -mcpu command line option.

.profiler
     This directive instructs assembler to add new profile entry to the object file.

Opcodes
=======

AS implements all the standard MSP 430 opcodes.  No additional pseudo-instructions are needed on this family.

For information on the 430 machine instruction set, see MSP430 User's Manual, document slau049d, Texas Instrument, Inc.

Profiling Capability
====================

It is a performance hit to use gcc's profiling approach for this tiny target. Even more -- jtag hardware facility does not perform any profiling functions. However we've got gdb's built-in simulator where we can do anything.

We define new section .profiler which holds all profiling information. We define new pseudo operation .profiler which will instruct assembler to add new profile entry to the object file. Profile should take place at the present address.

Pseudo operation format:

.profiler flags,function_to_profile [, cycle_corrector, extra]

where:

          flags is a combination of the following characters:

     s
          function entry

     x
          function exit

     i
          function is in init section

     f
          function is in fini section

     l
          library call

     c
          libc standard call

     d
          stack value demand

     I
          interrupt service routine

     P
          prologue start

     p
          prologue end

     E
          epilogue start

     e
          epilogue end

     j
          long jump / sjlj unwind

     a
          an arbitrary code fragment

     t
          extra parameter saved (a constant value like frame size)

function_to_profile
     a function address

cycle_corrector
     a value which should be added to the cycle counter, zero if omitted.

extra
     any extra parameter, zero if omitted.

For example:

     .global fxx
     .type fxx,@function
     fxx:
     .LFrameOffset_fxx=0x08
     .profiler "scdP", fxx     ; function entry.
     			  ; we also demand stack value to be saved
       push r11
       push r10
       push r9
       push r8
     .profiler "cdpt",fxx,0, .LFrameOffset_fxx  ; check stack value at this point
     					  ; (this is a prologue end)
     					  ; note, that spare var filled with
     					  ; the farme size
       mov r15,r8
     ...
     .profiler cdE,fxx         ; check stack
       pop r8
       pop r9
       pop r10
       pop r11
     .profiler xcde,fxx,3      ; exit adds 3 to the cycle counter
       ret                     ; cause 'ret' insn takes 3 cycles