Bell 32V development
[unix-history] / usr / src / standalone / fdump.c
CommitLineData
d52f1552
TL
1# include "CON.h"
2# include "FL.h"
3/* */
4char input[130] ; /* term input buffer */
5int count , dskoff , error ;
6char *bufptr ;
7/* */
8main() {
9/*
10* Stand-alone program to dump RX11 floppy disk to VAX LSI console
11* printer in hex format.
12* Use specifies start sector(from 0) and no. of sectors.
13*/
14
15putlin("fdump : floppy-to-console hex dump") ;
16putnl() ;
17
18doff :
19putstr("start 128-byte block no. : ") ;
20getcon(input) ;
21dskoff = a2l(input) ;
22if (dskoff < 0) goto fini ;
23if (dskoff > MAXSEC-1) goto doff ;
24
25gknt :
26putstr("no. blocks : ") ;
27getcon(input) ;
28count = a2l(input) ;
29if (count < 0) goto gknt ;
30if (count == 0) count = 1 ;
31
32error = 0 ;
33
34if (init()) {
35 putlin("init error") ;
36 return(-1) ;
37 }
38
39putlin(" HI < - - LO") ;
40putnl() ;
41
42while ((error == 0) && (count--)) {
43 if (flrs(dskoff,bufptr)) {
44 putlin("floppy i/o error") ;
45 ioerr :
46 error++ ;
47 continue ;
48 }
49 if (prsec()) {
50 goto ioerr ;
51 }
52 putnl() ;
53 putnl() ;
54 dskoff++ ; /* next block */
55}
56
57goto doff ;
58
59fini :
60return(0) ;
61}
62
63/* */
64
65init()
66{
67extern char *end ;
68
69bufptr = (char *)(((int)&end+511) & 017777777000) ;
70return(0) ;
71}
72
73/* */
74
75prsec()
76{
77/*
78* Print 128 bytes on VAX LSI console as hex
79* characters.
80* Translate bytes in 'bufptr[]' to hex char's
81* and out to console, 64 char's per line.
82* (32 bytes per line)
83*/
84register int i , j ;
85int k , addr ;
86char c , *hp , *fr ;
87char tmp[258] , ltmp[65] ;
88
89ltmp[64] = '\0' ;
90hp = "block # \0\0\0\0\0\0\0" ;
91l2a(dskoff-1,&hp[8]) ;
92putlin(hp) ;
93putnl() ;
94
95hxcnvt(bufptr,128,tmp) ; /* convert bytes to hex char's */
96
97for (i = 0,addr = 0 ; (i < 256); i+=64,addr +=64 ) {
98 hp = ltmp ;
99 fr = (&tmp[i+63]) ;
100 for ( k = 32 ; k ; k--) {
101 (*hp++) = *(fr-1) ;
102 (*hp++) = (*fr--) ;
103 fr-- ;
104 }
105 putstr(ltmp) ;
106 l2x(addr,input) ;
107 putstr(" : ") ;
108 putlin(input) ;
109 }
110return(0) ;
111}
112
113/* */
114
115hxcnvt(in,knt,out)
116register char *in , *out ;
117int knt ;
118{
119/*
120* Convert 'knt' bytes in char array 'in' to 'knt*2'
121* hex char's and store in char array 'out'.
122*/
123register unsigned int bit4 , byte ;
124
125byte = 0 ;
126while (knt--) {
127 byte = (*in++) ;
128 bit4 = (byte>>4) & 017 ;
129 (*out++) = (bit4<10?bit4+0x30:bit4+0x57) ;
130 bit4 = byte & 017 ;
131 (*out++) = (bit4<10?bit4+0x30:bit4+0x57) ;
132 }
133return(0) ;
134}