home *** CD-ROM | disk | FTP | other *** search
- /* xcmd.c - dump the CP/M CCP command in hex and ASCII */
- /* 1982/08/16 18:44 */
- /*
- Derived from the assembly language routine XCMD in
- David E. Cortesi's INSIDE CP/M: A Guide for Users and Programmers,
- Holt, Rinehart and Winston, New York 1982, p. 219-220.
-
- C version:
-
- Copyright 1982 William G. Hutchison, Jr.
- P.O. Box 278
- Exton, PA 19341-0278
- U.S.A.
-
- CompuServe 70665,1307
-
-
-
-
- This program may be used freely for any non-commercial
- purpose, provided that the user does not remove or alter
- this notice or the copyright statement.
- Those who wish to sell or lease this program, or to
- incorporate it into a product for sale or lease, should
- apply to the author (above) for licensing information.
- This program is not covered by a warranty, either
- express or implied. The author shall not be responsible for
- any damages (including consequential) caused by reliance on
- the materials presented, including but not limited to
- typographical errors or arithmetic errors.
-
-
-
- */
-
- #include c80def.h
- #include printf.c
-
- /* define the number of Bytes Per Line to be dumped: */
- #define BPL 16
-
- static char *cpmfcb= 0x5C;
- static char *cpmbuff=0x80;
-
- main()
- {
- printf("\nDefault FCB:\n\n");
- hex_dump(cpmfcb, 32);
- printf("\nCommand tail:\n\n");
- hex_dump(cpmbuff, peek(cpmbuff));
- }
-
- hex_dump(base, len)
- char *base;
- int len;
- {
- char *p;
- int i;
-
- for (; len > 0; len-= BPL, base+= BPL) {
- printf("%4x:", (unsigned)base);
- for (p= base, i= (len > BPL)? BPL : len; i > 0; i--)
- printf(" %2x", peek(p++));
- for (i= BPL-len; i > 0; i--)
- printf(" ");
- printf(" ");
- for (p= base, i= (len > BPL)? BPL : len; i > 0; i--)
- printf("%c", printable(*p++));
- printf("\n");
- }
- } /* end of hex_dump */
-
- peek(p)
- char *p;
- {return (0xFF & *p);}
-
- #ifdef ASCII
- printable(c)
- char c;
- {
- return (32 <= c && c <= 127? c : '.');
- }
- #endif