push, pushm, pop, popm


-

The push, pushm, pop, and popm instructions are directives that are not available in the device.

They push the values of specified registers to the stack area or pop the values of specified registers from the stack area.

 

-

In asrh, these instructions should be specified in the following formats.

-

push reg1

-

pushm reg1, reg2, ..., regN

-

pop reg1

-

popm reg1, reg2, ..., regN

 

-

The instructions are expanded as shown below and multiple machine-language instructions are generated.

Format

Result of Assembly

push    reg1
add     -4, sp
st.w    reg1, 0[sp]
pushm   reg1, reg2, …, regN
addi    -4 * N, sp, sp
st.w    regN, 4 * (N - 1)[sp]
  :
st.w    reg2, 4 * 1[sp]
st.w    reg1, 4 * 0[sp]
pop     reg1
ld.w    0[sp], reg1
add     4, sp
popm    reg1, reg2, …, regN
ld.w    4 * 0[sp], reg1
ld.w    4 * 1[sp], reg2
  :
ld.w    4 * (N - 1)[sp], regN
addi    4 * N, sp, sp

Note

The values of PSW are undefined because the add or addi instruction is used.
We recommend the use of the pushsp or popsp instruction provided by the device.