home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / JAMAPI.ZIP / TPAPI.ZIP / JCRC32.ASM < prev    next >
Encoding:
Assembly Source File  |  1993-07-01  |  5.8 KB  |  140 lines

  1. ;;
  2. ;;    JAM(mbp) - The Joaquim-Andrew-Mats Message Base Proposal
  3. ;;
  4. ;;    Turbo Pascal API
  5. ;;
  6. ;;    Written by Joaquim Homrighausen.
  7. ;;
  8. ;;    ----------------------------------------------------------------------
  9. ;;
  10. ;;    jcrc32.asm
  11. ;;
  12. ;;    CRC-32 calculation on block
  13. ;;
  14. ;;    Copyright 1993 Joaquim Homrighausen, Andrew Milner, Mats Birch, and
  15. ;;    Mats Wallin. ALL RIGHTS RESERVED. But see below notice.
  16. ;;
  17. ;;    ----------------------------------------------------------------------
  18. ;;
  19. ;;    The original C code for this CRC-32 function was written by Gary S.
  20. ;;    Brown and then converted to 8086 assembler by Joaquim Homrighausen.
  21. ;;
  22. ;;  So, in all fairness, here is the copyright notice from Gary's original
  23. ;;    code. This is the only function excepted from the copyright status of
  24. ;;    the JAM TP API.
  25. ;;
  26. ;;    Copyright (C) 1986 Gary S. Brown. You may use this program, or code or
  27. ;;    tables extracted from it, as desired without restriction.
  28. ;;
  29. ;;    ----------------------------------------------------------------------
  30. ;;
  31. ;;    TASM (3.x):
  32. ;;        tasm /ml /m5 /p /w2 /zi JCRC32;
  33. ;;
  34. ;;    MASM (5.x):
  35. ;;        masm /Ml /p /w2 /Zi JCRC32;
  36. ;;
  37. ;;    Turbo Pascal prototype:
  38. ;;        function crc32(VAR Buf; BufLen:WORD; OldCRC:LONGINT):LONGINT;
  39. ;;
  40. ;;    Initializer:
  41. ;;        $ffffffff (-1)
  42. ;;
  43. CODE SEGMENT WORD PUBLIC
  44.  
  45.     ASSUME CS:CODE, DS:NOTHING, ES:NOTHING
  46.  
  47.     PUBLIC CRC32
  48.  
  49. ctablo: dw 0
  50.     dw 12438, 24876, 20922, -15335, -2929, -23243, -27229, -30670, -18268
  51.     dw -5858, -9848, 19499, 31933, 11527, 7569, 4196, 8434, 29000
  52.     dw 16862, -11139, -6933, -19119, -31289, -26538, -22336, -1670, -13844
  53.     dw 23631, 27865, 15715, 3573, 8392, 4190, 16868, 29042, -6959
  54.     dw -11193, -31235, -19093, -22278, -26516, -13866, -1728, 27875, 23669
  55.     dw 3535, 15705, 12460, 58, 20864, 24854, -2891, -15325, -27239
  56.     dw -23281, -18274, -30712, -9806, -5852, 31879, 19473, 7595, 11581
  57.     dw 16784, 28934, 8380, 4138, -31351, -19169, -7003, -11213, -13918
  58.     dw -1740, -22386, -26600, 3515, 15661, 27799, 23553, 20980, 24930
  59.     dw 12504, 78, -27155, -23173, -2879, -15273, -9786, -5808, -18198
  60.     dw -30596, 7647, 11593, 31987, 19557, 24920, 20942, 116, 12514
  61.     dw -23231, -27177, -15251, -2821, -5782, -9732, -30650, -18224, 11635
  62.     dw 7653, 19551, 31945, 28988, 16810, 4112, 8326, -19163, -31309
  63.     dw -11255, -7009, -1778, -13928, -26590, -22348, 15639, 3457, 23611
  64.     dw 27821, -31968, -19530, -7668, -11622, 18233, 30639, 9749, 5763
  65.     dw 2834, 15236, 27198, 23208, -12533, -99, -20953, -24911, -27836
  66.     dw -23598, -3480, -15618, 22365, 26571, 13937, 1767, 7030, 11232
  67.     dw 31322, 19148, -8337, -4103, -16829, -28971, -23576, -27778, -15676
  68.     dw -3502, 26609, 22375, 1757, 13899, 11226, 6988, 19190, 31328
  69.     dw -4157, -8363, -28945, -16775, -19572, -31974, -11616, -7626, 30613
  70.     dw 18179, 5817, 9775, 15294, 2856, 23186, 27140, -89, -12495
  71.     dw -24949, -20963, -15696, -3546, -23652, -27894, 1705, 13887, 26501
  72.     dw 22291, 19074, 31252, 11182, 6968, -29029, -16883, -4169, -8415
  73.     dw -11564, -7614, -19464, -31890, 5837, 9819, 30689, 18295, 23270
  74.     dw 27248, 15306, 2908, -24833, -20887, -45, -12475, -7560, -11538
  75.     dw -31916, -19518, 9825, 5879, 18253, 30683, 27210, 23260, 2918
  76.     dw 15344, -20909, -24891, -12417, -23, -3556, -15734, -27856, -23642
  77.     dw 13829, 1683, 22313, 26559, 31278, 19128, 6914, 11156, -16841
  78.     dw -29023, -8421, -4211
  79.  
  80. ctabhi: dw 0
  81.     dw 30471, -4594, -26359, 1901, 28778, -5789, -24988, 3803, 31196
  82.     dw -7979, -26670, 2486, 32433, -6216, -28481, 7607, 27312, -3143
  83.     dw -31554, 6874, 28125, -2860, -31789, 4972, 25707, -670, -30107
  84.     dw 5121, 25350, -1521, -29432, 15214, 19561, -10912, -23961, 15363
  85.     dw 19204, -11763, -23286, 13749, 17074, -9285, -21316, 13016, 17887
  86.     dw -9002, -21551, 9945, 20958, -14121, -16432, 8628, 22195, -12358
  87.     dw -18243, 10242, 24325, -14836, -20213, 12143, 22632, -16031, -18842
  88.     dw 30428, 475, -26414, -4139, 29105, 1718, -24641, -5960, 30727
  89.     dw 3840, -27127, -7922, 32618, 2157, -28316, -6557, 27499, 7276
  90.     dw -31387, -3486, 27654, 6913, -32248, -2801, 26032, 4791, -29762
  91.     dw -839, 25309, 5594, -29485, -1068, 19890, 15029, -23620, -11077
  92.     dw 19167, 15832, -23343, -11306, 17257, 13422, -21145, -9632, 17412
  93.     dw 13059, -22006, -8947, 20485, 9986, -16885, -14068, 22376, 8303
  94.     dw -18074, -12703, 24286, 10713, -20272, -14377, 22963, 11956, -18499
  95.     dw -16198, -4680, -25921, 950, 29873, -5419, -25134, 1243, 29660
  96.     dw -7325, -27548, 3437, 31338, -7154, -27895, 2560, 32007, -4081
  97.     dw -30968, 7681, 26886, -2206, -32667, 6508, 28267, -300, -30253
  98.     dw 4314, 26589, -1607, -28994, 6071, 24752, -10538, -24111, 14552
  99.     dw 20447, -11845, -22852, 16309, 18610, -10227, -20726, 13827, 16644
  100.     dw -8352, -22425, 12654, 18025, -13471, -17306, 9583, 21096, -13300
  101.     dw -17653, 8706, 21765, -14918, -19779, 11188, 23731, -15657, -18992
  102.     dw 11481, 23518, -25756, -5021, 30058, 621, -25591, -5362, 29191
  103.     dw 1280, -27201, -7496, 31665, 3254, -27950, -6699, 31964, 3035
  104.     dw -31021, -3628, 26845, 8154, -32322, -2375, 28592, 6327, -30712
  105.     dw -241, 26118, 4353, -28827, -1950, 24939, 5740, -24566, -10483
  106.     dw 19972, 14595, -22681, -12192, 18793, 15982, -20783, -9770, 16607
  107.     dw 14296, -22084, -8517, 18354, 12469, -16963, -13638, 21427, 9396
  108.     dw -17712, -12841, 21726, 9177, -19610, -15263, 23912, 10863, -19445
  109.     dw -15604, 23045, 11522
  110.  
  111. CRC32 proc far
  112.     push    bp
  113.     mov     bp, sp
  114.     mov     dx, word ptr [bp+8]
  115.     mov     ax, word ptr [bp+6]
  116.     mov     cx, word ptr [bp+10]
  117.     les     si, dword ptr [bp+12]
  118.     xor     di, di
  119. repeat:
  120.     mov     bx, di               
  121.     mov     bl, es:[si]          
  122.     xor     bl, al               
  123.     shl     bx, 1
  124.     mov     al, ah               
  125.     mov     ah, dl               
  126.     mov     dl, dh               
  127.     xor     dh, dh
  128.     xor     ax, word ptr ctablo [bx]
  129.     xor     dx, word ptr ctabhi [bx]
  130.     inc     si
  131.     loop    repeat
  132.     pop     bp
  133.     ret     10
  134. CRC32 endp
  135.  
  136. CODE ENDS
  137.      END
  138.  
  139. ;; end of file "jcrc32.asm"
  140.