.MCALL .MODULE .MODULE CATB,VERSION=01,COMMENT= ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion 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 Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .ENABL GBL,LC .SBTTL Macro and data definitions .MCALL DEFIN$ DEFIN$ ;Definitions for IND files .PSECT $CATB .SBTTL $CDTB and $COTB - Convert decimal/octal to binary ;+ ;$CDTB - Convert decimal to binary ;$COTB - Convert octal to binary ; ; Input: R0 = Address of next character in input buffer. ; ; Output: R0 = address of next character in input buffer. ; R1 = converted number ; ; If carry gets set the number is too large. Leave the routine with ; c-bit set for caller to handle. ;- .ENABL LSB $CDTB:: MOV #10.,R2 ;Set base 10. conversion radix BR COTB ;Branch to common routine $COTB:: MOV #8.,R2 ;Set base 8. conversion radix COTB: JSR R5,$SAVRG ;Save non-volaitle registers CLR R1 ;Clear accumulated value 1$: MOVB (R0)+,R5 ;Get next byte CMPB #,R5 ;Blank? BEQ 1$ ;If eq yes - skip it CMPB #,R5 ;Horizontal tab? BEQ 1$ ;Yes, ignore it 2$: SUB #,R5 ;Subtract character bias CMPB R5,R2 ;Check against base BHIS 3$ ;Out of range MOV R0,R4 ;Save string pointer MOV R2,R0 ;Set multiplicand CALL $MUL ;Multiply em up TST R0 ;Anything returned in the high order word? BNE 4$ ;Yes posible error MOV R4,R0 ;Restore pointer ADD R5,R1 ;Accumulate result BCS 4$ ;Overflow, exit routine with c-bit set MOVB (R0)+,R5 ;Fetch next character BR 2$ ;Check if end 3$: MOVB -1(R0),R2 ;Get terminal character BR 5$ ;Return 4$: MOVB (R4)+,R5 ;Get next character SUB #,R5 ;Subtract character bias CMPB R5,R2 ;Check against base BLO 4$ ;Still more MOVB -(R4),R2 ;Get terminating character SEC ;Set c-bit for error 5$: RETURN .DSABL LSB .END