;
; COPYRIGHT 1980,1981,1982,1983,1984 CONVERGENT TECHNOLOGIES, INC.
; ALL RIGHTS RESERVED
;
; THIS PROGRAM IS FURNISHED UNDER A LICENSE RESTRICTING ITS USE SOLELY FOR THE
; OPERATION OF A DESIGNATED COMPUTER FOR A PARTICULAR PURPOSE, AND MAY NOT BE
; COPIED OR OTHERWISE USED WITHOUT THE PRIOR WRITTEN CONSENT OF CONVERGENT
; TECHNOLOGIES, INC.  TITLE TO AND OWNERSHIP OF THE PROGRAM, INCLUDING ITS
; SOURCE CODE, SHALL AT ALL TIMES REMAIN IN CONVERGENT TECHNOLOGIES.
;

STACK SEGMENT STACK 'STACK'		; default stack so programs won't crash 
	DB 512 DUP (?)
STACK ENDS


Out(
Start Pass: )

*define(MakeLabel)(
segrqCS segment at rqCS
	org rqIP
	rcName label byte
	PUBLIC rcName
segrqCS ends
Out(.))

*DEFINE(NewRqName)(' new CS:IP format
IF ((level AND 1) EQ 1) THEN (Error) ELSE ('
set(rqCS, (rcode AND 0FF8h) OR level SHR 1)'
if (rqCS GT 21h) THEN (set(rqCs, rqCS OR 0F000h))FI'
set(rqIP, 210h + ((rcode AND 7) SHL 1)  (rqCS SHL 4))'
MakeLabel)FI)

*Define(Error)(Out(
No Procedural Interface for level level, rq rcode, name rcname
)
ERROR; No Procedural Interface for level level, rq rcode, name rcname
)

' Must make names with macro arguments so substitution works left to right.
*Define(MakeName( First, Second ))(define(rcName)(FirstSecond))

*Define(RqName( rq, name ))('
set(rqBased,rq+base)' Alt rqs start 800h higher
set(level, rq SHR 12)' No level shifts allowed when apply base
set(rcode,(rqBased AND 0FFFh))'
define(rcName)(Prefix(name))'
IF (level EQ 0 OR eval(rq) GE 0FFE0h) THEN ('
set(tmp,(rqBased AND 0FFF8h))'
set(rqCS,(tmp) AND 0FFFFh)'
set(rqIP,(210h + (tmp*10h) + ((rqBased*2) AND 0Fh)) AND 0FFFFh)'
MakeLabel'
) ELSE (NewRqName)FI)

*DEFINE (Same( original , copy ))(
define(rcName)(Prefix(copy))'
PUBLIC rcName
rcName EQU Prefix(original)
)

IF (not(*Isdef(base))) THEN ('
SET(base,0)' No base, rq codes are asis
)FI

IF (not(*Isdef(Prefix))) THEN ('
DEFINE(Prefix)()' No prefix, names are asis
)FI
ReOpen