User Tools

Site Tools


cdc:nos2.source:nam5871:xdrbyte

XDRBYTE

Table Of Contents

  • [00003] PROC XDRBYTE (BUFFER, BUFPOS, BYTEARR, BYTELEN, OPERATION)
  • [00005] XDRBYTE CONVERT BETWEEN BYTES AND EXT DATA REPRESENTATION

Source Code

XDRBYTE.txt
  1. *DECK XDRBYTE
  2. USETEXT TEXTXDR
  3. PROC XDRBYTE (BUFFER, BUFPOS, BYTEARR, BYTELEN, OPERATION);
  4. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  5. # TITLE XDRBYTE CONVERT BETWEEN BYTES AND EXT DATA REPRESENTATION #
  6.  
  7. BEGIN # XDRBYTE #
  8. #
  9. **** XDRBYTE - CONVERT BETWEEN BYTES AND EXT DATA REPRESENTATION
  10. *
  11. * THIS PROCEDURE WILL READ DATA OUT OF *BUFFER*, OR WRITE DATA INTO
  12. * *BUFFER* DEPENDING ON THE *OPERATION* PARAMETER. THE DATA IN
  13. * *BUFFER* IS IN XDR (EXTERNAL DATA REPRESENTATION) FORMAT, 8 BIT
  14. * BYTES PACKED 7.5/CYBER WORD. THE DATA IN *BYTEARR* IS 8 BIT
  15. * INTEGERS.
  16. *
  17. * PROC XDRBYTE (BUFFER, BUFPOS, BYTEARR, BYTELEN, OPERATION)
  18. *
  19. * ENTRY BUFFER = INTEGER ARRAY PACKED 7.5 BYTES/WORD.
  20. * BUFPOS = INDEX OF NEXT BYTE TO BE READ OR WRITTEN.
  21. * BYTEARR = 8 BIT BYTE ARRAY.
  22. * BYTELEN = NUMBER OF BYTE VALUES TO BE READ OR
  23. * WRITTEN TO BYTEARRAY.
  24. * OPERATION = EITHER *READ* FROM OR *WRITE* TO *BUFFER*.
  25. *
  26. * EXIT BUFFER = DATA READ OUT OR WRITTEN TO.
  27. * BUFPOS = BYTE POSITION IN *BUFFER* AFTER OPERATION.
  28. * BYTEARR = DATA READ OUT OR WRITTEN TO.
  29. *
  30. * METHOD IF OPERATION IS *READ*, *BYTELEN* BYTES ARE READ OUT OF
  31. * *BUFFER* AND STORED IN *BYTEARR*.
  32. * IF THE OPERATION IS *WRITE*, *BYTELEN* BYTES ARE READ
  33. * FROM *BYTEARR* AND ARE STORED IN *BUFFER*.
  34. * *BUFPOS* IS UPDATED TO THE NEXT READ/WRITE BYTE POSITION.
  35. * THE ARITHMETIC MODULO BASE 60 FUNCTION IS PERFORMED ON
  36. * *BUFPOS* MULTIPLIED BY EIGHT TO DETERMINE THE BIT
  37. * POSITION WITHIN BUFFER. IF THE POSITION IS 56, THE
  38. * BYTE IS SPLIT ACROSS TWO WORDS. THE BYTE IS THEN READ
  39. * FROM OR WRITTEN TO THE PROPER LOCATION.
  40. * THE CALLER IS RESPONSIBLE FOR MAKING SURE THAT THE
  41. * DESTINATION ARRAY IS LARGE ENOUGH TO HOLD THE NUMBER
  42. * OF VALUES SPECIFIED.
  43. *
  44. #
  45.  
  46. #
  47. **
  48. #
  49.  
  50. ARRAY BUFFER [0:0] S(1); # ARRAY OF DATA, 7.5 BYTES/WORD #
  51. ITEM BUF$WRD U(00,00,60); # WORD REFERENCE #
  52. ITEM BUFPOS I; # CUR BYTE POSITION IN BUFFER #
  53. ARRAY BYTEARR [0:0] S(1); # ARRAY OF INTEGERS #
  54. ITEM BYTE$WRD U(00,00,60); # WORD REFERENCE #
  55. ITEM BYTELEN I; # NUMBER OF BYTES TO BE PROCESSD#
  56. ITEM OPERATION S:XDROPER; # OPERATION TO PERFORM ON BUFFER#
  57.  
  58. ITEM INDEX I; # LOOP INDEX #
  59. ITEM BITPOS I; # BIT POSITION IN BUFFER #
  60. ITEM WORDPOS I; # WORD POSITION IN BUFFER #
  61. CONTROL EJECT;
  62. #
  63. **** START MAIN PROCEDURE
  64. #
  65.  
  66. BITPOS = XDRMODU (BUFPOS * 8, 60);# INITIAL BIT POSITION IN BUF #
  67. WORDPOS = (BUFPOS * 2) / 15; # INITIAL WORD INDEX WITHIN #
  68. BUFPOS = BUFPOS + BYTELEN; # ENDING BUFFER LOCATION #
  69.  
  70. SWITCH OPER$:XDROPER OPER$READ:READ,
  71. OPER$WRITE:WRITE;
  72.  
  73. GOTO OPER$ [OPERATION];
  74. BEGIN # OPERATION TYPE #
  75.  
  76. OPER$READ:
  77.  
  78. FOR INDEX = 0 STEP 1 UNTIL (BYTELEN - 1) DO
  79. BEGIN # LOOP THROUGH REQUESTED BYTES #
  80. IF BITPOS EQ 56
  81. THEN
  82. BEGIN # BYTE SPLIT BETWEEN WORDS #
  83. BYTE$WRD [INDEX] = B<56,4>BUF$WRD [WORDPOS] * 16 +
  84. B<0,4>BUF$WRD [WORDPOS + 1];
  85. WORDPOS = WORDPOS + 1;
  86. BITPOS = 4;
  87. END
  88. ELSE
  89. BEGIN # BYTE IN SINGLE CM WORD #
  90. BYTE$WRD [INDEX] = B<BITPOS,8>BUF$WRD [WORDPOS];
  91. BITPOS = BITPOS + 8;
  92. IF BITPOS GQ 60
  93. THEN
  94. BEGIN
  95. BITPOS = 0;
  96. WORDPOS = WORDPOS + 1;
  97. END
  98. END
  99. END # LOOP THROUGH REQUESTED BYTES #
  100.  
  101. GOTO OPER$END;
  102.  
  103. OPER$WRITE:
  104.  
  105. FOR INDEX = 0 STEP 1 UNTIL (BYTELEN - 1) DO
  106. BEGIN # LOOP THROUGH REQUESTED BYTES #
  107. IF BITPOS EQ 56
  108. THEN
  109. BEGIN # BYTE SPLIT BETWEEN WORDS #
  110. B<56,4>BUF$WRD [WORDPOS] = B<52,4>BYTE$WRD [INDEX];
  111. B<0,4>BUF$WRD [WORDPOS + 1] = B<56,4>BYTE$WRD [INDEX];
  112. WORDPOS = WORDPOS + 1;
  113. BITPOS = 4;
  114. END
  115. ELSE
  116. BEGIN # BYTE IN SINGLE CM WORD #
  117. B<BITPOS,8>BUF$WRD [WORDPOS] = BYTE$WRD [INDEX];
  118. BITPOS = BITPOS + 8;
  119. IF BITPOS GQ 60
  120. THEN
  121. BEGIN
  122. BITPOS = 0;
  123. WORDPOS = WORDPOS + 1;
  124. END
  125. END
  126. END # LOOP THROUGH REQUESTED BYTES #
  127.  
  128. GOTO OPER$END;
  129.  
  130. END # OPERATION TYPE #
  131.  
  132. OPER$END:
  133.  
  134. RETURN; # RETURN TO CALLER #
  135.  
  136. END # XDRBYTE #
  137.  
  138. TERM
cdc/nos2.source/nam5871/xdrbyte.txt ยท Last modified: 2023/08/05 17:23 by Site Administrator