Commit | Line | Data |
---|---|---|
d52f1552 TL |
1 | # include "CON.h" |
2 | # include "FL.h" | |
3 | /* */ | |
4 | char input[130] ; /* term input buffer */ | |
5 | int count , dskoff , error ; | |
6 | char *bufptr ; | |
7 | /* */ | |
8 | main() { | |
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 | ||
15 | putlin("fdump : floppy-to-console hex dump") ; | |
16 | putnl() ; | |
17 | ||
18 | doff : | |
19 | putstr("start 128-byte block no. : ") ; | |
20 | getcon(input) ; | |
21 | dskoff = a2l(input) ; | |
22 | if (dskoff < 0) goto fini ; | |
23 | if (dskoff > MAXSEC-1) goto doff ; | |
24 | ||
25 | gknt : | |
26 | putstr("no. blocks : ") ; | |
27 | getcon(input) ; | |
28 | count = a2l(input) ; | |
29 | if (count < 0) goto gknt ; | |
30 | if (count == 0) count = 1 ; | |
31 | ||
32 | error = 0 ; | |
33 | ||
34 | if (init()) { | |
35 | putlin("init error") ; | |
36 | return(-1) ; | |
37 | } | |
38 | ||
39 | putlin(" HI < - - LO") ; | |
40 | putnl() ; | |
41 | ||
42 | while ((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 | ||
57 | goto doff ; | |
58 | ||
59 | fini : | |
60 | return(0) ; | |
61 | } | |
62 | ||
63 | /* */ | |
64 | ||
65 | init() | |
66 | { | |
67 | extern char *end ; | |
68 | ||
69 | bufptr = (char *)(((int)&end+511) & 017777777000) ; | |
70 | return(0) ; | |
71 | } | |
72 | ||
73 | /* */ | |
74 | ||
75 | prsec() | |
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 | */ | |
84 | register int i , j ; | |
85 | int k , addr ; | |
86 | char c , *hp , *fr ; | |
87 | char tmp[258] , ltmp[65] ; | |
88 | ||
89 | ltmp[64] = '\0' ; | |
90 | hp = "block # \0\0\0\0\0\0\0" ; | |
91 | l2a(dskoff-1,&hp[8]) ; | |
92 | putlin(hp) ; | |
93 | putnl() ; | |
94 | ||
95 | hxcnvt(bufptr,128,tmp) ; /* convert bytes to hex char's */ | |
96 | ||
97 | for (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 | } | |
110 | return(0) ; | |
111 | } | |
112 | ||
113 | /* */ | |
114 | ||
115 | hxcnvt(in,knt,out) | |
116 | register char *in , *out ; | |
117 | int 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 | */ | |
123 | register unsigned int bit4 , byte ; | |
124 | ||
125 | byte = 0 ; | |
126 | while (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 | } | |
133 | return(0) ; | |
134 | } |