$MACRO type string to lun 3
?? 3,4,5
        br #@5
#@4=.
	.ascii ~#@1~
#@3=.
	.even
#@5=.
I%NB <#@2> <pu.sh <#@2>>
I%B  <#@2> <pu.sh <40>>
?+ 2
        qiow$s #io.wvb,#3,#15. ,, ,, <#<#@4>,#<#@3-#@4>,#<#@2>>
$ENDM
;
$MACRO pu.sh
?- <#@1>
$ENDM
$MACRO moveb from to nbytes
?? 4
        mov #@1,r0
        mov #@2,r1
        mov #@3,r2
#@4=.
        movb (r0)+,(r1)+
        sob r2,#@4
$ENDM
/
        PROGRAM SD
        .title SD
        .enabl lc
        .psect send
        .enabl ama
	.nlist sym

        space=40
        cr=15
        esc=33
        bad=4
        good=1

        .mcall sdat$,exit$s,dir$,STOP$S,gtsk$s,gmcr$
        .mcall exst$s,qiow$s

sdat:  sdat$ trnsfr,uic
gmcr:   gmcr$
 
uic:    .byte 1,1
puic:   .byte 1,1
text:  .ASCII /                                                /
        .EVEN

task:   .blkw   16.

eof:    .word 0
p:      .word 0

start:

        gtsk$s #task                    ;get task parms
        mov task+g.tspc,uic             ;default uic
        mov task+g.tsdu,puic            ;protection uic (why is it tsDU???)

        dir$ #gmcr                      ;get command line
        IF $dsw LE #4                   ;check it
usage:
           type <Send Usage: Send filename1 filename2 ...>
           exst$s #bad
        ELSE
           mov #gmcr+g.mcrb+4,p            ;set pointer to start of input
           DO FOREVER
               call clear                  ;clear send to blanks
               call getf                   ;get next file on line
               IF CC                       ;cc if something there
                  dir$ #sdat               ;send
                  stop$s                   ;stop until done
               ELSE
                  exit$s                   ;cs means no more
               FI
           OD
        FI

clear:
        movb #space,text                   ;put space in 1st position
        moveb #text  #text+1   #30.        ;propgate spaces to right
        rts pc


getf:
        IF eof NE #0                       ;did we set eof last time
           sec                             ;yes, done
           rts pc
        ELSE

           mov #text,r1                    ;output location
           DO FOREVER
               movb @p,r0                  ;next input char
               IFB r0 = #esc OR r0 = #cr   ;terminator of buffer
                  inc eof                  ;yes, also eof next time
                  clc                      ;not eof this time
                  rts pc
               ELSEIFB r0 = #space
                  inc p                    ;end of this filename
                  clc                      ;not eof
                  rts pc
               ELSE
                  movb r0,(r1)+            ;move char to output
                  inc p                    ;next output position
               FI
           OD
        FI

        .end start
