; O U T P U T P R O C E D U R E S .TITLE OutputRoutines ; PURPOSE: ; Provides output of several variable types to the standard ; output device - normally the user's terminal. .EXTERNAL Lib$Put_Output ; STANDARD CALLING SEQUENCE FOR EACH LINE OF OUTPUT: ; CALLS #0, InitializeOutput ; call a procedure for each value to be printed ; CALLS #0, TypeOutputLine ; Constants: Blank = ^A" " Dot = ^A"." LengthBuf = 80 ; Length of output buffer NumDigits = 10 ; Number of decimal digits ; Storage: ; .... The output buffer, its descriptor and argument list .... Buf: .BLKB LengthBuf ; Output buffer BufDescrpt = . CurrentLength: .BLKW 1 ; Number of characters in buf .BYTE 14 ; Data type .BYTE 1 ; Fixed length string .ADDRESS Buf ; Address of buffer ArgList: .LONG 1 ; Number of arguments .ADDRESS BufDescrpt ; Address of descriptor ; .... Other data .... NextLoc: .BLKL 1 ; Address of next location in Buf PackedBuf: .BLKB NumDigits+2/2 ; Buffer for packed decimal Stars: .ASCII '***********' ; Used for error output ; * * * * * Macro CheckForRoom * * * * * ; Macro to check to see if there is enough room in the buffer for the ; next field. If not, it prints the current buffer and reinitializes it. ; Argument: FieldLength: Word, Length (number of characters) of the ; field to be added to the buffer. .MACRO CheckForRoom, FieldLength, ?OK ADDW3 FieldLength, CurrentLength, R0 CMPW #LengthBuf, R0 ; Is there room in buf? BGEQ OK ; If not ;. . . CALLS #0, TypeOutputLine ; output line, CALLS #0, InitializeOutput ; initialize output, MOVW FieldLength, R0 ; set char. in buffer OK: MOVW R0, CurrentLength ; Update number of characters ; in the buffer .ENDM CheckForRoom ; * * * * * Procedure InitializeOutput * * * * * ; Purpose: Called to clear out buffer and initialize a line of output. ; Standard call: ; CALLS #0, InitializeOutput ; Arguments: None .ENTRY InitializeOutput, ^M ; Initialize output by clearing output buffer MOVC5 #0, Buf, #Blank, #LengthBuf, Buf ; Store blanks in buffer CLRW CurrentLength ; No characters in buffer MOVAB Buf, NextLoc ; NextLoc = Beginning of buffer RET ; * * * * * Procedure OutASCII(ASCII string, Length) * * * * * ; Purpose: Puts an ASCII string in the output buffer. Does not leave ; any spaces around the string. ; Standard call: ; PUSHL Length of string ; PUSHAB ASCII string ; CALLS #2, OutASCII ; Arguments: ; Name Offset Use Type Passed by String = 4 ; Character string longword reference Length = 8 ; Number of characters longword value .ENTRY OutASCII, ^M CheckForRoom Length(AP) MOVC3 Length(AP), @String(AP), @NextLoc MOVL R3, NextLoc ; Save location of next field RET ; * * * * * Procedure OutLong(Longword value) * * * * * ; Purpose: Puts a longword in the output buffer. Leaves a blank ; before and after value. Prints 10 digits plus sign. ; Standard call: ; PUSHAL Value ; CALLS #1, OutLong ; Argument: ; Name Offset Use Type Passed by Value = 4 ; Value to be printed longword reference .ENTRY OutLong, ^M CheckForRoom #NumDigits+3 INCL NextLoc ; Leave leading blank CVTLP @Value(AP), #NumDigits, PackedBuf CVTPS #NumDigits, PackedBuf, #NumDigits, @NextLoc ADDL2 #NumDigits+2, NextLoc ; Leave room for digits, sign and ; final blank RET ; * * * Procedure OutFloat(Floating value, decimal places) * * * ; Purpose: Puts a floating point number in the output buffer. Leaves ; blanks before and after value. Prints 10 digits plus and decimal ; point. Call specifies number of decimal places. If the value is too ; large, it is replaced by stars. ; Standard call: ; PUSHL Number of decimal places ; PUSHAF Value ; CALLS #2, OutFloat ; Arguments: ; Name Offset Use Type Passed by Value = 4 ; Value to be printed floating reference NumPlaces = 8 ; Num. of decimal places longword value .ENTRY OutFloat, ^M CheckForRoom #NumDigits+4 ; .... Make sure the number of decimal places is legal .... MOVW NumPlaces(AP), R2 ; Get decimal places CMPW R2, #NumDigits ; If decimal places > NumDigits BLEQU OK2 ; then MOVW #NumDigits, R2 ; decimal places = NumDigits OK2: MOVZWL R2, R6 ; R6 <-- decimal places ; .... Multiply by 10 to the number of decimal places .... MOVF @Value(AP), R4 ; Get value TSTW R2 ; Check number of digits Loop: BLEQU Done ; Branch if done MULF2 #10.0, R4 ; Multiply value by 10 DECW R2 ; Decrement counter BRB Loop ; Repeat ; .... Convert the result to a longword, packed decimal, and ASCII .... Done: INCL NextLoc ; Leave a leading blank CVTRFL R4, R4 ; Convert to integer BVS TooBig ; Branch if too big CVTLP R4, #NumDigits, PackedBuf CVTPS #NumDigits, PackedBuf, #NumDigits, @NextLoc BRB OK3 TooBig: MOVC3 #NumDigits+1, Stars, @NextLoc OK3: ADDL2 #NumDigits+3, NextLoc ; Update NextLoc ; .... Insert decimal point .... SUBL3 R6, NextLoc, R7 ; Find beginning of decimal SUBL2 #2, R7 ; part MOVC3 R6, (R7), 1(R7) ; Move decimal part right MOVB #Dot, (R7) ; Insert decimal point RET ; * * * * * Procedure TypeOutputLine * * * * * ; Purpose: Types the current contents in the buffer. ; Standard call: ; CALLS #0, TypeOutputLine ; Arguments: None .ENTRY TypeOutputLine, ^M< > CALLG ArgList, G^Lib$Put_Output RET .END