Google
 

Trailing-Edge - PDP-10 Archives - CFS_TSU04_19910205_1of1 - update/cblsrc/gc.mac
There are 16 other files named gc.mac in the archive. Click here to see a list.
; UPD ID= 1344 on 8/2/83 at 4:21 PM by NIXON                            
TITLE	GC FOR LIBOL
SUBTTL	CONVERT COMP-3 TO BINARY	/ACK

	SEARCH COPYRT
	SALL

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.

COPYRIGHT (C) 1974, 1983, 1984 BY DIGITAL EQUIPMENT CORPORATION

;REVISION HISTORY:

;V10 *****

;	15-DEC-74	/ACK	CREATION.
;	15-JAN-86	KWS	Change the return in GC3NEG so it doesn't
;				indirect.

;*****

	SEARCH	LBLPRM		;DEFINE PARAMETERS.
	%%LBLP==:%%LBLP
IFN TOPS20,<SEARCH MACSYM>
IFE TOPS20,<SEARCH MACTEN>

	EXTERN	EASTB.		;FORCE EASTBL TO BE LOADED.

	HISEG
	.COPYRIGHT		;Put standard copyright statement in REL file

COMMENT	\

	THIS ROUTINE CONVERTS A PACKED DECIMAL STRING TO A ONE OR TWO WORD
BINARY NUMBER.

CALL:
	MOVE	16,[Z	AC,PARAMETER ADDRESS]
	PUSHJ	17,GC3.

PARAMETERS:
	THE ACCUMULATOR FIELD OF AC 16 CONTAINS THE AC INTO WHICH THE
FIRST WORD OF THE RESULT IS TO BE PLACED.
	THE RIGHT HALF OF AC 16 POINTS TO A WORD IN THE FOLLOWING FORMAT:
	BITS	0-5	BYTE RESIDUE FOR THE INPUT FIELD.
	BIT	6	1 IF THE FIELD IS EXPLICITLY SIGNED.
	BITS	7-17	SIZE OF THE FIELD.
	BITS	18-35	ADDRESS OF THE FIRST CHARACTER OF THE INPUT FIELD.
	THE INPUT IS A SEQUENCE OF NINE BIT BYTES, EACH CONSISTING OF TWO
FOUR BIT DECIMAL NUMBERS RIGHT JUSTIFIED IN EACH BYTE.

RETURNS:
	CALL+1	ALWAYS.

REGISTERS USED:
	SW, CNT, IPTR, AC, AC+1, AC+2, CH, T1 (ALIAS CH), T2, JAC

\
	ENTRY	GC3.

	EXTERN	SET1.		;ROUTINE TO PICK UP THE PARAMETERS.

	EXTERN	PACFL.		;POINTER TO THE NUMBER OF THE AC INTO
				; WHICH WE ARE TO PLACE THE RESULT.
	EXTERN	RET.1

GC3.:	MOVEI	CH,	^D8		;TELL SET1. THAT WE ARE PLAYING
					; WITH EBCDIC.
	JSP	JAC,	SET1.		;GO PICK UP THE PARAMETERS.

GC:	TRNN	CNT,	1		;IS THE NUMBER OF DIGITS TO BE
					; ODD OR EVEN.
	TLO	SW,	OECNT		;EVEN, REMEMBER THAT.

	CAILE	CNT,	^D10		;ONE OR TWO WORD RESULT?
	JRST		GC1		;TWO WORDS - USE DOUBLE
					; PRECISION ROUTINE.

;HERE WE WORK ON A SINGLE PRECISION RESULT.

	ADDI	CNT,	2		;SEE HOW MANY NINE BIT BYTES WE
	LSH	CNT,	-1		; HAVE.
	PUSHJ	PP,	GC3CSP		;GO CONVERT THE NUMBER.
	JSP	JAC,	GC3NEG		;SEE IF WE HAVE TO NEGATE THE RESULT
	JRST		GDSP1.		;[1154]RETURN TO GET SINGLE PRECISION
					; ROUTINE TO STORE THE RESULT.
;COME HERE IF THE RESULT IS TO BE DOUBLE PRECISION.

GC1:	HRRI	SW,	(CNT)		;SAVE THE COUNT.
	MOVEI	CNT,	5		;SET IT TO 5.
	PUSHJ	PP,	GC3CSP		;GO CONVERT 9 DIGITS.
	IMULI	AC+1,	^D10		;SHIFT THE RESULT ONE DIGIT.
	ADDI	AC+1,	(T1)		;ADD IN THE 9TH DIGIT.
	HRRZI	CNT,	-^D8(SW)	;FIGURE OUT HOW MUCH MORE WE HAVE
	LSH	CNT,	-1		; TO CONVERT.
	SOJE	CNT,	GC2		;ONLY ONE DIGIT?
	JSP	JAC,	GC3G2		;NO, GO GET TWO DIGITS AND MAKE
					; THEM INTO A BINARY NUMBER.
	IMULI	AC,	^D100		;SHIFT THE ACCUMULATION LEFT BY
	MULI	AC+1,	^D100		; TWO DIGITS.
	PUSHJ	PP,	GC3CP		;TAKE CARE OF CROSS PRODUCT AND
					; ADD IN THE TWO DIGITS.
	SOJG	CNT,	GC3G2		;LOOP IF THERE IS MORE THAN ONE
					; DIGIT LEFT.
GC2:	ILDB	T1,	IPTR		;GET THE LAST DIGIT AND THE SIGN.
	LSHC	T1,	-4		;SEPARATE THEM.
	IMULI	AC,	^D10		;SHIFT THE ACCUMULATION LEFT BY
	MULI	AC+1,	^D10		; ONE DIGIT.
	PUSHJ	PP,	GC3CP		;TAKE CARE OF CROSS PRODUCT AND
					; ADD IN THE LAST DIGIT.
	LSHC	T1,	4		;GET THE SIGN BACK.
	ANDI	T1,	17		;ISOLATE IT.
	JSP	JAC,	GC3NEG		;NEGATE THE RESULT?
	JRST		GDDP5.		;[1154]RETURN TO GET DOUBLE PRECISION
					; DISPLAY ROUTINE TO STORE
					; THE RESULT.
;SUBROUTINE TO CONVERT A BCD NUMBER OF 9 OR FEWER DIGITS TO A ONE
; WORD BINARY NUMBER.

COMMENT	\

CALL:
	PUSHJ	PP,GC3CSP

ENTRY CONDITIONS:
	(IPTR)	=	BYTE POINTER TO THE INPUT STRING.
	(CNT)	=	(NUMBER OF DIGITS TO BE CONVERTED + 1) / 2

EXIT CONDITIONS:
	(AC)	=	0
	(AC+1)	=	THE RESULT OF THE CONVERSION
	(T1)	=	THE LAST FOUR BITS OF THE LAST BYTE (IF DOING A
			 SINGLE PRECISION CONVERSION, THIS IS THE SIGN.
			 IF DOING THE FIRST PART OF A DOUBLE PRECISION
			 CONVERSION THIS IS THE TENTH DIGIT.)
	(T1+1)	=	GARBAGE.

RETURNS:
	CALL+1	ALWAYS.

\

GC3CSP:	SETZB	AC,	AC+1		;CLEAR A PLACE TO ACCUMULATE
					; THE RESULT
	TLZE	SW,	OECNT		;ODD OR EVEN NUMBER OF DIGITS?
	JRST		GC3CS8		;EVEN, GO GET THE FIRST ONE.
GC3CS2:	SOJE	CNT,	GC3CS5		;JUMP IF ONLY ONE DIGIT TO CONVERT.
	JSP	JAC,	GC3G2		;GET THE NEXT TWO BCD DIGITS IN BINARY.
	IMULI	AC+1,	^D100		;SHIFT THE ACCULULATION LEFT BY TWO DIGITS.
	ADDI	AC+1,	(T1)		;ADD IN THE TWO DIGITS.
	SOJG	CNT,	GC3G2		;JUMP IF THERE IS MORE THAN ONE
					; DIGIT LEFT.

GC3CS5:	ILDB	T1,	IPTR		;GET THE NEXT DIGIT AND THE SIGN
					; (OR TWO DIGITS.)
	LSHC	T1,	-4		;SEPARATE THEM.
	IMULI	AC+1,	^D10		;SHIFT THE ACCULULATION LEFT
					; BY ONE DIGIT.
	ADDI	AC+1,	(T1)		;ACCUMULATE THE RESULT.
	LSHC	T1,	4		;GET THE SIGN (OR TENTH DIGIT.)
	ANDI	T1,	17		;ISOLATE IT.
	POPJ	PP,			;RETURN.

GC3CS8:	ILDB	AC+1,	IPTR		;GET THE FIRST DIGIT.
	ANDI	AC+1,	17		;GET RID OF ANY JUNK.
	SOJA	CNT,	GC3CS2		;GO CONVERT THE REST.
;SUBROUTINE TO GET TWO BCD DIGITS AND CONVERT THEM TO BINARY.

COMMENT	\

CALLS:
	JSP	JAC,	GC3G2		;THE FIRST TIME.
	SOJG	CNT,	GC3G2		;SUBSEQUENT TIMES.

ENTRY CONDITIONS:
	(IPTR)	=	BYTE POINTER TO THE INPUT STRING.

EXIT CONDITIONS:
	(T1)	=	THE RESULT OF THE CONVERSION.
	(T1+1)	=	GARBAGE.

\

GC3G2:	ILDB	T1,	IPTR		;GET	A*16+B
	LDB	T1+1,	[POINT 4,T1,31]	;GET	A
	LSH	T1+1,	1		;FORM	A*2
	SUBI	T1,	(T1+1)		;FORM	A*16+B-A*2
	LSH	T1+1,	1		;FORM	A*4
	SUBI	T1,	(T1+1)		;FORM	A*16+B-A*2-A*4 = A*10+B
	JRST		(JAC)		;RETURN
;SUBROUTINE TO SEE IF WE HAVE TO NEGATE THE RESULT.

COMMENT	\

CALL:
	JSP	JAC,	GC3NEG

ENTRY CONDITIONS:
	(T1)	=	THE SIGN.

EXIT CONDITIONS:
	(T2)	=	THE AC INTO WHICH THE RESULT IS TO BE PLACED.
	(SW)
		LS	ALWAYS 1
		LM	IF THE SIGN WAS SOME FORM OF "-" THIS IS 1.

RETURNS:
	THIS ROUTINE ALWAYS RETURNS +1.		;[1154]

\

GC3NEG:	TLO	SW,	LS		;TURN ON THE LEADING SIGN FLAG.
	CAIE	T1,	13		;SOME FORM OF "-"?
	CAIN	T1,	15
	TLO	SW,	LM		;YES, REMEMBER IT.
	LDB	T2,	PACFL.		;FIND OUT WHERE TO PUT THE RESULT.
	JRST		(JAC)		;[1154]RETURN THROUGH CALL+1.
;SUBROUTINE USED BY THE DOUBLE PRECISION ROUTINE TO HANDLE THE CROSS
; PRODUCT AND ADDING IN THE DIGIT(S).

COMMENT	\

CALL:
	PUSHJ	PP,	GC3CP

ENTRY CONDITIONS:
	(AC)	=	HIGH ORDER WORD LESS THE CROSS PRODUCT.
	(AC+1)	=	CROSS PRODUCT.
	(AC+2)	=	LOW ORDER WORD.
	(T1)	=	DIGITS TO BE ADDED INTO THE ACCUMULATION.

EXIT CONDITIONS:
	(AC)	=	HIGH ORDER WORD.
	(AC+1)	=	LOW ORDER WORD.

\

GC3CP:	ADD	AC,	AC+1		;ADD IN THE CROSS PRODUCT.
	MOVE	AC+1,	AC+2		;GET THE LOW ORDER WORD.
	JOV		.+1		;CLEAR THE OVERFLOW FLAG.
	ADDI	AC+1,	(T1)		;ADD IN THE DIGIT(S).
	JOV		.+2		;DID WE OVERFLOW?
	POPJ	PP,			;NO, RETURN.
	TLZ	AC+1,	(1B0)		;CLEAR THE SIGN BIT OF THE LOW
					; ORDER WORD.
	AOJA	AC,	.-2		;BUMP THE HIGH ORDER WORD AND
					; RETURN
GDSP1.:	TXNN	SW,SW.SGN
	JRST	GDSP2			;JUMP IF WE CAN'T HAVE A SIGN.
	TLNN	SW,	LS		;LEADING SIGN?
	LSH	SW,	1		;NO, PUT THE IMBEDDED NEGATIVE FLAG
					; WHERE THE LEADING NEGATIVE FLAG WAS.
	TLNE	SW,	LM		;NEGATE RESULTS?
	MOVNS		AC+1		;YES, DO SO.
GDSP2:	MOVEM	AC+1,	(T2)		;STORE RESULTS.
	POPJ	PP,			;RETURN.

GDDP5.:	TXNN	SW,SW.SGN
	JRST	GDDP6			;JUMP IF WE CAN'T HAVE A SIGN.
	TLNN	SW,	LS		;LEADING SIGN?
	LSH	SW,	1		;NO, PUT THE IMBEDDED NEGATIVE SWITCH
					; WHERE THE LEADING NEGATIVE SWITCH WAS.
	TLNN	SW,	LM		;NEGATE?
	JRST		GDDP6		;NO, GO STORE THE RESULTS.
	SETCAM	AC,	(T2)		;NEGATE THE HIGH ORDER WORD AND
					; STORE IT.
	MOVNM	AC+1,	1(T2)		;NEGATE THE LOW ORDER WORD AND
					; STORE IT.
	JUMPN	AC+1,	RET.1		;JUMP IF THE LOW ORDER WORD IS
					; NON-ZERO.
	HRLZI	AC+1,	(1B0)		;GET A SIGN BIT.
	MOVEM	AC+1,	1(T2)		;STORE THE LOW ORDER WORD
	AOSA		(T2)		;BUMP THE HIGH ORDER WORD AND TURN
					; ON THE SIGN IN THE LOW ORDER WORD.
GDDP6:	DMOVEM	AC,	(T2)		;STORE THE RESULT
	POPJ	PP,			;RETURN.

	END