Sample Procedures; At And Ufv Functions; Conditional Code Generation; Procedure That References A Procedure - Xerox 530 Language And Operations Reference Manual

Table of Contents

Advertisement

Example 40. AT and UFV Functions
Normally, the AT function returns the value zero for
all forward references.
Use of UFV allows the actual
type to be returned on the generati on pass (see
Chapter 1) of the assemo
I
er.
CSECT
DATA
AT(UFV(LABE L))
1
on definition
pass, 2 on gen-
LABE L
RES
a
eration pass.
SAMPLE PROCEDURES
The following examples illustrate how procedures are used
in generating conditional code and how one procedure def-
inition may call another.
Example 41. Conditional Code Generation
This procedure tests N in the procedure reference state-
ment to determine whether straight iterative code or an
indexed
loop is to be generated.
If
N is greater than 3,
an indexed loop will be generated; if N is less than or
equal to 3, straight code will be generated.
In either
case, the resultant code will sum the elements of a table
and store the result in a specified location.
The procedure definition is
TOTE
K
x
Y
CNAME
PROC
RCPY
EQU
GOTO, K+l
DO
ADD
FIN
DO
LDX
ADD
BIX
FIN
STA
PEND
0,7
AF(2»3
X,Y
AF(2)
AF(I )+X-l
K=l
=-AF(2)
Clear accumu-
lator
Produces the
value 1 if N>3
or
a
if N :5 3
AF (1 )+AF (2), 1
$-1
AF(3)
The procedure reference has the genera
I
form
TOTE
ADDRS, N, ANS
where
ADDRS
represents the address of the first value
in the table.
N
is the number of va
I
ues to sum.
48
Sample Procedures
ANS
represents the address of the location
where the sum is to be stored.
For the procedure reference
Y
TOTE
ALPH, 2, BETA
instructions equivalent to the following lines would be
generated in-line at assembly time.
Y
RCPY
0,7
Clear the accumulator.
ADD
ALPH
Add contents of A LPH
to accumulator.
ADD
ALPH+l
Add contents of ALPH
+1 to accumulator.
STA
BETA
Store answer.
If the procedure reference were
TOTE
ALPH, 5, BETA
the generated code would be equivalent to
RCPY
0,7
Clear the accumulator.
LDX
=-5
The va
I
ue -5 is stored
in a literal pool and
its address is made the
effecti ve address of
LDX. Thus, load index
with the value -5.
ADD
ALPH+5,1
Index register 1 con-
tains -5 (on the first
pass).
ALPH+5-5=ALPH.
BIX
$ -
1
Increment index regis-
ter 1 by 1 and branch.
STA
BETA
Store answer.
Example 42. Procedure that References a Procedure
The procedure EXCH exchanges the contents of the
A-register and a memory location m.
The procedure reference has the form
EXCH
m,
x, b
The EXCH procedure in turn references the LDE (load
E-register) procedure.
LDE is defined first.
LDE
CNAME
PROC
RCPY
LDA
SCLD
PEND
A,E
AF(1), AF(2), AF(3)
16

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sigma 3Sigma 2

Table of Contents