User Tools

Site Tools


cdc:nos2.source:nam5871:ssbebf

SSBEBF

Table Of Contents

  • [00002] PROC SSBEBF (TABLE, ORD, BIT, LEN, RESULT)
  • [00003] SSBEBF - EXTRACT BITFIELD FROM A TABLE.
  • [00007] EXTRACT BITFIELD FROM A TABLE.

Source Code

SSBEBF.txt
  1. *DECK SSBEBF
  2. PROC SSBEBF (TABLE, ORD, BIT, LEN, RESULT);
  3. # TITLE SSBEBF - EXTRACT BITFIELD FROM A TABLE. #
  4.  
  5. BEGIN # SSBEBF #
  6. #
  7. ** SSBEBF - EXTRACT BITFIELD FROM A TABLE.
  8. *
  9. * D. G. DEPEW. 81/10/08.
  10. *
  11. * PROC SSBEBF (TABLE, ORD, BIT, LEN, RESULT)
  12. *
  13. * ENTRY TABLE = ARRAY FROM WHICH BITFIELD IS TO BE EXTRACTED.
  14. * ORD = WORD ORDINAL WITHIN TABLE WHERE BITFIELD STARTS.
  15. * BIT = STARTING BIT POSITION WITHIN THE WORD (SYMPLESE).
  16. * LEN = NUMBER OF BITS TO EXTRACT (RANGE: 1 TO 60).
  17. *
  18. * EXIT RESULT = RESULT OF THE EXTRACTION, CONCATENATED (WHEN A
  19. * WORD BOUNDARY IS CROSSED) AND RIGHT JUSTIFIED
  20. * WITH LEADING ZEROES.
  21. * TABLE = UNCHANGED.
  22. * ORD = INCREMENTED BY 1 IF THE BITFIELD SPANS A WORD
  23. * BOUNDARY.
  24. * BIT = FIRST BIT POSITION AFTER THE EXTRACTED BITFIELD.
  25. * LEN = UNCHANGED.
  26. *
  27. * NOTES RESULT IS UNPREDICTABLE IF LEN IS OUT OF RANGE.
  28. * IF THE SPECIFIED BITFIELD SPANS A WORD BOUNDARY, THE
  29. * OVERFLOW BITS ARE TAKEN FROM THE NEXT CONSECUTIVE CM
  30. * WORD. THAT IS, NO CONSIDERATION IS MADE FOR SYMPL
  31. * PARALLEL ARRAYS OR FOR ARRAYS WITH AN ENTRY SIZE
  32. * GREATER THAN ONE.
  33. #
  34.  
  35. ARRAY TABLE [00:00] S(1); #TABLE CONTAINING BITFIELD #
  36. ITEM T$WD U(00,00,60);
  37.  
  38. ITEM ORD; #WORD WITHIN TABLE #
  39. ITEM BIT; #STARTING BIT WITHIN WORD #
  40. ITEM LEN; #LENGTH OF BITFIELD #
  41. ITEM RESULT U; #WORD THAT RECEIVES BITFIELD #
  42.  
  43. ITEM THIS; #NUM OF BITS TO EXTRACT FM SPECIFIED WORD #
  44. ITEM NEXT; #NUM OF BITS TO EXTRACT FM FOLLOWING WORD #
  45.  
  46.  
  47.  
  48.  
  49.  
  50. IF (BIT + LEN) GR 60
  51. THEN # WORD BOUNDARY IS SPANNED #
  52. BEGIN
  53. THIS = 60 - BIT;
  54. NEXT = BIT + LEN - 60;
  55. RESULT = (B<BIT,THIS> T$WD[ORD] * 2 ** NEXT)
  56. LOR (B<0,NEXT> T$WD[ORD + 1]);
  57. ORD = ORD + 1;
  58. BIT = NEXT;
  59. END
  60. ELSE # WORD BOUNDARY NOT SPANNED #
  61. BEGIN
  62. RESULT = B<BIT,LEN> T$WD[ORD];
  63. IF (BIT + LEN) EQ 60
  64. THEN # BITFIELD ENDS ON WORD BOUNDARY #
  65. BEGIN
  66. ORD = ORD + 1;
  67. BIT = 0;
  68. END
  69. ELSE # SIMPLEST CASE #
  70. BIT = BIT + LEN;
  71. END
  72.  
  73. END # SSBEBF #
  74.  
  75. TERM
cdc/nos2.source/nam5871/ssbebf.txt ยท Last modified: 2023/08/05 17:23 by Site Administrator