beautypg.com

Register lists for pushm and popm instructions, Instruction alignment – Zilog ZUSBOPTS User Manual

Page 253

background image

UM017105-0511

Expressions

Zilog Developer Studio II – ZNEO™

User Manual

225

XREF erw1:EROM ; erw1 declared to be in EROM

Register Lists for PUSHM and POPM Instructions

The ZNEO processor provides the

PUSHM

and

POPM

instructions to push or pop multiple

registers. (Actually, the ZNEO processor provides the

PUSHMHI

,

PUSHMLO

,

POPMHI

, and

POPMLO

instructions, which each push or pop half the register set.The ZNEO assembler

accepts

PUSHM

and

POPM

and generates the lower level instructions.) The list of registers

to be pushed or popped can be expressed either as a register list or as an immediate value.
If an immediate value is used, the least significant bit represents R0, and the most signifi-
cant bit represents R15. The following examples illustrate the syntax for register lists:

myFunction:

PUSHM ; Save registers R0,R1,R2,R8, and R12

; Code for myFunction

POPM ; Restore Registers

RET ; and return

; The same example, using immediate values:

hisFunction:

PUSHM #1107H ; Save registers R0,R1,R2,R8, and R12

; Code for hisFunction

POPM #1107H ; Restore Registers

RET ; and return

; The same example, using equates:

RegList EQU

"

"

herFunction:

PUSHM RegList ; Save registers

; Code for herFunction

POPM RegList ; Restore Registers

RET ; and return

Instruction Alignment

Because all ZNEO instructions must be aligned to an even address, the ZNEO assembler
implicitly inserts an ALIGN directive in front of each instruction. Thus, the following
example assembles correctly:

; Some code

RET

_L1: DW %1234 ; Some data, perhaps used by previous routine

DB %3 ; Warning, next address is odd

myFunction: ; OK, implicitly aligned to next even address

LINK #%20

Of course, it does no harm to insert an ALIGN 2 or a .EVEN directive ahead of a function,
just to be safe.

This manual is related to the following products: