PostHeaderIcon PIC18F67K22: One Hundred and Twenty-Eight Kilobytes, Two Boundaries

Doubling the array from 64K to 128K doubles the address range and not the address field. The instruction set’s short branches were already insufficient at 64K; at 128K the long forms carry addresses that cross a line the architecture treats specially, and the code reflects it.

For a reader, that is an advantage. Code produced across two boundaries acquires structure that a uniform address space would not give it — and the structure is visible without symbols.

The two transitions

The first is at the 64K mark, where the address no longer fits in the width the short forms provide. The second is the point at which the toolchain stops assuming a single contiguous region and starts treating the upper half as a separate area, typically with its own paging.

An image built for 128K therefore contains three kinds of content:

Region Encodings Typical contents
Lower Short branches where possible Start-up, main loop, hot routines
Lower, upper part Long branches Larger functions, tables
Upper Long branches, explicit page handling Cold code, large tables, strings

The third row is where the informative content tends to be. Cold code is written later, by fewer people, with less review — and on a device this size there is room for it.

Reading the encodings as evidence

A branch’s encoding tells you where its target is, which tells you something about the code’s organisation:

  • Short forms clustered. The region’s code is self-contained and near its callers.
  • Long forms everywhere. The region calls across the array, so it is probably a utility layer or an entry point.
  • Page register manipulation before a call. The target is in another page, and the manipulation names the page.

The third is the most specific. A few instructions setting an upper address before a call identify the target’s region without following the branch, and a cluster of such sequences marks a module boundary.

Tables at this scale

With 128K available, firmware tends to carry rather than compute. The tables are the domain knowledge, and on this part they are worth finding deliberately.

Three forms dominate:

  • Calibration curves, monotonic with a regular stride;
  • String tables, ASCII in whatever representation the compiler chose;
  • Protocol constant blocks, small integers with structure.

The first is the most informative and the least protected. A monotonic table read by an indexed loop is a curve, its endpoints give the measurement range, and its resolution gives the number of bits actually used — which is often fewer than the converter provides.

The protection arrangement at 128K

Four blocks, as on the 64K parts, but each larger. The practical effect is that a partial read is either three quarters of a great deal or one quarter of it, and the arithmetic of what is worth attempting changes.

At this size a device with the first block closed and the rest open still yields ninety-six kilobytes — enough to contain complete modules, and enough for the missing block to be reconstructed from behaviour rather than regretted.

What the image does not tell you

  • The configuration, which is outside the array.
  • The data array, which is separate.
  • Which regions were readable, unless that is recorded.
  • The revision, which decides errata.

At 128K the temptation to treat a large image as a complete description is stronger than at 16K, and the omission is proportionally no smaller.

Sequence

  1. Read the configuration; establish the block map.
  2. Read the array twice; discard disagreements.
  3. Locate the reset path from the first block if available.
  4. Decode outward from entry points, not linearly.
  5. Partition by page boundary; the code already does.
  6. Record the map with the image.

Step five is specific to this size. A linear disassembly of 128K produces an unresolvable listing; one partitioned at the page boundary and anchored at entry points produces something a reader can navigate.

Related reading

FAQ

Why does a 128K image look different from two 64K images? Because the toolchain handles the upper page explicitly, producing different encodings across the boundary.

Do short branches disappear at this size? No, but they appear only within reach. Cross-array calls use long forms.

Where are the informative tables? Often in the upper region, among cold code that received less review.

Is a 96K partial image useful? Yes — enough for whole modules, with the missing quarter reconstructable from behaviour.

Should a large image be disassembled linearly? No. Partition at the page boundary and anchor at entry points.

Conclusion

One hundred and twenty-eight kilobytes means two boundaries, and the code’s encodings document them. Reading the page handling as structure, partitioning at the boundary, and treating the tables as the payload turns a large image into a navigable one — and the size, which looks like an obstacle, is what provides the structure.

Comments are closed.