Question about a register dependent macro

May 28, 2006 2 Replies

The Keil assembler has eight 8 bit registers which can be alternatively used in some versions of the 8051 as four 16 bit registers or even two 32 bit registers:



8 bit: R0 R1 R2 R3 R4 R5 R6 R7
16 bit: WR0=R0:R1 WR2=R2:R3 WR4=R4:R5 WR6=R6:R7
32 BIR: DR0=R0:R1:R2:R3 DR4=R4:R5:R6:R7

I would like to write some macros to ease the usage of the WRx and DRx register combinations. If the argument is WR4, a sequence of instructions like



ADD .. R5 ADDC .. R4



and if the argument is DR0, a sequence like



ADD .. R3 ADDC .. R2 ADDC .. R1 ADDC .. R0



shall be generated. How can this be easily done?



You could name the macros ADDW and ADDQ

Rene

Ok, but this does not solve the problem that WR0 needs to be resolved as R0 and R1 and WR4 needs to be resolved as R4 and R5.

Is there any possibility to write something like

IF Arg = "WR0" Reg0 = R0 Reg1 = R1 ELSEIF Arg = "WR4" Reg0 = R4 Reg1 = R5 ENDIF

?

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required