.LAYOUT 3,2
.LEFT MARGIN 0
.RIGHT MARGIN 80
.NO DATE
.NO NUMBER
.NO FLAGS COMMENT
.NO FLAGS ALL
.XLOWER
.FIGURE DEFERRED 15
.C;The MLR Macro Language
.B 5
.C;Structured Programming
.C;in
.C;VAX-11 Macro
.B 10
.C;by
.B
.C;Rodrick A. Eldridge
.C;Iowa State University
.PG
.C;Overview
.B 3
This paper presents a set of macros which implement, in VAX-11 Macro, the
structured programming structures presented in the following pages.
.B 2
The notation used to show the format of each macro is presented below:
.LIST
.LE;Words in upper case must be entered exactly as show in either
all upper case or all lower case letters.
.LE;Words in lower case may be any symbol allowed by the assembler.
.LE;Words in [ ] are optional; if specified, words in upper case must be
intered as in 1. above; words in lower case may be entered as in 2. above.
The [ ]'s are not entered as part of the word.
.LE;Words in { } are a list of possible choices separated by the symbol |;
you may specify only one of the words listed.
If specified, follow rules 1. and 2. above.
The { }'s are not entered as part of the word.
.LE;Words in < > may be a list of symbols separated by commas or blanks.
The < >'s are required.
.LE;The entire macro may be specified on one line; or broken up on several lines
by placing the symbol - on lines to be continued.
.LE;Words followed by ... may be repeated zero or more times.
.END LIST
.B 5
.C;Caution
.B 3
Do not use any symbols beginning with the letters "MLR_" in your program,
these symbols are to be considered reserved for the MLR macros.
Also, do not use any symbol that has has the same name as one of the MLR macros.
.PG
.C;References
.B 3
.LIST
.LE;TOP-DOWN STRUCTURED PROGRAMMING TECHNIQUES,
by Clement L. McGowan and John R. Kelly;
Petrocelli/Charter, Mason/Charter Publications, 1975.
(QA76.6.M318 1975)
.LE;COMPUTER PROGRAMMING AND ARCHITUCTURE -- The VAX 11,
by Henry M. Levy and Richard H. Eckhouse, Jr;
Digital Equipment Corporation, Digital Press, 1980.
(QA76.8.V37)
.LE;VAX MACRO AND INSTRUCTION SET REFERENCE MANUAL;
Digital Equipment Corporation, September 1984.
(AA-Z700A-TE)
.LE;VAX ARCHITECTURE HANDBOOK;
Digital Equipment Corporation.
.LE;TLXSPM - TELEX Structured Macros;
MOSTEK OPS DECUS SIG tape submission.
[VAX83A.DFWLUG.MOSTEK.OPSPLN.TLXSPM]
.LE;QUADMATH - Quadword Math;
HUGHES AIRCRAFT DECUS SIG tape submission.
[VAX83C.HUGHES]
.END LIST
.PG
.LITERAL
ADDQ  add,sum
ADDQ3 add1,add2,sum
.END LITERAL
.X ADDQ
.X ADDQ3
.B 3
These macros perform quadword addition.
.B
These macros will produce inline code to perform the quadword addition.
However, if the macros:
.B
.LITERAL
	EXTERNAL MODULE ADDQ  <add,sum>
	EXTERNAL MODULE ADDQ3 <add1,add2,sum>
.END LITERAL
.B
are specified before the ADDQ and ADDQ3 macros are specified, these macros
will produce code to call external routines to preform the quadword addition
instead.
.B
After the addition is performed, r0 will contain the following values:
.B
.LITERAL
	-1	sum < 0
	0	sum = 0
	1	sum > 0
.END LITERAL
.B
The ADDQ macro is equivalent to the expression:
.B
.LITERAL
	sum = add + sum
.END LITERAL
.B
and the ADDQ3 macro is equivalent to the expression:
.B
.LITERAL
	sum = add1 + add2
.END LITERAL
.B
Example:
.B
.LITERAL
	procedure add
	var
	  sum: 		.blkq 1
	  add1: 	.blkq 1
	  add2: 	.blkq 1
	begin
	  addq3 add1,add2,sum
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also CLRQ, CMPQ, DIVQ4, MOVQ, MULQ, MULQ3, SUBQ, SUBQ3 and TSTQ.
.PG
.LITERAL
CASE index <label-list> [BASE=base] [TYPE=type] DO
  label1: OF
          END
  label2: OF
          END
  .
   .
    .
  labeln: OF
	  END
  OTHERWISE
END
.END LITERAL
.X CASE
.X DO
.X OF
.X OTHERWISE
.X END
.B 3
This macro implements the CASEB, CASEW or CASEL instruction,
generates the case table from a list of branch distinations and
calculates the index limit.
.B
If the "base" is not specified, BASE=#0 is assumed.
.B
If the "type" is not specified, TYPE=L is assumed.
.B
The OF macro begins code statements for the case index value corresponding with
the "label" specified in the case table generated by the CASE macro.
For every OF macro specified, a corresponding END macro must also be
specified.
The END macro corresponding to the OF macro will generate a branch to the end
of the CASE structure.
.B
The OTHERWISE macro begins code statements for the default case, i.e. when
the case "index" is outside the <label-list> supplied.
The OTHERWISE macro and it's corresponding code statements are optional.
.B
For every CASE macro specified, a corresponding END macro must also be
specified.
The END macro corresponding to the CASE macro will generate the appropriate
labels.
.B
Example:
.B
.LITERAL
	case r1 <one,two,three> base=#1 do
	one:	of
		  . . .
		end
	two:	of
		  . . .
		end
	three:	of
		  . . .
		end
	otherwise
	  . . .
	end
.END LITERAL
.PG
CLRQ dst
.X CLRQ
.B 3
This instruction clears a quadword.
.B
After the quadword is cleared, r0 will contain the following value:
.B
.LITERAL
	0	dst = 0
.END LITERAL
.B
This macro will produce inline code to perform the quadword clear.
However, if the macro:
.B
.LITERAL
	EXTERNAL MODULE CLRQ <dst>
.END LITERAL
.B
is specified before the CLRQ macro is specified, this macro
will produce code to call an external routine to preform the quadword
clear instead.
.B
Example:
.B
.LITERAL
	procedure clear
	var
	  target: 	.blkq 1
	begin
	  clrq target
	  . . .
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CMPQ, DIVQ4, MOVQ, MULQ, MULQ3, SUBQ, SUBQ3 and TSTQ.
.PG
CMPQ src,dst
.X CMPQ
.B
This macro performs quadword comparison.
.B
After the comparison is performed, r0 will contain the following values:
.B
.LITERAL
	-1	src < dst
	0	src = dst
	1	src > dst
.END LITERAL
.B
This macro will produce inline code to perform the quadword comparison.
However, if the macro:
.B
.LITERAL
	EXTERNAL MODULE CMPQ <src,dst>
.END LITERAL
.B
is specified before the CMPQ macro is specified, this macro
will produce code to call an external routine to preform the quadword
comparison instead.
.B
Example:
.B
.LITERAL
	procedure compare
	var
	  source: 	.blkq 1
	  target: 	.blkq 1
	begin
	  cmpq source,target
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CLRQ, DIVQ4, MOVQ, MULQ, MULQ3, SUBQ, SUBQ3 and TSTQ.
.PG
.LITERAL
DESCR .BLKx length [address] [allot]
.END LITERAL
.X DESCR
.B 3
This macro will allocate the appropriate descriptor structure for the storage
type specified:
.B
One the following directives must be used in place of .BLKx.
.B
.LITERAL
	.BLKA	addresses (longwords)
	.BLKB	bytes
	.BLKD	double-precision floating-point (quadwords)
	.BLKF	single-precision floaging-point (longwords)
	.BLKG	G_floating (quadwords)
	.BLKH	H_floating (octawords)
	.BLKL	longwords
	.BLKO	octawords
	.BLKQ	quadwords
	.BLKT	characters (bytes)
	.BLKW	words
.END LITERAL
.B
If "length" is specified as "0", a dynamic descriptor sturcture will be
generated.
.B
If "address" is specified as "*", the DESCR macro will also generate the
appropriate block storage allocation directive.
.B
If "address" is not specified, no storage allocation directive is generated;
you must then follow the DESCR macro with the appropriate storage allocation
directive.
.B
If "address" is specified and "allot" is specified as "*", the DESCR macro
will generate the appropriate block storage allocation directive and
assign it to the label "address".
.B
Example:
.B
.LITERAL
	var
	  dynamic: 	descr .blkt 0		; dynamic descriptor

	  string: 	descr .blkt 512 *	; create descriptor and
						; allocate 512 bytes

	  buffer_descr: descr .blkt 512 buffer *; create descriptor and
						; allocate 512 bytes, assigning
						; it to the label buffer

	const
	  device_length=64

	var
	  device_descr: descr .blkt device_length device_name
	  device_name: 	.blkb device_length
.END LITERAL
.PG
DIVQ4 divisor,dividend,quotient,remainder
.X DIVQ4
.B 3
This macro performs quadword division.
.B
After the division is performed, r0 will contain the following values:
.B
.LITERAL
	-1	quotient < 0
	0	quotient = 0
	1	quotient > 0
.END LITERAL
.B
This macro will produce inline code to perform the quadword division.
However, if the macro:
.B
.LITERAL
	EXTERNAL MODULE DIVQ4 <divr,divd,quo,rem>
.END LITERAL
.B
is specified before the DIVQ4 macro is specified, this macro
will produce code to call an external routine to preform the quadword
division instead.
.B
The DIVQ4 macro is equivalent to the expression:
.B
.LITERAL
	(quoitent,remainder) = divisor / dividend
.END LITERAL
.B
Example:
.B
.LITERAL
	procedure divide
	var
	  divisor: 	.blkq 1
	  dividend: 	.blkq 1
	  quotient: 	.blkq 1
	  remainder: 	.blkq 1
	begin
	  divq4 divisor,divident,quotient,remainder
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CLRQ, CMPQ, MOVQ, MULQ, MULQ3, SUBQ, SUBQ3 and TSTQ.
.PG
.LITERAL
EXTERNAL variable
EXTERNAL <variable-list>
.END LITERAL
.X EXTERNAL
.B 3
The EXTERNAL macro defines the variable or variable-list as
external by generating the .EXTERNAL directive.
.B
This is used to specify variables that are external to the
module or procedure being assembled.
.B
Example:
.B
.LITERAL
	EXTERNAL table
	EXTERNAL <one,two,three>
.END LITERAL
.PG
.LITERAL
EXTERNAL MODULE external-name <argument-list> [internal-name]
.END LITERAL
.X EXTERNAL 
.X MODULE
.B 3
The EXTERNAL MODULE macro specifies that "external-name" is an external
module and that "<argument-list>" are the required arguments for the
external module.
.B
If "internal-name" is specified, this specifies the internal name of the
external module.
.B
Example:
.B
.LITERAL
	global module example
	external module    LIB$DAY_OF_WEEK <day,num> dayofweek
	var
	  day: 		.blkl 1
	  num: 		.blkl 1
	  degrees:	.blkf 1
	begin
	  . . .
	  dayofweek  day,num
	  . . .
	  movf	degress,r0
	  sin
	  . . .
	end
.END LITERAL
.PG
.LITERAL
EXTERNAL PROCEDURE external-name [internal-name]
.END LITERAL
.X EXTERNAL 
.X PROCEDURE
.B 3
The EXTERNAL MODULE macro specifies that "external-name" is an external
procedure.
.B
If "internal-name" is specified, this specifies the internal name of the
external procedure.
.B
Example:
.B
.LITERAL
	global module example
	external procedure MTH$SIN_R4 sin
	var
	  degrees:	.blkf 1
	begin
	  . . .
	  movf	degress,r0
	  sin
	  . . .
	end
.END LITERAL
.PG
.LITERAL
FOR index [FROM=initial] TO=limit [BY=increment] [TYPE=type] DO
  EXIT
END
.END LITERAL
.X FOR
.X DO
.X EXIT
.X END
.B 3
The FOR macro will generate code to perform a loop using the ACB (add, compare and
branch) assembly instruction;
therefore, the loop will always execute at least once.
.B
If "initial" is not specified, the "index" is expected to already contain
its inital value;
otherwise, the FOR macro will generate the appropriate code to move the
"initial" value to the "index".
.B
If "increment" is not specified, BY=#1 is assumed.
.B
If "type" is not specified, TYPE=L is assumed.
.B
The EXIT macro will generate code to branch to the next instruction following
the END macro.
The EXIT macro is optional.
.B
The END macro will generate the ACBx instruction to loop back to the
corresponding FOR macro and generate the appropriate labels for the EXIT macro.
For every FOR macro specified, a corresponding END macro must also be
specified.
.B
In the example below, the END macro will branch back to the beginning of the
FOR loop 10 times.
.B
.LITERAL
	procedure example
	const
	  length=10
	var
	  limit: 	.long length-1
	  table: 	.blkl length
	begin
	  for r1 from=#0 to=limit do
	    clrl table[r1]
	  end
	end
.END LITERAL
.PG
.LITERAL
GLOBAL MODULE name [<argument-list>] -
  [PSECT=psect-name] -
  [MASK=<register-list>]
CONST
  constants
VAR
  variables
BEGIN
  EXIT [value] [TYPE=type]
  RETURN
END
.END LITERAL
.X GLOBAL 
.X MODULE
.X CONST
.X VAR
.X BEGIN
.X EXIT
.X RETURN
.X END
.B 3
The GLOBAL MODULE macro sets up the enviorment for a globally accessable
module.
.B
If an <argument-list> is specified, each argument in the list will be
appended to the module name and each resultant string is used in a
constant assignment, assigning each with it's offset value from AP.
The constant "narg" append to the module name is always assigned the value of
0 and represents the number of arguments passed to this module.
.B
If <register-list> is not specified, MASK=<r2,r3,r4,r5> is assumed.
.B
If "psect-name" is specified, then "psect-name" appended with the string
"_global" will be the .PSECT name,
otherwise, the name of the module appended with the string "_global"
will be the .PSECT name.
.B
The CONST and VAR macros generate no code, but serves as a documentation aid.
The CONST macro and VAR macro are optional and can be specified as often as
required for documentation purposes.
.B
The BEGIN macro separates the data portion of a module from the code portion.
.B
The EXIT macro will generate a "$EXIT_S r0" instruction.  If "value" is
specified, the value will be moved to r0 before the $EXIT_S intruction is
generated.  If "type" is not specified, TYPE=L.
The EXIT macro is optional.
.B
The RETURN macro will generate a "RET" instruction.
.B
The END macro is used to end the global module.
If this is the last module in the assembly, the .END instruction can be
specified instead of the END macro.
.B.TP 10
Example:
.B
.LITERAL
	.title example
	global module example <a,b,c>
	const
	  $ssdef
	  length=3
	var
	  table: 	.blkl 3
	begin
	  if <cmpl #length,example.narg(AP)> neq then
	    exit #ss_insfarg
	  else
	    movl example.a(AP),table
	    movl example.b(AP),table+4
	    movl example.c(AP),table+8
	    clrl r0
	  end
	  return
	.end
.END LITERAL
.PG
.LITERAL
GLOBAL PROCEDURE name -
  [PSECT=psect-name]
CONST
  constants
VAR
  variables
BEGIN
  EXIT [value] [TYPE=type]
  RETURN
END
.END LITERAL
.X GLOBAL 
.X PROCEDURE
.X CONST
.X VAR
.X BEGIN
.X EXIT
.X RETURN
.X END
.B 3
The GLOBAL PROCEDURE macro sets up the enviorment for a globally accessable
procedure.
.B
If "psect-name" is specified, then "psect-name" appended with the string
"_global" will be the .PSECT name,
otherwise, the name of the procedure appended with the string "_code"
will be the .PSECT name.
.B
The CONST and VAR macros generate no code, but serves as a documentation aid.
The CONST macro and VAR macro are optional and can be specified as often as
required for documentation purposes.
.B
The BEGIN macro separates the data portion of a procedure from the code portion.
.B
The EXIT macro will generate a "$EXIT_S r0" instruction.  If "value" is
specified, the value will be moved to r0 before the $EXIT_S intruction is
generated.  If "type" is not specified, TYPE=L.
The EXIT macro is optional.
.B
The RETURN macro will generate a "RSB" instruction.
.B
The END macro is used to end the global procedure.
If this is the last procedure in the assembly, the .END instruction can be
specified instead of the END macro.
.B.TP 10
Example:
.B
.LITERAL
	.title example
	global module procedure
	begin
	  clrl r1
	  return
	.end
.END LITERAL
.PG
GOTO label
.X GOTO
.B 3
The GOTO macro generates a word displacement branch to the "label" specified.
.B
Example:
.B
.LITERAL
	procedure example
	begin
	  . . .
	label:
	  . . .
	  GOTO label
	end
.END LITERAL
.PG
.LITERAL
IF predicate THEN
ELSEIF predicate
ELSE
END
.END LITERAL
.X IF
.X THEN
.X ELSEIF
.X ELSE
.X END
.B 3
The IF macro generates code to execute a alternative control structure.
.B
The "predicate" may take one of the following forms:
.LIST
.LE;condition
.LE;instruction condition
.LE;instruction ... condition
.END LIST
where "condition" is one of the following mnemonics:
.B
.LITERAL
	EQL	EQLU		NEQ	NEQU
	GTR	GTRU		LSS	LSSU
	GEQ	GEQU		LEQ	LEQU
	CC	CS		VC	VS
	<LBS source>		<LBC source>
	<BS  position,base>	<BC  position,base>
	<BSS position,base>	<BCS position,base>
	<BSC position,base>	<BCC position,base>
.END LITERAL
.B
and "instruction" can be any assembly instruction or macro.
.B
Compound predicates may be formed by using the boolean operators AND and OR.
.B
Note that the operators associate to the right, so that the implied grouping
of "A OR B AND C OR D" is "A OR (B AND (C OR D))".
.B
In order to associate to the left, we use the operators ANDIF and ORIF.
.B
In other words, ANDIF and ORIF act as a closing parenthesis for the expression
to their left and as an opening parenthesis for the expression to their right;
hence, "A OR B ANDIF C OR D" is "(A OR B) AND (C OR D)".
.B
The ELSEIF macro ends the "true" part of an IF structure and begins a subsequent
nested IF structure.
The ELSEIF macro is optional and can be specified as often as required.
For every ELSEIF macro specified, a correspsonding IF macro must also be
specified.
.B
The ELSE macro ends the "true" part of an IF structure and begins the "false"
part.
The ELSE macro is optional.
For every ELSE macro specified, a corresponding IF macro must also be
specified.
.B.TP 10
The following IF structure:
.B
.LITERAL
	if <cmpw number,#10> lss then
	  movl	#1,digits
	elseif <cmpw number,#100> lss then
	  movl	#2,digits
	elseif <cmpw number,#1000> lss then
	  movl	#3,digits
	elseif <cmpw number,#10000> lss then
	  movl	#4,digits
	else
	  movl	#5,digits
	end
.END LITERAL
.B
is equivalent to:
.B
.LITERAL
	if <cmpw number,#10> lss then
	  movl	#1,digits
	  if <cmpw number,#100> lss then
	    movl  #2,digits
	    if <cmpw number,#1000> lss then
	      movl  #3,digits
	      if <cmpw number,#10000> lss then
	        movl  #4,digits
	      else
	        movl  #5,digits
	      end
	    end
	  end
	end
.END LITERAL
.PG
.LITERAL
LOOP
  CONTINUE
  EXIT
END
.END LITERAL
.X LOOP
.X CONTINUE
.X EXIT
.X END
.B
The LOOP macro begins a iterative control structure.
.B
The EXIT macro will generate code to branch to the next instruction after the
corrensponding END macro.
The EXIT macro is optional.
.B
The CONTINUE macro generates no code, but serves as a documentation aid.
The CONTINUE macro is optional and can be specified as often as required.
.B
The END macro generates a branch back to the corresponding LOOP macro and
also generates the appropriate label for the EXIT macro.
For every LOOP macro specified, a corresponding END macro must also be
specified.
.B
The WHILE macro, the REPEAT-UNTIL macro and the REPEAT-FOREVER macro are
implemented using the LOOP and IF macros.
.B
Example:
.B
.LITERAL
	global module example
	var
	  file			: $fab
	  record		: $rab
	procedure process_file
 	  begin
	    loop
	      $get record
	      if <cmpl #rms_eof,r0> eql then
	        movl #rms_normal,r0
	        exit
	      elseif <cmpl #rms_normal,r0> neq then
	        exit
	      end
	      . . .
	    end
	  end
	begin
	  . . .
	  process_file
	  if <cmpl #rms_normal,r0> then
	    exit
	  end
	end
.END LITERAL
.B
See also WHILE and REPEAT
.PG
.LITERAL
MODULE name <arguments> -
  [PSECT=psect-name] -
  MASK=<register-list>
CONST
  constants
VAR
  variables
BEGIN
  EXIT [value] [TYPE=type]
  RETURN
END
.END LITERAL
.X MODULE
.X CONST
.X VAR
.X BEGIN
.X EXIT
.X RETURN
.X END
.B 3
This macro sets up the environment for an interal module.
.B
If "psect-name" is specified, then "psect-name" appended with the string
"_local" will be the .PSECT name,
otherwise, the name of the module appended with the string "_code"
will be the .PSECT name.
.B
If <register-list> is not specified, MASK=<r2,r3,r4,r5> is assumed.
.B
The CONST and VAR macros generate no code, but serves as a documentation aid.
The CONST and VAR macros are optional and can be specified as often as
required for documentation purposes.
.B
The BEGIN macro separates the data portion of a module from the code portion.
.B
The EXIT macro will generate a "$EXIT_S r0" instruction.  If "value" is
specified, the value will be moved to r0 before the $EXIT_S intruction is
generated.  If "type" is not specified, TYPE=L is assumed.
.B
The RETURN macro will generated a "RET" instruction.
.B
The END macro is used to end the module.
For every MODULE macro specified, an END macro must also be specified.
If this is the last module in the assembly, an .END instruction can be
specified instead of the END macro.
.B
Example:
.B
.LITERAL
	module name
	var
	  save:		.blkw 1
	begin
	  movl r0,save
	  . . .
	  movl save,r0
	  return
	end
.END LITERAL
.PG
MOVQ src,dst
.X MOVQ
.B 3
This instruction moves quadwords.
.B
After the quadword is moved the following condition, r0 will contain the
following values:
.B
.LITERAL
	-1	dst < 0
	0	dst = 0
	1	dst > 0
.END LITERAL
.B
This macro will produce inline code to perform the quadword move.
However, if the macro:
.B
.LITERAL
	EXTERNAL MODULE MOVQ <src,dst>
.END LITERAL
.B
is specified before the MOVQ macro is specified, this macro
will produce code to call an external routine to preform the quadword
move instead.
.B
Example:
.B
.LITERAL
	procedure move
	var
	  source: 	.blkq 1
	  target: 	.blkq 1
	begin
	  movq source,target
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CLRQ, CMPQ, DIVQ4, MULQ, MULQ3, SUBQ, SUBQ3 and TSTQ.
.PG
.LITERAL
MULQ  multiplier,product
MULQ3 multiplier,multipland,product
.END LITERAL
.X MULQ
.X MULQ3
.B 3
These macros perform quadword multiplication.
.B
After the multiplication is performed, r0 will contain the following values:
.B
.LITERAL
	-1	product < 0
	0	product = 0
	1	product > 0
.END LITERAL
.B
These macros will produce inline code to perform the quadword multiplication.
However, if the macros:
.B
.LITERAL
	EXTERNAL MODULE MULQ  <mulr,prod>
	EXTERNAL MODULE MULQ3 <mulr,muld,prod>
.END LITERAL
.B
are specified before the MULQ and MULQ3 macros are specified, these macros
will produce code to call an external routine to preform the quadword
multiplication instead.
.B
The MULQ macro is equivalent to the expression:
.B
.LITERAL
	product = multiplier * product
.END LITERAL
.B
and the MULQ3 macro is equivalent to the expression:
.B
.LITERAL
	product = multiplier * multipland
.END LITERAL
.B
Example:
.B
.LITERAL
	procedure multiply
	var
	  multiplier: 	.blkq 1
	  multipland: 	.blkq 1
	  product: 	.blkq 1
	begin
	  mulq3 multiplier,multipland,product
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CLRQ, CMPQ, DIVQ4, MOVQ, SUBQ, SUBQ3 and TSTQ.
.PG
.LITERAL
PROCEDURE name -
  [PSECT=psect-name]
CONST
  constants
VAR
  variables
BEGIN
  EXIT [value] [TYPE=type]
  RETURN
END
.END LITERAL
.X PROCEDURE
.X CONST
.X VAR
.X BEGIN
.X EXIT
.X RETURN
.X END
.B 3
This macro sets up the environment for an interal routine.
.B
If "psect-name" is specified, then "psect-name" appended with the string
"_local" will be the .PSECT name,
otherwise, the procedure name appended with the string "_code"
will be the .PSECT name.
.B
The CONST and VAR macros generate no code, but serves as a documentation aid.
The CONST and VAR macros are optional and can be specified as often as
required for documentation purposes.
.B
The BEGIN macro separates the data portion of a procedure from the code portion.
.B
The EXIT macro will generate a "$EXIT_S r0" instruction.  If "value" is
specified, the value will be moved to r0 before the $EXIT_S intruction is
generated.  If "type" is not specified, TYPE=L is assumed and, therefore,
a "MOVL value,r0" instruction would be generated.
.B
The RETURN macro will generated a "RSB" instruction.
.B
The END macro is used to end the procedure.
For every PROCEDURE macro specified, an END MACRO must also be specified.
If this is the last procedure in the assembly, the .END instruction can be
specified instead of the END macro.
.B
Example:
.B
.LITERAL
	procedure name
	var
	  save: 	.blkw 1
	begin
	  movl r0,save
	  . . .
	  movl save,r0
	  return
	end
.END LITERAL
.PG
.LITERAL
PSECT psect-name <attributes>
END
.END LITERAL
.X PSECT
.X END
.B 3
The PSECT macro sets up a .PSECT enviornment after saving the current
enviornement by generating .SAVE_PSECT and .PSECT directives.
.B
"psect-name" will be the .PSECT name and have the "attributes" specified.
.B
The END macro restores the previous enviornment by generating a .RESTORE_PSECT
directive.
.B
Example:
.B
.LITERAL
	PSECT example <RD,NOWRT,EXE,LONG>
	  . . .
	END
.END LITERAL
.PG
.LITERAL
REPEAT
  EXIT
FOREVER
.END LITERAL
.X REPEAT
.X EXIT
.X FOREVER
.B 3
The REPEAT-FOREVER iterative control structure:
.B
.LITERAL
	repeat
	  . . .
	forever
.END LITERAL
.B
is equivalent to:
.B
.LITERAL
	loop
	  . . .
	end
.END LITERAL
.B
See LOOP.
.PG
.LITERAL
REPEAT
  EXIT
UNTIL predicate
.END LITERAL
.X REPEAT
.B 3
The REPEAT-UNTIL iterative control structure:
.B
.LITERAL
	repeat
	  . . .
	  exit
	  . . .
	until predicate
.END LITERAL
.B
is equivalent to:
.B
.LITERAL
	loop
	  . . .
	  exit
	  . . .
	  if predicate then exit end
	end
.END LITERAL
.B
See LOOP and IF.
.PG
.LITERAL
RECORD name -
  [PSECT=psect-name]
END
.END LITERAL
.X RECORD
.X END
.B 3
The RECORD macro:
.B
.LITERAL
	record example
	  . . .
	end
.END LITERAL
.B
is equivalent to:
.B
.LITERAL
	psect example_abs <ABS>
	  . . .
	end
.END LITERAL
.B
If "psect-name" is specified, then "psect-name" will be the .PSECT name;
otherwise, the name of the record appended with the string "_abs"
will be the psect name.
.B
For every RECORD macro specified, a corresponding END macro must also be
specified.
.B
Example:
.B
.LITERAL
	record uic
	  uic.member	: .blkw 1
	  uic.group	: .blkw 1
	  .=uic.member
	  uic.longword	: .blkl 1
	end
.END LITERAL
.PG
.LITERAL
SUBQ  sub,dif
SUBQ3 sub,min,dif
.END LITERAL
.X SUBQ
.X SUBQ3
.B 3
These macros perform quadword subtraction.
.B
After the subtraction is performed, r0 will contain the following values:
.B
.LITERAL
	-1	dif < 0
	0	dif = 0
	1	dif > 0
.END LITERAL
.B
This macro will produce inline code to perform the quadword subtraction.
However, if the macros:
.B
.LITERAL
	EXTERNAL MODULE SUBQ  <sub,dif>
	EXTERNAL MODULE SUBQ3 <sub,min,dif>
.END LITERAL
.B
are specified before the SUBQ and SUBQ3 macros are specified, therse macros
will produce code to call an external routine to preform the quadword
subtraction instead.
.B
The SUBQ macro is equivalent to the expression:
.B
.LITERAL
	dif = sub - dif
.END LITERAL
.B
and the SUBQ3 macro is equivalent to the expression:
.B
.LITERAL
	dif = sub - min
.END LITERAL
.B
Example:
.B
.LITERAL
	procedure subtract
	var
	  sub: 		.blkq 1
	  dif: 		.blkq 1
	begin
	  subq sub,dif
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CLRQ, CMPQ, DIVQ4, MOVQ, MULQ, MULQ3, and TSTQ.
.PG
TSTQ dst
.X TSTQ
.B 3
This macro performs quadword comparison against zero.
.B
After the test is performed the following condition, r0 will contain the
following values:
.B
.LITERAL
	-1	dst < 0
	0	dst = 0
	1	dst > 0
.END LITERAL
.B
This macro will produce inline code to perform the quadword test.
However, if the macro:
.B
.LITERAL
	EXTERNAL MODULE TSTQ <dst>
.END LITERAL
.B
is specified before the TSTQ macro is specified, this macro
will produce code to call an external routine to preform the quadword
test instead.
.B
Example:
.B
.LITERAL
	procedure test
	var
	  target: 	.blkq 1
	begin
	  tstq target
	  if <tstl r0> eql then
	    . . .
	  end
	end
.END LITERAL
.B
See also ADDQ, ADDQ3, CLRQ, CMPQ, DIVQ4, MOVQ, MULQ, MULQ3, SUBQ and SUBQ3.
.PG
.LITERAL
WHILE predicate DO
  EXIT
END
.END LITERAL
.X WHILE
.X DO
.X EXIT
.X END
.B 3
The WHILE iterative control structure:
.B
.LITERAL
	while predicate do
	  . . .
	  exit
	  . . .
	end
.END LITERAL
.B
is equivalent to:
.B
.LITERAL
	loop
	  if predicate then continue else exit end
	  . . .
	  exit
	  . . .
	end
.END LITERAL
.B
See LOOP and IF.
.IF index
.FLAGS COMMENT
.REQUIRE "mlr.rnx"
.ENDIF index
