hexline.f
上传用户:szhypcb168
上传日期:2007-01-06
资源大小:2187k
文件大小:1k
- c==========================================================================
- c
- c ROUTINE
- c puthex & gethex
- c
- c FUNCTION
- c convert integer stream to hexadecimal format
- c
- c
- c SYNOPSIS
- c subroutine puthex (nb, bits, line)
- c entry gethex (nb, bits, line)
- cc
- c**************************************************************************
- c
- subroutine puthex (nb, bits, line)
- implicit undefined(a-z)
- integer j, k, m, n, nb, bits(nb)
- character*(*) line, hex*16
- data hex /'0123456789ABCDEF'/
- c
- k = 0
- m = 0
- line = ' '
- 10 if (k .ge. nb) return
- n = 0
- do 15 j = 1, 4
- k = k + 1
- if (k .le. nb) n = or (n, ishft(bits(k).and.1, 4-j))
- cAlli if (k .le. nb) n = ior (n, ishft(bits(k).and.1, 4-j))
- 15 continue
- m = m + 1
- if (m .gt. len(line)) stop 'Hex string too small'
- line(m:m) = hex(n+1:n+1)
- goto 10
- c
- entry gethex (nb, bits, line)
- k = 0
- m = 0
- 20 if (k .ge. nb) return
- m = m + 1
- if (m .gt. len(line)) stop 'Hex string too small'
- n = index (hex, line(m:m)) - 1
- if (n .lt. 0) stop 'Illegal character'
- do 25 j = 1, 4
- k = k + 1
- if (k .le. nb) bits(k) = and (ishft(n, j-4), 1)
- cAlli if (k .le. nb) bits(k) = iand (ishft(n, j-4), 1)
- 25 continue
- goto 20
- end