PUSHM / POPM instruction format

As per described in the R32C reference software manual these instructions can save and restore multiple registers,

I then tried the following:  

       pushm      R2R0,A0

       jsr               Enter_xmit_buffer0         ; my routine to xmit chars on Uart0

       popm        A0,R2R0  

which is working fine, but when I tried the following:

       pushm      R2R0,A0

       jsr               Enter_xmit_buffer0         ; my routine to xmit chars on Uart0

       popm       R2R0,A0  

it's also working fine!

 

I thought the push/pop order did matter.

Strange to ask why it is working, it's not the usual case here but I really would like to figure out.

 

Thks for your usual coop,

 

Jean-Pierre

Parents Reply
  • Why should this be surprising?
    A POPM or PUSHM generates only 1 instruction consisting of 2 bytes. In this instruction the different registers are coded as bits in the second instruction byte. No matter in which sequence you define the registers, it will always set the same bits in the instruction. So it always works.
    Please have a look at the description of POPM/PUSHM in chapter 4.3 of the R32C Software Manual.

Children