ATmega128V: The Register That Tells You Where the Boundary Is
A sixteen-bit pointer reaches sixty-four kilobytes. With a flash array larger than that, reading a constant in the upper half requires an extra byte of address, and on this architecture that byte lives in a dedicated register which the code must set before each such access.
The register is therefore a marker. Every write to it is a statement that the next operation addresses something above the line, and a sequence of such writes draws the image’s structure in a way that no disassembly listing makes obvious.
How the access works
Three instructions, in order, for any constant above the boundary:
- Load the high byte into the extended register.
- Load the low word into a register pair.
- Perform the load from program space.
For code below the boundary, step one does not appear. That asymmetry is the marker: a region full of extended-register writes is code that reads data from the upper half, and a region without them is code that does not.
| Pattern | Meaning |
|---|---|
| Extended register written before every table read | Table lives above 64 KB |
| Written once at start-up, never again | Pointer fixed for a single table |
| Written inside a loop with a changing value | Stride over a large structure |
| Never written | All data below the line |
What this gives an analyst
Three things, none available from the file layout alone:
The boundary location. The first address where the pattern appears is where the upper half begins to be used, which is usually where the build ran out of room below.
Table locations. A fixed pointer set at start-up means a single large table, and its address follows from the register and low word values.
Structure of large data. A varying high byte inside a loop means a stride, and the stride is often the size of a record — which identifies what the data is.
Why this matters more than the file format
A hex file records addresses, so the boundary is already visible in the file. A disassembly is different: it presents instructions in address order and a table read looks like any other instruction except for the register load before it.
Reading the file tells you where things are. Reading the register writes tells you what the code thinks is there, which is the more useful of the two when the layout is unfamiliar.
The low-voltage grade and a long read
A 128 KB array takes time to read, and at the bottom of the V range the margin narrows. Two habits make the difference:
- Read in passes, verifying each page against itself before moving on.
- Re-read the first page at the end and compare with the first pass.
The second is the only check that covers the whole session rather than one page. A file that is correct for the first sixty kilobytes and wrong for the second is a real outcome on a marginal setup, and it produces a plausible-looking image.
Reading order
- Signature, fuses, lock byte.
- Array read, verified page by page.
- Decode the vector table and the reset target.
- Locate extended-register writes and record the addresses they precede.
- Interpret tables from the pointer values recorded in step 4.
Step 5 is where the marker becomes a location. The register and the low word together give an address, and that address is where the data actually is — which is frequently a step the file layout alone cannot justify.
Related notes
- ATmega128P and binary layout — the same boundary in a file with no addresses.
- ATmega128PV and long reads — the electrical side of a 128 KB pass.
- ATmega128A and EEPROM wear — the other array on this die.
FAQ
Does every access above 64 KB need the extra register? Yes, for constant data read from program space. Code execution uses the program counter, which is already wide.
Can the register be left set across calls? It can, and firmware often does, which makes the pattern less regular than a rule would suggest.
Is the boundary in the same place in every build? No. It appears wherever the linker placed the first large table.
Does a smaller part in the family have this register? No. It exists because the array is large.
Conclusion
The extended address register is a structural marker that a listing hides. Every write to it points at something above the boundary, and reading those writes before reading the code turns an unfamiliar image into a map of where its data lives — which is exactly the information a file format cannot supply.