Trailing-Edge
-
PDP-10 Archives
-
decuslib20-06
-
decus/20-153/comp.mac
There is 1 other file named comp.mac in the archive. Click here to see a list.
TITLE COMP FOR RPGLIB %1
SUBTTL COMPARISON ROUTINES
; COMP
;
; THIS SECTION CONTAINS BOTH NUMERIC AND ALPHA COMPARISON
; ROUTINES. ALPHA ROUTINES COURTESY LIBOL-10 AND THE FOLKS
; AT DEC.
;
; BOB CURRIER NOVEMBER 30, 1975 00:44:04
;
; ALL RIGHTS RESERVED
;
HISEG
ENTRY CMP.11
ENTRY CMP.12
ENTRY CMP.21
ENTRY CMP.22
ENTRY CMP%11
ENTRY CMP%12
ENTRY CMP%21
ENTRY CMP%22
ENTRY COMP%
ENTRY CMP%76
ENTRY CMP%96
ENTRY CMP%97
ENTRY .EQ.
ENTRY .GT.
ENTRY .LT.
ENTRY INDCLR
SEARCH RPGPRM ; GET THOSE PARAMETERS
EXTERN RET.1
EXTERN RET.2
EXTERN RET.3
;SINGLE WORD COMP
CMP%11: MOVE HIGHB,(PA) ; GET A WORD
CAMLE HIGHA,HIGHB
JRST RET.3 ; A > B
CAME HIGHA,HIGHB
JRST RET.2 ; A < B
JRST RET.1 ; A = B
.EQ.: MOVE TA,@UOCAL.##
JSP JAC,INDCLR ; TURN 'EM ALL OFF
LDB TC,[POINT 8,TA,23] ; GET INDICATOR
.SET: JUMPE TC,.+2 ; DON'T LET ANY ZEROEES THRU
PUSHJ PP,SINDT## ; SET IT
AOS (PP) ; SKIP
POPJ PP, ; EXIT
.GT.: MOVE TA,@UOCAL.
JSP JAC,INDCLR ; TURN ME OFF, DEAD MAN
LDB TC,[POINT 8,TA,7]
JRST .SET ; SET INDICATOR
.LT.: MOVE TA,@UOCAL.
JSP JAC,INDCLR ; CLEAR THOSE INDICATORS
LDB TC,[POINT 8,TA,15]
JRST .SET
;DOUBLE TO DOUBLE
CMP%22: MOVE HIGHB,(PA)
MOVE LOWB,1(PA)
CMP.: CAMGE HIGHA,HIGHB
JRST RET.2
CAME HIGHA,HIGHB
JRST RET.3
CAMGE LOWA,LOWB
JRST RET.2
CAME LOWA,LOWB
JRST RET.3
JRST RET.1
;ONE TO TWO
CMP%12: MOVE 2,1
SETZ 1,
TLNE 2,1B18 ; NEGATIVE?
SETO 1, ; YES - HIGH ORDER = -1
JRST CMP.22 ; GO FINISH
;TWO TO ONE
CMP%21: MOVE LOWB,(PA)
SETZ HIGHB,
TLNE HIGHB,1B18
SETO HIGHB,
JRST CMP.
;CLEAR ANY INDICATORS LEFT ON FROM ELSEWHERES
INDCLR: LDB TC,[POINT 8,TA,7] ; GET ONE
JUMPE TC,.+2 ; SKIP IF NO INDICATOR
PUSHJ PP,SINDF## ; TURN IT OFF
LDB TC,[POINT 8,TA,15] ; GET ANOTHER
JUMPE TC,.+2 ; DON'T TURN OFF ZERO
PUSHJ PP,SINDF ; AND TURN IT OFF TOO
LDB TC,[POINT 8,TA,23] ; AND STILL ANOTHER
JUMPE TC,.+2 ; IGNORE ZEROES
PUSHJ PP,SINDF ; AND TURN THIS OFF TOO
JRST (JAC) ; THEN EXIT
;MAIN ENTRY POINTS
CMP.11: JSP CH,.CMP.
CMP.22: JSP CH,.CMP.
CMP.12: JSP CH,.CMP.
CMP.21: JSP CH,.CMP.
.CMP.: PUSHJ PP,@.CMP8-CMP.11-1(CH)
JRST .EQ.
JRST .LT.
JRST .GT.
.CMP7: EXP COMP%
EXP CMP%76
EXP CMP%96
EXP CMP%97
.CMP8: EXP CMP%11
EXP CMP%22
EXP CMP%12
EXP CMP%21
%%LBLP==:%%LBLP
EBCMP.==:EBCMP.
BIS==:BIS
EXTERN EASTB. ;FORCE EASTBL TO BE LOADED.
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.
REGISTERS USED:
CH, JAC, T2, IPTR, OPTR
\
;LOCAL AC DEFINITIONS:
ICH==TAC3
;[130] CNT==TAC4
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 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,< JRST 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.
>
COMP.: JSP CH,..CMP
CMP.76: JSP CH,..CMP
CMP.96: JSP CH,..CMP
CMP.97: JSP CH,..CMP
..CMP: PUSHJ PP,@.CMP7-COMP.-1(CH)
JRST .EQ.
JRST .LT.
JRST .GT.
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: JSP JAC, SET2.## ; SET UP PARAMETERS
EXP RET.1 ; TAKE EQUAL RETURN IF ZERO SIZE
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: 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,,0] ;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.1 ;OTHERWISE RETURN
;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.1 ;RETURN TO CALL+1 IF THE STRINGS
; ARE EQUAL.
;COME HERE WHEN WE DETERMINE THAT THE STRINGS ARE NOT EQUAL.
CMP3: CAIG CH, (ICH) ;SECOND STRING LARGER?
JRST RET.3 ;NO, FIRST GREATER
JRST RET.2 ;RETURN VIA LESS THAN
;DEFINE AC'S
HIGHA==S1
LOWA==S2
TC==6 ; MUST AGREE WITH RPGMAN
HIGHB==TAC3
LOWB==TAC4
TA==TAC5
PA==16
END