76
CHAPTER 3 CPU ARCHITECTURE
(2) Operation code generation method with RA78K4
With RA78K4, if there is an instruction with the same function as an instruction for which A or AX is directly entered
in the operand column of the instruction operation list, the operation code for which A or AX is directly entered
in the operand column is generated first.
Example
The function is the same when B is used as r in a MOV A,r instruction, and when A is used as r and
B is used as r’ in a MOVr,r’ instruction, and the same code (MOV,A,B) is used in the assembler source
program. In this case, RA78K4 generates code equivalent to the MOV A, r instruction.
If A, X, B, C, AX or BC is written in an instruction for which r, r’, rp and rp’ are specified in the operand column,
the A, X, B, C, AX and BC instructions generate an operation code that specifies the following registers according
to the operand of the RA78K4 RSS pseudo-instruction.
Register
RSS = 0
RSS = 1
A
R1
R5
X
R0
R4
B
R3
R7
C
R2
R6
AX
RP0
RP2
BC
RP1
RP3
If R0 to R7 or RP0 to RP4 is written as r, r’, rp or rp’ in the operand column, an operation code in accordance
with that specification is output (an operation code for which A or AX is directly entered in the operand column
is not output.)
R1, R3, R2 or R5, R7, R6 cannot be used for registers A, B and C used in indexed addressing and based indexed
addressing.
(3) Operating precautions
Switching the RSS bit has the same effect as having two register sets. However, when writing a program, care must
be taken to ensure that the static program code and dynamic RSS bit changes at the time of program execution
always coincide.
Also, a program that sets RSS to 1 cannot be used by a program that uses the context switching function, and
therefore program usability is poor. Moreover, since different registers are used with the same name, program
readability is poor and debugging is difficult. Therefore, if it is necessary to set RSS to 1, these disadvantages must
be fully taken into consideration when writing a program.
A register not specified by the RSS bit can be accessed by writing its absolute name.