	.TITLE CLON
	.ENABLE LC
	.IDENT /101388/

;	File:[22,310]CLON.MAC
;	Author: Jim Bostwick  13-MAY-1988 
;	History: JMB 13-MAY-1988
;
;	Last Edit: 9-OCT-1989 18:20:32 
;

.REM |

Procedure CLON(table:Logical_table_typ;
		Log_nam: Packed array [lo..hi:Integer] of char;
		Equ_str: Packed array [elo..ehi:Integer] of char
	);External;

{*USER*
 Pascal-3 procedure to create a logical name. Table specifies the logical
name table to contain the task (include the file LogNam.Typ). The modifiers
"terminal" and "privileged" are NOT provided. Use "SPAWN DFL" if required.  
 Log_nam and Equ_str are defined as conformant string parameters. 

 Directive Status is available in $DSW on return.
} 

|

;
; Assemble with PASMAC.MAC as prefix file.
;
; j.m.b.  13-MAY-1988 22:10:03 
;

	.MCALL CLON$S
	
	PROC CLON
	PARAM Table, INTEGER	; Pascal scalar used as number
	PARAM lnm, ADDRESS	; pointer to logical name string
	PARAM lnmlo, INTEGER	; low conformant param
	PARAM lnmhi, INTEGER	; hi conformant param
	PARAM enm, ADDRESS	; Pointer to equivalence string
	PARAM enmlo, INTEGER	; low conformant param
	PARAM enmhi, INTEGER	; hi conformant param
	SAVE <R0,R1,R2,R3,R4 >
	BEGIN
	mov	lnm(sp), r3	; get lnm pointer
	mov	lnmlo(sp), r0	; get low bound
	beq	10$		; if eq - type-0 string
;
; get length in use of type-1 string
;
	mov	r3, r4		; copy string pointer
	mov	lnmhi(sp), r1	; get high bound
	sub	r0, r1		; get max length
	add	r1, r4		; point to end of string
	inc	r4		; ... point past end
5$:	tstb	-(r4)		; scan down past null bytes
	bne	20$		; found virtual end
	sob	r1, 5$		; keep looking
	br	20$		; if zero length

10$:	movb	(r3)+, r1	; get length in r1, and
				;   skip length byte
	bic	#^C377, r1	; it's an unsigned byte
;
; r3-> lnm, r1=lnmlen	r0, r2, r4 avail
;
20$:	mov	enm(sp), r4	; get ens pointer
	mov	enmlo(sp), r0	; get low ens bound
	beq	30$		; if eq - type-0 string

	mov	enmhi(sp), r2	; compute length
	sub	r0, r2		; got it
	add	r4, r2		; r2 -> end of string
	inc	r2		; r2 -> past string

25$:	tstb	-(r2)		; look for null bytes
	bne	26$		; found virtual end -br
	sob	r0, 25$		; 
	
26$:	mov 	r0, r2		; set length in r2
	br	40$	

30$:	movb	(r4)+, r2	; get length in r2, and
				;   skip length byte
	bic 	#^C377, r2	; it's an unsigned byte

40$:	mov	sp, r0		; local copy 
;50$:	br	50$		; for debug
	CLON$S  #1,table(r0),r3,r1,r4,r2	
	ENDPR
	.END

