Intranet Catprocess
  1. news...
  2. about Blackvoxel
  3. download
  4. manual
  5. videos
  6. about us
  1. Pushregs/Popregs

    pushregs : Registers -> Stack
    popregs : Stack -> Registers

    Affected Flags
    C V N Z
           

    The pushregs and popregs instructions purpose is saving and restoring registers to (or from) stack. These instructions can save or restore all registers in one single instruction. The pushreg instruction is often used at the entry of a subroutine to save the registers used in it. Registers R0 to R14 can be saved with the exception of the R15 register because this particular register is the stack pointer. The popregs is often used at the exit of the subroutine to restore registers before the rts instruction. These two instructions take an argument in the form of register list.

    Forms and variants

    registerlist =list of registers as the following example : r0/r1/r2/r5/r10-r12

    Form Effect
    pushregs regiserlist
    Registers -> Stack
    popregs registerlist
    Stack -> Registers

    Instruction encoding

    M = Register List, 1 bit per register. Bit 0 = Register 0.
    
    Instruction Op
    Code
    Cycles Encoding
    pushregs rx-rx/rx... 0C 1032 00001100 0MMMMMMM MMMMMMMM
    popregs rx-rx/rx... 4C 1032 01001100 0MMMMMMM MMMMMMMM

    Code Examples

    // Example : Subroutine with pushregs/popregs

    subroutine: pushregs r0/r1/r4-r8

    ; Some processing using registers r0/r1/r4/r5/r6/r7/r8 here

    popregs r0/r1/r4-r8
    rts
     
     
  2. Google+