MACFLM	MACRO M1110  22-AUG-78 01:24  PAGE 2





      1					;

      2					; PREFIX FILE FOR DECIMAL VERSION NUMBERS

      3					;

      4		000001 				R$$DVN=1

CBTA	MACRO M1110  22-AUG-78 01:24  PAGE 3





      1						.TITLE	CBTA

      2						.IDENT	/04.3/

      3					                                                                                ;**-1

      4					;

      5					; COPYRIGHT (C) 1975, 1977

      6					; DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.

      7					;

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

      9					; SINGLE COMPUTER SYSTEM AND MAY  BE  COPIED   ONLY  WITH  THE

     10					; INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE,  OR

     11					; ANY OTHER COPIES THEREOF, MAY NOT BE PROVIDED  OR  OTHERWISE

     12					; MADE AVAILABLE TO ANY OTHER PERSON   EXCEPT FOR  USE ON SUCH

     13					; SYSTEM AND TO ONE WHO AGREES TO THESE LICENSE  TERMS.  TITLE

     14					; TO AND OWNERSHIP OF THE SOFTWARE SHALL AT ALL  TIMES  REMAIN

     15					; IN DEC.

     16					;

     17					; THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT

     18					; NOTICE AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL

     19					; EQUIPMENT CORPORATION.

     20					;

     21					; DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF

     22					; ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.

     23					;

     24					; VERSION 04.3

     25					;                                                                               ;**-1

     26					; D. N. CUTLER/C. MONIA 06-APR-74

     27					;                                                                               ;**NEW**

     28					; MODIFICATIONS:                                                                ;**NEW**

     29					;                                                                               ;**NEW**

     30					; NO.		DATE		PROGRAMMER                                      ;**NEW**

     31					; ---		----		----------                                      ;**NEW**

     32					;                                                                               ;**NEW**

     33					; 030		07-JAN-75	C. MONIA                                        ;**NEW**

     34					; 044		10-DEC-75	C. MONIA

     35					; EB067		24-JUL-77	E. BAATZ

     36					;		22-SEP-77	A. GOLDSTEIN

     37					; 050		15-DEC-77	E. MARISON

     38					;

     39					; BINARY TO ASCII CONVERSION

     40					;

     41					; LOCAL MACROS

     42					;

     43					; SETUP CONVERSION CONTROL WORD ON STACK

     44					;

     45					; STCVT	RADIX,WIDTH,SIGNED,COMPR,BLANKS

     46					;

     47					; WHERE:

     48					;

     49					;	RADIX=NUMERIC VALUE SPECIFYING CONVERSION RADIX

     50					;	WIDTH=NUMERIC VALUE FROM 1 TO 7 SPECIFYING FIELD WIDTH

     51					;	SIGNED=SIGN OR MAGNITUDE FLAG. ASCII STRING 'SIGN' SPECI-

     52					;	       FIES SIGNED CONVERSION. ANYTHING ELSE SPECIFIES MAGNI-

     53					;	       TUDE.

     54					;

     55					;	COMPR=COMPRESS LEADING ZEROS FLAG. ASCII STRING 'COMPRES' SPE-

     56					;	     CIFIES COMPRESSION OF LEADING ZEROS. ANYTHING ELSE MEANS

     57					;	     INCLUDE LEADING ZEROS OR SPACES IN CONVERSION.

CBTA	MACRO M1110  22-AUG-78 01:24  PAGE 3-1





     58					;

     59					;	BLANK=REPLACE LEADING ZEROS WITH BLANKS (SPACES). ASCII STRING

     60					;	       'BLANKS' MEANS BLANK REPLACEMENT IF ZERO COMPRESS IS DIS-

     61					;	        ABLED. ANYTHING ELSE SPECIFIES ZERO PADDING

     62					;

     63

     64						.MACRO	STCVT	RADIX,WIDTH,SIGN,COMPR,BLANK

     65					$$$BLK=0

     66					$$$SGN=0

     67					$$$SUP=1*1000

     68						.IF IDN	<BLANK>,<BLANKS>

     69					$$$BLK=1*2000

     70						.ENDC

     71						.IF IDN	<SIGN>,<SIGNED>

     72					$$$SGN=1*400

     73						.ENDC

     74						.IF IDN	<COMPR>,<COMPRES>

     75					$$$SUP=0*1000

     76						.ENDC

     77						MOV	#<WIDTH*4000>!$$$BLK!$$$SGN!$$$SUP!RADIX,-(SP)

     78						.ENDM

     79

     80					; ++50

     81						.IIF	NDF,R$$DVN,R$$DVN=0	; 0 = OCTAL VERSION #

     82										; 1 = DECIMAL VERSION #

     83					; ++50

     84					;+

     85					; **-$CBDAT-CONVERT DATE TO TWO DIGIT DECIMAL MAGNITUDE

     86					; **-$CBDMG-CONVERT BINARY TO DECIMAL MAGNITUDE

     87					; **-$CBDSG-CONVERT BINARY TO DECIMAL SIGNED

     88					; **-$CBOMG-CONVERT BINARY TO OCTAL MAGNITUDE

     89					; **-$CBVER-CONVERT BINARY TO VERSION NUMBER RADIX (R$$DVN=0 OCTAL,R$$DVN=1 DECIMAL)

     90					; **-$CBTA-GENERAL PURPOSE BINARY TO ASCII CONVERSION

     91					; **-$CBOSG-CONVERT BINARY TO OCTAL SIGNED

     92					; **-$CBTMG-CONVERT BINARY BYTE TO OCTAL MAGNITUDE

     93					;

     94					; INPUTS:

     95					;

     96					;	R0=ADDRESS TO STORE FIRST BYTE IN OUTPUT STRING.

     97					;	R1=NUMBER TO BE CONVERTED.

     98					;	R2=ZERO SUPPRESSION INDICATOR.

     99					;		IF R2 EQ 0, THEN SUPPRESS ZEROS.

    100					;		IF R2 NE 0, THEN DO NOT SUPPRESS ZEROS.

    101					;

    102					; IF $CBTA IS CALLED THEN R2 MUST CONTAIN THE FOLLOWING INFORMATION

    103					;

    104					;	LOW BYTE=CONVERSION RADIX (2-10.)

    105					;	BIT 8=MAGNITUDE/SIGNED CONVERSION (1=SIGNED)

    106					;

    107					;	BIT 9=ZERO COMPRESS FLAG (0=COMPRESS LEADING ZEROS)

    108					;

    109					;	BIT 10=BLANK FILL FLAG (1=REPLACE LEADING ZEROS WITH BLANKS

    110					;	       IF ZERO COMPRESS DISABLED, 0=ZERO FILL).

    111					;

    112					;	BITS 11-15=FIELD WIDTH (1-32)

    113					;

    114					;

CBTA	MACRO M1110  22-AUG-78 01:24  PAGE 3-2





    115					; OUTPUTS:

    116					;

    117					;	R0=ADDRESS OF NEXT BYTE AFTER LAST DIGIT STORED.

    118					;

    119					;	IF THE CONVERTED DIGIT EXCEEDS 9, THE RESULT IS BIASED TO FALL

    120					;	IN THE RANGE  A - Z

    121					;

    122					;-

    123

    124					;

    125					; CONVERT TWO-DIGIT DATE TO ASCII

    126					;

    127

    128						.ENABL	LSB

    129

    130	000000				$CBDAT::			;

    131	000000					STCVT	10.,2.,MAGN,NOCOMP,NOBLANK ; PUSH CONVERSION PARAMETERS

    132	000004	000420 				BR	10$		; CONVERT NUMBER

    133

    134					;

    135					; CONVERT 5-DIGIT UNSIGNED DECIMAL TO ASCII

    136					;

    137

    138						.IF	EQ,R$$DVN-1		; ++50

    139	000006				$CBVER::			; ++50

    140						.ENDC				; ++50

    141	000006				$CBDMG::			;

    142	000006					STCVT	10.,5.,MAGN,NOCOMP,NOBLANK ; PUSH CONVERSION PARAMETERS

    143	000012	000415 				BR	10$		; CONVERT TO ASCII

    144

    145					;

    146					; CONVERT 5-DIGIT SIGNED DECIMAL TO ASCII

    147					;

    148

    149	000014				$CBDSG::			;

    150	000014					STCVT	10.,5.,SIGNED,NOCOMP,NOBLANK ; PUSH CONVERSION PARAMETERS

    151	000020	000412 				BR	10$		;

    152

    153					;

    154					; CONVERT BINARY TO OCTAL MAGNITUDE

    155					;

    156

    157						.IF	EQ,R$$DVN		; ++50

    158					$CBVER::			; ++50

    159						.ENDC				; ++50

    160	000022				$CBOMG::			;

    161	000022					STCVT	8.,6.,MAGN,NOCOMP,NOBLANK ; PUSH CONVERSION PARAMETERS

    162	000026	000407 				BR	10$		; CONVERT TO ASCII

    163

    164					;

    165					; CONVERT BINARY TO OCTAL SIGNED

    166					;

    167

    168	000030				$CBOSG::			;

    169	000030					STCVT	8.,6.,SIGNED,NOCOMP,NOBLANK ; PUSH CONVERSION PARAMETERS

    170	000034	000404 				BR	10$		; CONVERT TO ASCII

    171

CBTA	MACRO M1110  22-AUG-78 01:24  PAGE 3-3





    172					;

    173					; CONVERT BINARY BYTE TO OCTAL MAGNITUDE

    174					;

    175

    176	000036				$CBTMG::			;

    177	000036	042701 	177400 			BIC	#177400,R1	; ENSURE THAT HIGH BYTE IS CLEAR

    178	000042					STCVT	8.,3.,MAGN,NOCOMP,NOBLANK ; PUSH CONVERSION PARAMETERS

    179

    180					;

    181					; SET OR CLEAR ZERO SUPPRESS FLAG

    182					;

    183

    184	000046				10$:				;

    185	000046	005702 				TST	R2		; SUPPRESS ZEROS?

    186	000050	001002 				BNE	20$		; IF NE NO

    187	000052	042716 	001000 			BIC	#1*1000,(SP)	; ENABLE ZERO SUPPRESS

    188	000056				20$:				;

    189	000056	012602 				MOV	(SP)+,R2	; SET CONTROL WORD

    190

    191						.DSABL	LSB

    192

    193					;

    194					; GENERAL BINARY TO ASCII CONVERSION

    195					;

    196

    197

    198	000060				$CBTA::				;

    199	000060					SAVRG			; SAVE THE NON-VOLATILE REGISTERS

    200	000064	110205 				MOVB	R2,R5		; COPY RADIX BYTE

    201	000066	105002 				CLRB	R2		; CLEAR BITS THAT SHIFT INTO FIELD WIDTH	; EB067

    202	000070	000302 				SWAB	R2		; POSITION REMAINING DATA TO LOW BYTE

    203	000072	006202 				ASR	R2		; SHIFT OFF MAGNITUDE FLAG			; EB067

    204	000074	103005 				BCC	10$		; IF C/C UNSIGNED CONVERSION			;**-1

    205	000076	005701 				TST	R1		; POSITIVE VALUE?

    206	000100	100003 				BPL	10$		; IF PL YES

    207	000102	005401 				NEG	R1		; MAKE VALUE POSITIVE

    208	000104	112720 	000055 			MOVB	#'-,(R0)+	; INSERT A MINUS SIGN

    209	000110				10$:				;

    210	000110	010004 				MOV	R0,R4		; COPY STRING POINTER

    211	000112	006002 				ROR	R2		; SHIFT OFF SUPPRESS FLAG			; EB067

    212	000114	006002 				ROR	R2		; TRANSFER TO R2				;**-2

    213	000116	006003 				ROR	R3		; GET BLANK/ZERO PAD FLAG

    214	000120	105003 				CLRB	R3		; CLEAR COUNT BYTE

    215	000122	150203 				BISB	R2,R3		; TRANSFER COUNT BYTE

    216	000124	105002 				CLRB	R2		; CLEAR FILL BYTE

    217	000126	152702 	000060 			BISB	#'0,R2		; SET FILL BYTE

    218	000132	010100 				MOV	R1,R0		;DIVIDEND TO R0

    219

    220

    221						.IF	DF	V1145

    222

    223					1$:	MOV	R0,R1		;DIVIDEND TO R1

    224						CLR	R0		;CLEAR HIGH PART

    225						DIV	R5,R0		;DIVIDE EM UP

    226

    227						.ENDC

    228

CBTA	MACRO M1110  22-AUG-78 01:24  PAGE 3-4





    229

    230						.IF	NDF	V1145

    231

    232	000134	010501 			1$:	MOV	R5,R1		;SET CONVERSION RADIX

    233	000136					CALL	$DIV		;DIVIDE EM UP

    234

    235						.ENDC

    236

    237

    238	000142	020127 	000011 			CMP	R1,#9.		; RESULT EXCEED NUMERICS?

    239	000146	101402 				BLOS	15$		; IF LOS NO

    240	000150	062701 	000007 			ADD	#7,R1		; BIAS TO FALL IN U/C ALPHABETIC

    241	000154				15$:				;

    242	000154	060201 				ADD	R2,R1		; ADD CHARACTER BIAS

    243	000156	010146 				MOV	R1,-(SP)	; SAVE CHARACTER

    244	000160	105303 				DECB	R3		; DECREMENT CHARACTER COUNT

    245	000162	003412 				BLE	3$		; IF LE NO DIGITS LEFT

    246	000164	005700 				TST	R0		; ZERO QUOTIENT

    247	000166	001006 				BNE	2$		; IF NE YES, GO AGAIN

    248	000170	005702 				TST	R2		; SUPPRESS ZEROS

    249	000172	100006 				BPL	3$		; IF PL YES, ALL DONE

    250	000174	005703 				TST	R3		; SUBSTITUTE BLANKS?

    251	000176	100002 				BPL	2$		; IF PL NO

    252	000200	042702 	000020 			BIC	#20,R2		; CONVERT FILL TO BLANK

    253	000204				2$:	CALL	1$		;DIVIDE AGAIN

    254	000210				3$:				;

    255	000210	112624 				MOVB	(SP)+,(R4)+	;STORE A DIGIT

    256	000212	010400 				MOV	R4,R0		;STORE TERMINAL ADDRESS

    257	000214					RETURN			;

    258

    259		000001 				.END

CBTA	MACRO M1110  22-AUG-78 01:24  PAGE 3-5

SYMBOL TABLE



CR    = 000015   	R$$11M= 000000   	$CBDSG  000014RG 	$CBTMG  000036RG 	$$    = 000001

FF    = 000014   	SPA   = 000040   	$CBOMG  000022RG 	$CBVER  000006RG 	$$$BLK= 000000

HT    = 000011   	VT    = 000013   	$CBOSG  000030RG 	$DIV  = ****** GX	$$$SGN= 000000

LF    = 000012   	$CBDAT  000000RG 	$CBTA   000060RG 	$SAVRG= ****** GX	$$$SUP= 001000

R$$DVN= 000001   	$CBDMG  000006RG



. ABS.	000000	   000

      	000216	   001

ERRORS DETECTED:  0



VIRTUAL MEMORY USED:  842 WORDS  ( 4 PAGES)

DYNAMIC MEMORY:  2772 WORDS  ( 10 PAGES)

ELAPSED TIME:  00:00:08

OBJ$:CBTA,LIS$:CBTA/-SP=SRC$:MACFLM,DECVER,CBTA

