*DECK NS$GNW
USETEXT CYB$NS
USETEXT DEF$NS
USETEXT SMB$NS
PROC NS$GNW(FROMARRAY,(BUFHDRSIZE),(NPWINDEX),NPUWORD); # GET NPU WORD #
# TITLE NS$GNW - GET NPU WORD. #
BEGIN # NS$GNW #
#
** NS$GNW - GET NPU WORD.
*
* J.C. LEE 1981
*
* THIS ROUTINE GETS A 16-BIT NPU WORD.
*
* PROC NS$GNW(FROMARRAY,(BUFHDRSIZE),(NPUINDEX),NPUWORD)
*
* ENTRY:
* FROMARRAY - ARRAY NPU WORD TO GET FROM.
* BUFHDRSIZE - BUFFER HEADER SIZE IN 8-BIT BYTES.
* NPUINDEX - NPU WORD INDEX AFTER BUFFER HEADER.
*
* EXIT:
* NPUWORD = 16-BIT NPU WORD.
*
* METHOD:
* THE 16-BIT NPU WORD IS EXTRACTED FROM THE "FROMARRAY".
*
#
ARRAY FROMARRAY [0:0] S(1);
BEGIN
ITEM ARRAYWORD U(0,0,60);
END
ITEM BUFHDRSIZE U; # BUFFER HEADER SIZE IN 8-BIT BYTES #
ITEM NPWINDEX U; # NPU WORD INDEX AFTER BUFFER HEADER #
ITEM NPUWORD U; # 16-BIT NPU WORD #
$BEGIN
XREF
BEGIN
PROC NS$DBG; # TRACE PROCEDURE CALLS #
END
$END
ITEM BITCOUNT I; # BIT COUNT #
ITEM I I; # TEMPORARY #
ITEM J I; # TEMPORARY #
ITEM K I; # TEMPORARY #
CONTROL EJECT;
$BEGIN
NS$DBG("GNW");
$END
P<SMB> = LOC(FROMARRAY); # FWA OF BUFFER #
NPUWORD = 0;
BITCOUNT = BUFHDRSIZE*ASCSIZE + NPWINDEX*NPWSIZE;
I = BITCOUNT / WL; # WORD INDEX #
J = BITCOUNT - I*WL; # FIRST BIT POSITION OF NPU WORD#
K = J + NPWSIZE - WL; # BITS IN NEXT CM WORD #
IF K GR 0
THEN # NPU WORD CROSSES CM WORD #
BEGIN
B<WL-NPWSIZE,NPWSIZE-K>NPUWORD = B<J,WL-J>SMBWORD[I];
B<WL-K,K>NPUWORD = B<0,K>SMBWORD[I+1];
END
ELSE # WHOLE NPU WORD FITS IN CM WORD#
NPUWORD = B<J,NPWSIZE>SMBWORD[I];
RETURN;
END # NS$GNW #
TERM