*DECK LFGMOVW
USETEXT LFGWKBS
PROC LFGMOVW(AN,AA,BPOS,NWDS,IW60,CKSM,MEMIN);
BEGIN #MOVWD#
*IF DEF,IMS
#
** LFGMOVW - MOVE WORDS.
*
* JJ MCAFEE 75/10/01
* M. E. VATCHER 81/02/23
*
* LFGMOVW MOVES AND SHIFTS LOAD DATA FROM AN INPUT ARRAY TO
* A SM ARRAY.
*
* PROC LFGMOVW(AN,AA,BPOS,NWDS,IW60,CKSM,MEMIN)
*
* ENTRY AN STARTING WORD OF SOURCE ARRAY
* AA STARTING WORD OF DESTINATION ARRAY
* BPOS STARTING BIT POSITION IN DESTINATION ARRAY
* NWDS 16 BIT WORD COUNT
* CKSM CHECKSUM
* MEMIN INPUT BUFFER FWA
*
* EXIT IW60 60 BIT WORD COUNT
*
* METHOD
*
* LFGMOVW PACKS THE MEMORY IMAGE OR OVERLAY IMAGE RECORD INTO
* THE WORKING STORAGE AREA *PDATA*. CHECKSUM IS STORED FIRST.
* THE DATA IS TAKEN FROM SOURCE *INBUF* AND SENT TO DESTINATION
* *PBUF*. THERE ARE TWO POSSIBLE CASES: 1)WHERE ALL THE DATA IS IN
* ONE WORD, AND 2) WHERE DATA IS SPLIT BETWEEN THE WORDS.
* LOOP FOR 105 16 BIT WORDS OR FEWER UNTIL PACKING COMPLETE.
*
#
*ENDIF
ITEM BPOS,NWDS,IW60,CKSM;
ITEM AA;
ITEM AN;
ITEM I U;
ITEM SINDX,DINDX,CKS,AWDS,SST,DST;
ITEM SBC,DBC,SWD,SFCU,SWS;
ARRAY MEMIN [0:0] S(1);
BEGIN
ITEM INBUF U;
END
FOR I = 0 STEP 1 UNTIL 35 DO
BEGIN
PBUF[I] = 0;
END
SINDX = AN; # SET START OF SOURCE ARRAY #
DINDX = AA; # SET START OF DESTN ARRAY #
IW60 = AA + 1; # NUMBER OF 60 BIT WORDS #
AWDS = NWDS + 1; # NO. OF 16 BIT WORDS#
SST = 0; # SOURCE BIT COUNT #
DST = BPOS; # DESTINATION BIT COUNT#
SBC = 16; DBC = 16;
SWD = CKSM;
GOTO LOOP2; #GO STORE CKSUM FIRST#
LOOP1:IF SST LQ 44 THEN # SOURCE WORD ALL IN ONE #
BEGIN
SWD = B<SST,SBC>INBUF[SINDX];
SST = SST + 16;
IF SST EQ 60 THEN
BEGIN
SST = 0;
SINDX = SINDX + 1;
END
END
ELSE # SOURCE WORD SPLIT OVER 2 #
BEGIN
SFCU = 60 - SST; # SET BFTS LEFT IN WORD 1 #
SWS = 44; # HOLD WORD START POSITION#
# HOLD WORD BFT COUNT #
B<SWS,SFCU>SWD = B<SST,SFCU>INBUF[SINDX];
SST = 0; # RESET START COUNT#
SWS = SWS + SFCU; # ADJUST HOLD WORD START POS#
SFCU = 16 - SFCU; # ADJUST NO. OF BITS LEFT #
SINDX = SINDX + 1; # ADJUST SOURCE INDEX #
B<SWS,SFCU>SWD = B<SST,SFCU>INBUF[SINDX];
SST = SST + SFCU; # ADJUST START POSITION #
END
LOOP2:IF DST LQ 44 THEN # DEST. WORD ALL IN ONE WORD#
BEGIN
B<DST,DBC>PBUF[DINDX] = SWD;
DST = DST + 16; # ADJUST DESIGN. START POS. #
IF DST EQ 60 THEN
BEGIN
DST = 0;
DINDX = DINDX + 1;
IW60 = IW60 + 1;
END
END
ELSE
BEGIN
SFCU = 60-DST; # SET BITS IN FIRST WORD#
SWS = 44; # SET START OF HOLD WORD #
B<DST,SFCU>PBUF[DINDX] = B<SWS,SFCU>SWD;
DINDX = DINDX + 1; # INC. DESTINATION INDEX #
IW60 = IW60 + 1; # INC. 60 BIT WORD COUNT #
SWS = SWS + SFCU; # ADJ. HOLD WORD START POS. #
DST = 0; # ADJ. DEST. WORD START POS.#
SFCU = 16 - SFCU; # ADJ. BIT COUNT #
B<DST,SFCU>PBUF[DINDX] = B<SWS,SFCU>SWD;
DST = DST + SFCU;
END
AWDS = AWDS - 1; #DECREMENT 16 BIT WORD COUNT#
IF AWDS GR 0 THEN GOTO LOOP1;
RETURN;
END
TERM