Google
 

Trailing-Edge - PDP-10 Archives - ap-c800d-sb - cmp.mac
There are 7 other files named cmp.mac in the archive. Click here to see a list.
TITLE	CMP FOR LIBOL V12
SUBTTL	COMPARE TWO DISPLAY FIELDS	/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, 1979 BY DIGITAL EQUIPMENT CORPORATION

;REVISION HISTORY:

;V10 *****

;	15-DEC-74	/ACK	CREATION.

;	5/10/75		/DBT	ADD BIS
;*****

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

	EXTERN	EASTB.		;FORCE EASTBL TO BE LOADED.

	HISEG

COMMENT	\

	THIS ROUTINE LEXICALLY COMPARES TWO DISPLAY FIELDS WHICH MAY OR
MAY NOT BE OF THE SAME DATA TYPE.

CALL:
	MOVEI	16,PARAMETER ADDRESS
	PUSHJ	17,COMP./CMP.76/CMP.96/CMP.97

PARAMETERS:
	WORD 1:
		BYTE POINTER FOR FIRST FIELD.
	WORD 2:
		BITS	0-5	BYTE POINTER RESIDUE FOR SECOND FIELD.
		BIT	6	IGNORED (1 IF THE FIELD IS EXPLICITLY SIGNED.)
		BITS	7-17	SIZE OF THE FIELDS.
		BITS	18-35	ADDRESS OF THE FIRST CHARACTER OF THE SECOND FIELD.

RETURNS:
	CALL+1	IF THE FIRST FIELD IS LESS THAN THE SECOND FIELD.
	CALL+2	IF THE FIRST FIELD IS GREATER THAN THE SECOND FIELD.
	CALL+3	IF THE FIRST FIELD IS EQUAL TO THE SECOND FIELD OR THE
		 LENGTH OF THE FIELDS ARE 0.

REGISTERS USED:
	CH, JAC, T2, IPTR, OPTR, CNT

\
;LOCAL AC DEFINITIONS:

	ICH==TAC3
	PTR1==IPTR
	PTR2==OPTR

	ENTRY	COMP.		;TO COMPARE TWO FIELDS OF THE SAME TYPE.
	ENTRY	CMP.76		;TO COMPARE AN ASCII FIELD TO A SIXBIT FIELD.
IFN EBCMP.,<
	ENTRY	CMP.96		;TO COMPARE AN EBCDIC FIELD TO A SIXBIT FIELD.
	ENTRY	CMP.97		;TO COMPARE AN EBCDIC FIELD TO AN ASCII FIELD.
>
	ENTRY	CMP2.		;TO COMPARE TWO FIELDS OF THE SAME DATA
				; TYPE IF THE AC'S HAVE BEEN SET UP
				; ALREADY.

	EXTERN	SET2.		;ROUTINE TO PICK UP THE PARAMETERS.
	EXTERN	RET.3		;RETURNS TO CALL+3.

	EXTERN	PTIBS.		;POINTER TO THE INPUT BYTE SIZE.
	EXTERN	PTOBS.		;POINTER TO THE OUTPUT BYTE SIZE.
	EXTERN	PTR67.		;POINTER TO CONVERT SIXBIT TO ASCII.
IFN EBCMP.,<
	EXTERN	PTR69.		;POINTER TO CONVERT SIXBIT TO EBCDIC.
	EXTERN	PTR79.		;POINTER TO CONVERT ASCII TO EBCDIC.
>

COMP.:
IFE	BIS,<	JSP	CH,	CMP	>
IFN	BIS,<	JSP	CH,	BISCMP	>
					; ENTER HERE TO COMPARE SIXBIT TO
					; SIXBIT, ASCII TO ASCII OR EBCDIC
					; TO EBCDIC,
CMP.76:	JSP	CH,	CMP		; HERE FOR ASCII TO SIXBIT,
IFN EBCMP.,<
CMP.96:	JSP	CH,	CMP		; HERE FOR EBCDIC TO SIXBIT AND
CMP.97:	JSP	CH,	CMP		; HERE FOR EBCDIC TO ASCII.
>
CMP4:	LDB	ICH,	PTIBS.
	MOVEI	ICH,	6
IFN EBCMP.,<
	MOVEI	ICH,	6
	MOVEI	ICH,	7
>
CMP5:	EXP	CMP2.
	EXP	CMP1
IFN EBCMP.,<
	EXP	CMP1
	EXP	CMP1
>
CMP6:	EXP	PTR67.
IFN EBCMP.,<
	EXP	PTR69.
	EXP	PTR79.
>


CMP:
IFN ANS74,<
	HLLZ	JAC,0(PARM)		;SEE IF COLLATING SEQUENCE
	JUMPE	JAC,CMPC		;YES
>
	JSP	JAC,	SET2.		;GO PICK UP THE PARAMETERS.
	EXP		RET.3		;RETURN THROUGH HERE ON NULL INPUT.
	XCT		CMP4-COMP.-1(CH)	;GET THE OUTPUT BYTE SIZE.
	DPB	ICH,	PTOBS.		;PUT IT IN THE OUTPUT POINTER.
	JRST		@CMP5-COMP.-1(CH)	;DISPATCH TO A CONVERSION ROUTINE.


IFN	BIS,<

BISCMP:
IFN ANS74,<
	HLLZ	JAC,0(PARM)		;SEE IF COLLATING SEQUENCE
	JUMPE	JAC,CMPC		;YES
>
	JSP	JAC,	BSET2.##	;GO GET PARAMS
	EXP	RET.3			;RETURN HERE ON NULL INPUT

	LDB	BIST0,	BPTIBS##		;GET INPUT BYTE SIZE
	DPB	BIST0,	BPTOBS##		;SET OUTPUT BYTE SIZE WITH IT
	EXTEND	B.FLAG,	[CMPSN]		;COMPARE NOT EQUAL
	JRST	RET.3			;EQUAL

	;CHECK FOR LESS THAN OR GREATER THAN

	LDB	BIST0,	SRCPT		;GET OFFENDING CHARACTERS
	LDB	BIST1,	DSTPT
	CAIL	BIST0,(BIST1)
	AOS	(PP)			;DST LESS THAN SRC
	POPJ	PP,			;SRC LESS THAN DST

>	;END OF BIS
;THE FOLLOWING TWO ROUTINES COULD BE COMBINED BUT SINCE MOST COMPARISONS
; ARE DONE ON STRINGS OF LIKE DATA TYPES, THE TIME SAVED IS WORTH THE COST.

;ROUTINE TO COMPARE FIELDS OF DIFFERING DATA TYPES:

CMP1:	MOVE	CPTR,	@CMP6-COMP.-2(CH)	;PICK UP THE CONVERSION POINTER.
CMP1A:	ILDB	ICH,	PTR1		;GET A CHAR FROM THE FIRST STRING.
	ILDB	CH,	PTR2		;GET A CHAR FROM THE SECOND STRING.
	LDB	CH,	CPTR		;CONVRT IT.
	CAIN	CH,	(ICH)		;ARE THEY THE SAME?
	SOJG	CNT,	CMP1A		;YES, LOOP IF THER ARE MORE.
	JUMPN	CNT,	CMP3		;JUMP IF THE STRINGS ARE NOT EQUAL.
	JRST		RET.3		;OTHERWISE RETURN TO CALL+3.

;ROUTINE TO COMPARE FIELDS OF THE SAME DATA TYPE.

CMP2.:	ILDB	ICH,	PTR1		;GET A CHAR FROM THE FIRST STRING.
	ILDB	CH,	PTR2		;GET A CHAR FROM THE SECOND STRING.
	CAIN	CH,	(ICH)		;ARE THEY THE SAME?
	SOJG	CNT,	CMP2.		;YES, LOOP IF THERE ARE MORE.
	JUMPE	CNT,	RET.3		;RETURN TO CALL+3 IF THE STRINGS
					; ARE EQUAL.

;COME HERE WHEN WE DETERMINE THAT THE STRINGS ARE NOT EQUAL.

CMP3:	CAIG	CH,	(ICH)		;SECOND STRING LARGER?
	AOS		(PP)		;NO, RETURN TO CALL+2
	POPJ	PP,			;RETURN.
;HERE FOR COLLATING SEQUENCE ON
IFN ANS74,<

CMP5C:	EXP	CMP2C.
	EXP	CMP1C
IFN EBCMP.,<
	EXP	CMP1C
	EXP	CMP1C
>


CMPC:	ADDI	PARM,1			;BYPASS COLLATING SEQUENCE
	JSP	JAC,SET2.		;GO PICK UP THE PARAMETERS.
	EXP	RET.3			;RETURN THROUGH HERE ON NULL INPUT.
	XCT	CMP4-COMP.-1(CH)	;GET THE OUTPUT BYTE SIZE.
	DPB	ICH,PTOBS.		;PUT IT IN THE OUTPUT POINTER.
	JRST	@CMP5C-COMP.-1(CH)	;DISPATCH TO A CONVERSION ROUTINE.
;THE FOLLOWING TWO ROUTINES COULD BE COMBINED BUT SINCE MOST COMPARISONS
; ARE DONE ON STRINGS OF LIKE DATA TYPES, THE TIME SAVED IS WORTH THE COST.

;ROUTINE TO COMPARE FIELDS OF DIFFERING DATA TYPES:

CMP1C:	MOVE	CPTR,@CMP6-COMP.-2(CH)	;PICK UP THE CONVERSION POINTER.
	MOVE	JAC,-1(PARM)	;GET COLLATING SEQUENCE
CMP1CA:	ILDB	ICH,PTR1	;GET A CHAR FROM THE FIRST STRING.
	ILDB	CH,PTR2		;GET A CHAR FROM THE SECOND STRING.
	LDB	CH,CPTR		;CONVRT IT.
	ADDI	CH,(JAC)	;INDEX INTO TABLE
	MOVE	CH,(CH)		;GET NEW CHAR.
	ADDI	ICH,(JAC)
	CAMN	CH,(ICH)	;ARE THEY THE SAME?
	SOJG	CNT,CMP1CA	;YES, LOOP IF THERE ARE MORE.
	JUMPN	CNT,CMP3C	;JUMP IF THE STRINGS ARE NOT EQUAL.
	JRST	RET.3		;OTHERWISE RETURN TO CALL+3.

;ROUTINE TO COMPARE FIELDS OF THE SAME DATA TYPE.

CMP2C.:	MOVE	JAC,-1(PARM)	;GET COLLATING SEQUENCE
CMP2CA:	ILDB	ICH,PTR1	;GET A CHAR FROM THE FIRST STRING.
	ILDB	CH,PTR2		;GET A CHAR FROM THE SECOND STRING.
	ADDI	CH,(JAC)	;INDEX INTO TABLE
	MOVE	CH,(CH)		;GET NEW CHAR.
	ADDI	ICH,(JAC)
	CAMN	CH,(ICH)	;ARE THEY THE SAME?
	SOJG	CNT,CMP2CA	;YES, LOOP IF THERE ARE MORE.
	JUMPE	CNT,RET.3	;RETURN TO CALL+3 IF THE STRINGS ARE EQUAL.

;COME HERE WHEN WE DETERMINE THAT THE STRINGS ARE NOT EQUAL.

CMP3C:	CAMG	CH,(ICH)	;SECOND STRING LARGER?
	AOS	(PP)		;NO, RETURN TO CALL+2
	POPJ	PP,		;RETURN.

>

	END