Trailing-Edge
-
PDP-10 Archives
-
decuslib20-06
-
decus/20-153/gd.mac
There are 9 other files named gd.mac in the archive. Click here to see a list.
TITLE GD FOR LIBOL V10 AND RPGLIB V1
SUBTTL CONVERT DISPLAY TO BINARY 12-DEC-74 /ACK
;COPYRIGHT 1974, 1975, DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
;ALL RPGII MODIFICATIONS COPYRIGHT 1976, BOB CURRIER AND CERRITOS COLLEGE
;REVISION HISTORY:
;V10 *****
; 12-DEC-74 /ACK CREATION.
; 5/15/75 /DBT BIS
;*****
SEARCH RPGPRM ;DEFINE PARAMETERS.
%%LBLP==:%%LBLP
EBCMP.==:EBCMP.
BIS==:BIS
EXTERN EASTB. ;FORCE EASTAB TO BE LOADED
HISEG
COMMENT \
THIS ROUTINE CONVERTS A DISPLAY ITEM TO A ONE OR TWO WORD BINARY ITEM.
CALL:
MOVE 16,[Z AC,PARAMETER ADDRESS]
PUSHJ 17,GD6./GD7./GD9.
PARAMETERS:
THE ACCUMULATOR FIELD OF AC 16 CONTAINS THE AC INTO WHICH THE FIRST
WORD OF THE RESULT IS TO BE PLACED.
THE RIGHT HALF OF AC 16 POINTS TO A WORD IN THE FOLLOWING FORMAT:
BITS 0-5 BYTE POINTER RESIDUE FOR THE INPUT FIELD.
BIT 6 1 IF THE FIELD IS SIGNED.
BITS 7-17 SIZE OF THE INPUT FIELD.
BITS 18-35 ADDRESS OF THE FIRST CHAR OF THE INPUT FIELD.
RETURNS:
CALL+1 ALWAYS.
REGISTERS USED:
CNT, CH, T1(ALIAS CH), T2, AC, AC+1, AC+2, IPTR, SW, JAC, CPTR
\
ENTRY GD6. ;IF THE INPUT IS SIXBIT.
ENTRY GD7. ;IF THE INPUT IS ASCII.
ENTRY GD9. ;IF THE INPUT IS EBCDIC.
ENTRY GDSP1. ;SINGLE PRECISION ROUTINE TO ADJUST THE
; SIGN AND STORE THE RESULT.
ENTRY GDDP5. ;DOUBLE PRECISION ROUTINE TO ADJUST THE
; SIGN AND STORE THE RESULT.
EXTERN SPCCH. ;SPECIAL CHARACTER FLAG.
EXTERN LDGCH. ;LEADING CHARACTER FLAG.
EXTERN IBNCH. ;IMBEDDED "-" FLAG.
EXTERN NOLCH. ;MASK USED TO CHANGE CPTR SO IT NO LONGER
; PICKS UP THE LEADING CHARACTER FLAG.
EXTERN RET.1
IFE BIS,<
;LOCAL AC DEFINITIONS:
CPTR==PARM
EXTERN PTRNM. ;TABLE OF POINTERS FOR CONVERTING
; CHARACTERS TO NUMBERS.
EXTERN SET1. ;PICKS UP THE PARAMETERS.
EXTERN PACFL. ;POINTER TO THE AC FIELD OF AC 16.
GD6.: JSP CH, GD ;ENTER HERE IF THE INPUT IS SIXBIT,
GD7.: JSP CH, GD ; HERE IF IT IS IN ASCII AND
GD9.: JSP CH, GD ; HERE IF IT IS IN EBCIDC.
GD: SUBI CH, GD6.-5 ;FIND OUT WHAT THE INPUT LOOKS LIKE.
JSP JAC, SET1. ;GO SET UP THE PARAMETERS.
LDB T2, PACFL. ;FIND OUT WHERE TO PUT THE RESULT.
MOVE CPTR, PTRNM.-6(SW) ;SELECT THE APPROPRIATE CONVERSION
; POINTER.
SETZB AC, AC+1 ;CLEAR A PLACE FOR THE RESULT.
CAILE CNT, ^D10 ;ONE OR TWO WORD RESULT?
JRST GDDP ;TWO WORDS - USE DOUBLE PRECISION
; ROUTINE.
;HERE WE WORK ON A SINGLE PRECISION RESULT.
GDSP: JSP JAC, GDSKP. ;GO SKIP OVER LEADING CHARS.
EXP GDSP2 ;RETURN THROUGH HERE IF THERE
; ARE NO SIGNIFICANT CHARS.
EXP GDSP3 ;RETURN THROUGH HERE IF WE FOUND
; A NON-SPECIAL CHAR.
EXP GDSP4 ;RETURN THROUGH HERE IF WE FOUND
; A SPECIAL CHAR.
;RETURN HERE FROM GDSKP IF WE SAW A LEADING SIGN.
JSP JAC, GDCSP1 ;GO CONVERT THE REMAINING CHARS.
GDSP0: EXP GDSP1. ;RETURN THROUGH HERE IF WE SAW
; A TERMINATING CHAR.
> ;END OF NON-BIS
;RETURN HERE FROM GDCSP IF WE HAVE EXHAUSTED THE STRING.
GDSP1.: TLNN SW, LS ;LEADING SIGN?
LSH SW, 1 ;NO, PUT THE IMBEDDED NEGATIVE FLAG
; WHERE THE LEADING NEGATIVE FLAG WAS.
TLNE SW, LM ;NEGATE RESULTS?
MOVNS AC+1 ;YES, DO SO.
GDSP2: MOVEM AC+1, (T2) ;STORE RESULTS.
POPJ PP, ;RETURN.
IFE BIS,<
;RETURN HERE FROM GDSKP IF WE SAW A NON-SPECIAL CHAR.
GDSP3: HRRZI JAC, GDSP0 ;WHERE TO GO WHEN WE ARE DONE CONVERTING.
JRST GDCSP2 ;GO START CONVERTING.
;RETURN HERE FROM GDSKP IF WE SAW A SPECIAL CHAR OTHER THAN A LEADING SIGN.
GDSP4: HRRZI JAC, GDSP0 ;WHERE TO GO WHEN WE ARE DONE CONVERTING.
JRST GDCSP4 ;GO START CONVERTING.
;HERE WE WORK ON DOUBLE PRECISION.
GDDP: JSP JAC, GDSKP. ;GO SKIP OVER LEADING CHARS.
EXP GDDP6 ;RETURN THROUGH HERE IF THERE
; ARE NO SIGNIFICANT CHARS.
EXP GDDP8 ;RETURN THROUGH HERE IF WE FOUND
; A NON-SPECIAL CHAR.
EXP GDDP9 ;RETURN THROUGH HERE IF WE FOUND
; A SPECIAL CHAR OTHER THAN
; A SIGN.
;RETURN HERE IF WE SAW A LEADING SIGN.
GDDP0: JSP JAC, GDDSET ;GO SET UP TO USE THE SINGLE
; PRECISION ROUTINE.
EXP GDCSP1 ;WHERE TO ENTER THE SINGLE
; PRECISION ROUTINE.
GDDSET: HRRI SW, -^D10(CNT) ;HOW MANY CHARS WILL BE LEFT.
CAILE CNT, ^D10 ;ARE THERE MORE THAN TEN CHARS?
MOVEI CNT, ^D10 ;WE WILL CONVERT THE FIRST TEN.
JSP JAC, @(JAC) ;GO CONVERT THEM.
EXP GDDP5. ;RETURN THROUGH HERE IF WE SAW
; A TERMINATING CHAR.
;RETURN HERE IF WE HAVE MORE TO CONVERT.
GDDP1: HRREI CNT, (SW) ;SEE HOW MANY MORE CHARS THERE ARE.
JUMPLE CNT, GDDP5. ;JUMP IF NONE.
GDDP2: ILDB CH, IPTR ;GET THE NEXT CHAR.
LDB T1, CPTR ;CONVERT IT.
TRZE T1, SPCCH. ;SPECIAL CHAR?
JRST GDDP10 ;YES, GO SEE WHAT TO DO WITH IT.
TLZ SW, IS ;CLEAR THE IMBEDDED SIGN SWITCH.
GDDP3: IMULI AC, ^D10 ;SHIFT THE ACCUMULATION LEFT ONE DIGIT.
MULI AC+1, ^D10
ADD AC, AC+1 ;TAKE CARE OF THE CROSS PRODUCT.
MOVE AC+1, AC+2 ;RESTORE THE LOW ORDER WORD.
JOV .+1 ;CLEAR THE OVERFLOW FLAG.
ADDI AC+1, (T1) ;ADD IN THE DIGIT.
JOV [TLZ AC+1, (1B0) ;IF OVERFLOW OCCURS, CLEAR THE SIGN
; OF THE LOW ORDER WORD
AOJA AC, .+1] ;AND BUMP THE HIGH ORDER WORD.
GDDP4: SOJG CNT, GDDP2 ;LOOP IF THERE ARE MORE CHARS.
> ;END OF NON-BIS
;COME HERE WHEN WE ARE FINISHED CONVERTING.
GDDP5.: TLNN SW, LS ;LEADING SIGN?
LSH SW, 1 ;NO, PUT THE IMBEDDED NEGATIVE SWITCH
; WHERE THE LEADING NEGATIVE SWITCH WAS.
TLNN SW, LM ;NEGATE?
JRST GDDP6 ;NO, GO STORE THE RESULTS.
SETCAM AC, (T2) ;NEGATE THE HIGH ORDER WORD AND
; STORE IT.
MOVNM AC+1, 1(T2) ;NEGATE THE LOW ORDER WORD AND
; STORE IT.
JUMPN AC+1, RET.1 ;JUMP IF THE LOW ORDER WORD IS
; NON-ZERO.
HRLZI AC+1, (1B0) ;GET A SIGN BIT.
AOSA (T2) ;BUMP THE HIGH ORDER WORD AND TURN
; ON THE SIGN IN THE LOW ORDER WORD.
GDDP6: MOVEM AC, (T2) ;STORE THE HIGH ORDER WORD.
MOVEM AC+1, 1(T2) ;STORE THE LOW ORDER WORD.
POPJ PP, ;RETURN.
IFE BIS,<
;COME HERE FROM GDSKP IF WE FIND A NON-SPECIAL CHAR.
GDDP8: JSP JAC, GDDSET ;GO SET UP TO USE THE SINGLE
; PRECISION ROUTINE.
EXP GDCSP2 ;WHERE TO ENTER THE SINGLE
; PRECISION ROUTINE.
;COME HERE FROM GDSKP IF WE FIND A SPECIAL CHAR OTHER THAN A LEADING SIGN.
GDDP9: JSP JAC,GDDSET ;GO SET UP TO USE THE SINGLE
; PRECISION ROUTINE.
EXP GDCSP4 ;WHERE TO ENTER THE SINGLE
; PRECISION ROUTINE.
;COME HERE IF WE SEE A SPECIAL CHAR WHILE DOING THE DOUBLE PRECISION
; CONVERSION.
GDDP10: TRZN T1, IBNCH. ;IMBEDDED "-" SIGN?
JRST @GDDP11(T1) ;NO, DISPATCH TO APPROPRIATE ROUTINE.
TLO SW, IS ;TURN ON THE IMBEDDED "-" SIGN SWITCH.
JRST GDDP3 ;GO ADD IN THE DIGIT.
;DISPATCH TABLE FOR SPECIAL CHARS:
GDDP11: EXP GDDP4 ;NULL - IGNORE IT.
EXP GDDP12 ;"+" - CLEAR IMBEDDED "-" SWITCH
; AND TERMINATE.
EXP GDDP12+1 ;"-" - SET IMBEDDED "-" SWITCH
; AND TERMINATE.
EXP GDDP5. ;TERMINATING CHAR - TERMINATE!
;COME HERE ON TERMINATING SIGNS.
GDDP12: TLZA SW, IS ;"+" TAKES PRECIDENCE OVER
; IMBEDDED SIGNS.
TLO SW, IS ;"-" TAKES PRECIDENCE OVER
; IMBEDDED SIGNS.
JRST GDDP5. ;TERMINATE!
;SUBROUTINE TO SKIP LEADING CHARACTERS.
COMMENT \
THIS ROUTINE SKIPS NON-SIGNIFICANT LEADING CHARACTERS IN A
DISPLAY FIELD. THE CONVERSION POINTER (CPTR), IN ADDITION TO PICKING UP THE
NUMBER TO WHICH THE CHARACTER IN CH IS TO BE CONVERTED, PICKS UP
SEVERAL FLAGS. THE FIRST FLAG IS THE LEADING CHARACTER FLAG. IF THIS
FLAG IS SET TO 1 THE CHARACTER IS A LEADING CHARACTER AND MAY BE
IGNORED. ON EXIT FROM THIS ROUTINE, IF WE HAVE SEEN A CHARACTER
WHICH IS NOT A LEADING CHARACTER, CPTR IS MODIFIED SO THAT IT NO
LONGER PICKS UP THE LEADING CHARACTER FLAG.
CALL:
JSP JAC, GDSKP
ENTRY CONDITIONS:
(IPTR) = BYTE POINTER TO THE FIRST INPUT CHAR.
(CPTR) = CONVERSION POINTER.
(CNT) = SIZE OF THE INPUT FIELD.
EXIT CONDITIONS:
(IPTR) = BYTE POINTER TO THE NEXT INPUT CHAR.
(CPTR) = CONVERSION POINTER (MODIFIED TO NO LONGER PICK UP THE
LEADING CHARACTER FLAG.)
(CNT) = NUMBER OF CHARACTERS REMAINING IN THE INPUT FIELD.
(SW) = LM IS TURNED ON IF WE SAW A LEADING "-".
LS IS TURNED ON IF WE SAW A LEADING "+" OR "-".
RETURNS:
@CALL+1 IF THERE ARE NO SIGNIFICANT CHARACTERS IN THE FIELD.
@CALL+2 IF WE FOUND A NON-SPECIAL CHAR.
@CALL+3 IF WE FOUND A SPECIAL CHARACTER OTHER THAN A LEADING SIGN.
CALL+4 IF WE FOUND A LEADING SIGN.
\
ENTRY GDSKP.
GDSKP.: ILDB CH, IPTR ;GET A CHAR.
LDB T1, CPTR ;CONVERT IT AND PICK UP FLAGS.
TRZN T1, LDGCH. ;LEADING CHAR?
JRST GDSKP1 ;NO, GO SEE IF IT'S A SIGN.
SOJG CNT, GDSKP. ;LOOP IF THERE ARE MORE CHARS.
JRST @(JAC) ;NO SIGNIFICANT CHARS, RETURN
; THROUGH CALL+1.
;COME HERE WHEN WE FIND A NON-LEADING CHAR.
GDSKP1: TLC CPTR, NOLCH. ;DON'T PICK UP THE LEADING CHAR
; FLAG ANY MORE.
TRZE T1, SPCCH. ;SOME KIND OF SPECIAL CHAR?
JRST GDSKP2 ;YES, GO SEE IF IT'S A SIGN.
JUMPE T1, GDSKP4 ;IF IT'S A ZERO, GO SKIP IT.
JRST @1(JAC) ;MUST BE A DIGIT, RETURN
; THROUGH CALL+2.
;IT'S A SPECIAL CHAR.
GDSKP2: CAIN T1, 2 ;MINUS?
TLOA SW, LM ;YES, REMEMBER THAT WE SAW IT.
CAIN T1, 1 ;PLUS?
TLOA SW, LS ;YES, REMEMBER THAT WE SAW A SIGN.
JRST @2(JAC) ;SPECIAL CHAR, OTHER THAN A SIGN
SOJLE CNT, @(JAC) ;IF IT'S ONLY A SIGN, TAKE THE
; NO SIGNIFICANCE RETURN.
;SKIP OVER LEADING ZEROES.
GDSKP3: ILDB CH, IPTR ;PICK UP THE NEXT CHAR.
LDB T1, CPTR ;CONVERT IT.
JUMPN T1, 3(JAC) ;IF IT'S NOT ZERO, RETURN TO
; CALL+4.
GDSKP4: SOJG CNT, GDSKP3 ;IF THERE ARE MORE CHARS, GO
; SEE IF THEY ARE ALSO ZEROES.
JRST @(JAC) ;OTHERWISE, TAKE THE
; NO-SIGNIFICANCE RETURN.
;SUBROUTINE TO CONVERT A STRING TO A SINGLE PRECISION NUMBER.
COMMENT \
THIS ROUTINE CONVERTS A STRING TO A SINGLE PRECISION NUMBER. IT IS
USED BY BOTH THE SINGLE AND DOUBLE PRECISION ROUTINES.
CALL:
JSP JAC, GDCSP
ENTRY CONDITIONS:
(IPTR) = BYTE POINTER TO THE NEXT CHAR.
(CPTR) = CONVERSION POINTER.
(CNT) = NUMBER OF CHARACTERS LEFT IN THE INPUT FIELD.
(AC+1) = 0
EXIT CONDITIONS:
(IPTR) =BYTE POINTER TO THE NEXT CHAR.
(CNT) = 0 (UNLESS A TERMINATING CHAR WAS SEEN.)
(AC+1) = THE CONVERTED NUMBER.
RETURNS:
@CALL+1 IF THE CONVERSION WAS TERMINATED BECAUSE OF A TERMINATING
CHAR.
CALL+2 IF THE CONVERSION WAS TERMINATED BECAUSE OF NO MORE INPUT.
\
GDCSP: ILDB CH, IPTR ;GET THE NEXT CHAR.
LDB T1, CPTR ;CONVERT IT.
GDCSP1: TRZE T1, SPCCH. ;SPECIAL CHAR?
JRST GDCSP4 ;YES, GO SEE WHAT TO DO ABOUT IT.
TLZ SW, IS ;CLEAR THE IMBEDDED SIGN SWITCH.
GDCSP2: IMULI AC+1, ^D10 ;SHIFT THE ACCUMULATION LEFT ONE.
ADDI AC+1, (T1) ;ADD IN THIS DIGIT.
GDCSP3: SOJG CNT, GDCSP ;LOOP IF THERE ARE MORE CHARS
JRST 1(JAC) ;OTHERWISE RETURN TO CALL+2.
;SAW A SPECIAL CHAR - SEE WHAT TO DO.
GDCSP4: TRZN T1, IBNCH. ;IMBEDDED "-" SIGN?
JRST @GDCSP5(T1) ;NO, DISPATCH TO APPROPRIATE ROUTINE.
TLO SW, IS ;TURN ON IMBEDDED "-" SIGN SWITCH.
JRST GDCSP2 ;GO ADD THE DIGIT IN.
;DISPATCH TABLE FOR SPECIAL CHARS:
GDCSP5: EXP GDCSP3 ;NULL - IGNORE IT.
EXP GDCSP6 ;"+" - CLEAR IMBEDDED "-" SWITCH
; AND TERMINATE.
EXP GDCSP6+1 ;"-" - SET IMBEDDED "-" SWITCH
; AND TERMINATE.
Z @(JAC) ;TERMINATING CHAR - RETURN THROUGH
; CALL+1.
;COME HERE ON TERMINATING SIGNS:
GDCSP6: TLZA SW, IS ;"+" TAKES PRECIDENCE OVER
; IMBEDDED SIGNS.
TLO SW, IS ;"-" TAKES PRECIDENCE OVER
; IMBEDDED SIGNS.
JRST @(JAC) ;TERMINATE!
> ;END OF NON-BIS
IFN BIS,<
ENTRY GDX.
; FLAGS FOR LEFT SIDE OF SW
LED.SG==3B35 ;LEADING SIGN MASK
LED.PL==1B35 ;LEADING +
LED.MI==1B34 ;LEADING -
EXTERN BSET1.,PACFL.,BPTNM.
; E0 TABLE FOR EXTEND CNVDB INSTRUCTION
CVDB.T: XWD CVTDBT, CVDB.6## ;SIXBIT
XWD CVTDBT, CVDB.7## ;ASCII
0
XWD CVTDBT, CVDB.9## ;EBCDIC
GD6.: JSP BISCH, GD ;SIXBIT INPUT
GD7.: JSP BISCH, GD ;ASCII INPUT
BLOCK 1
GD9.: JSP BISCH, GD ;EBCDIC INPUT
GD:
SUBI BISCH, GD6.-5 ;COMPUTE BYTE SIZE
GDX.:: ;ENTRY FOR PNZ CALL
JSP JAC, BSET1. ;GET PARAMETER
LDB BIST0, PACFL. ;GET RESULTANT AC
HRLM SRCCNT, (PP) ;SAVE THE SIZE.
GD0: EXTEND B.FLAG, CVDB.T-6(SW)
JRST ABRTCK ;ABORT CHECK
;UN ABORTED EXIT
NUMFIN:
JUMPL SW,SIGNED ;CAN IT BE SIGNED
NEGIFM: TLNE B.FLAG, BFLG.M ;NEGATE IF M FLAG ON
JRST NEGATE
NONEG: HLRZ SRCCNT, (PP) ;GET THE SIZE BACK.
CAILE SRCCNT, ^D10 ;ONE OR TWO WORD RESULT.
JRST NONEG2 ;TWO, GO ON.
MOVEM DSTLO, (BIST0) ;STORE RESULT.
POPJ PP, ;RETURN.
NONEG2: DMOVEM DSTHI, (BIST0) ;STORE RESULT
POPJ PP,
SIGNED: TLNN SW,LED.SG ;ANY LEADING SIGNS
JRST NONEG ;NONE
LEDSGN: TLNE SW,LED.PL ;LEADING PLUS???
JRST NEGIFM ;YES
NEGNOM: TLNE B.FLAG,BFLG.M ;NEGATE IF M NOT ON
JRST NONEG
NEGATE: HLRZ SRCCNT, (PP) ;GET THE SIZE BACK.
CAILE SRCCNT, ^D10 ;ONE OR TWO WORD RESULT.
JRST NEGAT2 ;TWO, GO ON.
MOVNM DSTLO, (BIST0) ;STORE RESULT.
POPJ PP, ;RETURN.
NEGAT2: DMOVNM DSTHI,(BIST0) ;STORE NEGATIVE RESULT
POPJ PP,
ABRTCK: ;INSTRUCTION ABORTED - WHY??
LDB BISCH, SRCPT ;GET OFFENDING CHARACTER
LDB BISCH, BPTNM.-6(SW) ;GET NUMERIC SYMBOL VALUE
ANDI BISCH, 3
; ALL ABORTS WILL COME FROM SPECIAL CHARACTERS
; AND THUS THE NUMERIC VALUE WILL BE THE SPECIAL VALUE
JRST @SPCTA0(BISCH)
SPCTA0: EXP GD0 ;IGNORE NULLS
EXP PLCK ;GRAPHIC PLUS
EXP MICK ;GRAPHIC MINUS
EXP BKTAB ;TRAILING BLANK OR TAB
MICK: ;GRAPHIC MINUS
TLNE SW,LED.SG ;ANY LEADING SIGNS YET
JRST LEDSG1 ;YES - DONE
SKIPN DSTHI ;ANY DIGITS YET?
SKIPE DSTHI+1
JRST NEGATE ;YES - TRAILING GRAPHIC -
TLO SW,LED.MI ;NOTE LEADING GRAPHIC -
JRST GD0 ;RESTART
PLCK: ;GRAPHIC PLUS
TLNE SW,LED.SG ;ANY LEADING SIGNS
JRST LEDSG1 ;YES - DONE
SKIPN DSTHI ;ANY DIGITS YET?
SKIPE DSTHI+1
JRST NONEG ;YES - DONE
TLO SW,LED.PL ;NOTE LEADING PLUS
JRST GD0 ;RESTART
BKTAB: ;ABORT ON BLANK OR TAB
TLNN SW,LED.SG ;ANY LEADING SIGNS
JRST NEGIFM ;NO - GO BY M FLAG
LEDSG1: ;LEADING SIGN WITH ABORT SO THAT INSTRUCTION NEVER GOT A
; CHANCE TO NEGATE THE NUMBER IE. M FLAG MEANS NOTHING
TLNN SW,LED.MI ;MINUS
JRST NONEG ;NO
JRST NEGATE ;YES.
> ;END OF BIS
END