Skip to content

Code structure and lookup routines ​

Draft. This page covers the 0110C6 program. The program area is byte-identical in all 16 public 0110C6 dumps. Most facts were read directly from the disassembly and are marked [verified]. Facts that come from data patterns or heuristics are marked [inferred]. Addresses are ECU bus addresses written as 24-bit hex. On the MS42 the bus address equals the file offset in the 512 KB image. See Memory map.

The disassembly was produced with an independent C166 disassembler (to be published separately), driven by tools/c166_analysis.py. The tool finds the disassembler through --c166dis DIR, the C166DIS environment variable, or ../c166dis. Its outputs are data/code_refs.json and data/coverage.json. See XDF coverage.

Address windows ​

Bus address = fileContentStatus
0x00000–0x0BFFFBoot sector: trap vectors, reset code at 0x0660, serial boot loader at 0x8000 (magic 5AA5 56C9, checked at 0xBFFC)verified
0x0C000–0x0DFFFExternal RAM, 8 KB (CS2, ADDRSEL2 = 0x00C1). Reached through DPP3verified (window), inferred (RAM)
0x0E000–0x0E7FF, 0x0F600–0x0FDFFXRAM and internal RAM (both RAM-tested at reset), SFRsverified
0x10000–0x10FFFCS3 window (ADDRSEL3 = 0x0100). The flash underneath is erasedverified (window), inferred (peripheral chip)
0x11000–0x3FFFFProgram code (segments 1–3)verified
0x48000–0x4FFFFCalibration, 32 KB (data pages 0x12, 0x13; XDF BASEOFFSET 0x48000)verified
0x50000–0x53FFFProgram constants (DPP1 page 0x14): idents, application vectors, header, tablesverified
0x60000–0x63FFF, 0x70000–0x7FFFFProgram code (segments 6, 7). The lookup library is at 0x060882verified
0x40000–0x47FFF, 0x54000–0x5FFFF, 0x64000–0x6FFFFErased (0xFF)verified

There is no remapping. The C167 runs from flash on CS0 at bus 0, so all JMPS/CALLS targets and far pointers are file offsets. CS1 (ADDRSEL1 = 0x0807, 0x80000–0xFFFFF) is configured at reset, but the application does not use it [inferred].

Boot, vectors, application entry ​

  • Reset [verified]. The reset vector (file 0x0000) goes to 0x00:0660. The reset code sets CP=0xF600, DPP0/1/2 = 0x12/0x14/0x13, SYSCON, BUSCON0–4 and ADDRSEL1–4, then the stack. When the words at 0x0BFFC are A55A C956, it jumps to the serial boot loader at 0x00:8004. Otherwise it RAM-tests IRAM, XRAM and external RAM, sets the DPPs again (0x000AAA) and runs 0x001D6A. That routine checks the program header and, if it is valid, enters the application through PUSH R5; PUSH R4; RETS at 0x0031BE.
  • Program header [verified]. The header is at file 0x502A4, in the constant page. 0x502A4–0x502A9 hold the upper limits for the RAM tests (0xFDFE, 0xE642, 0xD366). The reset code reads them and caps them at 0xFDFE/0xE7FE/0xDFE2. The far pointer at 0x502AA (offset, segment) is the application entry, 0x03:FD4E (0110AD: 0x03:FD62). The block from 0x502EE holds seg:offset pointers to the calibration (0x048000, 0x04FEE0, 0x04800C, 0x048010) and to the vector table.
  • Magic words [verified]. The program starts with 90 48 24 42 at 0x50000, and the calibration ends with 42 24 48 90 at 0x4FFF0. The reset code checks both: 0x0007CE checks the first, and 0x001368 reads 0x4FFF0–0x4FFF3.
  • Vectors [verified]. File 0x0000–0x01FF holds 128 JMPS vectors. Vector 0 is the reset vector, and a few others go to boot handlers (for example vector 2 → 0x00:320C). The rest are JMPS 0x05:(0x00A4 + 4n), so they forward to slot n of the application vector table at 0x0500A4. There, used slots jump into segments 1, 2, 3 and 7, and unused slots jump to themselves.
  • Ident check [verified]. 0x013390 compares the calibration ident bytes 0x48008–0x4800D byte by byte with the program ident at 0x50036–0x5003B (0110C6 in both).

Application DPPs ​

The reset code sets these DPPs, and the application keeps them [verified]. Across all 84,542 decoded instructions there are only two kinds of DPP write outside the boot sector. The diagnostic memory-access routines (0x0200F0–0x020CCA) save DPP0, load it with a page taken from the request bytes, and restore it after one access. 0x075E18 re-loads DPP0 = 0x12 before it calls back into the boot sector.

DPPPageWindowUsed for
DPP00x120x48000–0x4BFFFCalibration, first 16 KB (near 0x0000–0x3FFF)
DPP10x140x50000–0x53FFFProgram constants (near 0x4000–0x7FFF)
DPP20x130x4C000–0x4FFFFCalibration, second 16 KB (near 0x8000–0xBFFF)
DPP30x030x0C000–0x0FFFFExternal RAM, XRAM, IRAM, SFRs (near 0xC000–0xFFFF)

The whole calibration is therefore reachable through 16-bit near addresses. This is the main difference from the MS43, which uses far (offset, page) pointers. Scalars are plain mem operands. For example, MOVB RL4, 0x0008 reads file 0x48008, and MOV R13, 0x070C reads 0x4870C. Of the 1,258 scalar addresses read, 1,247 go through DPP0, 11 go through DPP2, and 2 use EXTS. All are reads. No copy of the calibration in RAM was found, and no code reads calibration data from RAM [inferred].

Task scheduler ​

These details were read at 0x076C9C, the last routine that the application entry calls [verified]:

  • Tick. The tick is the CAPCOM compare interrupt CC26 (trap 0x3A, application vector 0x05018C → 0x0795DE). The handler re-arms the compare with ADD CC26, #0xFA and sets the flag 0xFD28.0 at 0x079620. The timer clock was not determined, so the tick period in time is not known.
  • Main loop (0x076CA0). On each tick, the loop clears 0xFD28.0, runs the fixed per-tick work, and steps the divider counters (for example 0xFB6B, reloaded with 2). It services the watchdog and posts task IDs into ring buffers.
  • Background dispatch. Between ticks, the loop first serves a 16-bit request mask (0xFDBA). PRIOR picks the highest set bit, and the far pointer comes from the table at DPP1 0x456E (file 0x5056E). Then the loop drains a 32-entry FIFO of task IDs (0xE5D8, read/write indices 0xE5D2/0xE5D3, overflow flag 0xFD24.11). The far pointer comes from the table at DPP1 0x44C2 (file 0x504C2, 4 bytes per ID). Both dispatches call 0x06002A (PUSH R5; PUSH R4; RETS, an indirect far call). A second FIFO (0xE5F8, indices 0xE5D4/0xE5D5) is filled the same way.

Code discovery ​

The table shows the result of each discovery stage. The last column counts undecoded non-0xFF bytes in the code segments (0x10000–0x3FFFF and 0x54000–0x7FFFF).

StageInstructionsUndecoded non-FF bytesEvidence
Boot vectors, application vectors, application entry, switch tables23,120196,599verified control flow
+ code that follows a RET/RETS/JMP, kept only if it decodes cleanly84,54112inferred
+ tables of ≥2 far code pointers in the constant page84,54212inferred

No stage hits an invalid opcode. In the constant page only the vector table is decoded. The 0110AD program gives 80,388 instructions with 11 undecoded bytes.

Switch statements compile to two idioms. The first is MOV R0,[R0+#tab]; JMPI cc_UC,[R0]. The second, which is common in MS42, is CMPB RL4,#k; JMPA cc_UGT,default; …; SHL R4,#1; ADD R4,#tab; MOV R4,[R4]; JMPI cc_UC,[R4]. Both use 16-bit entries in the DPP1 page. 53 tables were resolved. The second idiom and the CMP(B)…; JMP cc_UGT range check were added to the disassembler's jump-table hook for this work. Without the range bound, unbounded tables produced bogus targets.

Lookup library (0x060882–0x060C43) ​

The library takes all arguments in registers. R12 is the near (DPP) address of the axis or table in the calibration, R13 is the input value, and the result comes back in R4. An axis search stores its result in shared RAM, and every table read that follows uses that result [verified]:

RAM (0110C6)Meaning
0xFA0FX index
0xFA02X fraction (16 bit, from DIVLU)
0xFA0EY index
0xFA04Y fraction
0xFA10Y-axis point count (the row stride)
0xFD06.4 / 0xFD06.5X / Y "no interpolation" flag (input clamped to an axis end or exactly on a point)

Axis format [verified]. The axis is a count N followed by N ascending values, both of the same width (u8 or u16). For example, 060882 reads RL2 = [R1+] (the count) and compares against the last value at R1 + N − 1. The XDF axis items start after the count: the axis at 0x488F3 has count 06 and the XDF item ldp_cam_av_in__eoi_ti_tra_ivvt starts at 0x488F4.

Map layout [verified], read from the MULU R13, R5 in 060A0C: element (ix, iy) is at table + (ix·Ny + iy)·elem. That is X-major, exactly as in MS43.

Example (0x070074): MOV R12,#0x08C8; MOVBZ R13,0xC424; CALLS 060882 searches the X axis at 0x488C8. Then MOV R12,#0xA523; CALLS 0609A4 reads a u8 curve at 0x4E523 (near 0xA523 → DPP2 → 0x4C000 + 0x2523).

RoutineRoleElementInterpolatesObjects
060882X-axis searchu8yes170
0608CAY-axis search (also stores the count)u8yes82
060916X-axis searchu16yes63
06095AY-axis searchu16yes36
060B40 / 060B66X / Y search, index onlyu8no39 / 8
060B90 / 060BB4X / Y search, index onlyu16no10 / 1
0609A41D curveu8yes136
0609D81D curveu16yes115
060A0C2D mapu8bilinear143
060AA42D mapu16bilinear82
060BDE / 060C2C1D, nearest pointu8no54 / 1
060BEA / 060C381D, nearest pointu16no34 / 2
060BF62D, nearest pointu8no20
060C102D, nearest pointu16no3

"Objects" is the number of distinct calibration objects passed to the routine. All 18 routines were read by hand. There are no descriptor routines like the MS43 ones. Axis and table element widths are independent, so any axis routine can be combined with any table routine. 0x060000–0x06087F holds the arithmetic helpers (multiply/divide with scaling, saturation, min/max). They take values, not calibration pointers.

Locating the library on other versions. The catalogue in tools/c166_analysis.py (LOOKUP_SIGS) stores, for each routine, its length and a SHA-256 of the instruction text with RAM, bit and jump addresses masked. The tool matches these signatures against every discovered function. On 0110AD the same 18 routines are found 0x24 bytes lower (06085E…). They use other RAM cells and flag bits, for example X index 0xFA0D and flag 0xFD06.2. research/2026-11-30/disasm/lookup_sigs.py re-checks this.

Other calibration access patterns ​

  • Pointer arrays (per cylinder) [verified]. For example, MOV R12,[R4+#0x6BBE]; CALLS 060BF6 at 0x02ECE8. The constant page holds arrays of near pointers indexed by cylinder: file 0x52BBE has 6 knock window starts id_knkwb_0..5, 0x52BCA has the ends id_knkwe_0..5, and 0x52BD6 has the ip_fac_knk_0..5 maps. The tool reads such an array up to the next constant-page address that the code names (18 objects).
  • Parameter records passed as arguments [verified]. 0x02DFAA copies R13 into R6 and reads R12 from [R6+#4], [R6+#6] and so on. Its two callers pass R13 = #0x6B4E and #0x6B60. These are 18-byte VANOS records (intake and exhaust) in the constant page. Each holds near pointers to the ip_t_fac_*_ivvt_*, ip_dly_*_ivvt_*, ip_t_ivvt_* and ip_fac_ctl_ivvt_* tables. The tool resolves this case by finding the single MOV Rk, R12..R15 copy at the function entry and using the constant arguments at every call site (14 objects).
  • Fault-path records [inferred]. These are 16-byte records in the constant page (0x528F4–0x52AC3 and others): +0 far pointer to a handler, +4 id, +6 near pointer to the u16 DTC code word in the calibration, +8..+E four RAM pointers. The tool detects them by pattern (runs of ≥3) and finds 146 DTC code words.
  • Near-to-far idiom. SHR Rx,#14 on a known near address. The MAF table id_maf_tab (0x497A6) is reached this way at 0x075D80, and id_fac_ti_ris/rpl__cycnr at 0x074B0E/0x074B2E. The extent is not known, so these count as weak references.
  • Checksum and monitor block. 0x4FEE0–0x4FEFF is read by the boot code (0x000AC2) and the monitor (0x01C1FE). It starts with the word 0x27BE, then seg:offset 0x048000, then 0x04F843. It is probably a checksum and its range [inferred]. See Checksums.

XDFs (GPL-3.0) and patchlist by the MS4x Dev Team. Not affiliated with BMW or Siemens.