.TITLE LGETYN Aleda Get Yes or No Answer. .PSECT Aleda,Gbl,Con .Dsabl GBL .Mcall $List, $Span ;;********************************************************************** ;; Fortran callable subroutine to access the console input device ;; (Alvin unit 0) for a yes or no answer to a question. ;; ;; The user specified prompt (question) is listed first. ;; ;; The provision for returning a BREAK indication is Ierror = 1 with the ;; Return Code = 1. A YES response is Ierror = 2, return code = 2. ;; A NO response is Ierror = 3, return code = 3. Any negative value ;; of Ierror or return code is an Aleda error code. ;; ;; Supports calls of the form: ;; Ierror = LGetYN ( Prompt, [ Return Code ] ) ;;********************************************************************** ;; Last Modified: 7-Aug-84 DVJensen ;; 19-Jul-85 DVJ - Switched to prompting from a static string rather than ;; buffering into the default. ;;********************************************************************** ;; .Mcall $Alv51 .Globl GetYN, PutList, GetParm, PutByte, GetDDA, ResetBuf ;External .Globl Span $Alv51 $Span ;;********************************************************************** LGetYN:: MOV R5,-(SP) ;SAVE REGISTERS USED MOV R4,-(SP) MOV R3,-(SP) MOV R2,-(SP) MOV R1,-(SP) Clr Code ;Initialize Variables Clr RtnAdr ;Fortran Calling Convention: Clr R0 ;Set for counting the parameters MOV (R5)+,R1 ;Get number of parameters passed. BIC #177400,R1 ;Clear possible high order junk Jsr PC,GetParm ;Get Parm # 1: User Prompt string. Bcs GetlError ;Required Parm - Abort if not provided. Mov R4,Prompt ;Get the starting address of the prompt string. Jsr PC,GetParm ;Get Parm # 2: Return Code Location. Bcs Getp5 ;Continue if not available (defaulted above) Mov R4,RtnAdr ;Save the address to return the code to. Getp5: Jsr R5,GetDDA ;Get the Device Descriptor Address. .Word 0 ;Requested unit is default console input device. Tst R0 ;Check if this was a valid unit number Beq GetL1Error ;Branch to error if no desc. Bit #Disabled,(R0) ;Is this device currently enabled? Bne GetEnaErr ;No, invalid device. Bit #Output,Lctl(R0) ;Is this an Output device? Bne GetOutDev ;Yes, branch - Cannot input from it. ; Bit #Seized,(R0) ;Is the Device Seized? (Available?) ; Bne GetSz ;; Jsr R5,GetDDA ;Check the Console list device. .Word 1 ;Requested unit is default console output device. Tst R0 ;Check if this was a valid unit number Beq Getl1Error ;Branch if no device defined. Bit #Disabled,(R0) ;Is the console list device enabled? Bne GetEnaErr ;No, error - branch. Bit #Output,Lctl(R0) ;Is this a valid output device? Beq GetInDev ;No, branch. Br GetSGO ;;**************************** GetL1Err: Mov #20.,R0 ;Error - No device Descriptor. GetLError: ;Error occurred - Code is in R0 Neg R0 ;Force return value negative to indicate error. Mov R0,Code ;Error returns error code and no count. Sec ; and Carry Set. Jmp GetLRtn ;and Return GetEnaErr: Mov #21.,R0 ;Error code #21 - Device not enabled. Br GetLError ;Return error code. GetOutDev: Mov #25.,R0 ;Error code #25 - Device not an input device. Br GetLError ;Return error code. GetInDEV: Mov #26.,R0 ;Error code #26 - Device is not an output device. Br GetLError ;Return error code. ;GetSZ: ; Mov #36.,R0 ;Error code #36 - Device is seized. ; Br GetLError ;Return error code. ;;**************************** ;; GetSGO: Mov R0,R2 ; Save Device Desc of List device. Mov Prompt,R3 ; Get the starting address of the user prompt. Mov R3,-(Sp) ; Push it on the stack - Build a static desc. Add #64.,(SP) ; Assume prompt is at most 64 chars long. Bcc 1$ ; If no carry, then did not wrap. Mov #177777,(sp) ; If carry, then must set end to be mem top. 1$: Mov R3,-(Sp) ; This is the starting address of the string. Mov SP,R3 ; This is the address of the string desc. Mov R3,R4 ; Span wants the descriptor in Reg 4. 2$: Jsr R5,Span ; Now look for a Null .Word 0 ; The string descriptor address is in Reg 4. .Word Return!SStr!Until!0 ; Span until a NULL. Br 3$ ; Not found, list maximum length prompt. Mov R0,2(SP) ; Set the end address of the prompt. 3$: Clr R0 ; Start with R0 = Zero. Jsr R5,GetYN ; Call GetYN to do the actual I/O. .Word 0 ; The prompt string desc. adrress is in R3. Br Break ; Break exit - branch. Inc R0 ; This is the NO exit. Inc R0 ; This is the YES return point. Break: Inc R0 ;Break branches to here. Now we have: ; Break = 1 ; Yes = 2 ; No = 3 Mov R0,Code ; Set the Functional return value. Cmp (SP)+,(SP)+ ; Pop the string descriptor from the stack. Clc ; Not an error, clear Carry. GetLRtn: Mov RtnAdr,R1 ; Did the user include the return code parm? Beq GetLExit ; No, exit. Mov Code,(R1) ; Move return value to return code address. GetLexit: MOV (SP)+,R1 MOV (SP)+,R2 MOV (SP)+,R3 MOV (SP)+,R4 MOV (SP)+,R5 RTS PC ;AND RETURN ;;**************************************************************************** Prompt: .Word 0 ; User Prompt start address. ;; Code: .Word 0 ; Count of characters transmitted to user. RtnAdr: .Word 0 ; Address of User's Location for Return Code. ;; ;;**************************************************************************** .END