User Tools

Site Tools


cdc:nos2.source:nam5871:xdrint

XDRINT

Table Of Contents

  • [00003] PROC XDRINT (BUFFER, BUFPOS, INTARR, INTLEN, OPERATION)
  • [00005] XDRINT CONVERT BETWEEN INTEGERS AND EXT DATA REPRESENTATION

Source Code

XDRINT.txt
  1. *DECK XDRINT
  2. USETEXT TEXTXDR
  3. PROC XDRINT (BUFFER, BUFPOS, INTARR, INTLEN, OPERATION);
  4. *CALL COPYRITE CDCNET - COPYRIGHT CONTROL DATA. 1992.
  5. # TITLE XDRINT CONVERT BETWEEN INTEGERS AND EXT DATA REPRESENTATION #
  6.  
  7. BEGIN # XDRINT #
  8. #
  9. **** XDRINT - CONVERT BETWEEN INTEGERS 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 *INTARR* IS 32 BIT
  15. * INTEGERS.
  16. *
  17. * PROC XDRINT (BUFFER, BUFPOS, INTARR, INTLEN, OPERATION)
  18. *
  19. * ENTRY BUFFER = INTEGER ARR PACKED 7.5 BYTES WORD.
  20. * BUFPOS = INDEX OF NEXT BYTE TO BE READ OR WRITTEN.
  21. * INTARR = 32 BIT INTEGER ARRAY.
  22. * INTLEN = NUMBER OF INTEGER VALUES TO BE READ OR
  23. * WRITTEN TO INTARRAY.
  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. * INTARR = DATA READ OUT OR WRITTEN TO.
  29. *
  30. * METHOD IF OPERATION IS *READ*, *INTLEN* INTEGERS ARE READ OUT OF
  31. * *BUFFER* AND STORED IN *INTARR*.
  32. * IF THE OPERATION IS *WRITE*, *INTLEN* BYTES ARE READ
  33. * FROM *INTARR* 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.
  39. * THE CALLER IS RESPONSIBLE FOR MAKING SURE THAT THE
  40. * DESTINATION ARRAY IS LARGE ENOUGH TO HOLD THE NUMBER
  41. * OF VALUES SPECIFIED.
  42. *
  43. #
  44.  
  45. #
  46. **
  47. #
  48.  
  49. ARRAY BUFFER [0:0] S(1); # ARRAY OF DATA, 7.5 BYTES/WORD #
  50. ITEM BUF$WRD U(00,00,60); # WORD REFERENCE #
  51. ITEM BUFPOS I; # CUR BYTE POSITION IN BUFFER #
  52. ARRAY INTARR [0:0] S(1); # ARRAY OF INTEGERS #
  53. ITEM INT$WRD U(00,00,60); # WORD REFERENCE #
  54. ITEM INTLEN I; # NUMBER OF BYTES TO BE PROCESSD#
  55. ITEM OPERATION S:XDROPER; # OPERATION TO PERFORM ON BUFFER#
  56.  
  57. ITEM BITPOS I; # BIT POSITION IN BUFFER #
  58. ITEM INDEX I; # LOOP INDEX #
  59. ITEM REMBUFF I; # BITS REMAINING IN CURRENT WORD#
  60. ITEM REMINT I; # BITS WRAPPED TO SECOND WORD #
  61. ITEM WORDPOS I; # WORD POSITION IN BUFFER #
  62. CONTROL EJECT;
  63. #
  64. **** START MAIN PROCEDURE
  65. #
  66.  
  67. BITPOS = XDRMODU (BUFPOS * 8, 60);# INITIAL BIT POSITION IN BUF #
  68. WORDPOS = (BUFPOS * 2) / 15; # INITIAL WORD INDEX WITHIN BUF #
  69. BUFPOS = BUFPOS + (INTLEN * 4); # ENDING BUFFER LOCATION #
  70.  
  71. SWITCH OPER$:XDROPER OPER$READ:READ,
  72. OPER$WRITE:WRITE;
  73.  
  74. GOTO OPER$ [OPERATION];
  75. BEGIN # OPERATION TYPE #
  76.  
  77. OPER$READ:
  78.  
  79. FOR INDEX = 0 STEP 1 UNTIL (INTLEN - 1) DO
  80. BEGIN # LOOP THROUGH REQUESTED INTEGER#
  81. IF BITPOS LQ 28 THEN
  82. BEGIN # INTEGER DOES NOT WRAP #
  83. INT$WRD [INDEX] = B<BITPOS, 32>BUF$WRD [WORDPOS];
  84. BITPOS = BITPOS + 32;
  85. IF BITPOS GQ 60
  86. THEN
  87. BEGIN
  88. BITPOS = 0;
  89. WORDPOS = WORDPOS + 1;
  90. END
  91. END
  92. ELSE
  93. BEGIN # INTEGER WRAPS BETWEEN 2 WORDS #
  94. REMBUFF = 60 - BITPOS; # BITS REMAINING IN CURRENT WORD#
  95. REMINT = 32 - REMBUFF; # NUMBER OF BITS IN SECOND WORD #
  96. INT$WRD [INDEX] = B<BITPOS, REMBUFF>BUF$WRD [WORDPOS] *
  97. (2 ** REMINT) +
  98. B<0, REMINT>BUF$WRD [WORDPOS + 1];
  99. WORDPOS = WORDPOS + 1;
  100. BITPOS = REMINT;
  101. END
  102.  
  103. END # LOOP THROUGH REQUESTED INTEGER#
  104.  
  105. GOTO OPER$END;
  106.  
  107. OPER$WRITE:
  108.  
  109. FOR INDEX = 0 STEP 1 UNTIL (INTLEN - 1) DO
  110. BEGIN # LOOP THROUGH REQUESTED INTEGER#
  111. IF BITPOS LQ 28 THEN
  112. BEGIN # INTEGER DOES NOT WRAP #
  113. B<BITPOS, 32>BUF$WRD [WORDPOS] = INT$WRD [INDEX];
  114. BITPOS = BITPOS + 32;
  115. IF BITPOS GQ 60
  116. THEN
  117. BEGIN
  118. BITPOS = 0;
  119. WORDPOS = WORDPOS + 1;
  120. END
  121. END
  122. ELSE
  123. BEGIN # INTEGER WRAPS BETWEEN 2 WORDS #
  124. REMBUFF = 60 - BITPOS; # BITS REMAINING IN CURRENT WORD#
  125. REMINT = 32 - REMBUFF; # NUMBER OF BITS IN SECOND WORD #
  126. B<BITPOS, REMBUFF>BUF$WRD [WORDPOS] =
  127. B<28, REMBUFF>INT$WRD [INDEX];
  128. B<0, REMINT>BUF$WRD [WORDPOS + 1] =
  129. B<28 + REMBUFF, REMINT>INT$WRD [INDEX];
  130. WORDPOS = WORDPOS + 1;
  131. BITPOS = REMINT;
  132. END
  133.  
  134. END # LOOP THROUGH REQUESTED INTEGER#
  135.  
  136. GOTO OPER$END;
  137.  
  138. END # OPERATION TYPE #
  139.  
  140. OPER$END:
  141.  
  142. RETURN; # RETURN TO CALLER #
  143.  
  144. END # XDRINT #
  145.  
  146. TERM
cdc/nos2.source/nam5871/xdrint.txt ยท Last modified: 2023/08/05 17:23 by Site Administrator