Google
 

Trailing-Edge - PDP-10 Archives - BB-H506D-SM_1983 - cobol/source/pnz.mac
There are 7 other files named pnz.mac in the archive. Click here to see a list.
TITLE	PNZ FOR LIBOL.
SUBTTL	DETERMINE IF A STRING IS POSITIVE, NEGATIVE OR ZERO	/ACK



;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, 1981 BY DIGITAL EQUIPMENT CORPORATION

;REVISION HISTORY:

;V10 *****

;	28-JAN-76	[424] FIX ZERO
;	19-DEC-74	/ACK	CREATION.

;	5/15/75		/DBT/	BIS
;*****

	SEARCH	LBLPRM		;DEFINE PARAMETERS.
	%%LBLP==:%%LBLP
	EBCMP.==:EBCMP.
	BIS==:BIS

	EXTERN	EASTB.		;FORCE EASTBL TO BE LOADED.

	HISEG

COMMENT	\

	THIS ROUTINE IS USED TO DETERMINE IF A STRING IS POSITIVE OR
IF A STRING IS NEGATIVE OR IF A STRING IS ZERO.

CALL:
	MOVEI	16,PARAMETER ADDRESS
	PUSHJ	17,POS.6/POS.7/POS.9/NEG.6/NEG.7/NEG.9/ZERO.6/ZERO.7/ZERO.9

PARAMETERS:
	BITS	0-5	BYTE POINTER RESIDUE FOR INPUT FIELD.
	BIT	6	1 IF AN OPERATIONAL SIGN IS PRESENT.
	BITS	7-17	SIZE OF THE INPUT FIELD.
	BITS	18-35	ADDRESS OF THE FIRST CHARACTER OF THE INPUT FIELD.


RETURNS:
	CALL+1	IF THE TEST FAILS.
	CALL+2	IF THE TEST SUCCEEDS.

REGISTERS USED:
	CH, T1 (ALIAS CH), T2, SW, JAC, PARM, CNT

\
IFE	BIS,<

;LOCAL AC DEFINITIONS:

	CPTR==PARM		;SO WE CAN USE GDSKP.


;THE POSITIVE TEST:

	ENTRY	POS.6		;IF THE INPUT IS SIXBIT.
	ENTRY	POS.7		;IF THE INPUT IS ASCII.
IFN EBCMP.,<
	ENTRY	POS.9		;IF THE INPUT IS EBCDIC.
>

POS.6:	JSP	CH,	POS		;ENTER HERE IF THE INPUT IS SIXBIT,
POS.7:	JSP	CH,	POS		; HERE IF IT IS ASCII AND
IFN EBCMP.,<
POS.9:	JSP	CH,	POS		; HERE IF IT IS EBCDIC.
>

POS:	SUBI	CH,	POS.6-5		;GET THE INPUT BYTE SIZE.
	JSP	T2,	PNZ		;GO SEE WHAT THE INPUT IS LIKE.
	AOSA		(PP)		;POSITIVE - SKIP RETURN.
	JUMPGE	SW,	RET.2		;NEGATIVE - BUT IT MAY STILL BE
					; POSITIVE, JUMP IF IT CAN'T 
					; HAVE A SIGN.
	POPJ	PP,			;ZERO RETURN.




;THE NEGATIVE TEST:

	ENTRY	NEG.6		;IF THE INPUT IS SIXBIT.
	ENTRY	NEG.7		;IF THE INPUT IS ASCII.
IFN EBCMP.,<
	ENTRY	NEG.9		;IF THE INPUT IS EBCDIC.
>

NEG.6:	JSP	CH,	NEG		;ENTER HERE IF THE INPUT IS SIXBIT,
NEG.7:	JSP	CH,	NEG		; HERE IF IT IS ASCII AND
IFN EBCMP.,<
NEG.9:	JSP	CH,	NEG		; HERE IF IT IS EBCDIC.
>

NEG:	SUBI	CH,	NEG.6-5		;GET THE INPUT BYTE SIZE.
	JSP	JAC,	SET1.		;GO PICK UP THE PARAMETERS.
	JUMPGE	SW,	RET.1		;JUMP IF WE CAN'T HAVE A SIGN.
	JSP	T2,	PNZ0		;GO SEE WHAT THE INPUT IS LIKE.
	POPJ	PP,			;POSITIVE - NON-SKIP RETURN.
	AOS		(PP)		;NEGATIVE - SKIP RETURN.
	POPJ	PP,			;ZERO - NON-SKIP RETURN.
;THE ZERO TEST:

	ENTRY	ZERO.6		;IF THE INPUT IS SIXBIT.
	ENTRY	ZERO.7		;IF THE INPUT IS ASCII.
IFN EBCMP.,<
	ENTRY	ZERO.9		;IF THE INPUT IS EBCDIC.
>

ZERO.6:	JSP	CH,	ZERO		;ENTER HERE IF THE INPUT IS SIXBIT,
ZERO.7:	JSP	CH,	ZERO		; HERE IF IT IS ASCII AND
IFN EBCMP.,<
ZERO.9:	JSP	CH,	ZERO		; HERE IF IT IS EBCDIC.
>

ZERO:	SUBI	CH,	ZERO.6-5	;GET THE INPUT BYTE SIZE.
	JSP	T2,	PNZ		;GO SEE WHAT THE INPUT IS LIKE.
	POPJ	PP,			;POSITIVE - NON-SKIP RETURN.
	POPJ	PP,			;NEGATIVE - NON-SKIP RETURN.
	AOS		(PP)		;ZERO - SKIP RETURN.
	POPJ	PP,
	SUBTTL	DETERMINE WHETHER A STRING IS POSITIVE, NEGATIVE OR ZERO.

COMMENT	\

	THIS SUBROUTINE DETERMINES WHETHER A STIRING IS POSITIVE, NEGATIVE
OR ZERO.

CALL:
	JSP	T2,	PNZ
OR	JSP	T2,	PNZ0

PARAMETERS:
  IF ENTERING AT PNZ:
	(CH)	A CODE DESCRIBING THE INPUT:
			6 ==: SIXBIT.
			7 ==: ASCII.
			8 ==: EBCDIC.
  IF ENTERING AT PNZ0:
	(SW)	RH:	A CODE DESCRIBING THE INPUT:
			6 ==: SIXBIT.
			7 ==: ASCII.
			8 ==: EBCDIC.
	(CNT)	THE SIZE OF THE INPUT STRING.
	(IPTR)	THE POINTER TO THE INPUT STRING.

RETURNS:
	CALL+1	IF THE STRING IS POSITIVE.
	CALL+2	IF THE STRING IS NEGATIVE.
	CALL+3	IF THE STRING IS ZERO.

REGISTERS USED:
	CH, T1 (ALIAS CH), SW, JAC, PARM, CNT

\

	EXTERN	GDSKP.		;ROUTINE TO SKIP LEADING CHARS.
	EXTERN	SET1.		;ROUTINE TO SET UP THE PARAMETERS.
	EXTERN	RET.1		;RETURNS TO CALL+1.
	EXTERN	RET.2		;RETURNS TO CALL+2.
	EXTERN	IBNCH.		;IMBEDDED "-" FLAG.
	EXTERN	SPCCH.		;SPECIAL CHAR FLAG.
	EXTERN	PTRNM.		;TABLE OF POINTERS TO FLAGS AND
				; NUMERIC REPRESENTATIONS.
PNZ:	JSP	JAC,	SET1.		;GO PICK UP THE PARAMETERS.
PNZ0:	MOVE	CPTR,	PTRNM.-6(SW)	;SELECT THE APPROPRIATE CONVERSION
					; POINTER.
	JSP	JAC,	GDSKP.		;GO SKIP OVER LEADING CHARS.
	Z		2(T2)		;RETURN THROUGH HERE IF THERE
					; ARE NO SIGNIFICANT CHARS (IE.
					; THE FIELD IS ZERO.)
	EXP		PNZ4		;RETURN THROUGH HERE IF WE FOUND
					; A NON-SPECIAL CHAR.
	EXP		PNZ3		;RETURN THROUGH HERE IF WE FOUND
					; A SPECIAL CHAR.

;RETURN TO HERE IF WE FOUND A LEADING SIGN.

	JRST		PNZ1A		;DON'T GET THE NEXT CHAR, WE
					; ALREADY HAVE IT FROM GDSKP.
PNZ1:	ILDB	CH,	IPTR		;GET THE NEXT CHAR.
	LDB	T1,	CPTR		;CONVERT IT AND PICK UP FLAGS.
PNZ1A:	TRZE	T1,	SPCCH.		;SPECIAL CHAR?
	JRST		PNZ3		;YES, GO SEE WHAT TO DO.
	JUMPN	T1,	PNZ4		;JUMP IF THE CHAR WAS NOT ZERO.
PNZ2:	SOJG	CNT,	PNZ1		;LOOP IF THER ARE MORE CHARS.
	JRST		2(T2)		;VALUE IS ZERO - RETURN TO CALL+3.

;SAW A SPECIAL CHAR.

PNZ3:	TRZN	T1,	IBNCH.		;IMBEDDED "-" SIGN?
	JUMPN	T1,	2(T2)		;NO, IF NOT NULL, VALUE IS ZERO,
					; RETURN TO CALL+3.
	JUMPE	T1,	PNZ2		;JUMP IF NULL OR SOME FORM OF ZERO.
	TLO	SW,	IS		;TURN ON IMBEDDED "-" SWITCH.
;VALUE IS NOT ZERO.

PNZ4:	TLNN	SW,	LS		;WAS THERE A LEADING SIGN?
	JRST		PNZ6		;NO, SEE IF WE HAVE MORE TO DO.
	TLNE	SW,	LM		;WAS THE LEADING SIGN A "-"?
	JRST		1(T2)		;YES, SKIP-RETURN.
	JRST		(T2)		;NO, MUST HAVE BEEN A "+",
					; NON-SKIP RETURN.

PNZ5:	ILDB	CH,	IPTR		;GET THE NEXT CHAR.
	LDB	T1,	CPTR		;CONVERT IT AND PICK UP FLAGS.
	TRZE	T1,	SPCCH.		;SPECIAL CHAR?
	JRST		PNZ10		;YES, GO SEE WHAT TO DO.
	TLZ	SW,	IS		;TURN OFF IMBEDDED "-" SWITCH.
PNZ6:	SOJG	CNT,	PNZ5		;LOOP IF THERE ARE MORE CHARS.
PNZ7:	TLNE	SW,	IS		;WAS THERE AN IMBEDDED "-"?
	JRST		1(T2)		;YES, SKIP-RETURN.
	JRST		(T2)		;NO, MUST HAVE BEEN A "+",
					; NON-SKIP RETURN.

;SPECIAL CHAR.

PNZ10:	TRZN	T1,	IBNCH.		;IMBEDDED "-" SIGN?
	JRST		@PNZ12(T1)	;NO, DISPATCH.
PNZ11:	TLO	SW,	IS		;TURN ON THE IMBEDDED "-" SWITCH.
					;GO SEE IF THERE IS MORE TO DO.

;DISPATCH TABLE:

PNZ12:	JRST		PNZ6		;NULL - IGNORE IT.
	Z		(T2)		;"+" - NON-SKIP RETURN.
	Z		1(T2)		;"-" - SKIP REUTN.
	EXP		PNZ7		;TERMINATE.
>	;END NON-BIS
IFN	BIS,<

;THE POSITIVE TEST:

	ENTRY	POS.6		;IF THE INPUT IS SIXBIT.
	ENTRY	POS.7		;IF THE INPUT IS ASCII.
IFN EBCMP.,<
	ENTRY	POS.9		;IF THE INPUT IS EBCDIC.
>

POS.6:	JSP	BISCH,	POS		;ENTER HERE IF THE INPUT IS SIXBIT,
POS.7:	JSP	BISCH,	POS		; HERE IF IT IS ASCII AND
IFN EBCMP.,<
	BLOCK	1
POS.9:	JSP	BISCH,	POS		; HERE IF IT IS EBCDIC.
>

POS:
	SUBI	BISCH,POS.6-5		;COMPUTE BYTE SIZE.
	HRLI	PARM,(<Z	DSTHI,0>)	;PUT DESTINATION AC INTO PARM
	PUSHJ	PP,	GDX.##		;CONVERT TO BINARY
	JUMPL	DSTHI,RET.1##		;NEGATIVE
	CAIN	DSTLO,0
	CAIE	DSTHI,0
	AOS	(PP)			;POSITIVE
	POPJ	PP,			;ZERO

;THE NEGATIVE TEST:

	ENTRY	NEG.6		;IF THE INPUT IS SIXBIT.
	ENTRY	NEG.7		;IF THE INPUT IS ASCII.
IFN EBCMP.,<
	ENTRY	NEG.9		;IF THE INPUT IS EBCDIC.
>

NEG.6:	JSP	BISCH,	NEG		;ENTER HERE IF THE INPUT IS SIXBIT,
NEG.7:	JSP	BISCH,	NEG		; HERE IF IT IS ASCII AND
IFN EBCMP.,<
	BLOCK	1
NEG.9:	JSP	BISCH,	NEG		; HERE IF IT IS EBCDIC.
>

NEG:
	SUBI	BISCH,NEG.6-5		;COMPUTE BYTE SIZE.
	HRLI	PARM,(<Z	DSTHI,0>)	;PUT DESTINATION AC INTO PARM
	PUSHJ	PP,GDX.
	JUMPL	DSTHI,RET.2##		;NEGATIVE
	POPJ	PP,			;POS/ZERO
;THE ZERO TEST:

	ENTRY	ZERO.6		;IF THE INPUT IS SIXBIT.
	ENTRY	ZERO.7		;IF THE INPUT IS ASCII.
IFN EBCMP.,<
	ENTRY	ZERO.9		;IF THE INPUT IS EBCDIC.
>

ZERO.6:	JSP	BISCH,	ZERO		;ENTER HERE IF THE INPUT IS SIXBIT,
ZERO.7:	JSP	BISCH,	ZERO		; HERE IF IT IS ASCII AND
IFN EBCMP.,<
	BLOCK	1
ZERO.9:	JSP	BISCH,	ZERO		; HERE IF IT IS EBCDIC.
>

ZERO:
	SUBI	BISCH,ZERO.6-5		;COMPUTE BYTE SIZE.

	HRLI	PARM,(<Z	DSTHI,0>)	;PUT DESTINATION AC INTO PARM
	PUSHJ	PP,GDX.
	CAIN	DSTLO,0			; [424] IS LOW PART ZERO?
	CAIE	DSTHI,0
	POPJ	PP,			;NON-ZERO
	JRST	RET.2##			;ZERO

>	;END OF BIS

	END