.PRINT	 ; ; move comments over 1 tab	C/;/	;/
.PRINT	 ; ; move back 1 tab        	C/	;/;/
.PRINT	 ; ; find leading spaces and convert to tabs	4y5y6y
.PRINT	 ; ; get 24 leading	1,$c/^                        /			/4p
.PRINT	 ; ;      16        	1,$c/^                /		/5p
.PRINT	 ; ;       8         	1,$c/^        /	/6p
.PRINT	 ; ;
.PRINT	 ; /
.PRINT	 ;         PROGRAM Ee      ;spread out text
$auto$=-2
.enabl lc
;15-aug-80 for Conroy C runtime
.PRINT	 ;  mutask=1
 mutask=1
.PRINT	 ;         .psect edi14
        .psect edi14
.PRINT	 ;          
         
.PRINT	 ;         .enabl lc
        .enabl lc
.PRINT	 ;         .enabl ama
        .enabl ama
.PRINT	 ;         .nlist sym
        .nlist sym
.PRINT	 ;          
         
.PRINT	 ;         .if df mutask
        .if df mutask
.PRINT	 ;         .MACRO pure
        .MACRO pure
        .psect pur,ro
        .ENDM 
.PRINT	 ;          
         
.PRINT	 ;         .MACRO impure
        .MACRO impure
        .psect ipur,rw
        .ENDM 
.PRINT	 ;         .iff 
        .iff 
.PRINT	 ;         .MACRO pure
        .MACRO pure
        .ENDM 
.PRINT	 ;          
         
.PRINT	 ;         .MACRO impure
        .MACRO impure
        .ENDM 
.PRINT	 ;         .endc 
        .endc 
.PRINT	 ;          
         
.PRINT	 ;          
         
.PRINT	 ;         .globl fillit   ;Subroutine for Nf command
        .globl fillit   ;Subroutine for Nf command
.PRINT	 ;          
         
.PRINT	 ;         impure 
        impure 
.PRINT	 ;          
         
.PRINT	 ;          
         
.PRINT	 ; ; - - -	 macro library calls
.PRINT	 ; ;       .mcall dir$,callr
.PRINT	 ; ; - - -	 system	macros
.PRINT	 ; ; - - -	 local data and	symbols
.PRINT	 ;          
         
.PRINT	 ; dir:    .word 0         ;direction
dir:    .word 0         ;direction
.PRINT	 ; i:      .word 0         ;index
i:      .word 0         ;index
.PRINT	 ; j:      .word 0         ;index
j:      .word 0         ;index
.PRINT	 ; nb:     .word 0         ;
nb:     .word 0         ;
.PRINT	 ; ne:     .word 0         ;
ne:     .word 0         ;
.PRINT	 ; nholes: .word 0         ;number of holes
nholes: .word 0         ;number of holes
.PRINT	 ;          
         
.PRINT	 ; outp:   .word 0         ;out pointer
outp:   .word 0         ;out pointer
.PRINT	 ; nextra: .word 0         ;extra blanks
nextra: .word 0         ;extra blanks
.PRINT	 ; outwds: .word 0         ;out words
outwds: .word 0         ;out words
.PRINT	 ;          
         
.PRINT	 ; ; temp:   .blkb 150.
.PRINT	 ;         nl=12 
        nl=12 
.PRINT	 ;         cr=15 
        cr=15 
.PRINT	 ;         space=40 
        space=40 
.PRINT	 ;         backspace=10           ;for computing the width function
        backspace=10           ;for computing the width function
.PRINT	 ;         tab=11 
        tab=11 
.PRINT	 ;          
         
.PRINT	 ; 	pure
	pure
.PRINT	 ;          
         
.PRINT	 ;          
         
.PRINT	 ; ;+
.PRINT	 ; ; fillit - spread out text in lbuf3
.PRINT	 ; ; input:
.PRINT	 ; ;
.PRINT	 ; ;       r0 = # of extra spaces
.PRINT	 ; ;       r1 = pointer into lbuf3
.PRINT	 ; ;       r2 = # of words on line
.PRINT	 ; ;       lbuf3 = ascii buffer to spread out
.PRINT	 ; ;-
.PRINT	 ;          
         
.PRINT	 ; fillit:  
fillit:  
.PRINT	 ;         mov r0,nextra
        mov r0,nextra
.PRINT	 ;         mov r1,outp
        mov r1,outp
.PRINT	 ;         mov r2,outwds
        mov r2,outwds
.PRINT	 ;          
         
.PRINT	 ;         IF nextra LE #0  OR   outwds LE #1
	CMP outwds,#1		;IS outwds LE #1
	BGT Ee4	;Not if GT
	BR Ee2		;condition met
Ee4=.
	TST nextra		;IS nextra LE #0
	BGT Ee1	;Not if GT
Ee2=.
.PRINT	 ;             rts pc
            rts pc
.PRINT	 ;         FI 
Ee1=.			; 
Ee3=.
.PRINT	 ;          
         
.PRINT	 ;         com dir
        com dir
.PRINT	 ;          
         
.PRINT	 ;         mov nextra,ne
        mov nextra,ne
.PRINT	 ;         LET nholes = outwds - #1
	MOV outwds,nholes
	DEC nholes
.PRINT	 ;         LET i = outp - #1
	MOV outp,i
	DEC i
.PRINT	 ;          
         
.PRINT	 ;         LET r1 = i + ne
	MOV i,r1
	ADD ne,r1
.PRINT	 ;         mov #lbs-2,r2           ;compute min of:
        mov #lbs-2,r2           ;compute min of:
.PRINT	 ;          
         
.PRINT	 ;         IF r1 LT r2
	CMP r1,r2		;IS r1 LT r2
	BGE Ee7	;Not if GE
.PRINT	 ;             mov r1,j
            mov r1,j
.PRINT	 ;         ELSE 
	JMP Ee10
Ee7=.			; 
.PRINT	 ;             mov r2,j
            mov r2,j
.PRINT	 ;         FI 
Ee10=.			; 
Ee9=.
.PRINT	 ;          
         
.PRINT	 ;         DO WHILE i LT j
Ee11=.
	CMP i,j		;Is i LT j
	BLT .+6	;Stay in loop
	JMP Ee12	;else end  while loop
.PRINT	 ;              
             
.PRINT	 ;             LET r1 = #lbuf3-1 + i           ;lbuf(i)
	MOV #lbuf3-1,r1
	ADD i,r1
.PRINT	 ;             LET r2 = #lbuf3-1 + j           ;lbuf(j)
	MOV #lbuf3-1,r2
	ADD j,r2
.PRINT	 ;             movb (r1),(r2)                  ; buf(j) <- buf(i)
            movb (r1),(r2)                  ; buf(j) <- buf(i)
.PRINT	 ;              
             
.PRINT	 ;             IFB (r1) = #space
	CMPB (r1),#space		;IS (r1) = #space
	BNE Ee13	;Not if NE
.PRINT	 ;                  
                 
.PRINT	 ;                 IF dir = #0
	TST dir		;IS dir = #0
	BNE Ee16	;Not if NE
.PRINT	 ;                     LET r2 = ne - #1
	MOV ne,r2
	DEC r2
.PRINT	 ;                     LET r2 = r2 / nholes
	clr r0
	mov r2,r1
	div nholes,r0
	mov r0,r2
.PRINT	 ;                     inc r2
                    inc r2
.PRINT	 ;                 ELSE 
	JMP Ee19
Ee16=.			; 
.PRINT	 ;                     LET r2 = ne / nholes
	MOV ne,r2
	clr r0
	mov r2,r1
	div nholes,r0
	mov r0,r2
.PRINT	 ;                 FI 
Ee19=.			; 
Ee18=.
.PRINT	 ; 
.PRINT	 ;                 mov r2,nb
                mov r2,nb
.PRINT	 ; 		LET ne = ne - nb
	SUB nb,ne
.PRINT	 ;                 dec nholes
                dec nholes
.PRINT	 ; 
.PRINT	 ; ; PRINTF #TEMP <dir=%d nb=%d nholes=%d i=%d j=%d ne=%d> dir nb nholes i j ne
.PRINT	 ; 
.PRINT	 ;                  
                 
.PRINT	 ;                 DO WHILE nb GT #0
Ee20=.
	TST nb		;Is nb GT #0
	BGT .+6	;Stay in loop
	JMP Ee21	;else end  while loop
.PRINT	 ;                     dec j
                    dec j
.PRINT	 ;                     LET r2 = #lbuf3-1 + j           ;lbuf(j)
	MOV #lbuf3-1,r2
	ADD j,r2
.PRINT	 ;                     movb #space,(r2)
                    movb #space,(r2)
.PRINT	 ; 		    dec nb
		    dec nb
.PRINT	 ;                 OD 
	JMP Ee20		;Repeat loop
Ee21=.
.PRINT	 ;             FI 
Ee13=.			; 
Ee15=.
.PRINT	 ;             dec i
            dec i
.PRINT	 ;             dec j
            dec j
.PRINT	 ;              
             
.PRINT	 ;         OD 
	JMP Ee11		;Repeat loop
Ee12=.
.PRINT	 ;          
         
.PRINT	 ;         rts pc
        rts pc
.PRINT	 ;         .end 
        .end 
