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.

How to define a macro with register pair inputs?

Hi,

I want to use macro in my project. For a simple parameter input, it is easy, such as:

ABC_1203a   

.macro li_state, r1u_state, ptrptr

add    li_state, r1u_state, ptrptr

.endm

I would like to have a pair register as the input in order to use DADD2 instruction. At the same time, I also need to use the single register of the reg pair in the macro. I try several writting without success.

Could you help me?

 

Regards,

 

 

  • Hi,

    Why not simple use two arguments to specify the register pair, as in MP A1,A0

    MP .macro R1_,R0_
        DADD2 R1_:R0_, A3:A2, A5:A4
        STW R0_,*+B14(0)
        .endm

    Or, with some substring work  MP2 A1:A0

    MP2 .macro RP_
        DADD2 RP_, A3:A2, A5:A4
        .var tmp
        .asg :RP_(3):,tmp
        .if $symcmp(tmp, ":")==0
        .asg :RP_(4,3):,tmp
        .else
        .asg :RP_(5,3):,tmp
        .endif
        STW tmp,*+B14(0)
        .endm