Trailing-Edge
-
PDP-10 Archives
-
BB-H506D-SM_1983
-
cobol/source/move.mac
There are 10 other files named move.mac in the archive. Click here to see a list.
; UPD ID= 1180 on 8/15/78 at 10:40 AM
TITLE MOVE FOR LIBOL
SUBTTL MOVE A STRING OF CHARACTERS /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, 1981 BY DIGITAL EQUIPMENT CORPORATION
;REVISION HISTORY:
;V10 *****
; 15-DEC-74 /ACK CREATION.
; 26-JAN-75 /ACK REWRITTEN - BAD REGISTER ALLOCATION.
; (T1 AND CH WERE THE SAME REGISTER, WHICH
; SCREWED UP BLT'S.)
; 5/10/75 /DBT BIS CODE
;*****
SEARCH LBLPRM ;DEFINE PARAMETERS.
%%LBLP==:%%LBLP
DEBUG==:DEBUG
BIS==:BIS
EXTERN EASTB. ;FORCE EASTBL TO BE LOADED.
HISEG
COMMENT \
THIS ROUTINE MOVES A STRING OF CHARACTERS FROM ONE PLACE TO ANOTHER.
MOVEI 16,PARAMETER ADDRESS
PUSHJ 17,MOVE.
PARAMETERS:
WORD 1:
BYTE POINTER TO THE INPUT STRING.
WORD 2:
BITS 0-5 BYTE POINTER RESIDUE FOR THE OUTPUT STRING.
BIT 6 IGNORED (1 IF THE FIELD IS EXPLICTLY SIGNED.)
BITS 7-17 SIZE OF THE FIELDS.
BITS 18-35 ADDRESS OF THE FIRST BYTE OF THE OUTPUT FIELD.
RETURNS:
CALL+1 ALWAYS.
REGISTERS USED:
JAC, CNT, CH, TAC2, TAC3, TAC4, IPTR, OPTR
\
ENTRY MOVE.
ENTRY MVD.AL ;MOVE ALL "LIT" TO DEPENDING VARIABLE
EXTERN SET2. ;ROUTINE TO PICK UP THE PARAMETERS.
EXTERN RET.1 ;RETURNS TO CALL+1.
EXTERN PTIBS. ;POINTER TO THE INPUT BYTE SIZE.
EXTERN PTOBS. ;POINTER OT THE OUTPUT BYTE SIZE.
T1==TAC2
T2==TAC2+1 ;ALSO KNOWN AS TAC3.
T3==TAC4
IFN BIS,<
;MAKE SURE THAT THE REGISTERS DON'T GET SCREWED UP.
CHKREG==0
IFN CNT-SRCCNT,<CHKREG==1>
IFE SRCPT-CNT,<CHKREG==1>
IFE SRCPT-OPTR,<CHKREG==1>
IFE DSTCNT-OPTR,<CHKREG==1>
IFN CHKREG,<
PRINTX ?MOVE IS BROKEN - BAD REGISTER ALLOCATION - CHECK LISTING.
CNT==CNT
SRCCNT==SRCCNT
SRCPT==SRCPT
DSTCNT==DSTCNT
OPTR==OPTR
>
>
MOVE.: JSP JAC, SET2. ;GO PICK UP THE PARAMETERS.
EXP RET.1 ;RETURN THROUGH HERE ON A NULL STRING.
LDB T3, PTIBS. ;GET THE INPUT BYTE SIZE.
DPB T3, PTOBS. ;MAKE IT THE OUTPUT BYTE SIZE.
IFE BIS,<
JUMPL 16, MOVDEP ;IF THIS A DEPENDING MOVE THEN SPECIAL CASE
>;END IFE BIS
CAIG CNT, ^D15 ;WORTH TRYING TO BLT?
JRST MOVE4 ;NO, GO MOVE CHAR'S.
HLRZ T1, IPTR
HLRZ T2, OPTR
CAIE T1, (T2) ;IS A BLT POSSIBLE?
JRST MOVE4 ;NO, GO MOVE CHAR'S.
;THE FOLLOWING LOOP SHOULD BE EXECUTED AT MOST FIVE TIMES.
TRZ T1, 770077 ;BYTE SIZE IN BITS 24-29.
MOVE1: LDB T2, [POINT 12,IPTR,11] ;NUMBER OF BITS LEFT.
CAIG T2, (T1) ;LESS THAN ONE BYTE LEFT?
AOJA IPTR, MOVE2 ;YES, GO MOVE UP TO NEXT WORD AND BLT.
CAIL T2, 4400 ;ARE WE AT A WORD BOUNDARY?
JRST MOVE3 ;YES, GO BLT.
ILDB CH, IPTR ;MOVE UP ONE BYTE.
IDPB CH, OPTR
SOJG CNT, MOVE1 ;LOOP.
IFE DEBUG,<
POPJ PP, ;THIS CAN'T HAPPEN! (BUT JUST IN
; CASE - NO HARM DONE.)
>
IFN DEBUG,<
OUTSTR [ASCIZ /
%MOVE fell through while looking for a word boundary at MOVE1+8 in MOVE.
/]
HALT RET.1
>
;MOVE UP TO THE NEXT WORD BECAUSE THERE IS LESS THAN 1 BYTE LEFT IN
; THIS ONE, THIS SHOULD ONLY HAPPEN FOR ASCII.
MOVE2: ADDI OPTR, 1
MOVEI CH, 44
DPB CH, [POINT 6,IPTR,5]
DPB CH, [POINT 6,OPTR,5]
;WE CAN BLT AT LEAST ONE WORD.
MOVE3: IDIV CNT, CHPRWD-6(T3) ;NUMBER OF WORDS TO TRANSFER (NOTE:
; NUMBER OF CHARACTERS LEFT IS IN CH).
HRRI T2, (OPTR) ;DESTINATION.
HRLI T2, (IPTR) ;SOURCE.
ADDI OPTR, (CNT) ;LAST WORD IN DESTINATION + 1.
BLT T2, -1(OPTR) ;FINALLY!!
JUMPE CH, RET.1 ;ANY MORE BYTES?
ADDI IPTR, (CNT) ;YES, UPDATE THE SOURCE POINTER.
MOVEI CNT, (CH) ;AND THE COUNT.
;COME HERE WHEN ALL ELSE FAILS.
MOVE4:
IFE BIS,<
ILDB CH, IPTR ;GET A CHAR.
IDPB CH, OPTR ;STASH IT.
SOJG CNT, MOVE4 ;LOOP IF THERE ARE MORE.
POPJ PP, ;OTHERWISE RETURN.
> ;END NON-BIS BYTE MOVE
IFN BIS,<
MOVE SRCPT,IPTR ;SET UP THE AC'S FOR THE
MOVE DSTCNT,CNT ; MOVSLJ.
MOVE DSTPT,OPTR
EXTEND CNT,[MOVSLJ] ;DO THE MOVE.
JRST XTND.E
POPJ PP, ;DONE
INTERN XTND.E
XTND.E: OUTSTR [ASCIZ /?Error return from Extend instruction./]
JRST KILL.##
> ;END BIS
IFE BIS,< ;MORE IFE BIS
;HERE FOR DEPENDING MOVE
; CNT = # CHARS IN SOURCE STRING
MOVDEP: HLRZ T2,16 ;GET # CHARS IN DEST.
TRZ T2,400000 ;CLEAR 1B0
;MOVE THE MINIMUM OF CNT AND T2 CHARS. IF DEST LEN IS GREATER, FILL WITH SPACES
MOVEI T3,(CNT)
CAILE CNT,(T2) ;GET CNT = MINIMUM
MOVE CNT,T2
ILDB CH,IPTR ;GET A CHAR
IDPB CH,OPTR ;STASH IT
SOJG CNT,.-2 ;LOOP FOR ALL
;SPACE FILL IF NECESSARY
CAIG T2,(T3) ;MORE CHARS IN DEST.?
POPJ PP, ;NO, DONE
SUB T2,T3 ;T2= # SPACES TO PUT IN
LDB T3,PTIBS. ;GET BYTE SIZE
SUBI T3,6
MOVE CH,[EXP 0,40,0,100](T3) ;GET A SPACE
IDPB CH,OPTR
SOJG T2,.-1
POPJ PP, ;DONE SPACE FILL...RETURN
>;END IFE BIS
;HERE FOR "MOVE ALL "LIT" TO DEPENDING VARIABLE"
;CALL: AC4/ SIZE OF LIT
; AC7/ COMPUTED SIZE OF "B"
; AC5/ BYTE PTR TO "A"
; AC10/ BYTE PTR TO "B"
; NOTE: THE BYTE SIZES MUST BE EQUAL!!
;RETURNS: .+1 ALWAYS
;THIS ROUTINE SMASHES ACS 4 THRU 12 INCLUSIVE
MVD.AL: CAMLE 7,4 ;JUST 1 OCCURANCE OR LESS?
JRST MVDAL1 ;NO, MORE
JUMPLE 7,RET.1 ;JUMP IF NOTHING TO DO
ILDB 6,5 ;GET A CHAR
IDPB 6,10 ;AND STORE IT
SOJG 7,.-2 ; UNTIL DONE
POPJ PP, ; THEN RETURN
MVDAL1: MOVE 11,10 ;SAVE FIRST BP TO "B"
MOVE 12,4 ;SAVE # CHARS IN LITERAL
ILDB 6,5 ;GET A CHAR
IDPB 6,10 ; AND STORE IT
SOJG 4,.-2 ;LOOP FOR ALL CHARS IN THE LITERAL
SUBI 7,(12) ;GET # CHARS LEFT TO MOVE
MOVE 5,11 ;NOW MOVE FROM THE BEGINNING OF "B"
ILDB 6,5 ;TO WHERE WE LEFT OFF
IDPB 6,10 ;. .
SOJG 7,.-2 ;UNTIL "B" IS FILLED UP
POPJ PP, ; THEN RETURN
;TABLE OF CHARACTERS PER WORD:
CHPRWD: EXP 6
EXP 5
EXP 0
EXP 4
END