Address spaces and instruction encoding – Zilog ZUSBOPTS User Manual

Page 252

Advertising
background image

Expressions

UM017105-0511

224

Zilog Developer Studio II – ZNEO™
User Manual

Address Spaces and Instruction Encoding

The ZNEO instruction set provides different encodings for many instructions depending
on whether an address or immediate data can be represented as an 8-, 16-, or 32-bit value.
In most cases, the ZNEO assembler selects the encoding that results in the smallest repre-
sentation of the instruction.

In doing so, the assembler makes use of the address space information for labels occurring
in instructions. Labels in a 32-bit address space (EROM or ERAM) are encoded as 32-bit
values, while labels in 16-bit address spaces (ROM, RAM, or IODATA) are encoded as
16-bit values. An otherwise undeclared label is assumed to be in a 16-bit address space.

If you want to override the assembler’s encoding, you can indicate the address space for a
label or for an absolute address with a colon (:) followed by the name of an address space.
For example:

LD R0,#myLabel ; if myLabel undeclared, gets 16-bit encoding

LD R0,#myLabel:EROM ; forces 32-bit encoding

In particular, absolute addresses in the range

8000H-FFFFH

are considered as 32-bit

unsigned values. If an address in internal RAM or the IO space is intended, you can obtain
the desired result in either of the following ways:

OR C001H:IODATA, R0 ; Specify the required space

OR FFFF_C0001,R0 ; or sign extend the address

The following example illustrates these features:

SEGMENT NEAR_DATA

nw1: DL %1 ; An address in near data, space is RAM

SEGMENT FAR_DATA

fw1: DL %2 ; An address in far data, space is ERAM

SEGMENT CODE

ADD nw1,R0 ; nw1 is in RAM, uses 16-bit encoding

ADD fw1,R1 ; fw1 is in ERAM, uses 32-bit encoding

LD R0,nw2 ; nw2 will be in RAM, uses 16-bit encoding

LD R1,fw2 ; fw2 will be in ERAM, uses 32-bit encoding

SUB R0,rw1 ; rw1 declared to be in ROM, uses 16-bit encoding

SUB R1,erw1 ; erw1 declared to be in EROM, uses 32-bit

encoding

LD xxx,R0 ; xxx undeclared, 16-bit encoding assumed

LD yyy:EROM,R1 ; yyy undeclared, 32-bit encoding forced.

SEGMENT NEAR_BSS

nw2: DS 4 ; nw2 is in near bss, space is RAM

SEGMENT FAR_BSS

fw2: DS 4 ; fw2 is far bss, space is ERAM

XREF rw1:ROM ; rw1 declared to be in ROM

Advertising
This manual is related to the following products: