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.

Explaination needed

Hai friends,

I need clarification  and also the differences between these operators in MSP430 assembly instructions.

@ operator

# operator

& operator

These operators makes me little bit confusion when i come to use Absolute and Symbolic addressing modes.

Waiting for a reply

Thank you

Karthikeyan.B

Assistant Professor

Embedded System Division

School of electronics Engineering

VIT University

Vellore, Tamilnadu, INDIA

bkarthikeyan@vit.ac.in

  • The user guide for your device should have some useful explanations in the CPU chapter.

    This is a very brief explanation:

    @ can use a register as a pointer e.g. "MOV.B     @SP, R12" will get the byte pointed to by the stack pointer and put it in R12.

    # can be used to refer to a set value e.g. "MOV.B     #100, R12" will set R12 to the value 100.  It is also used for calling functions e.g. "CALL     #myfunc"

    & can be used to refer to variables e.g. if you have a variable called myvar and want to copy it to R12 you could use "MOV.B     &myvar, R12"

    Perhaps one of the other members will give you a fuller explanation - I'm a bit busy at the moment!

     

    Perhaps you could post some of the commands you are confused by and someone will be able to explain them in context....

     

    Regards,

    Chris.

  • chris_m said:
    Perhaps one of the other members will give you a fuller explanation

    It was quite complete as an overview.

    Some more in-detail info:
    (which can be also extracted form the CPU section - addressing modes - of the family users guide (albeit too much spread across several sub-section to be of immediate use)

    The MSP430 has several addressing modes. Its design is orthogonal, which means that (almost) every instruction supports every addressing mode.

    The supported modes are:

    1) register mode:  "Rn" - Register contents are operand (available for source and destiantion operand)
    2) indexed mode: "X(Rn)" - Rn+X points to a memory address that contains the operand (source and destination)
    3) symbolic mode: "X" - PC+X points to the address that contains the operand. (source and destination). Usually, X is given as label, and later calculated during link stage by the position of the instruction and the position of the operand. It's useful if a function has function-specific constant data like the format string for local printf calls.
    4) absolute mode: "&X" - X is the absolute memory address that contains the operand (source and destination) '&' is the usualy way for accessing registers or global variables or constants)
    5) indirect register mode: "@Rn" - the content of the register is thememory address that contains the operand.(source operand only. Destination is emulated with "0(Rn)".
    6) indirect autoincrement mode: "@Rn+" - like indirect register, but after the operation, Rn is increments by 1 (byte operation), 2 (word operation) or 4 (address word operation). It is used for the pop instruction (mov @R1+,Rn == POP Rn) (Push, however, is a separate special instruction)
    7) immediate mode: "#X" - 'X' is the operand value. (source only - destination would make no sense anyway) This is the default mode for any byte/word constants as well as calls.

    If used on the status register R2 or the R3 register, the different addressing modes have a special meaning. Only register and absolute mode give the expected result for R2. (the others won't make much sense anyway). All other addressing modes on these two registers return a fixed value instead. This allows 1-cycle instructions for operations with an immediate operand of -1, 1, 0, 2, 4, 8. The compiler will automatically use this if these constants are required, e.g. for checking the status register flags, or for incrementing or decrementing operations.

     

**Attention** This is a public forum