.title ttout Terminal output .ident "V02.00" ;+ ; Index Terminal output ; ; Usage ; ; ttosf(buffer); ; char *buffer; /* Address of string */ ; ; ttosnf(buffer); ; char *buffer; /* Address of string */ ; ; ttocf(ch); ; char ch; /* Character to buffer */ ; ; ttocnf(ch); ; char ch; /* Character to buffer */ ; ; ; Description ; ; ttosf() buffers the passed character string into an internal ; user output buffer and flushes the full contents of the buffer ; to the terminal. ; ; ttosnf() buffers the passed character string into an internal user ; output buffer. The buffer is not flushed unless it fills up. In ; which case, the buffer is flushed and any remaining characters ; are buffered. The capacity of the internal output buffer is 132. ; characters, unless the user makes a call to the outbuf() routine ; and resets the output buffer size. ; ; ttocf() buffers the passed character into an internal user output ; buffer and flushes the contents of the output buffer to the terminal. ; ; ttocnf() buffers the passed character into an internal user output ; buffer. The buffer is not flushed unless it fills up. ; ; All of the terminal output routines return a 1 if successful and ; a 0 if an error occurred. ; ;- ; Edit History ; V02.00 19-Oct-82 TTC Rework of CS library ; .psect c$code ttocf:: movb 2(sp),r1 ; r1 = character call putbyt ; Put char in output buffer call flush ; Flush output buffer return ttosf:: mov r2,-(sp) ; Save r2 mov 4(sp),r2 ; r2 --> message 10$: movb (r2)+,r1 ; r1 = character beq 20$ ; Branch if end of string call putbyt ; Put char in output buffer br 10$ ; Get next character 20$: call flush ; Flush output buffer mov (sp)+,r2 ; Restore r2 return ttocnf:: movb 2(sp),r1 ; r1 = character call putbyt ; put character in output buffer return ttosnf:: mov r2,-(sp) ; Save r2 mov 4(sp),r2 ; r2 --> message 10$: movb (r2)+,r1 ; r1 = character beq 20$ ; Branch if end of string call putbyt ; Put character in output buffer br 10$ ; Get next character 20$: mov (sp)+,r2 ; Restore r2 return .sbttl putbyt Put a byte into output buffer ; ; PUTBYT - Put a byte into the output buffer ; ; Inputs: ; r1 = byte to put into output buffer ; ; Outputs: ; Byte is put in output buffer and buffer pointer ; is updated. ; putbyt: cmpb #012,r1 ; Is it a newline? bne 10$ ; (No) movb #015,@$$bptr ; (Yes), insert a inc $$bptr cmp $$bptr,$$bend ; Buffer full? bne 10$ ; (No) mov r1,-(sp) ; (Yes), save r1 call flush ; Flush the buffer mov (sp)+,r1 ; Restore r1 10$: movb r1,@$$bptr ; Buffer character inc $$bptr ; Increment buffer pointer cmp $$bptr,$$bend ; Buffer full? bne 20$ ; (No) call flush ; (Yes), flush it 20$: return .end