Motorola HC12 Refrence Manual page 16

Table of Contents

Advertisement

Most operations can use accumulator A or B interchangeably. However, there are a
few exceptions. Add, subtract, and compare instructions involving both A and B (ABA,
SBA, and CBA) only operate in one direction, so it is important to make certain the cor-
rect operand is in the correct accumulator. The decimal adjust accumulator A (DAA)
instruction is used after binary-coded decimal (BCD) arithmetic operations. There is
no equivalent instruction to adjust accumulator B.
2.1.2 Index Registers
16-bit index registers X and Y are used for indexed addressing. In the indexed ad-
dressing modes, the contents of an index register are added to 5-bit, 9-bit, or 16-bit
constants or to the content of an accumulator to form the effective address of the in-
struction operand. The second index register is especially useful for moves and in
cases where operands from two separate tables are used in a calculation.
2.1.3 Stack Pointer
The CPU12 supports an automatic program stack. The stack is used to save system
context during subroutine calls and interrupts, and can also be used for temporary
data storage. The stack can be located anywhere in the standard 64-Kbyte address
space and can grow to any size up to the total amount of memory available in the sys-
tem.
The stack pointer holds the 16-bit address of the last stack location used. Normally,
the SP is initialized by one of the first instructions in an application program. The stack
grows downward from the address pointed to by the SP. Each time a byte is pushed
onto the stack, the stack pointer is automatically decremented, and each time a byte
is pulled from the stack, the stack pointer is automatically incremented.
When a subroutine is called, the address of the instruction following the calling instruc-
tion is automatically calculated and pushed onto the stack. Normally, a return from
subroutine (RTS) or a return from call (RTC) instruction is executed at the end of a
subroutine. The return instruction loads the program counter with the previously
stacked return address and execution continues at that address.
When an interrupt occurs, the current instruction finishes execution (REV, REVW, and
WAV instructions can be interrupted, and resume execution once the interrupt has
been serviced), the address of the next instruction is calculated and pushed onto the
stack, all the CPU registers are pushed onto the stack, the program counter is loaded
with the address pointed to by the interrupt vector, and execution continues at that ad-
dress. The stacked registers are referred to as an interrupt stack frame. The CPU12
stack frame is the same as that of the M68HC11.
2.1.4 Program Counter
The program counter (PC) is a 16-bit register that holds the address of the next instruc-
tion to be executed. It is automatically incremented each time an instruction is fetched.
MOTOROLA
2-2
OVERVIEW
CPU12
REFERENCE MANUAL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cpu12

Table of Contents