CVT_ATB         - ASCII NUMBER TO BINARY CONVERSION              22-AUG-1978 04:23:28   VAX-11 MACRO X0.3-11               Page   0

TABLE OF CONTENTS   



   (1)      48  HISTORY			; DETAILED

   (1)      57  DECLARATIONS

CVT_ATB         - ASCII NUMBER TO BINARY CONVERSION              22-AUG-1978 04:23:28   VAX-11 MACRO X0.3-11               Page   1

V0007                                                                                                                            (1)



                                     0000     1 	.TITLE	CVT_ATB - ASCII NUMBER TO BINARY CONVERSION

                                     0000     2 	.IDENT	/V0007/		

                                     0000     3 

                                     0000     4 ;

                                     0000     5 ; COPYRIGHT (C) 1977

                                     0000     6 ; DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS 01754

                                     0000     7 ;

                                     0000     8 ; THIS SOFTWARE IS FURNISHED  UNDER A LICENSE FOR USE ONLY ON A SINGLE

                                     0000     9 ; COMPUTER  SYSTEM AND  MAY BE  COPIED ONLY WITH  THE INCLUSION OF THE

                                     0000    10 ; ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE, OR ANY OTHER COPIES THEREOF,

                                     0000    11 ; MAY NOT BE PROVIDED OR  OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON

                                     0000    12 ; EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO THESE LICENSE

                                     0000    13 ; TERMS.  TITLE TO AND  OWNERSHIP OF THE  SOFTWARE  SHALL AT ALL TIMES

                                     0000    14 ; REMAIN IN DEC.

                                     0000    15 ;

                                     0000    16 ; THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE

                                     0000    17 ; AND SHOULD  NOT BE CONSTRUED  AS A COMMITMENT  BY DIGITAL  EQUIPMENT

                                     0000    18 ; CORPORATION.

                                     0000    19 ;

                                     0000    20 ; DEC ASSUMES  NO  RESPONSIBILITY  FOR  THE USE OR  RELIABILITY OF ITS

                                     0000    21 ; SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

                                     0000    22 

                                     0000    23 ;

                                     0000    24 ; EQUATED SYMBOLS:

                                     0000    25 ;

                           00000004  0000    26 	COUNT	= 4			; COUNT ARG IN ARG LIST

                           00000008  0000    27 	STRING	= 8			; STRING ARG

                           0000000C  0000    28 	RESULT	= 12			; RESULT ADDRESS

                                     0000    29 

                                     0000    30 ;++

                                     0000    31 ;

                                     0000    32 ; FACILITY: SYSTEM LIBRARY

                                     0000    33 ;

                                     0000    34 ; ABSTRACT:

                                     0000    35 ;

                                     0000    36 ;	THIS ROUTINE PERFORMS ASCII INTEGER TO BINARY CONVERSION IN

                                     0000    37 ;	DECIMAL, OCTAL, AND HEX RADIX; RADIX DETERMINED BY ENTRY POINT.

                                     0000    38 ;	AN OPTIONAL LEADING SIGN IS ACCEPTED.

                                     0000    39 ;

                                     0000    40 ; ENVIRONMENT:

                                     0000    41 ;

                                     0000    42 ;	STAR NATIVE MODE PROCESSOR, ANY ACCESS LEVEL. NO SPECIAL

                                     0000    43 ;	INSTRUCTIONS OR SYSTEM SERVICES ARE USED. 9 LONGWORDS OF

                                     0000    44 ;	STACK SPACE NEEDED.

                                     0000    45 ;

                                     0000    46 ;--

                                     0000    47 ;

                                     0000    48 	.SBTTL	HISTORY			; DETAILED

                                     0000    49 ;

                                     0000    50 ; AUTHOR:  ANDREW C. GOLDSTEIN  26-JAN-78  16:48

                                     0000    51 ;

                                     0000    52 ; MODIFIED BY:

                                     0000    53 ;	, : VERSION

                                     0000    54 ; 01	 -

                                     0000    55 

CVT_ATB         - ASCII NUMBER TO BINARY CONVERSION              22-AUG-1978 04:23:28   VAX-11 MACRO X0.3-11               Page   2

V0007           DECLARATIONS                                                                                                     (1)



                                     0000    57 	.SBTTL	DECLARATIONS

                                     0000    58 ;++

                                     0000    59 ;

                                     0000    60 ; FUNCTIONAL DESCRIPTION:

                                     0000    61 ;

                                     0000    62 ; THE ROUTINE WORKS IN THE OBVIOUS MANNER OF ALL CONVERSION ROUTINES:

                                     0000    63 ; IT SCANS THE INPUT STRING AND CONVERTS EACH CHARACTER INTO ITS

                                     0000    64 ; NUMERICAL EQUIVALENT AND CHECKS IT FOR LEGALITY AGAINST THE RADIX.

                                     0000    65 ; THE NUMBER BEING ACCUMULATED IS THEN MULTIPLIED BY THE RADIX AND THE

                                     0000    66 ; NEW DIGIT IS ADDED IN. NON-RADIX CHARACTERS IN THE INPUT STRING CAUSE

                                     0000    67 ; AN ERROR RETURN. A SIGN IN OTHER THAN THE FIRST CHARACTER POSITION

                                     0000    68 ; AND OVERFLOW FROM 32 BITS (UNSIGNED) ALSO CAUSE AN ERROR RETURN.

                                     0000    69 ;

                                     0000    70 ; CALLING SEQUENCE:

                                     0000    71 ;	CALL LIB$CVT_DTB (COUNT,STRING,RESULT)	; CONVERT DECIMAL TO BINARY

                                     0000    72 ;	CALL LIB$CVT_OTB (COUNT,STRING,RESULT)	; CONVERT OCTAL TO BINARY

                                     0000    73 ;	CALL LIB$CVT_HTB (COUNT,STRING,RESULT)	; CONVERT HEX TO BINARY

                                     0000    74 ;

                                     0000    75 ;

                                     0000    76 ; INPUT PARAMETERS:

                                     0000    77 ;	COUNT:	BYTE COUNT OF INPUT STRING

                                     0000    78 ;	STRING:	ADDRESS OF INPUT STRING

                                     0000    79 ;

                                     0000    80 ; IMPLICIT INPUTS:

                                     0000    81 ;	NONE

                                     0000    82 ;

                                     0000    83 ; OUTPUT PARAMETERS:

                                     0000    84 ;	RESULT:	ADDRESS TO STORE LONGWORD RESULT

                                     0000    85 ;

                                     0000    86 ; IMPLICIT OUTPUTS:

                                     0000    87 ;	NONE

                                     0000    88 ;

                                     0000    89 ; COMPLETION CODES:

                                     0000    90 ;	R0 = 1	SUCCESFUL CONVERSION

                                     0000    91 ;	   = 0	ILLEGAL CHARACTER OR ZERO BYTE COUNT

                                     0000    92 ;

                                     0000    93 ; SIDE EFFECTS:

                                     0000    94 ;	NONE

                                     0000    95 ;

                                     0000    96 ;--

                                     0000    97 

                                     0000    98 	.ENABL	LSB

                                     0000    99 

                                 00000000   100 	.PSECT	LIB$CODE,NOWRT,PIC,SHR,LONG

                                     0000   101 ;

                                     0000   102 ; BASE AND VALUE TABLES TO CONVERT DIGITS INTO THEIR NUMERICAL VALUES

                                     0000   103 ;

                           30 41 61  0000   104 BASETAB:	.BYTE	^A'a',    ^A'A',    ^A'0'

                           39 5A 7A  0003   105 TOPTAB:		.BYTE	^A'z',    ^A'Z',    ^A'9'

                           30 37 57  0006   106 VALTAB:		.BYTE	^A'a'-10, ^A'A'-10, ^A'0'-00

                                     0009   107 

                                     0009   108 

                                     0009   109 LIB$CVT_DTB::				; ENTRY FOR DECIMAL CONVERT

                               003C  0009   110 	.WORD	^M<R2,R3,R4,R5>		; SAVE REGISTERS 2-5

            52            0A     D0  000B   111 	MOVL	#10,R2			; R2 = RADIX

                          0C     11  000E   112 	BRB	10$

                                     0010   113 

CVT_ATB         - ASCII NUMBER TO BINARY CONVERSION              22-AUG-1978 04:23:28   VAX-11 MACRO X0.3-11               Page   3

V0007           DECLARATIONS                                                                                                     (1)



                                     0010   114 LIB$CVT_OTB::				; ENTRY FOR OCTAL CONVERT

                               003C  0010   115 	.WORD	^M<R2,R3,R4,R5>		; SAVE REGISTERS 2-5

            52            08     D0  0012   116 	MOVL	#8,R2			; R2 = RADIX

                          05     11  0015   117 	BRB	10$

                                     0017   118 

                                     0017   119 LIB$CVT_HTB::				; ENTRY FOR HEX CONVERT

                               003C  0017   120 	.WORD	^M<R2,R3,R4,R5>		; SAVE REGISTERS 2-5

            52            10     D0  0019   121 	MOVL	#16,R2			; R2 = RADIX

                                     001C   122 

                          50     7C  001C   123 10$:	CLRQ	R0			; ZERO INITIAL NUMBER

                          53     7C  001E   124 	CLRQ	R3			; AND STRING POINTER & SIGN

                          53     D7  0020   125 	DECL	R3			; BACK OFF COUNT

                          40     11  0022   126 	BRB	70$			; AND ENTER PRE-TESTED LOOP

                                     0024   127 

            55         08 BC43   9A  0024   128 20$:	MOVZBL	@STRING(AP)[R3],R5	; GET NEXT CHARACTER

                          53     D5  0029   129 	TSTL	R3			; SEE IF THIS IS FIRST CHARACTER

                          0E     12  002B   130 	BNEQ	30$			; SKIP SIGN CHECK IF NOT

            2B            55     91  002D   131 	CMPB	R5,#^A'+'		; CHECK FOR PLUS

                          32     13  0030   132 	BEQL	70$

            2D            55     91  0032   133 	CMPB	R5,#^A'-'		; CHECK FOR MINUS

                          04     12  0035   134 	BNEQ	30$			; BRANCH IF NOT

                          54     D6  0037   135 	INCL	R4			; SET NEGATIVE FLAG

                          29     11  0039   136 	BRB	70$			; OK - LOOP FOR NEXT CHARACTER

                                     003B   137 

                          51     D4  003B   138 30$:	CLRL	R1			; INIT TABLE INDEX

         BE AF41          55     91  003D   139 40$:	CMPB	R5,BASETAB[R1]		; CHECK DIGIT AGAINST BASE CHARACTER

                          07     1F  0042   140 	BLSSU	50$			; BRANCH IF DIGIT IS LESS

         BA AF41          55     91  0044   141 	CMPB	R5,TOPTAB[R1]		; CHECK DIGIT AGAINST TOP CHARACTER

                          06     1B  0049   142 	BLEQU	60$			; BRANCH IF LESS - VALID

            51            03     F2  004B   143 50$:	AOBLSS	#3,R1,40$		; NOT THIS RANGE - TRY NEXT LOWER BASE

                          EE         004E       

                          26     11  004F   144 	BRB	90$			; NOT A LEGAL DIGIT

                                     0051   145 

            55         B1 AF41   82  0051   146 60$:	SUBB	VALTAB[R1],R5		; COMPUTE NUMERIC VALUE (NOTE - ALWAYS +)

            52            55     D1  0056   147 	CMPL	R5,R2			; CHECK DIGIT AGAINST RADIX

                          1C     1E  0059   148 	BGEQU	90$			; TOUGH LUCK ......

            50            52     7A  005B   149 	EMUL	R2,R0,R5,R0		; SCALE VALUE BY RADIX AND ADD DIGIT

            50            55         005E       

                          51     D5  0060   150 	TSTL	R1			; CHECK FOR OVERFLOW

                          13     12  0062   151 	BNEQ	90$

                                     0064   152 

            53         04 AC     F2  0064   153 70$:	AOBLSS	COUNT(AP),R3,20$	; LOOP FOR DIGITS

                          BB         0068       

                                     0069   154 

            03            54     E9  0069   155 	BLBC	R4,80$			; CHECK SIGN BIT

            50            50     CE  006C   156 	MNEGL	R0,R0			; MAKE NEGATIVE IF DESIRED

         0C BC            50     D0  006F   157 80$:	MOVL	R0,@RESULT(AP)		; STORE RESULT

            50            01     D0  0073   158 	MOVL	#1,R0			; RETURN TRUE

                                 04  0076   159 	RET

                                     0077   160 ;

                                     0077   161 ; TO HERE ON ANY BAD CHARACTER

                                     0077   162 ;

                          50     D4  0077   163 90$:	CLRL	R0			; RETURN FALSE

                                 04  0079   164 	RET

                                     007A   165 

                                     007A   166 	.DSABL	LSB

                                     007A   167 

CVT_ATB         - ASCII NUMBER TO BINARY CONVERSION              22-AUG-1978 04:23:28   VAX-11 MACRO X0.3-11               Page   4

V0007           DECLARATIONS                                                                                                     (1)



                                     007A   168 

                                     007A   169 

                                     007A   170 	.END

CVT_ATB         - ASCII NUMBER TO BINARY CONVERSION              22-AUG-1978 04:23:28   VAX-11 MACRO X0.3-11               Page   5

SYMBOL TABLE                                                                                                                     (1)



BASETAB          00000000 R     02   

COUNT          = 00000004            

LIB$CVT_DTB      00000009 RG    02   

LIB$CVT_HTB      00000017 RG    02   

LIB$CVT_OTB      00000010 RG    02   

RESULT         = 0000000C            

STRING         = 00000008            

TOPTAB           00000003 R     02   

VALTAB           00000006 R     02   





PROGRAM SECTION SYNOPSIS



.  ABS  .        00000000      00     NOPIC   USR   CON   ABS   LCL NOSHR NOEXE NORD  NOWRT BYTE  

. BLANK .        00000000      01     NOPIC   USR   CON   REL   LCL NOSHR   EXE   RD    WRT BYTE  

LIB$CODE         0000007A      02       PIC   USR   CON   REL   LCL   SHR   EXE   RD  NOWRT LONG  





THERE WERE NO ERRORS OR WARNINGS.

28306. BYTES LEFT IN FREE MEMORY POOL.

OBJ$:CVTATB,LIS$:CVTATB/-SP=SRC$:CVTATB

0 MLB DIR RDS - 0 GETS TO DEFINE 0 MACROS. 2 INTER. FILE WRITES. 

