Google
 

Trailing-Edge - PDP-10 Archives - BB-H580E-SB_1985 - gd.mac
There are 9 other files named gd.mac in the archive. Click here to see a list.
; UPD ID= 2843 on 5/14/80 at 3:18 PM by WRIGHT                          
TITLE	GD FOR LIBOL V12C
SUBTTL	CONVERT DISPLAY TO BINARY	/ACK



	SEARCH	COPYRT
	SALL

;COPYRIGHT (C) DIGITAL EQUIPMENT CORPORATION 1974, 1985
;ALL RIGHTS RESERVED.
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE.

;REVISION HISTORY:
;V12A *****
;[630] 14-MAY-80 /DAW		FIX CONVERSION OF ITEM WITH LEADING +
;
;V10 *****
;	13-AUG-76	[451] FIX NUMERIC MOVES FOR BIS
;	12-DEC-74	/ACK	CREATION.
;	5/15/75		/DBT	BIS
;	8/4/77		/DAW	ADD CVTDB. ROUTINE - SETUP DONE INLINE
;*****
	SEARCH	LBLPRM		;DEFINE PARAMETERS.
	%%LBLP==:%%LBLP
	EBCMP.==:EBCMP.
	BIS==:BIS
	EXTERN	EASTB.		;FORCE EASTAB TO BE LOADED
	HISEG
	.COPYRIGHT		;Put COPYRIGHT statement in .REL file.

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

OPDEF	PJRST	[JRST]

IFN TOPS20,<SEARCH MONSYM>
DEFINE TYPE(ADDR),<
IFE TOPS20,<OUTSTR ADDR>
IFN TOPS20,<PUSH PP,1
	HRROI 1,ADDR
	PSOUT%
	POP	PP,1>
>;END DEFINE TYPE

DEFINE TYPET1,<
IFE TOPS20, OUTCHR 1
IFN TOPS20, PBOUT%
>;END DEFINE TYPET1

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.:	JUMPGE	SW,	GDSP2		;JUMP IF WE CAN'T HAVE A SIGN.
	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.:	JUMPGE	SW,	GDDP6		;JUMP IF WE CAN'T HAVE A SIGN.
	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.
IFN BIS,<
	MOVEM	AC+1,	1(T2)		;STORE THE LOW ORDER WORD
>
	AOSA		(T2)		;BUMP THE HIGH ORDER WORD AND TURN
					; ON THE SIGN IN THE LOW ORDER WORD.
GDDP6:
IFN BIS,<
	DMOVEM	AC,	(T2)		;STORE THE RESULT
>
IFE BIS,<
	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:	CVTDBT	CVDB.6##		;SIXBIT
	CVTDBT	CVDB.7##		;ASCII
	0
	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.

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:	DMOVN	DSTHI,DSTHI		;NEGATE THE RESULT
	JUMPGE	DSTHI,NONEG2		;IF 0, DON'T TURN ON SIGN BIT
	TLO	DSTLO,(1B0)		;PUT BACK SIGN BIT
NONEG2:	DMOVEM	DSTHI,	(BIST0)		;STORE 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	TSTSGN			; [451] YES SEE IF RESULT S/B NEG

	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

TSTSGN:	JUMPL	SW,NEGATE	; [451] NEGATIVE IF INPUT IS SIGNED
	JRST	NONEG		; [451] ELSE THE RESULT IS POSITIVE
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.

;CVTDB ROUTINE
	ENTRY	CVTDB.		;(BIS) SETUP DONE INLINE
; CALLED FROM INLINE CODE AS FOLLOWS:
;	MOVE	AC5,BYTE.PTR.TO.INPUT.STRING
;	MOVEI	AC4,SIZE.OF.INPUT.STRING
;	MOVE	SW,[XWD FLAGS,BYTE.SIZE]
;	PUSHJ	PP,CVTDB##
;	MOVE AC,AC10  -OR-  DMOVE AC,AC7
CVTDB.:	EXTEND	B.FLAG,CVDB.T-6(SW)
	 JRST	CVABRT		;ABORT CHECK

	JUMPL	SW,SIGN1	;JUMP IF SIGNED

NEGIF1:	TLNN	B.FLAG,BFLG.M	;IF M FLAG ON..
	 POPJ	PP,
	JRST	NEGAT1		;NEGATE

SIGN1:	TLNN	SW,LED.SG	;LEADING SIGN?
	 POPJ	PP,		;NOPE
	TLNE	SW,LED.PL	;LEADING PLUS?
	 JRST	NEGIF1		;YES, USE "M" FLAG
	TLNE	B.FLAG,BFLG.M	;NEGATE IF M NOT ON
	 POPJ	PP,
NEGAT1:	TLNE	SW,(1B1)
	 JRST	NEG2		;TWO WORD RESULT
	MOVN	DSTLO,DSTLO
	POPJ	PP,
NEG2:	DMOVN	DSTHI,DSTHI	;NEGATE 2-WORD RESULT
	JUMPGE	DSTHI,.+2	; 0 - DON'T TURN ON SIGN BIT
	TLO	DSTLO,(1B0)	;PUT BACK SIGN BIT
	POPJ	PP,

;HERE IF CONVERSION ABORTS

CVABRT:	LDB	BISCH,5		;GET OFFENDING CHARACTER
	LDB	BISCH,BPTNM.-6(SW) ;GET NUMBER SYMBOL VALUE
	ANDI	BISCH,3

	JRST	@SPCTA1(BISCH)	;DISPATCH ON CHARACTER TYPE

SPCTA1:	EXP	CVTDB.		;NULL - IGNORE
	EXP	CVPLCK		;GRAPHIC PLUS
	EXP	CVMICK		;GRAPHIC MINUS
	EXP	CVBKTB		;TRAILING BLANKS OR TABS

;PLUS
CVPLCK:	TLNE	SW,LED.SG	;ANY LEADING SIGNS SEEN YET?
	 JRST	LEDSG2		;YES, DONE
	SKIPN	DSTHI		;NO--ANY DIGITS YET?
	SKIPE	DSTHI+1
	 POPJ	PP,		;YES--DONE

	TLO	SW,LED.PL	;REMEMBER LEADING PLUS
	JRST	CVTDB.		;CONTINUE CONVERSION

;MINUS
CVMICK:	TLNE	SW,LED.SG	;ANY LEADING SIGNS SEEN YET?
	 JRST	LEDSG2		;YES--DONE
	SKIPN	DSTHI
	SKIPE	DSTHI+1		;ANY DIGITS YET?
	 JRST	TSTSG1		;YES, DONE
	TLO	SW,LED.MI	;REMEMBER LEADING MINUS
	JRST	CVTDB.		;CONTINUE CONVERSION

;BLANK OR TAB
CVBKTB::	TLNN	SW,LED.SG	;ANY LEADING SIGNS?
	 JRST	NEGIF1		;NO--GO BY "M" FLAG
	TLNE	SW,LED.PL	;[630] LEADING PLUS?
	 POPJ	PP,		;[630] YES, POSITIVE ANSWER, RETURN

TSTSG1:	JUMPL	SW,NEGAT1	;NEGATE IF INPUT IS SIGNED
	 POPJ	PP,		;ELSE RESULT IS POSITIVE

LEDSG2:	TLNN	SW,LED.MI	;MINUS?
	 POPJ	PP,		;NO
	JRST	NEGAT1		;YES--NEGATE RESULT


;;[12B];; IF THERE IS A SEPARATE SIGN, BE REALLY PICKY ABOUT
;WHAT THE DATA LOOKS LIKE.  A RUNTIME WARNING WILL BE GENERATED
; IF THERE IS JUNK.

IFN ANS74,<
ENTRY CVDBL.			;CVTDB. WITH LEADING SIGN
ENTRY CVDBT.			;CVTDB. WITH TRAILING SIGN

;EXTRA FLAGS FOR "SW":
	SW%TER==(1B5)		;ALREADY TYPED ERROR MESSAGE ONCE

;NUMERIC CONVERSION INSTRUCTIONS
CSSCV:	CVTDBT	NUMS.6##	;SIXBIT
	CVTDBT	NUMS.7##	;ASCII
	0
	CVTDBT	NUMS.9##	;EBCDIC

CVDBL.:	DMOVEM	4,CVARGS##	;SAVE ARGS INCASE ERRORS
	PUSH	PP,1		;SAVE AC1
	ILDB	1,5		; GET FIRST CHARACTER - SHOULD BE GRAPHIC SIGN
	PUSHJ	PP,@TYPCA3-6(SW) ;CONVERT TO ASCII CHARACTER
	CAIE	1,"+"		;GRAPHIC PLUS
	CAIN	1,"-"		;OR GRAPHIC MINUS
	 JRST	CVTDL1		;YES, OK SO FAR
	PUSHJ	PP,CVTDL2	;"Numeric conversion check.."
	DMOVE	4,CVARGS##	;GET BACK ARGS..
	IBP	5		;SKIP OVER FIRST CHAR..
CVTDL1:	TLO	SW,LED.PL	;ASSUME LEADING +
	CAIN	1,"-"		;UNLESS IT WAS GRAPHIC MINUS..
	 TLC	SW,LED.PL!LED.MI ; TURN ON LED.MI, OFF LED.PL
	POP	PP,1		;RESTORE AC1
	SUBI	B.FLAG,1	;MAKE IT ONE LESS CHARACTER..
	EXTEND	B.FLAG,CSSCV-6(SW) ;CONVERT THE NUMBER..
	 JRST	CVTDL2		;ABORT CHECK (SHOULDN'T HAPPEN!)
	JUMPL	SW,CVTDL3	;JUMP IF SIGNED.
	POPJ	PP,		;UNSIGNED RESULT - RETURN WITH MAGNITUDE

CVTDL2:	TLOE	SW,SW%TER	;IF ALREADY GAVE ERROR,
	 POPJ	PP,		;JUST RETURN
	TYPE	[ASCIZ/%LBLCVT Numeric conversion check for leading separate sign item
/]
	PJRST	TYPCAG		;TYPE ARGUMENTS TO THE ROUTINE, THEN POPJ

TYPCAG:	DMOVE	4,CVARGS##	;RESTORE INITIAL ARGS.
	TYPE	<[ASCIZ/ [LBLCVD Invalid data was: !/]>
TYPCA1:	SOJL	4,TYPCA2	;JUMP WHEN ALL DONE
	ILDB	1,5		;GET CHARACTER IN AC1
	PUSHJ	PP,@TYPCA3-6(SW) ;CONVERT TO ASCII CHARACTER
	TYPET1			;TYPE IT
	JRST	TYPCA1		;LOOP FOR WHOLE DATA ITEM

TYPCA3:	TYPCA4			;CONVERT SIXBIT TO ASCII
	TYPCA5			;ASCII TO ASCII PRINTABLE
	0
	TYPCA6			;EBCDIC TO ASCII PRINTABLE

;Convert SIXBIT character to ASCII printable
TYPCA4:	ADDI	1,40		;CONVERT SIXBIT TO ASCIZ
	POPJ	PP,		;RETURN - THEY'RE ALL PRINTABLE

;Convert ASCII character to ASCII printable
TYPCA5:	SKIPN	1	;CONVERT NULLS TO
	MOVEI	1," "	;SPACES
	CAIGE	1," "	;IF CONTROL-CHARACTER..
	MOVEI	1,"\"	;WE WILL TYPE BACKSLASH
	POPJ	PP,	;RETURN

;Convert EBCDIC character to ASCII printable
TYPCA6:	LDB	1,IPT971##	;CONVERT EBCDIC TO ASCII
	JRST	TYPCA5		;CONVERT TO PRINTABLE CHARACTER

;HERE WHEN DONE PRINTING THE INVALID DATA
TYPCA2:	TYPE	<[ASCIZ/!]
/]>
	POPJ	PP,		;RETURN WITH WHAT WE GOT.

CVTDL3:	TLNE	SW,LED.PL	;LEADING PLUS?
	 POPJ	PP,		;YES, LEAVE AS IS
	TLNE	SW,(1B1)	;CHECK FOR 2-WORD RESULT
	 JRST	NEG2		;GO NEGATE IT
	MOVN	DSTLO,DSTLO	;NEGATE 1-WORD RESULT
	POPJ	PP,		;RETURN

;CONVERT DECIMAL TO BINARY, TRAILING SEPARATE SIGN
CVDBT.:	DMOVEM	4,CVARGS##	;SAVE ARGUMENTS, INCASE ERRORS
	EXTEND	B.FLAG,CSSCV-6(SW)	;CONVERT..
	 JRST	CVTAT		;ABORT FOR TRAILING SIGN
CVTDT1:	TYPE	[ASCIZ/%LBLCVT Numeric conversion check for trailing separate sign
/]
	PJRST	TYPCAG		;TYPE ARGUMENT TO THE ROUTINE, THEN RETURN

;Normal case should get here as the instruction aborts on
; the last character, which will be + or -.
CVTAT:	TRNE	B.FLAG,-1	;SHOULD BE NO CHARACTERS LEFT!
	 JRST	CVTDT1		;NO, RANDOM CHARACTER IN MIDDLE OF ITEM
	PUSH	PP,1		;SAVE 1
	LDB	1,5		;GET OFFENDING CHARACTER
	PUSHJ	PP,@TYPCA3-6(SW) ;CONVERT TO ASCII CHARACTER
	CAIN	1,"+"		;GRAPHIC PLUS?
	 JRST	CVTAT1		;YES, RETURN
	CAIE	1,"-"		;GRAPHIC MINUS?
	 JRST	[POP PP,1	;No, FIX STACK
		JRST CVTDT1]	;(Error: RANDOM CHARACTER IN SIGN POSITION)
	POP	PP,1		;RESTORE T1
	JUMPL	SW,NEGAT1	;NEGATE IT IF ANSWER IS SIGNED
	POPJ	PP,		;NO, JUST RETURN WITH POSITIVE NUMBER

;Number ends with graphic plus - leave answer as is.
CVTAT1:	POP	PP,1		;RESTORE 1
	POPJ	PP,		;RETURN
>;END IFN ANS74
>	;END OF BIS
	END