CPU Registers
M68HC11E Family Data Sheet, Rev. 5.1
Freescale Semiconductor
67
At the end of the interrupt service routine, an return-from interrupt (RTI) instruction is executed. The RTI
instruction causes the saved registers to be pulled off the stack in reverse order. Program execution
resumes at the return address.
Certain instructions push and pull the A and B accumulators and the X and Y index registers and are often
used to preserve program context. For example, pushing accumulator A onto the stack when entering a
subroutine that uses accumulator A and then pulling accumulator A off the stack just before leaving the
subroutine ensures that the contents of a register will be the same after returning from the subroutine as
it was before starting the subroutine.
Figure 4-2. Stacking Operations
SP–2
STACK
RTNH
SP–1
RTNL
SP
70
PC
MAIN PROGRAM
$9D = JSR
JSR, JUMP TO SUBROUTINE
dd
NEXT MAIN INSTR.
RTN
DIRECT
PC
MAIN PROGRAM
$AD = JSR
ff
NEXT MAIN INSTR.
RTN
INDEXED, X
PC
MAIN PROGRAM
$18 = PRE
ff
NEXT MAIN INSTR.
RTN
INDEXED, Y
$AD = JSR
PC
MAIN PROGRAM
$BD = PRE
ll
NEXT MAIN INSTR.
RTN
INDEXED, Y
hh
SP
STACK
CCR
SP+1
ACCB
SP+2
ACCA
SP+3
IXH
SP+4
IXL
SP+5
IYH
SP+6
IYL
SP+7
RTNH
SP+8
SP+9
70
RTNL
PC
INTERRUPT ROUTINE
$3B = RTI
SP–9
STACK
CCR
SP–8
ACCB
SP–7
ACCA
SP–6
IXH
SP–5
IXL
SP–4
IYH
SP–3
IYL
SP–2
RTNH
SP–1
SP
70
RTNL
PC
MAIN PROGRAM
$3F = SWI
PC
MAIN PROGRAM
$3E = WAI
SWI, SOFTWARE INTERRUPT
WAI, WAIT FOR INTERRUPT
RTI, RETURN FROM INTERRUPT
SP–2
STACK
RTNH
SP–1
RTNL
SP
70
PC
MAIN PROGRAM
$8D = BSR
PC
MAIN PROGRAM
$39 = RTS
BSR, BRANCH TO SUBROUTINE
RTS, RETURN FROM
SUBROUTINE
SP
STACK
RTNH
SP+1
RTNL
SP+2
70
LEGEND:
RTN = ADDRESS OF NEXT INSTRUCTION IN MAIN PROGRAM TO
BE EXECUTED UPON RETURN FROM SUBROUTINE
RTNH = MOST SIGNIFICANT BYTE OF RETURN ADDRESS
RTNL = LEAST SIGNIFICANT BYTE OF RETURN ADDRESS
= STACK POINTER POSITION AFTER OPERATION IS COMPLETE
dd = 8-BIT DIRECT ADDRESS ($0000–$00FF) (HIGH BYTE ASSUMED
TO BE $00)
ff = 8-BIT POSITIVE OFFSET $00 (0) TO $FF (255) IS ADDED TO INDEX
hh = HIGH-ORDER BYTE OF 16-BIT EXTENDED ADDRESS
ll = LOW-ORDER BYTE OF 16-BIT EXTENDED ADDRESS
rr= SIGNED RELATIVE OFFSET $80 (–128) TO $7F (+127) (OFFSET
RELATIVE TO THE ADDRESS FOLLOWING THE MACHINE CODE
OFFSET BYTE)