Trailing-Edge
-
PDP-10 Archives
-
BB-H580E-SB_1985
-
gc.mac
There are 16 other files named gc.mac in the archive. Click here to see a list.
TITLE GC FOR LIBOL V12C
SUBTTL CONVERT COMP-3 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:
;V10 *****
; 15-DEC-74 /ACK CREATION.
;*****
SEARCH LBLPRM ;DEFINE PARAMETERS.
%%LBLP==:%%LBLP
EXTERN EASTB. ;FORCE EASTBL TO BE LOADED.
HISEG
.COPYRIGHT ;Put COPYRIGHT statement in .REL file.
COMMENT \
THIS ROUTINE CONVERTS A PACKED DECIMAL STRING TO A ONE OR TWO WORD
BINARY NUMBER.
CALL:
MOVE 16,[Z AC,PARAMETER ADDRESS]
PUSHJ 17,GC3.
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 RESIDUE FOR THE INPUT FIELD.
BIT 6 1 IF THE FIELD IS EXPLICITLY SIGNED.
BITS 7-17 SIZE OF THE FIELD.
BITS 18-35 ADDRESS OF THE FIRST CHARACTER OF THE INPUT FIELD.
THE INPUT IS A SEQUENCE OF NINE BIT BYTES, EACH CONSISTING OF TWO
FOUR BIT DECIMAL NUMBERS RIGHT JUSTIFIED IN EACH BYTE.
RETURNS:
CALL+1 ALWAYS.
REGISTERS USED:
SW, CNT, IPTR, AC, AC+1, AC+2, CH, T1 (ALIAS CH), T2, JAC
\
ENTRY GC3.
EXTERN SET1. ;ROUTINE TO PICK UP THE PARAMETERS.
EXTERN GDSP1. ;ROUTINE TO NEGATE THE SINGLE PRECISION
; RESULT, IF NECESSARY, AND STORE IT.
EXTERN GDDP5. ;ROUTINE TO NEGATE THE DOUBLE PRECISION
; RESULT, IF NECESSARY, AND STORE IT.
EXTERN PACFL. ;POINTER TO THE NUMBER OF THE AC INTO
; WHICH WE ARE TO PLACE THE RESULT.
GC3.: MOVEI CH, ^D8 ;TELL SET1. THAT WE ARE PLAYING
; WITH EBCDIC.
JSP JAC, SET1. ;GO PICK UP THE PARAMETERS.
GC: TRNN CNT, 1 ;IS THE NUMBER OF DIGITS TO BE
; ODD OR EVEN.
TLO SW, OECNT ;EVEN, REMEMBER THAT.
CAILE CNT, ^D10 ;ONE OR TWO WORD RESULT?
JRST GC1 ;TWO WORDS - USE DOUBLE
; PRECISION ROUTINE.
;HERE WE WORK ON A SINGLE PRECISION RESULT.
ADDI CNT, 2 ;SEE HOW MANY NINE BIT BYTES WE
LSH CNT, -1 ; HAVE.
PUSHJ PP, GC3CSP ;GO CONVERT THE NUMBER.
JSP JAC, GC3NEG ;SEE IF WE HAVE TO NEGATE THE RESULT
EXP GDSP1. ;RETURN TO THE GET SINGLE PRECISION
; ROUTINE TO STORE THE RESULT.
;COME HERE IF THE RESULT IS TO BE DOUBLE PRECISION.
GC1: HRRI SW, (CNT) ;SAVE THE COUNT.
MOVEI CNT, 5 ;SET IT TO 5.
PUSHJ PP, GC3CSP ;GO CONVERT 9 DIGITS.
IMULI AC+1, ^D10 ;SHIFT THE RESULT ONE DIGIT.
ADDI AC+1, (T1) ;ADD IN THE 9TH DIGIT.
HRRZI CNT, -^D8(SW) ;FIGURE OUT HOW MUCH MORE WE HAVE
LSH CNT, -1 ; TO CONVERT.
SOJE CNT, GC2 ;ONLY ONE DIGIT?
JSP JAC, GC3G2 ;NO, GO GET TWO DIGITS AND MAKE
; THEM INTO A BINARY NUMBER.
IMULI AC, ^D100 ;SHIFT THE ACCUMULATION LEFT BY
MULI AC+1, ^D100 ; TWO DIGITS.
PUSHJ PP, GC3CP ;TAKE CARE OF CROSS PRODUCT AND
; ADD IN THE TWO DIGITS.
SOJG CNT, GC3G2 ;LOOP IF THERE IS MORE THAN ONE
; DIGIT LEFT.
GC2: ILDB T1, IPTR ;GET THE LAST DIGIT AND THE SIGN.
LSHC T1, -4 ;SEPARATE THEM.
IMULI AC, ^D10 ;SHIFT THE ACCUMULATION LEFT BY
MULI AC+1, ^D10 ; ONE DIGIT.
PUSHJ PP, GC3CP ;TAKE CARE OF CROSS PRODUCT AND
; ADD IN THE LAST DIGIT.
LSHC T1, 4 ;GET THE SIGN BACK.
ANDI T1, 17 ;ISOLATE IT.
JSP JAC, GC3NEG ;NEGATE THE RESULT?
EXP GDDP5. ;RETURN TO GET DOUBLE PRECISION
; DISPLAY ROUTINE TO STORE
; THE RESULT.
;SUBROUTINE TO CONVERT A BCD NUMBER OF 9 OR FEWER DIGITS TO A ONE
; WORD BINARY NUMBER.
COMMENT \
CALL:
PUSHJ PP,GC3CSP
ENTRY CONDITIONS:
(IPTR) = BYTE POINTER TO THE INPUT STRING.
(CNT) = (NUMBER OF DIGITS TO BE CONVERTED + 1) / 2
EXIT CONDITIONS:
(AC) = 0
(AC+1) = THE RESULT OF THE CONVERSION
(T1) = THE LAST FOUR BITS OF THE LAST BYTE (IF DOING A
SINGLE PRECISION CONVERSION, THIS IS THE SIGN.
IF DOING THE FIRST PART OF A DOUBLE PRECISION
CONVERSION THIS IS THE TENTH DIGIT.)
(T1+1) = GARBAGE.
RETURNS:
CALL+1 ALWAYS.
\
GC3CSP: SETZB AC, AC+1 ;CLEAR A PLACE TO ACCUMULATE
; THE RESULT
TLZE SW, OECNT ;ODD OR EVEN NUMBER OF DIGITS?
JRST GC3CS8 ;EVEN, GO GET THE FIRST ONE.
GC3CS2: SOJE CNT, GC3CS5 ;JUMP IF ONLY ONE DIGIT TO CONVERT.
JSP JAC, GC3G2 ;GET THE NEXT TWO BCD DIGITS IN BINARY.
IMULI AC+1, ^D100 ;SHIFT THE ACCULULATION LEFT BY TWO DIGITS.
ADDI AC+1, (T1) ;ADD IN THE TWO DIGITS.
SOJG CNT, GC3G2 ;JUMP IF THERE IS MORE THAN ONE
; DIGIT LEFT.
GC3CS5: ILDB T1, IPTR ;GET THE NEXT DIGIT AND THE SIGN
; (OR TWO DIGITS.)
LSHC T1, -4 ;SEPARATE THEM.
IMULI AC+1, ^D10 ;SHIFT THE ACCULULATION LEFT
; BY ONE DIGIT.
ADDI AC+1, (T1) ;ACCUMULATE THE RESULT.
LSHC T1, 4 ;GET THE SIGN (OR TENTH DIGIT.)
ANDI T1, 17 ;ISOLATE IT.
POPJ PP, ;RETURN.
GC3CS8: ILDB AC+1, IPTR ;GET THE FIRST DIGIT.
ANDI AC+1, 17 ;GET RID OF ANY JUNK.
SOJA CNT, GC3CS2 ;GO CONVERT THE REST.
;SUBROUTINE TO GET TWO BCD DIGITS AND CONVERT THEM TO BINARY.
COMMENT \
CALLS:
JSP JAC, GC3G2 ;THE FIRST TIME.
SOJG CNT, GC3G2 ;SUBSEQUENT TIMES.
ENTRY CONDITIONS:
(IPTR) = BYTE POINTER TO THE INPUT STRING.
EXIT CONDITIONS:
(T1) = THE RESULT OF THE CONVERSION.
(T1+1) = GARBAGE.
\
GC3G2: ILDB T1, IPTR ;GET A*16+B
LDB T1+1, [POINT 4,T1,31] ;GET A
LSH T1+1, 1 ;FORM A*2
SUBI T1, (T1+1) ;FORM A*16+B-A*2
LSH T1+1, 1 ;FORM A*4
SUBI T1, (T1+1) ;FORM A*16+B-A*2-A*4 = A*10+B
JRST (JAC) ;RETURN
;SUBROUTINE TO SEE IF WE HAVE TO NEGATE THE RESULT.
COMMENT \
CALL:
JSP JAC, GC3NEG
ENTRY CONDITIONS:
(T1) = THE SIGN.
EXIT CONDITIONS:
(T2) = THE AC INTO WHICH THE RESULT IS TO BE PLACED.
(SW)
LS ALWAYS 1
LM IF THE SIGN WAS SOME FORM OF "-" THIS IS 1.
RETURNS:
THIS ROUTINE ALWAYS RETURNS TO THE LOCATION SPECIFIED IN CALL+1.
\
GC3NEG: TLO SW, LS ;TURN ON THE LEADING SIGN FLAG.
CAIE T1, 13 ;SOME FORM OF "-"?
CAIN T1, 15
TLO SW, LM ;YES, REMEMBER IT.
LDB T2, PACFL. ;FIND OUT WHERE TO PUT THE RESULT.
JRST @(JAC) ;RETURN THROUGH CALL+1.
;SUBROUTINE USED BY THE DOUBLE PRECISION ROUTINE TO HANDLE THE CROSS
; PRODUCT AND ADDING IN THE DIGIT(S).
COMMENT \
CALL:
PUSHJ PP, GC3CP
ENTRY CONDITIONS:
(AC) = HIGH ORDER WORD LESS THE CROSS PRODUCT.
(AC+1) = CROSS PRODUCT.
(AC+2) = LOW ORDER WORD.
(T1) = DIGITS TO BE ADDED INTO THE ACCUMULATION.
EXIT CONDITIONS:
(AC) = HIGH ORDER WORD.
(AC+1) = LOW ORDER WORD.
\
GC3CP: ADD AC, AC+1 ;ADD IN THE CROSS PRODUCT.
MOVE AC+1, AC+2 ;GET THE LOW ORDER WORD.
JOV .+1 ;CLEAR THE OVERFLOW FLAG.
ADDI AC+1, (T1) ;ADD IN THE DIGIT(S).
JOV .+2 ;DID WE OVERFLOW?
POPJ PP, ;NO, RETURN.
TLZ AC+1, (1B0) ;CLEAR THE SIGN BIT OF THE LOW
; ORDER WORD.
AOJA AC, .-2 ;BUMP THE HIGH ORDER WORD AND
; RETURN
END