beautypg.com

6 program counter relative mode (ra) – Zilog Z80380 User Manual

Page 30

background image

4-5

Z380

U

SER

'

S

M

ANUAL

Z

ILOG

DC-8297-03

2.

Load accumulator from location (IX-1) in Extended mode

SETC

XM

;Set Extended mode

LD

A, (IX-1)

;Load into the accumulator the
;contents of the memory location
;whose address is one less than
;the contents of IX

A

IXz

IX

Before instruction execution

01

0001

0000

After instruction execution

23

0001

0000

Memory location

0000FFFF

23

Address calculation: In Extended mode, 0FFH encoding in
the instruction is sign extended to a 32-bit value before the
address calculation, but calculation is done in modulo 2

32

and takes into account the index register’s extended
portion.

00010000

+

FFFFFFFF
0000FFFF

4.2.6 Program Counter Relative Mode (RA)

The Program Counter Relative Addressing mode is used
by certain program control instructions to specify the
address of the next instruction to be executed (specifically,
the sum of the Program Counter value and the displace-
ment value is loaded into the Program Counter). Relative
addressing allows reference forward or backward from the
current Program Counter value; it is used for program
control instructions such as Jumps and Calls that access
constants in the memory.

As a displacement, an 8-bit, 16-bit, or 24-bit value can be
used. The address to be loaded into the Program Counter
is computed by adding the two’s complement signed
displacement specified in the instruction to the current
Program Counter.

Note that computation of the effective address is affected
by the mode of operation (Native or Extended). In Native
mode, address computation is done in modulo 2

16

, and the

PC Extend (PC31-PC16) is forced to 0 and will not affect
this portion. In Extended mode, address computation is
done is modulo 2

32

, and will affect the contents of PC

extend if there is a carry or borrow operation.

Also, in Native mode,

Instruction

PC

MEMORY

OPERATION

ADDRESS

+

OPERAND

DISPLACEMENT

Example of RA mode:
1.

Jump relative in Native mode, 8-bit displacement

JR

$-2

;Jumps to the location
;(Current PC value) – 2
;’$’ represents for current PC value
;This instruction jumps to itself.
;since after the execution of this instruction,
;PC points to the next instruction.