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.

Constant generator

1. what is constant generator in msp & its advantage.

2. I tried to download :RAM Function Example.zip from http://processors.wiki.ti.com/index.php/Compiler/diagnostic_messages/MSP430/1531 , but when I open it  it ask for password

  • Hi,

    Aamir Ali said:
    1. what is constant generator in msp & its advantage.

    See this

    http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/54673.aspx

    Best regards,

    aes

  • The format of an MSP instruction can be thought of as something like  "OPCODE SRCMODE SRCREG DSTMODE DSTREG <additionalInfo>"

    The constant generator is a mode for the source operand that allows you get certain common values to use in your operation, without having to use memory for them, or without having to have a special instruction.

    For example, consider an "increment" instruction "INC R2"; many architectures have a special instruction to implement this.  Others will implement it as "add #1, R2", where you'll have to have "1" in a memory location somewhere.  On the MSP430, the constant "1" comes from the constant generator, so it doesn't take any extra memory, nor a special instruction.

  • westfw said:
    The format of an MSP instruction can be thought of as something like  "OPCODE SRCMODE SRCREG DSTMODE DSTREG <additionalInfo>" [...]

    Good description.

    For further detail, I want to add that if SRCREG is R3, or SRCREG is R2 and SRCMODE is not register mode, then the result of this combination is a fixed value rather than a value based on the selected addressing mode and register content. (R3 actually does not have any accessible content at all, it's a "write-only register" - you canwrite to it in register mode, but it has no effect on anything and you cannto access the value again :) )

    So seven of the eight possible combinations of SRCMODE and R2/R3 (the eight is R2 with SRCMODE= register mode) gives one of the seven fixed values 0,1,2,4,8, 255 (=-1) and 65535 (=-1)

    It is no coincidence that 1,2,4,8 are also the status bits in the status register (so a check for any status is a fast one-word BIT operation with one of these constants)

    It also makes a lot dedicated instructions superfluous (such as a clear instruction - a MOV from constant 0 to the destination does the same) Same for EINT/DINT which are just BIC/BIS instructions with constant 8 on destination SR/R2. INC and DEC as well as INCD/DECD are ADD/SUB with cosntant 1 or 2 etc. It keeps the CPU core small and power-efficient.

**Attention** This is a public forum