Bgnd Instruction - ROHS MC9S08QE128 Reference Manual

Table of Contents

Advertisement

Recovery from stop mode depends on the particular HCS08 and whether the oscillator was stopped in stop
mode. Refer to the
Modes of Operation
8.4.5

BGND Instruction

The BGND instruction is new to the HCS08 compared to the M68HC08. BGND would not be used in
normal user programs because it forces the CPU to stop processing user instructions and enter the active
background mode. The only way to resume execution of the user program is through reset or by a host
debug system issuing a GO, TRACE1, or TAGGO serial command through the background debug
interface.
Software-based breakpoints can be set by replacing an opcode at the desired breakpoint address with the
BGND opcode. When the program reaches this breakpoint address, the CPU is forced to active background
mode rather than continuing the user program.
The CALL is similar to a jump-to-subroutine (JSR) instruction, but the subroutine that is called can be
located anywhere in the normal 64-Kbyte address space or on any page of program expansion memory.
When CALL is executed, a return address is calculated, then it and the current program page register value
are stacked, and a new instruction-supplied value is written to PPAGE. The PPAGE value controls which
of the possible 16-Kbyte pages is visible through the window in the 64-Kbyte memory map. Execution
continues at the address of the called subroutine.
The actual sequence of operations that occur during execution of CALL is:
1. CPU calculates the address of the next instruction after the CALL instruction (the return address)
and pushes this 16-bit value onto the stack, low byte first.
2. CPU reads the old PPAGE value and pushes it onto the stack.
3. CPU writes the new instruction-supplied page select value to PPAGE. This switches the destination
page into the program overlay window in the CPU address range 0x8000 0xBFFF.
4. Instruction queue is refilled starting from the destination address, and execution begins at the new
address.
This sequence of operations is an uninterruptable CPU instruction. There is no need to inhibit interrupts
during CALL execution. In addition, a CALL can be performed from any address in memory to any other
address. This is a big improvement over other bank-switching schemes, where the page switch operation
can be performed only by a program outside the overlay window.
For all practical purposes, the PPAGE value supplied by the instruction can be considered to be part of the
effective address. The new page value is provided by an immediate operand in the instruction.
The RTC instruction is used to terminate subroutines invoked by a CALL instruction. RTC unstacks the
PPAGE value and the return address, the queue is refilled, and execution resumes with the next instruction
after the corresponding CALL.
The actual sequence of operations that occur during execution of RTC is:
1. The return value of the 8-bit PPAGE register is pulled from the stack.
2. The 16-bit return address is pulled from the stack and loaded into the PC.
3. The return PPAGE value is written to the PPAGE register.
Freescale Semiconductor
chapter for more details.
MC9S08QE128 MCU Series Reference Manual, Rev. 2
Chapter 8 Central Processor Unit (S08CPUV4)
153

Hide quick links:

Advertisement

Table of Contents
loading

Related Products for ROHS MC9S08QE128

This manual is also suitable for:

Mc9s08qe96Mc9s08qe64

Table of Contents