Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-06 - decus/20-153/pc.mac
There are 10 other files named pc.mac in the archive. Click here to see a list.
TITLE	PC FOR LIBOL V10 AND RPGLIB V1.
SUBTTL	CONVERT BINARY TO COMP-3	15-DEC-74	/ACK

;COPYRIGHT 1974, 1975, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
;ALL RPGII MODIFICATIONS COPYRIGHT 1976, BOB CURRIER AND CERRITOS COLLEGE

;REVISION HISTORY:

;V10 *****

;	15-DEC-74	/ACK	CREATION.

;*****

	SEARCH	RPGPRM		;DEFINE PARAMETERS.
	%%LBLP==:%%LBLP

	EXTERN	EASTB.		;FORCE EASTBL TO BE LOADED.

	HISEG

COMMENT	\

	THIS ROUTINE CONVERTS A ONE OR TWO WORD BINARY NUMBER TO A
COMP-3 ITEM.

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

PARAMETERS:
	THE ACCUMULATOR FIELD OF AC 16 CONTAINS THE AC WHICH CONTAINS THE
FIRST WORD OF THE NUMBER TO BE CONVERTED.  THE SECOND WORD, IF ANY, IS IN
THE FOLLOWING AC.
	THE RIGHT HALF OF AC 16 POINTS TO A WORD IN THE FOLLOWING FORMAT:
	BITS	0-5	BYTE RESIDUE FOR THE OUTPUT FIELD.
	BIT	6	1 IF THE FIELD IS EXPLICITLY SIGNED.
	BITS	7-17	SIZE OF THE OUTPUT FIELD.
	BITS	18-35	ADDRESS OF THE FIRST BYTE OF THE OUTPUT FIELD.
	THE OUTPUT IS A SEQUENCE OF NINE BIT BYTES EACH OF WHICH,EXCEPT
THE LAST, CONSISTS OF TWO FOUR BIT DECIMAL DIGITS, RIGHT JUSTIFIED IN EACH
BYTE.  THE LAST BYTE CONSTISTS OF A DECIMAL DIGIT IN BITS 1 THROUGH 4 AND 
A SIGN IN BITS 5 THROUGH 8.

RETURNS:
	CALL+1	ALWAYS.

REGISTERS USED:
	JAC, AC, AC+1, AC+2, CNT, SAV9, SW, IPTR

\
;LOCAL AC DEFINITIONS.

	SAV9==TAC2
	OPTR==IPTR

	ENTRY	PC3.

	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.

PC3.:	MOVEI	CH,	^D8		;TELL SET1. THAT WE ARE PLAYING
					; WITH EBCDIC.
	JSP	JAC,	SET1.		;GO PICK UP THE PARAMETERS.
	LDB	AC+2,	PACFL.		;FIND OUT WHERE THE INPUT IS.
	MOVE	AC+1,	(AC+2)		;PICK IT UP.
	MOVE	AC+2,	1(AC+2)		;(JUST IN CASE IT'S DOUBLE PRECISION.)

	JUMPL	AC+1,	PC4		;JUMP IF THE INPUT IS NEGATIVE.
	CAIG	CNT,	^D10		;ONE WORD?
	JRST		PC3		;YES, GO TO SINGLE PRECISION ROUTINE.

;HERE WE CONVERT A TWO WORD BINARY NUMBER TO COMP-3.

PC1:	DIV	AC+1,	PC3T1+5		;BREAK OFF NINE DIGITS.
	MOVE	SAV9,	AC+2		;SAVE THEM.
	IDIVI	AC+1,	^D10		;GET THE TENTH DIGIT.
	HRRI	SW,	(AC+2)		;SAVE IT.
	MOVEI	CNT,	-^D10(CNT)	;FIGURE OUT HOW MANY CHARS TO CONVERT.
	JSP	JAC,	PC3CVT		;GO CONVERT THEM.
	ORI	AC+1,	(SW)		;COMBINE THE ELEVENTH AND TENTH DIGITS.
	DPB	AC+1,	OPTR		;STORE THEM.
	MOVE	AC+1,	SAV9		;GET THE OTHER NINE DIGITS BACK.
	SKIPA	CNT,	[EXP ^D9]		;SET THE COUNT.

;WE COME HERE TO CONVERT A SINGLE PRECISION NEGATIVE NUMBER.

PC2:	MOVMS		AC+1		;MAKE IT POSITIVE.

;WE COME HERE TO CONVERT A SINGLE PRECISION POSITIVE NUMBER.

PC3:	JSP	JAC,	PC3CVT		;CONVERT THE DIGITS.
	ORI	AC+1,	17		;ASSUME THE RESULT IS UNSIGNED.
	JUMPGE	SW,	PC3A		;JUMP IF IT IS.
	TLNN	SW,	LS!LM		;WAS THE INPUT NEGATIVE?
	TRZA	AC+1,	3		;NO, MAKE THE SIGN 14.
	TRZ	AC+1,	2		;YES, SIGN BECOMES 15.
PC3A:	DPB	AC+1,	OPTR		;STORE THE FIRST DIGIT AND THE SIGN.
	POPJ	PP,			;RETURN.
;WE COME HERE IF THE INPUT IS NEGATIVE.

PC4:	TLO	SW,	LS!LM		;TURN ON THE NEGATIVE SIGN SWITCHES.
	CAIG	CNT,	^D10		;ONE WORD?
	JRST		PC2		;YES, GO MAKE THE INPUT POSITIVE.

	SETCA	AC+1,	AC+1		;NEGATE THE HIGH ORDER WORD.
	MOVNS		AC+2		;NEGATE THE LOW ORDER WORD.
	TLZ	AC+2,	(1B0)		;CLEAR THE SIGN OF THE LOW ORDER WORD.
	JUMPN	AC+2,	PC1		;IF THE LOW ORDER WORD IS NOT
					; ZERO, GO START CONVERTING.
	AOJA	AC+1,	PC1		;OTHERWISE BUMP THE HIGH ORDER
					; WORD AND GO START CONVERTING.
;SUBROUTINE TO CONVERT A BINARY NUMBER TO PACKED DECIMAL.

COMMENT	\

CALL:
	JSP	JAC,	PC3CVT

ENTRY CONDITIONS:
	(AC+1)	=	THE NUMBER TO BE CONVERTED.
	(CNT)	=	NUMBER OF DIGITS TO BE CONVERTED

EXIT CONDITIONS:
	(AC)	=	THE LAST DIGIT STORED IN BITS 32-35.
	(AC+1)	=	THE LAST DIGIT STORED IN BITS 28-31.
	(AC+2)	=	0
	(CNT)	=	0

RETURNS:
	CALL+1	ALWAYS.

\

PC3CVT:	IDIV	AC+1,	DECTAB##(CNT)	;MAKE SURE THE NUMBER IS IN RANGE.
	ADDI	CNT,	2		;SEE HOW MANY NINE BIT BYTES WE
	LSH	CNT,	-1		; HAVE.
PC3CV1:	MOVE	AC,	AC+2		;GET THE REMAINING DIGITS.
	IDIV	AC,	PC3T2-1(CNT)	;GET THE NTH DIGIT.
	IDIV	AC+1,	PC3T1-1(CNT)	;GET THE N+1ST DIGIT.
	DPB	AC,	[POINT 4,AC+1,31]	;COMBINE THEM.
	IDPB	AC+1,	OPTR		;STORE THEM.
	SOJG	CNT,	PC3CV1		;LOOP IF THERE ARE MORE.
	JRST		(JAC)		;OTHERWISE RETURN.
	SUBTTL	TABLES.

PC3T1:	DEC	1
	DEC	10
	DEC	1000
	DEC	100000
	DEC	10000000
	DEC	1000000000

PC3T2:	DEC	1
	DEC	100
	DEC	10000
	DEC	1000000
	DEC	100000000
	DEC	10000000000

	END