# Copyright (c) 1979 Regents of the University of California
# char sccsid[] = "@(#)31write.s 4.1 10/10/80";
bbc $fWRITE,FUNIT(r7),ewriteit
pushl $1 #number of items
pushl FSIZE(r7) #item size
movl FBUF(r7),r5 #ptr to FILE
bbs $ioERR,FLAG(r5),ewrite
cvtbl (r10)+,r5 #r5 has number of longword arguements
bbc $fWRITE,FUNIT(r7),ewriteit
calls r5,_fprintf #output formatted data
movl FBUF(r7),r5 #ptr to FILE
bbs $ioERR,FLAG(r5),ewrite
bbc $fWRITE,FUNIT(r7),ewriteit
bbs $ioERR,FLAG(r5),ewrite #check for I/O error
bbc $fWRITE,FUNIT(r7),ewriteit
calls $4,_fwrite #output string
movl FBUF(r7),r5 #ptr to FILE
bbs $ioERR,FLAG(r5),ewrite
aobleq LLIMIT(r7),LCOUNT(r7),l3101
bbc $fWRITE,FUNIT(r7),ewriteit
pushl $linefeed #push a linefeed
bbs $ioERR,FLAG(r5),ewrite #check for I/O error
bbc $fWRITE,FUNIT(r7),ewriteit
pushl $formfeed #push a formfeed
jbs $ioERR,FLAG(r5),ewrite #check for I/O error
addl3 (r10)+,ap,r6 #r6 points to scalar name list
movl (sp)+,r3 #r3 has data value
cmpw r3,(r6)+ #check for value out of range
movzwl (r6)[r3],r4 #r4 has string index
pushab (r6)[r4] #push string ptr
cvtbl (r10)+,r0 #r0 has width value
movzwl (r10)+,r1 #r1 has minimum width value
movl (sp),r2 #r2 has requested width
blss efmt #check for negative values
subl2 r0,r2 #shave down value
cmpl r1,r2 #check for below minimum width
movl r1,(sp) #force to be at least minimum width
movl r2,(sp) #set to reduced value
cvtbl (r10)+,r0 #r0 has width value
cmpl (sp),r0 #check for greater than max allowed
movl r0,(sp) #use smaller value