PROCEDURE ,010000 ;+ ; Copyright (C) 1976 ; Digital Equipment Corporation, Maynard, Mass. ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the inclu- ; sion of the above copyright notice. This software, or any ; other copies thereof, may not be provided or otherwise made ; available to any other person except for use on such system ; and to one who agrees to these license terms. Title to and ; ownership of the software shall at all times remain in DEC. ; ; The information in this software is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation. ; ; DEC assumes no responsibility for the use or reliability of its ; software on equipment which is not supplied by DEC. ; ; Written: 08-Feb-80, -1.0.0-, ; ; Modified: ; ; Verified: ;- CODE NUMBR ;+ ; RCNR--relative decimal conversion routine ; ; Inputs: ; ; R3=base value to be augmented. ; ; Outputs: ; ; nonskip return if no number is present. ; ; skip return with R3 updated to new value. ;- RCNR:: MOV R3,-(SP) ; save work registers CALL RCNO ; convert decimal number JMP 40$ ; nonskip return if null BEQ 30$ ; if eq no sign specified ADD (SP),R3 ; augment base value 30$: ADD #4,2(SP) ; set skip return 40$: TST (SP)+ ; pop base value RETURN ; return to caller .SBTTL READ SIGNED DECIMAL NUMBER .enabl lsb ; ; read signed decimal number for command decoder ; non-skip return if none found ; RCNO:: CLR R3 ; clear answer ac CLR -(SP) ; and sign flag RCN1: CALL CCIN ; read character from command line CMPEQ R1,#CR,RCN5 ; leading carriage return? CMPEQ R1,#PD,RCN5 ; leading period? CMPEQ R1,#SEMI,RCN5 ; leading character semicolon? CMPEQ R1,#CMA,50$ ; leading comma? BITB #CHASP,CHATBL(R1) ; is it a spacing character ; (space or tab)? BNE RCN1 ; ne - yes CMPNE R1,#'+,10$ ; not plus sign? INC (SP) ; set plus sign present 10$: CMPNE R1,#'-,20$ ; not minus sign? COM (SP) ; set negate flag 20$: TSTEQ (SP),RCN2 ; sign not specified? RCN3: CALL CCIN ; read another character RCN2: BITB #CHANU,CHATBL(R1) ; is this char a digit? BEQ RCN4 ; eq - no ASL R3 ; multiply by 10. MOV R3,-(SP) ; ASL R3 ; ASL R3 ; ADD (SP)+,R3 ; SUB #60,R1 ; subtract out character bias ADD R1,R3 ; add in digit BR RCN3 ; and loop for more. RCN4: CMPNE R1,#CMA,30$ ; not comma? CALL CCIN ; read next character 30$: TST (SP) ; sign negative? BPL 40$ ; if pl no NEG R3 ; negate number 40$: ADD #4,2(SP) ; set skip return RCN5: MOVB R1,GCSCH ; store break character 50$: TST (SP)+ ; clean stack RETURN ; .dsabl lsb .SBTTL DECPRT -- DECIMAL PRINT ROUTINE DECPRT:: .IF NDF R$$EIS ; if no eis, use $div MOV #12,R1 ; standard decimal print routine CALL $DIV ; divide .IFF ; otherwise, use div MOV R0,R1 ; get number into low order CLR R0 ; clear high order. DIV #12,R0 ; divide by 10. .ENDC ; r$$eis MOV R1,-(SP) TSTEQ R0,10$ ; no more digits to convert? CALL DECPRT ; no 10$: MOV (SP)+,R1 ; get a digit ADD #'0,R1 ; make ascii digit JMP FOUT ; output to file. .SBTTL DECPR -- TOC OUTPUT ROUTINE DECPR:: .IF NDF R$$EIS ; if no eis, use $div MOV #12,R1 ; standard decimal print routine CALL $DIV ; divide .IFF ; otherwise, use div MOV R0,R1 ; move into low order of pair CLR R0 ; clear high order DIV #12,R0 ; divide by 10. .ENDC ; r$$eis MOV R1,-(SP) ; TSTEQ R0,1$ ; any left to divide ? CALL DECPR ; no 1$: MOV (SP)+,R1 ; get the digit ADD #60,R1 ; make ascii digit JMP TFOUT ; output to file .END