Declaring And Calling A Procedure - HP 3000 III Series Manual

Table of Contents

Advertisement

Machine Instructions and Stack Operations
SOURCE LANGUAGE
1
BEGIN INTEGER ANSWER;
2 INTEGER PROCEDURE QUOTIENT (J,K);
3 VALUE J,K;
Pro-
4 INTEGER J,K;
cedure
~
5
BEGI N
6
QUOTIENT -
J/K;
7
END;
Call
~
8 ANSWER -
QUOTIENT (25,10);
9
END:
MACHINE LANGUAGE
Assembly
Octal
,.
10
lOAD Q-5
041605
11
lOAD Q-4
041604
Pro-
12
DIV, DEL
002340
cedure
13
STOR Q-6
051606
14
EXIT, 2
031402
15
ZERO,NOP
000600
16
lDI,31
021031
Call
~
17
lDI,12
021012
18
PCAl,20
031020
19
STOR DB+O
051000
20
PCAl (to system)
031xxx
MATHEMATICAL LANGUAGE
Procedure:
Call:
Execution:
ANSWER
=
J/K
Solve ANSWE R for
J
=
25 and K
=
10
ANSWER
=
25/10
=
2, remainder 5
Note: Decimal 25
=
Octal 31
Decimal 10
=
Octal 12
Figure 4-16.
Declaring and Calling A Procedure
pilation error
will result.
Line 5 begins the
procedure body.
Actually,
since this procedure
consists of only
one statement,
the BEGIN statement and END statement
(line 7)
are superfluous.
They are
included here, however,
to illustrate the
common form
for a procedure
(normally involving a compound statement).
Line
4-40

Advertisement

Table of Contents
loading

Table of Contents