home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / hp9000basic / hpbdeh.f77 < prev    next >
Text File  |  2020-01-01  |  4KB  |  165 lines

  1.     program hpbdeh
  2. c
  3. c    See "hpbker.bwr" for details.
  4. c
  5. c    Adapted from the FORTRAN-77 program "k11hex.ftn" originally
  6. c    written by Brian Nelson  02-Mar-84  13:50:23.
  7. c
  8. c    This abbreviated version of the original program can be used
  9. c    ONLY for DECODE of "simple" (no checksum bytes) HEX-coded files
  10. c    that are formatted with 64 characters per line, and which have a
  11. c    decoded length that is exactly equal to an integral number of
  12. c    RT-11 blocks.  The 'checksum' verification routine in Brian's
  13. c    program has been omitted.  The size of the task image is about
  14. c    18 kB, and it should run on a PDP-11 under any of the RT-11
  15. c    monitors (SJ, FB, or XM), or under TSX+.  However, it has been 
  16. c    tested in this form ONLY under TSX+.  Conversion times depend on
  17. c    the system and its loading: hpbker.hex, read from a hard disk,
  18. c    took about 2.5 min on a lightly-loaded pdp-11/73; the same file
  19. c    took about 8.5 min to convert when read from an RX-50 floppy on
  20. c    a fairly busy PDP-11/23+.  Conversion times for other HPB*. HEX 
  21. c    files are proportionately shorter.
  22. c
  23. c                                          Roger Wallace 24-Apr-89
  24. c
  25. c
  26. c    To compile and link:        FORTRAN/REC:512   HPBDEH.F77
  27. c
  28. c                                LINK  HPBDEH
  29. c
  30. c
  31. c
  32.     byte    infil(40),outfil(40)
  33. c
  34.     write (5,30040)
  35.     write (5,30030)
  36.     write (5,30035)
  37.     write (5,30000)
  38.     read  (5,30010) infil
  39.     write (5,30020)
  40.     read  (5,30010) outfil
  41.     infil(40)  = 0
  42.     outfil(40) = 0
  43.     open    (unit=1,type='OLD',name=infil,readonly,
  44.     1     carriagecontrol='LIST')
  45.     open    (unit=2,type='NEW',name=outfil,access='DIRECT',
  46.     1     recordsize=512/4,form='UNFORMATTED')
  47.     call cretsk
  48.     close (unit=1)
  49.     close (unit=2)
  50.     call exit
  51. c
  52. 30000    format (1x,'Input  HEX file ? '$)
  53. 30010    format (64a1)
  54. 30020    format (1x,'Output DEH file ? '$)
  55. 30030    format (1x,'Program DECODES simple 64 chars/line HEX files. ')
  56. 30035    format (1x,'No checksum routine included. '//)
  57. 30040    format (1x,' '//)
  58. c
  59.     end
  60. c
  61. c
  62. c
  63. c
  64. c
  65. c
  66.     subroutine cretsk
  67. c
  68.     implicit integer (a-z)
  69.     byte buffer(512)
  70.     byte lbuff(64)
  71.     byte cbuff(6)
  72.     byte chr
  73.     integer chmap(256)
  74.     data chmap /256*0/
  75. c
  76. c    WARNING: Any "illegal" HEX character, not 0-9 or A-F, will simply
  77. c    be set to zero.  This program will run, but he resulting decode
  78. c    will be corrupted and probably not usable.  Make sure you have 
  79. c    "clean" HEX sources!
  80. c
  81.     chmap(48) = 0
  82.     chmap(49) = 1
  83.     chmap(50) = 2
  84.     chmap(51) = 3
  85.     chmap(52) = 4
  86.     chmap(53) = 5
  87.     chmap(54) = 6
  88.     chmap(55) = 7
  89.     chmap(56) = 8
  90.     chmap(57) = 9
  91.     chmap(65) = 10
  92.     chmap(66) = 11
  93.     chmap(67) = 12
  94.     chmap(68) = 13
  95.     chmap(69) = 14
  96.     chmap(70) = 15
  97. c
  98.     type *,' '
  99.     type *,' '
  100.     write (5,30040)
  101. c
  102.     rnum = 1
  103.     blkidx = 1
  104. 10    continue
  105.     off = 1
  106.     do 90 j = 1 , 16
  107.       read(1,30010,end=100,err=99) lbuff
  108.       i = 1
  109.       do 20 k = off,off+31
  110.          buffer(k) = chr( chmap(lbuff(i))*16 + chmap(lbuff(i+1)) )
  111.          i = i + 2
  112. 20      continue
  113.       off = off + 32
  114. 90    continue
  115.     write(2'rnum) buffer
  116.     write (5,30060)
  117.     if (blkidx .eq. 78) then
  118.       write (5,30070)
  119.       blkidx = 0
  120.     endif
  121.     rnum = rnum + 1
  122.     blkidx = blkidx + 1
  123.     go to 10
  124. c
  125. 99    continue
  126.     write (5,30070)
  127.     type *,'      Error reading HEX file.  Decode aborted.'
  128.     write (5,30070)
  129.     return
  130. c
  131. 100    continue
  132.     write (5,30070)
  133.     type *,'      Decoding completed. '
  134.     type *,' '
  135.     wrnum = rnum - 1
  136.     write (5,30050) wrnum
  137. c
  138. c    Yes, it's rnum - 1.  The rnum counter is incremented AFTER the 
  139. c    write, but before the check for 'end-of-file'.
  140. c
  141. 30010    format (64a1)
  142. 30040    format (1x,'Now starting to decode the HEX file ....'//)
  143. 30050    format (1x,'      Number of RT-11 blocks written: 'I6///)
  144. 30060    format (1h+,'*'$)
  145. 30070    format (1x,' '/)
  146. c
  147.     return
  148.     end
  149. c
  150. c
  151. c
  152. c
  153. c
  154. c
  155.     byte function chr(i)
  156. c
  157.     integer i
  158.     byte b(2)
  159.     integer ch
  160.     equivalence (b(1),ch)
  161.     ch = i
  162.     chr = b(1)
  163.     return
  164.     end
  165.