User Tools

Site Tools


cdc:nos2.source:nam5871:lfgcksm

LFGCKSM

Table Of Contents

  • [00004] LFGCKSM - ROUTINE TO CALCULATE THE CHECKSUM
  • [00007] CALCULATE CHECKSUM.

Source Code

LFGCKSM.txt
  1. *DECK LFGCKSM
  2. IDENT LFGCKSM
  3. COMMENT LFGCKSM - ROUTINE TO CALCULATE THE CHECKSUM
  4. TITLE LFGCKSM - ROUTINE TO CALCULATE THE CHECKSUM
  5. ENTRY LFGCKSM
  6. *IF DEF,IMS
  7. ** LFGCKSM - CALCULATE CHECKSUM.
  8. *
  9. * JJ MCAFEE 75/07/01
  10. * M. E. VATCHER 81/02/24
  11. *
  12. * LFGCKSM FORMS A CHECKSUM BY TAKING THE ONE"S COMPLEMENT OF
  13. * THE INTEGER SUM OF N 16 BIT WORDS.
  14. *
  15. * LFGCKSM(BUFADD,BITPOS,NWDS,CKSM)
  16. *
  17. * ENTRY BUFADD ADDRESS OF BUFFER CONTAINING DATA
  18. * BITPOS BIT POSITION (0-59) OF MOST SIGNIFICANT BIT OF
  19. * FIRST WORD
  20. * NWDS NUMBER OF 16 BIT WORDS TO CHECKSUM
  21. *
  22. * EXIT CKSM WORD WHERE CHECKSUM IS RETURNED, RIGHT JUSTIFIED
  23. *
  24. * METHOD
  25. *
  26. * GIVEN THE INPUT BUFFER DATA AND THE NUMBER OF 16 BIT WORDS
  27. * IN THE BUFFER, CALCULATE THE CHECKSUM, MAPPING AND SHIFTING
  28. * BITS AS NEEDED. REGISTERS USED: ALL B AND X REGISTERS, AND
  29. * A1,A2,A4,A5,A6,A7.
  30. *
  31. *ENDIF
  32. LFGCKSM DATA 0 ENTRY
  33. B7=1
  34. SB7 1
  35. *
  36. * PICK UP AND SAVE ENTRY PARAMETERS
  37. *
  38. SA2 X1 BUFFER ADDRESS ADDRESS
  39. SA2 X2 BUFFER FWA
  40. SA1 A1+B7
  41. SA5 X1 STARTING BIT POSITION
  42. SB2 X5 INTO B2
  43. SA1 A1+B7
  44. SA5 X1 NUMBER OF 16 BIT WORDS
  45. SB3 X5 INTO B3
  46. SA1 A1+B7 CKSUM STORAGE ADDRESS
  47. SA5 X1 INTO A5
  48. *
  49. * FORM CONSTANTS AND SUCH
  50. *
  51. SB1 16
  52. SB4 60 HANDY COUNT TO HAVE IN A 60 BIT MACHINE
  53. MX6 0 CLEAR X6 FOR CHECKSUM
  54. SB2 B2+B7 INCREMENT START BIT COUNT BY 1
  55. LT B2,B1,SPEC WRAP AROUND START, SPECIAL PROCESS
  56. *
  57. *
  58. * PICK UP WORDS AND DROP OUT 16 BIT CHECKSUM WORDS
  59. *
  60. *
  61. CKS1 MX5 16 FORM MASK FOR 16 BIT WORD
  62. LX5 B2,X5 SHIFT MASK
  63. BX3 X5*X2 GET 16 BIT WORD FROM BUFFER
  64. SB5 B4-B2 GET SHIFT COUNT TO POS. WORD IN LOW BITS
  65. SB5 B5+B1
  66. LX7 B5,X3 POSITION WORD IN LOW 16 BITS
  67. IX6 X6+X7 INTEGER ADD FOR CHECKSUM
  68. MX5 1 CHECK FOR OVERFLOW
  69. LX5 17
  70. BX5 X6*X5
  71. ZR X5,CKS2 NONE, CONTINUE
  72. MX5 44
  73. BX6 -X5*X6 MASK OUT LOW 16 BITS
  74. SX6 X6+B7 AND ADD IN OVERFLOW
  75. *
  76. * MOVE, SHIFT, REPOSITION AND START AGAIN
  77. *
  78. CKS2 SB3 B3-B7 SEE IF FINISHED
  79. ZR B3,EXIT
  80. SB2 B2-B1 DECREMENT START BY 16
  81. GE B2,B1,CKS1 IF START .GE. 16, BACK TO MAIN LOOP
  82. NZ B2,SPEC IF START .LT. 16, BUT .GT. 0, SPECIAL PROC.
  83. SB2 B4 RESET START
  84. SA2 A2+B7 GET NEXT BUFFER WORD
  85. EQ CKS1 BACK TO MAIN LOOP
  86. *
  87. * SPECIAL PROCESSING FOR END WORD WRAPAROUND
  88. *
  89. SPEC MX5 16 FORM MASK
  90. LX4 B2,X5 POSITION MASK
  91. MX7 16
  92. LX7 16 SET UP MASK MASK
  93. BX4 X4*X7 NOW HAVE MASK FOR LOW BITS OF WD 1
  94. BX3 X4*X2 GET LOW BITS
  95. SB5 B1-B2 SEE HOW MANY TO MOVE
  96. LX3 B5,X3 MOVE LOWER BITS TO ALLOW FOR UPPER BITS
  97. LX5 B2,X5 POSITION MASK FOR UPPER BITS
  98. BX5 -X7*X5 REMOVE ALL BUT UPPER BITS
  99. SA2 A2+B7 GET NEW BUFFER WORD
  100. BX4 X5*X2 AND PICK UP UPPER BITS
  101. LX4 B5,X4 MOVE TO LOW POSITION
  102. BX7 X3+X4 ADD TO UPPER BITS
  103. IX6 X6+X7 INTEGER ADD FOR CHECKSUM
  104. MX5 1 CHECK FOR OVERFLOW
  105. LX5 17
  106. BX5 X6*X5
  107. ZR X5,SPEC1 NONE, CONTINUE
  108. MX5 44
  109. BX6 -X5*X6 MASK OUT LOW 16 BITS
  110. SX6 X6+B7 AND ADD IN OVERFLOW
  111. *
  112. * RESET EVERYTHING
  113. *
  114. SPEC1 SB3 B3-B7
  115. ZR B3,EXIT EXIT IF FINISHED
  116. SB2 B4-B5 RESET B2 FOR NEXT WORD
  117. EQ CKS1 GO BACK TO MAIN LOOP
  118. *
  119. * FINISHED, STORE CHECKSUM AND EXIT
  120. EXIT MX7 16 TAKE COMPLEMENT OF SUM
  121. LX7 16
  122. BX6 -X6*X7
  123. SA6 A5
  124. EQ LFGCKSM
  125. END
cdc/nos2.source/nam5871/lfgcksm.txt · Last modified: 2023/08/05 17:22 by Site Administrator