*DECK SSBEBF PROC SSBEBF (TABLE, ORD, BIT, LEN, RESULT); # TITLE SSBEBF - EXTRACT BITFIELD FROM A TABLE. # BEGIN # SSBEBF # # ** SSBEBF - EXTRACT BITFIELD FROM A TABLE. * * D. G. DEPEW. 81/10/08. * * PROC SSBEBF (TABLE, ORD, BIT, LEN, RESULT) * * ENTRY TABLE = ARRAY FROM WHICH BITFIELD IS TO BE EXTRACTED. * ORD = WORD ORDINAL WITHIN TABLE WHERE BITFIELD STARTS. * BIT = STARTING BIT POSITION WITHIN THE WORD (SYMPLESE). * LEN = NUMBER OF BITS TO EXTRACT (RANGE: 1 TO 60). * * EXIT RESULT = RESULT OF THE EXTRACTION, CONCATENATED (WHEN A * WORD BOUNDARY IS CROSSED) AND RIGHT JUSTIFIED * WITH LEADING ZEROES. * TABLE = UNCHANGED. * ORD = INCREMENTED BY 1 IF THE BITFIELD SPANS A WORD * BOUNDARY. * BIT = FIRST BIT POSITION AFTER THE EXTRACTED BITFIELD. * LEN = UNCHANGED. * * NOTES RESULT IS UNPREDICTABLE IF LEN IS OUT OF RANGE. * IF THE SPECIFIED BITFIELD SPANS A WORD BOUNDARY, THE * OVERFLOW BITS ARE TAKEN FROM THE NEXT CONSECUTIVE CM * WORD. THAT IS, NO CONSIDERATION IS MADE FOR SYMPL * PARALLEL ARRAYS OR FOR ARRAYS WITH AN ENTRY SIZE * GREATER THAN ONE. # ARRAY TABLE [00:00] S(1); #TABLE CONTAINING BITFIELD # ITEM T$WD U(00,00,60); ITEM ORD; #WORD WITHIN TABLE # ITEM BIT; #STARTING BIT WITHIN WORD # ITEM LEN; #LENGTH OF BITFIELD # ITEM RESULT U; #WORD THAT RECEIVES BITFIELD # ITEM THIS; #NUM OF BITS TO EXTRACT FM SPECIFIED WORD # ITEM NEXT; #NUM OF BITS TO EXTRACT FM FOLLOWING WORD # IF (BIT + LEN) GR 60 THEN # WORD BOUNDARY IS SPANNED # BEGIN THIS = 60 - BIT; NEXT = BIT + LEN - 60; RESULT = (B T$WD[ORD] * 2 ** NEXT) LOR (B<0,NEXT> T$WD[ORD + 1]); ORD = ORD + 1; BIT = NEXT; END ELSE # WORD BOUNDARY NOT SPANNED # BEGIN RESULT = B T$WD[ORD]; IF (BIT + LEN) EQ 60 THEN # BITFIELD ENDS ON WORD BOUNDARY # BEGIN ORD = ORD + 1; BIT = 0; END ELSE # SIMPLEST CASE # BIT = BIT + LEN; END END # SSBEBF # TERM