MOTOROLA
A-6
COMPARISON OF CPU16/M68HC11 CPU ASSEMBLY LANGUAGE
For More Information On This Product,
Go to: www.freescale.com
CPU16
REFERENCE MANUAL
Short branch instructions consist of an 8-bit opcode and an 8-bit operand contained in
one word. Long branch instructions consist of an 8-bit prebyte and an 8-bit opcode in
one word, followed by an operand word. Bit condition branches consist of an 8-bit
opcode and an 8-bit operand in one word, followed by one or two operand words.
When a branch instruction executes, PK : PC point to an address equal to the address
of the first word of the instruction plus $0006. The range of displacement for each type
of branch is relative to this value. In addition, because prefetches are automatically
aligned to word boundaries, only even offsets are valid — an odd offset value is
rounded down.
A.3.4.3 Subroutines
Subroutines can be called by short (BSR) or long (LBSR) branches, or by a jump
(JSR). The RTS instruction returns control to the calling routine. BSR consists of an 8-
bit opcode with an 8-bit operand. LBSR consists of an 8-bit prebyte and an 8-bit
opcode in one word, followed by an operand word. JSR consists of an 8-bit opcode
with a 20-bit argument. RTS consists of an 8-bit prebyte and an 8-bit opcode in one
word.
When a subroutine instruction is executed, PK: PC contain the address of the calling
instruction plus $0006. All three calling instructions stack return PK : PC values prior
to processing instructions from the new instruction stream. In order for RTS to work
with all three calling instructions, however, the value stacked by BSR must be
adjusted.
LBSR and JSR are two-word instructions. In order for program execution to resume
with the instruction immediately following them, RTS must subtract $0002 from the
stacked PK : PC value. BSR is a one-word instruction — it subtracts $0002 from PK :
PC prior to stacking so that execution will resume correctly.
A.3.4.4 Interrupts
Interrupts are a type of exception, and are thus subject to special rules regarding exe-
cution process. This comparison is limited to the effects of SWI (software interrupt) and
RTI (return from interrupt) instructions.
Both SWI and RTI consist of an 8-bit prebyte and an 8-bit opcode in one word. SWI
initiates synchronous exception processing. RTI causes execution to resume with the
instruction following the last instruction that completed execution prior to interrupt.
Asynchronous interrupts are serviced at instruction boundaries. PK : PC
+
$0006 for
the following instruction is stacked, and exception processing begins. In order to
resume execution with the correct instruction, RTI subtracts $0006 from the stacked
value.
Interrupt exception processing is included in the SWI instruction definition. The PK :
PC value at the time of execution is the first word address of SWI plus $0006. If this
value were stacked, RTI would cause SWI to execute again. In order to resume exe-
cution with the instruction following SWI, $0002 is added to the PK : PC value prior to
stacking.
F
Freescale Semiconductor, Inc.
n
.