.title prompt ;+ ; integer function prompt(pstr, buf, int) ;- ap=%5 pstr=2 buf=4 int=6 .psect $r.rwd,con,rw,rel,lcl,d secpmt: .ascii <15><12>" _" ; secondary prompt string .even .psect $r.roi,con,ro,rel,lcl,i .enabl lsb prompt:: mov ap,-(sp) ; save argument pointer sub #6,sp ; build Fortran call block on stack mov #2,(sp) ; number of arguments to getlin mov int(ap),4(sp) ; address of int mov @int(sp),r0 ; rat4 unit call r$gfbk ; get RFDB address in r1 mov #eof,r0 ; assume error bcs 100$ ; invalid rat4 unit bit #rf.tty,(r1) ; is this a terminal unit? beq 90$ ; NO, just do a getlin inc (sp) ; 3 args to getlin for continuation tstb @pstr(ap) ; null prompt string? beq 90$ ; YES, just do a getlin mov pstr(ap),r3 ; initialize starting address of prompt mov sp,ap ; set up arg ptr for r$rput 10$: mov #secpmt,r2 ; CR-LF address mov #2,r0 ; 2 characters to write call r$rput ; write them to tty clr r0 ; initialize count mov r3,r2 ; starting address of prompt 20$: cmpb #newlin,(r3) ; NEWLINE character? beq 30$ ; YES, write buffer tstb (r3) ; at end of prompt? beq 30$ ; YES, write buffer inc r0 ; increment character count inc r3 ; address of next character br 20$ ; do again 30$: tst r0 ; any characters to write? beq 35$ ; NO call r$rput ; write them to tty 35$: tstb (r3) ; end of prompt string? beq 40$ ; YES, do getlin inc r3 ; bump past NEWLINE br 10$ ; try again 40$: mov 6(sp),ap ; restore arg pointer 90$: cmp #3,(sp) ; three args? bne 95$ ; NO movb @pstr(ap),secpmt+2 ; copy first character of prompt mov #secpmt,6(sp) ; address of prompt string 95$: mov buf(ap),2(sp) ; buffer for getlin mov sp,ap ; arg pointer for getlin call getlin ; get the next line 100$: add #10,sp ; restore stack return .end