Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-10 - 43,50517/dpsub.mac
There are 7 other files named dpsub.mac in the archive. Click here to see a list.
TITLE	DPSUB FOR RPGLIB %1
SUBTTL	DOUBLE-PRECISION INTEGER SUBTRACTION	PETE WILSON/ALB/CAM/RBC

;USED TO BE
;COPYRIGHT 1974, DIGITAL EQUIPMENT CORP., MAYNARD, MA.
;BUT CONVERTED TO RPGII VERSION, 24-NOV-75, BOB CURRIER

	HISEG

;CALLING SEQUENCE:
;	MOVE 16,<Z AC,OPERAND B>
;	PUSHJ 17,SUB.12/SUB.21/SUB.22

;ENTER WITH FIRST OPERAND (OPERAND A) IN ACCUMULATOR SPECIFIED BY AC-FIELD OF PARAMETER
;SECOND OPERAND (OPERAND B) IS ACCESSED VIA AC 16 (WHERE THE UUO IS).
; IF DOUBLE-PRECISION:
;	0(16) GETS HIGH-ORDER WORD, 1(16) REFERENCES LOW HALF.
; IF SINGLE-PRECISION:
;	0(16) REFERENCES SINGLE WORD.
;EXIT WITH TWO-WORD RESULT IN AC'S SPECIFIED BY AC-FIELD OF PARAMETER

	ENTRY	SUB.12	;SUB TWO WORDS IN MEMORY TO ONE WORD IN AC 1.
	ENTRY	SUB.21	;SUB ONE WORD IN MEMORY TO TWO WORDS IN AC'S 0 AND 1.
	ENTRY	SUB.22	;SUB TWO WORDS IN MEMORY TO TWO WORDS IN AC'S 0 AND 1.

RS=11		;RESULT AC POINTER
TA=13		;TEMPORARY
TB=14		;TEMPORARY
TC=15		;TEMPORARY
PA=16		;POINTER TO OPERAND B.
PP=17		;PUSH-DOWN POINTER.

SUB.21:	SKIPGE	0(PA)		;SUB SINGLE TO DOUBLE, CHECK SIGN OF LOW B OPERAND.
	TDZA	TC,TC		;MAKE SIGN OF HIGH-ORDER B OPERAND AGREE
	SETO	TC,		;  WITH LOW-ORDER SIGN.
	SOJA	PA,SUBXX		;THEN ADJUST POINTER AND ENTER MAIN LINE.

SUB.12:	LDB	RS,[POINT 4,PA,12]	;GET INPUT AC
	MOVE	TA,0(RS)	;GET OPERAND
	MULI	TA,1		;CREATE DOUBLE-PRECISION
	SETCM	TC,0(PA)	;GET HI-PART OF OTHER OPERAND
	JRST	SUBXX1

SUB.22:	SETCM	TC,0(PA)	;SUB DOUBLE TO DOUBLE, GET HIGH-ORDER B WORD.

SUBXX:	LDB	RS,[POINT 4,PA,12] ;GET OPERAND AC
	MOVE	TA,0(RS)	;GET OPERAND
	MOVE	TB,1(RS)
SUBXX1:	JFCL	17,.+1		;CLEAR ARITHMETIC FLAGS.
	PUSHJ	PP,CHECK	;BE SURE SIGNS AGREE
	SUB	TB,1(PA)	;SUB LOW-ORDER WORDS.
	JCRY1	CARRYS		;IF A CARRY OCCURRED, GO ADJUST HIGH-ORDER WORD.
SUBXX2:	ADD	TA,TC		;SUB TWO HIGH-ORDER WORDS.
	PUSHJ	PP,CHECK	;BE SURE SIGNS AGREE
	MOVEM	TA,0(RS)	;STASH HI-PART
	MOVEM	TB,1(RS)	;STASH LOW PART
	POPJ	PP,		;RETURN
CHECK:	TLNE	TA,1B18		;MAKE SIGN OF LOW-ORDER PART
	TLOA	TB,1B18		;  AGREE WITH SIGN OF
	TLZ	TB,1B18		;  HIGH-ORDER RESULT.
	POPJ	PP,

;COME HERE ON CARRY GENERATED IN ADDITION OF LOW-ORDER WORDS.
CARRYS:	AOJ	TA,		;ADD CARRY TO HIGH-ORDER HALF.
	PUSHJ	PP,CHECK	;THEN GO CHECK FOR SIGN CHANGE IN HIGH HALF.
	JRST	SUBXX2		;AND GO ADD HIGH-ORDER WORDS.

	END