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.

Instruction 'CALL' emulated?

Hi, i'm new to the MSP430 so this may be a stupid question, but how is the 'CALL' instruction not considered an emulated instruction?

 

Maybe i'm just missing something but it seems like the 'CALL' is emulated by a subtraction and a few moves.

 

Thanks!

  • Without knowing much about your actual implementation, my first guess would be that the function you are calling was inlined and thus the function call removed.

    Please provide some more information, did you program something using C and are looking at the generated assembler code of your compiler/which compiler are you using?

    Or am I just too tired to get your point right now?

  • Sorry, I should have given more info.

    I'm actually not writing any program, I was just interested in why this is.

  • TI defines the term "emulated instructions" as:

    The emulated instructions are instructions that make code easier to write and read, but do not have op-codes themselves,

    For example:

    The instruction "MOV #0,dst" copies the constant 0 to a destination (register or memory). Thus TI can define an emulated instruction "CLR dst" by "MOV #0,dst".

    The "CALL dst" instruction has its own op-code. No other instruction has the same op-code can be used to emulate it.

  • Thank you, I didn't realize that was the definition of emulated instructions.

  • 1730645 said:
    Maybe I'm just missing something but it seems like the 'CALL' is emulated by a subtraction and a few moves.


    No, the 'call' instruction is not emulated.

    Emulated instructions are instruction that have functionality that is available through standard instructions as well.

    e.g. a "pop R15" instruction can be done by "mov SP+,R15". And instructions like INC or DEC or EINT or DINT can be done by ADD, BIC or BIS by using the constant generator. Same instruction length, same result, same execution time.
    Some other instructions are replaced and not emulated. Whenever a value from the constant generator can be used, it will be done automatically.
    So a "AND #248, R15" will be replaced by a "BIC #8, R15" which in turn gets transparently translated into "BIC @R2+, R15" (where @R2+ accesses the constant generator and results in an immediate value of 8 without incrementing the R2 register)
    Since the register names and addressing modes are bit patterns in the instruction word, this results in a one-word, one cycle instruction rather than a two-word, two cycle instruction.

    But some instruction cannot be emulated. While RET is just a POP R0, RETI, which is a "POP R2, POP R0" sequence, cannot be emulated.
    And while POP itself can be emulated, a push cannot since it is a MOV followed by a R1 decrement, and there is no post-decrement addressing mode.

    CALL too is not emulated, as it is a "push R0, MOV #dest, R0" combo.

  • RETI is not a "POP R1, POP R2" but a "POP R2 (SR), POP R0 (PC)".

  • You’re right that it is POP R2; POP R0. I’ve corrected it. In case someone else stumbles across this 3 years old thread. :)
    “POP x “ itself is an emulated instruction: MOV @R1+, x; (a POP can also go to a memory location, even an indexed or indirect one)

    However, RETI, as it needs to be monolithic, can’t be emulated by two MOV instructions, so it has its own opcode.

**Attention** This is a public forum