
PICDIS - A Simple PIC16C84 Disassembler
---------------------------------------

Markus Kuhn -- mskuhn@cip.informatik.uni-erlangen.de -- 1994-12-25


PICDIS will disassemble code for the Microchip PIC16C84
microcontroller. 

The first command line argument must be the name of a input file which
contains the machine code.

The format of this file may either be Intel hex16 or binary. The binary
format is a sequence of 14-bit machine words, each of which is stored
as two bytes. The first byte contains in bits 0 to 5 the six most
significant bits of the word (the other bits must be 0), the second
byte contains the remaining eight less significant bits.

The disassembler listing is sent to standard output and may be
redirected into a file using '>' on most operating systems. E.g. you
can start the disassembler with:

  picdis prog.hex

or

  picdis -ab prog.bin prog.ctl >prog.asm

The following command line options are available:

  -a    Produce an output format suitable for an assembler (i.e.,
        without addresses and machine code bytes, but with labels).
        Output compatibility has been tested with Microchip's
        MPALC V4.14 assembler. All labels start with 'L' followed
        by a letter which indicates the number of references to this
        address followed by the hexadecimal address.

  -b    The input file is in binary format (16-bit words, most
        significant byte first). Default input file format is Intel
        hex16.

PICDIS has been written in Standard C and should compile on all
systems.

For bug fixes, suggested improvements, etc. please contact me by
electronic mail at <mskuhn@cip.informatik.uni-erlangen.de>. PICDIS is
copyrighted by Markus Kuhn and may be used and redistributed
non-commercially by anyone freely (GNU General Public Licence).


Control File
------------

An optional second command line argument may specify a 'control file'
for the disassemble process. This powerful and flexible feature allows
you to produce a nicely commented and easily readable listing quickly.

The control file may contain e.g. comments which shall be included into
the disassembler listing. Each line of the control file has the form:

  aa bbbb cccc cccc cccccccc ccc ccc....

where aa is a 2-letter control code, bbbb is a 4-digit hexadecimal
number (usually an address in the code to which the control code
refers) and cccc... is some text (e.g. a comment). For example the line

  cc 01f6 here starts the interrupt handler

causes the disassembler to print the specified comment text after the
command found at address 01f6.

Possible control codes are:

  cc  Print a comment line on the same line as the command

  sc  Insert a comment line one line before a command

  hd  Insert a better visible header comment before a command and
      print the same comment also after GOTO and CALL instructions
      which refer to this address

  pr  Print comment lines before the first command

  cs  Specify the 4-digit hexadecimal checksum of the machine code
      file. This gives a warning if the checksum specified
      after cs and the checksum of the machine code don't match
      Use this warning in order to find out the correct checksum
      value the first time. This feature allows to make sure
      that a control file is not accidentially used with a
      different machine code file.

  bt  Print a comment after bit manipulation instructions on specific
      bits in memory. The 4-digit hexadecimal number here has the
      form 0ffb where ff is the RAM address and b is the number of the
      bit. E.g.

        bt 0236 bit is true if key has been pressed

      will print the comment text after the instructions

        BCF 0x23,6             ; bit is true if key has been pressed
        BSF 0x23,6             ; bit is true if key has been pressed
        BTFSC 0x23,6           ; bit is true if key has been pressed
        BTFSS 0x23,6           ; bit is true if key has been pressed

      This makes it especially easy to comment the access to single bits
      which are used as boolean variables in the code.


About the PIC16C84
------------------

The processor for which this disassembler has been developped is a very
cheap (~15 USD) and fast 8-bit CMOS RISC-like microcontroller. It is a
very nice piece of hardware if you want to include easily a robust CPU
into a tiny cheap device without much effort (only the RC or crystal
oscillator are required additional components).

Some of its characteristics are:

  - Only 35 instructions (easy to learn)
  - runs up to 10 MHz = 400 ns per instruction
  - 1024 x 14-bit onchip program EEPROM
  - 36 x 8-bit onchip RAM
  - 64 x 8-bit onchip data EEPROM (can be written by onchip software)
  - 13 bidirectional I/O pins (can drive LEDs directly, up to 20 mA)
  - 8-bit real time clock/counter, 8-bit prescaler
  - onchip reset logic, watchdog timer, power saving sleep mode
  - supports crystal or RC oscillator
  - no external bus
  - 18-pin package
  - ESD protection
  - supply voltage: 2.0 V to 6.0 V
  - has a serial programming mode (using only 5 pins) which
    allows to build a trivial to-it-yourself programmer (< 30 USD)
    connected to a PC Centronics port

For more information, check the data sheet DS30081B about the
microcontroller and data sheet DS30189A which is the EEPROM
programming specification. Address of the manufacturer is

  Microchip Technology Inc.
  2355 West Chandler Blvd.
  Chandler, AZ 85224-6199
  USA
  phone +1 602 786-7200
  fax   +1 602 899-9210


Modification history
--------------------

V1.0  1994-11-27  Initial release
V1.1  1994-12-25  New control code 'bt' and tiny modifications
                  that avoid warnings from some compilers.


Have fun ...

Markus

[end]
