PostHeaderIcon Attack Chip PIC16C73A Program: Paging, Vectors and the Shape of the Image

An image extracted from a program array arrives as a flat sequence of words. Nothing in the file says where the code begins, where a table begins, or where a page ends. Those structures have to be recovered from the content, and on this device the most important one is a boundary that the instruction set imposes rather than the hardware.

The A revision matters for a separate reason: it changed peripheral behaviour in ways that a copy has to respect, and a customer comparing two units from different revisions will see differences that look like copy errors. Both concerns — image structure and revision identity — belong in the same job.

How the address space is actually organised

The core addresses program memory with a program counter wider than a single instruction’s operand field can express. Call, goto and table-read instructions carry a limited number of address bits, and a hardware latch supplies the rest. The result is a memory space divided into pages and a set of conventions for crossing between them.

Element Where it sits Why it matters for the image
reset vector address zero the first word must be a valid jump
interrupt vector a few words above reset must be a valid instruction, usually a jump
page boundary at 2K words page-crossing sequences appear at every crossing
configuration word top of the space not code, must be excluded from disassembly
unused tail after the last code word reads as the erased pattern

The page boundary is the structural fact that gives the image its fingerprint. Below it, a call needs only the low bits. Above it, the high bits must be set beforehand, and compilers emit that setup immediately before the call. The pattern is regular enough to be recognised mechanically, and recognising it is what tells you the disassembly is aligned.

Alignment before interpretation

The single most common defect in a listing produced from a recovered image is a one-word misalignment. It produces a document full of plausible-looking instructions that do not form a program, and it can consume hours before anyone notices.

Two checks catch it immediately.

The first is the reset vector. Word zero of a working image is a jump to the start of the initialisation code, and the target must be inside the array. If word zero decodes to something that is not a jump, either the image starts at a different address than assumed or the alignment is wrong.

The second is the page-crossing signature. In an aligned listing, the sequences that set the high address bits appear at consistent points relative to call sites. Shift everything by one word and those sequences lose their relationship to the calls that follow them.

A third check is available where the image is large enough to contain tables: a table read is a computed jump into a run of return-with-literal instructions, and that run has a distinctive visual appearance. Its position relative to the preceding call is another alignment witness.

What the interrupt vector tells you about the design

On this generation the interrupt vector is a fixed address and there is no vector table. Every interrupt source shares one entry point, and the firmware sorts out which one fired by testing flags in order.

That has three consequences visible in the image. The handler is one large routine rather than a set of small ones. It saves and restores context explicitly, because the hardware saves nothing. And its ordering of flag tests encodes the designer’s priority scheme, which is often the most useful single piece of information in the whole image, because it reveals what the product considers urgent.

For a customer trying to understand a competitor’s product, that priority ordering is worth more than the algorithm. It says which events the product cannot afford to miss, which in turn says what the product is for.

The A revision and what changed

The A suffix is not cosmetic. Revisions in this family changed peripheral behaviour — timer behaviour, analogue converter timing, the behaviour of certain registers after reset — in ways that are documented in errata rather than in the datasheet.

For a copy job the practical points are these. A device carrying the earlier revision programmed with code written for the later one may fail in a specific corner. A device carrying the later revision programmed with code that works around an earlier erratum still works, because the workaround is redundant rather than harmful. So the safe direction of copying is later silicon to earlier code, not the reverse.

Recording the revision at the start of the job costs one read and prevents a class of failure that is otherwise extremely hard to explain six months later.

Protection and what it blocks

The protection bit on this generation stops the programming interface from reading the array. It does not stop the device from executing, and it does not stop the device from being used as an oracle: a program that reveals its behaviour through its outputs can be studied while locked.

That distinction shapes the strategy. If the array is readable, the job is extraction and interpretation. If it is not, the job becomes behavioural, and the deliverable changes from a file to a description — pin behaviour, bus traffic, timing, responses to inputs. Both are legitimate outcomes and neither is a failure, but they are different products and should be quoted as such.

Producing a listing someone can read

The output of this kind of work is used by engineers, and the majority of its value is in the annotations rather than in the instructions.

  • Mark the vectors and the handler boundary explicitly.
  • Mark every table and literal pool, so that data does not read as broken code.
  • Mark every page boundary and the code that sets it.
  • Name the peripheral registers being accessed, since bare addresses are unreadable.
  • Note the configuration word decoding at the end, not at the beginning, because it is context rather than content.

The third item is what separates a listing that can be followed from one that has to be reverse-engineered a second time.

For the same device family treated from the storage-technology side rather than the address-structure side, PIC16C74B binary reading covers charge retention and marginal cells. The smaller 18-pin sibling is handled in PIC16C556A software recovery, where the same paging rules apply with a shorter array. And for the mask-programmed variant where none of the reading is possible through the interface, PIC16CR83 heximal copying explains what changes.

One question about the goal

Before the listing is produced, it is worth asking what it will be used for. A customer maintaining a legacy product needs the peripheral access patterns named. A customer building a replacement needs the interfaces identified, not the internals documented. A customer investigating a failure needs the priority ordering and the error paths.

The same image serves all three, and the annotations that make it useful differ. Spending ten minutes on that question produces a document that answers it, instead of a complete disassembly that answers nothing in particular.

Comments are closed.