Table of Contents

EXTRACT

Table Of Contents

  • [00007] EXTRACT/INSERT - BIT MANIPULATION ROUTINE.
  • [00199] VVA - VERIFY VALIDITY OF ARGUMENTS.

Source Code

EXTRACT.txt
  1. IDENT EXTRACT
  2. ENTRY EXTRACT
  3. ENTRY INSERT
  4. SYSCOM B1
  5. *COMMENT EXTRACT/INSERT - BIT MANIPULATION ROUTINE.
  6. COMMENT COPYRIGHT CONTROL DATA SYSTEMS INC. 1992.
  7. TITLE EXTRACT/INSERT - BIT MANIPULATION ROUTINE.
  8. SPACE 4
  9. ***** EXTRACT/INSERT - BIT MANIPULATION ROUTINE.
  10. *
  11. * W. E. MARTIN. 78/10/30.
  12. EXTRACT SPACE 4,45
  13. *** EXTRACT/INSERT - BIT MANIPULATION ROUTINE.
  14. *
  15. * EXTRACT/INSERT SUPPORTS THE COBOL TASK WRITER FOR THE
  16. * SITUATIONS WHERE BIT-ORIENTED OPERATIONS SUCH AS *TARO* AND
  17. * *TSIM* MONITOR REQUESTS ARE DESIRED. THE BASIC OPERATION
  18. * PROVIDED IS TO RIGHT-JUSTIFY THE FIELD SPECIFIED IN THE
  19. * ARGUMENTS, SO THAT MORE TRADITIONAL *COBOL* ARITHMETIC CAN
  20. * BE PERFORMED. ALTHOUGH THIS ROUTINE MAY BE ENTERED FROM
  21. * *FTN*, IT-S USE IS INTENDED TO AID THE *COBOL* PROGRAMMER WHO
  22. * FINDS THAT THE *STRING/UNSTRING* FUNCTIONS DO NOT PERFORM THE
  23. * NECESSARY OPERATIONS SATISFACTORILY, OR THAT HIS DATA DOES
  24. * NOT LEND ITSELF TO COMPUTATIONAL-4 MAPPING.
  25. *
  26. * THE VALUE FIELDS OF THE PARAMETER LIST ARE CHECKED FOR
  27. * EXISTENCE AND SIZE. IF ANY ARGUMENTS ARE MISSING OR LARGER
  28. * THAN THE WORD SIZE, THEN THE TASK IS ABORTED.
  29. *
  30. * COBOL CALL -
  31. *
  32. * ENTER EXTRACT USING SOURCE, DESTINATION, LOC1, LOC2.
  33. *
  34. * FTN CALL -
  35. *
  36. * CALL EXTRACT ( SOURCE, DESTINATION, LOC1, LOC2)
  37. *
  38. * WHERE - SOURCE = SOURCE FIELD TO HAVE BITS EXTRACTED FROM.
  39. * MAY BE ANY DATA TYPE, BUT MUST BEGIN ON A WORD
  40. * BOUNDARY.
  41. *
  42. * THE REMAINING ITEMS MUST BE COMPUTATIONAL-1
  43. * OR INTEGER.
  44. *
  45. * DESTINATION = DATA-NAME TO RETURN THE EXTRACTED
  46. * BITS.
  47. *
  48. * LOC1 = BEGINNING BIT POSITION IN THE SOURCE FIELD.
  49. *
  50. * LOC2 = LENGTH OF BIT STRING TO EXTRACT FROM SOURCE.
  51. *
  52. * USES A - 0, 1, 2, 6.
  53. * X - 0, 1, 2, 6, 7.
  54. * B - 1, 4.
  55. *
  56. * CALLS VVA.
  57. *
  58. * MACROS ARGERR.
  59. SPACE 4
  60. * COMMON TEXTS.
  61.  
  62.  
  63. *CALL COMCMAC
  64. *CALL COMKMAC
  65. SPACE 4
  66. VFD 42/0LEXTRACT,18/EXTRACT
  67.  
  68. EXT2 SA1 EXTA RESTORE THE (A0)
  69. SA0 X1+
  70.  
  71. EXTRACT SUBR ENTRY/EXIT
  72. SX6 A0+ SAVE (A0)
  73. SB1 1
  74. ZR X1,EXT1 IF NO ARGUMENTS - ABORT TASK
  75. SA6 EXTA
  76. SA2 X1+ READ SOURCE FIELD
  77.  
  78. * DETERMINE VALIDITY OF ARGUMENTS.
  79.  
  80. RJ VVA VERIFY VALIDITY OF ARGUMENTS
  81. NE B4,EXT1 IF ERROR IN ARGUMENTS - ABORT TASK
  82.  
  83. * EXTRACT SPECIFIED FIELD.
  84.  
  85. SX1 59
  86. SB4 X5-1 ADJUSTED BIT STRING LENGTH
  87. MX7 1
  88. AX7 B4 (X7) = MASK
  89. SB4 X4+1 SHIFT COUNT FOR MASK
  90. LX7 B4 POSITION MASK
  91. BX6 X7*X2
  92. IX1 X1-X4 COMPUTE SHIFT COUNT
  93. IX1 X1+X5
  94. SB4 X1 SHIFT COUNT TO RIGHT JUSTIFY
  95. LX6 B4
  96. SA6 X3
  97. EQ EXT2 RESTORE (A0) AND RETURN
  98.  
  99. * PROCESS PARAMETER ERROR.
  100.  
  101. EXT1 SA1 EXTRACT READ *RJ* ADDRESS
  102. MX0 30
  103. LX1 30
  104. SA1 X1-1
  105. BX6 -X0*X6
  106. SA6 EXTA
  107. ARGERR A6 EXIT TO EXECUTIVE
  108.  
  109. EXTA CON 0 STORAGE FOR (A0)
  110. INSERT SPACE 4,35
  111. *** INSERT - INSERT BITS INTO A WORD.
  112. * INSERT IS INTENDED TO PROVIDE A COMPANION CAPABILITY FOR
  113. * THE EXTRACT ROUTINE, BY MOVING USER-SPECIFIED BIT STRINGS
  114. * TO ARBITRARY POSITIONS WITHIN A GIVEN WORD. THIS THEN
  115. * ALLOWS THE COBOL PROGRAMMER THE ABILITY TO TEST AND SET
  116. * BITS WHICH OTHERWISE WOULD REQUIRE CUMBERSOME ARITHMETIC
  117. * OPERATIONS.
  118. *
  119. * COBOL ENTRY -
  120. *
  121. * ENTER INSERT USING SOURCE, DESTINATION, LOC3, LOC4.
  122. *
  123. * FTN ENTRY -
  124. *
  125. * CALL INSERT ( SOURCE, DESTINATION, LOC3, LOC4)
  126. *
  127. * WHERE - SOURCE = SOURCE FIELD TO HAVE BITS EXTRACTED FROM.
  128. * THIS ITEM MAY BE ANY DATA TYPE, BUT MUST BEGIN ON A
  129. * WORD BOUNDARY.
  130. *
  131. * THE REMAINING ITEMS MUST BE COMPUTATIONAL-1
  132. * OR INTEGER.
  133. *
  134. * DESTINATION = DATA-NAME TO RETURN THE EXTRACTED
  135. * BITS.
  136. *
  137. * LOC3 = BEGINING BIT POSITION IN THE DESTINATION
  138. * FIELD - MAYBE COMPUTATIONAL-1 OR INTEGER.
  139. *
  140. * LOC4 = LENGTH OF BIT STRING IN SOURCE WORD - MAY BE
  141. * COMPUTATIONAL-1 OR INTEGER.
  142. *
  143. * USES A - 0, 1, 2, 3, 6.
  144. * X - 1, 2, 3, 6, 7.
  145. * B - 1, 2, 3, 4.
  146. *
  147. * CALLS VVA.
  148. *
  149. * MACROS ARGERR.
  150.  
  151.  
  152. VFD 42/0LINSERT,18/INSERT
  153.  
  154. INT2 SA1 INTA RESTORE (A0)
  155. SA0 X1+
  156.  
  157. INSERT SUBR ENTRY/EXIT
  158. SX6 A0+ SAVE (A0)
  159. SB1 1
  160. ZR X1,INT1 IF NO ARGUMENTS - ABORT TASK
  161. SA6 INTA
  162. SA2 X1+ READ SOURCE FIELD
  163.  
  164. * DETERMINE VALIDITY OF ARGUMENTS.
  165.  
  166. RJ VVA VERIFY VALIDITY OF ARGUMENTS
  167. NE B4,INT1 IF ERROR IN ARGUMENTS - ABORT TASK
  168. SA3 X3+ READ DESTINATION FIELD
  169.  
  170. * INSERT SOURCE FIELD INTO DESTINATION FIELD.
  171.  
  172. SB4 X5-1 (B4) = LENGTH OF MASK
  173. MX7 1
  174. AX7 B4
  175. SB2 B4+B1
  176. LX7 B2 POSITION MASK TO EXTRACT SOURCE FIELD
  177. BX2 X7*X2 EXTRACT VALUE
  178. SB3 X4 (B3) = BEGINNING BIT POSITION
  179. SB3 B3-B4
  180. LX7 B3 POSITION MASK
  181. LX2 B3
  182. BX6 -X7*X3
  183. BX6 X2+X6
  184. SA6 A3
  185. EQ INT2 RESTORE (A0) AND RETURN
  186.  
  187. * PROCESS PARAMETER ERROR.
  188.  
  189. INT1 SA1 INSERT READ *RJ* ADDRESS
  190. MX0 30
  191. LX1 30
  192. SA2 X1-1 READ TRACEBACK WORD
  193. BX6 -X0*X6
  194. SA6 INTA
  195. ARGERR A6 EXIT TO EXECUTIVE
  196.  
  197. INTA CON 0 STORAGE FOR (A0)
  198. VVA SPACE 4,15
  199. ** VVA - VERIFY VALIDITY OF ARGUMENTS.
  200. *
  201. * ENTRY (A1) = FWA OF LIST OF ARGUMENT ADDRESSES.
  202. *
  203. * EXIT (X3) = ADDRESS OF DESTINATION FIELD.
  204. * (X4) = BEGINNING BIT POSITION ARGUMENT.
  205. * (X5) = LENGTH ARGUMENT.
  206. * (B4) = 0, IF NO ERROR.
  207. * .NE. 0, IF ERROR IN ARGUMENT.
  208. *
  209. * USES X - 1, 3, 4, 5, 6, 7.
  210. * A - 3, 4, 5.
  211. * B - 3, 4.
  212.  
  213.  
  214. VVA SUBR ENTRY/EXIT
  215. SA3 A1+B1 ADDRESS OF DESTINATION FIELD
  216. SA4 A3+B1 ADDRESS OF BEGINNING BIT POSITION FIELD
  217. SA5 A4+B1 ADDRESS OF BIT STRING LENGTH FIELD
  218. SB4 B1 SET ERROR FLAG
  219. ZR X3,VVAX IF NO DESTINATION ARGUMENT
  220. ZR X4,VVAX IF NO BEGINNING BIT POSTION ARGUMENT
  221. ZR X5,VVAX IF NO LENGTH ARGUMENT
  222. SA4 X4 READ BEGINNING BIT POSITION
  223. SA5 X5 READ LENGTH
  224. SX6 B1
  225. IX6 X5-X6
  226. SX1 59
  227. NG X4,VVAX IF RANGE ERROR (BIT POSITION .LT. 0)
  228. NG X6,VVAX IF RANGE ERROR (LENGTH .LT. 1)
  229. IX7 X1-X5
  230. IX6 X1-X4
  231. NG X7,VVAX IF RANGE ERROR (LENGTH .GT. 59)
  232. NG X6,VVAX IF RANGE ERROR (BIT POSITION .GT. 59)
  233. IX6 X5-X4
  234. SB3 X6
  235. GT B3,B1,VVAX IF RANGE ERROR
  236. SB4 B0+ CLEAR ERROR FLAG
  237. EQ VVAX RETURN
  238.  
  239. SPACE 4
  240. END