User Tools

Site Tools


cdc:nos2.source:nam5871:ssbsbf

SSBSBF

Table Of Contents

  • [00002] PROC SSBSBF (TABLE, ORD, BIT, LEN, SOURCE)
  • [00003] SSBSBF - STORE BITFIELD IN A TABLE.
  • [00007] STORE BITFIELD IN A TABLE.

Source Code

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