; * * * * * * * * * * * ; * INPUT MACRO * ; * * * * * * * * * * * .MACRO Input Prompt, Byte, Word, Long, Float, - ASCII, Length=#1, Hex, ?PromptBuf, - ?Cont, ?Message, ?TempBuf, ?HasSign .EXTERNAL Lib$Get_Input, Lib$Put_Output .EXTERNAL OTS$CVT_T_D, OTS$CVT_TZ_L ; Inputs various types of data ; Registers R0 through R7 are saved and restored. They cannot ; be changed by a call to this macro. ; * * * * * * * * * * * .NARG NumArg___ ; *** Check for too many .IF GT NumArg___-1 ; positional arguments .WARN 1 ; Missing argument name in Input macro .PRINT 1 ; Remember to use the format .PRINT 1 ; Input , VariableType = Location .ENDC ; * * * * * * * * * * * BRB Cont ; *** Skip past buffers Message: ; *** Room for buffers .ASCID " " ; 20-character buffer MessageLength___ = . - Message - 8 .BLKB 1 ; allows room for shift PromptBuf: .ASCID "Prompt" TempBuf: .BLKB 8 ; * * * * * * * * * * * Cont: ; *** Initialize PUSHR #^M PUSHAW PromptBuf ; *** Input string PUSHAW Message CALLS #2, G^Lib$Get_Input .IF NB Byte'Word'Long ; *** Convert Integer SKPC #^A" ", #MessageLength___, @Message+4 ; Find leading sign MOVW R0, R6 ; Save remaining bytes MOVL R1, R7 ; Save address of sign CMPB (R1), #^A"-" ; Does it begin with "-"? BEQL HasSign ; then HasSign CMPB (R1), #^A"+" ; Does it begin with "+"? BEQL HasSign ; then HasSign MOVC3 R0, (R1), 1(R1) ; Make room for sign MOVB #^A"+", (R7) ; and insert + sign INCW R6 ; Increment char count HasSign: LOCC #^A" ", R6, (R7) ; Find end of number SUBW R0, R6 ; Find number of bytes DECW R6 ; Find number of digits CVTSP R6, (R7), R6, TempBuf ; Convert to packed CVTPL R6, TempBuf, R0 ; Convert to longword .ENDC .IIF NB, Byte, CVTLB R0, Byte; *** Store Byte .IIF NB, Word, CVTLW R0, Word; *** Store Word .IIF NB, Long, MOVL R0, Long; *** Store Long .IF NB ASCII MOVC5 Message, @Message+4, #^A" ", Length, ASCII .ENDC .IF NB Float ; *** Read floating value PUSHL #1 ; Push flag to ignore blanks PUSHL #0 ; Push scale factor PUSHL #0 ; Push digits in assumed fraction PUSHAQ TempBuf ; Push address of quad buffer PUSHAL Message ; Push address of descriptor CALLS #5, G^OTS$CVT_T_D ; Call conversion routine CVTDF TempBuf, Float ; Convert and store value .ENDC .IF NB Hex ; *** Read hex value into longword PUSHL #1 ; Push flag to ignore blanks PUSHL #4 ; Push number of bytes in value PUSHAL TempBuf ; Push address of temp buffer PUSHAL Message ; Push address descriptor CALLS #4, G^OTS$CVT_TZ_L ; Call conversion routine MOVL TempBuf, Hex ; Store longword .ENDC POPR #^M .ENDM Input ; * * * * * * * * * * * ; * OUTPUT MACRO * ; * * * * * * * * * * * .MACRO Output Label, Byte, Word, Long, Float, - ASCII, Length=#1, Hex, - ?Cont, ?Message, ?TempBuf, ?ValueDesc .EXTERNAL Lib$Put_Output .EXTERNAL FOR$CVT_D_TE, OTS$CVT_L_TZ ; Outputs various types of data ; Registers R0 through R5 are saved and restored. They cannot ; be changed by a call to this macro. ; * * * * * * * * * * * .NARG NumArg___ ; *** Check for too many .IF GT NumArg___-1 ; positional arguments .WARN 2 ; Missing argument name on Output macro .PRINT 2 ; Remember to use the format .PRINT 2 ; Output , VariableType = Location .ENDC ; * * * * * * * * * * * BRB Cont ; *** Skip past buffers .NCHR NumChar___,