951-KLR-PAGES

KLR Code Outline

0x000 - 0x003 – prep for trigger routine. The rest is at 0x77

0x003 - 0x006 – prep for INT interrupt. The rest is at 0x30E

0x007 - 0x072 – timer interrupt

0x003 - 0x108 – trigger/initialization

0x109 - 0x??? – LED blinking (in the middle of trigger routine)

0x??? - 0x1B0 – more trigger init

0x1B1 - 0x1C7 – calcuate timing delay (using 73h + 3Fh)

0x1C8 - 0x200 – nop

0x200 - 0x29C – calculate blink codes, store in 33h

0x29C - 0x2B5 – call 0x500 (afterwards, manipulate stack for housekeeping function list at 0x800?)

0x2B5 - 0x2FF – nop

0x300 - 0x20d – generic 8x8 bit multiply (16-bit result)

0x30E - 0x329 – INT routine

0x32B - 0x335 – decrement error counters, set error code (33h)

0x336 - 0x39D – ? diagnostic output - possibly unused?

0x39E - 0x3FB – nop

0x3FB - 0x3FF – ? a few probably unused instructions

0x400 - 0x408 – ADC function table

0x409 - 0x40A – constants for knock testing (comparison to 2Fh)

0x40B - 0x40D – jmpp to ADC function from table at 0x400 (offset 2Ch)

0x40E - 0x426 – ADC function #1 - select address

0x427 - 0x42B – ADC function #3 - self-test

0x43C - 0x44B – ADC function #2 - sef-test (called 3 times)

0x44C - 0x48B – ADC function #4 - ADC read ch. 0-3

0x48C - 0x497 – ADC funciton #5 - ADC read ch. 5 (KNOCK)

0x498 - 0x4B7 – ADC function #6 - ADC read ch. 4 (MAP)

0x4B8 - 0x7FF – nop

0x800 - 0x813 – misc. function list (housekeeping)

0x814 - 0x8FF – nop

0x900 - 0x924 – read routine for rpm maps, and rpm/throttle PID gain map

0x925 - 0x990 – rpm maps (various rpm-dependant constants)

0x991 - 0x9B1 – rpm/throttle map for PID gain (value loaded into 6Bh)

0x9B1 - 0x9FF – nop

0xA00 - 0xA0E – rpm map axis

0xA0F - 0x??? – ? unkown number of possibly unused opcodes before the next function begins

0xA16 - 0xA56 – calculate 3Ah (throttle position)

0xA57 - 0xA81 – read rpm axis value into 43h

0xA82 - 0xA8C – read CV feedforward map using rpm/throttle, into 68h

0xA8D - 0xA9D – read target boost using rpm/throttle, into 51h. Subtract 57h (knock-related boost reduction).

0xA9E - 0xAAD – calculate R4 counter values for ADC read angles

0xAAE - 0xAFF – nop

0xB00 - 0xB7F – CV feed-forward map (rpm/throttle)

0xB80 - 0xB8A – multiply @r0 by rpm value in 24h

0xB8C - 0xB8C – ? unkown jmp instruction

0xB8D - 0xBFC – nop

0xBFD - 0xBFF – ? unknown jmp

0xC01 - 0xC7F – target boost map (rpm/throttle)

0xC80 - 0xCD4 – map read routine (map determined by f1)

0xCD4 - 0xCFF – nop

0xD00 - 0xDDD – knock detection, timing/boost retard, self-test

0xDDE - 0xDF7 – part of PID (call the exponential smoothing function)

0xDF7 - 0xDFF – nop

0xE00 - 0xE07 – boost control PID loop (controlled by 2Ch)

0xE08 - 0xE2F – exponential smoothing function

0xE30 - 0xE81 – boost control PID (derivative term?)

0xE82 - 0xEF5 – boost control PID (proportional & integral terms?)

0xEF6 - 0xEF6 – call 0xF00

0xEF8 - 0xEFF – nop

0xF00 - 0xFA8 – CV PWM calculation (PID output + CV feedforward; also cap timing delay at 6 deg.)

0xFA9 - 0xFBC – call exp. smoothing and rotate cylinder values for adaptive knock threshold

0xFBD - 0xFD4 – calculate rpm-dependant coefficient for knock threshold (using map value 47h)

0xFD5 - 0xFDE – helper for PID output; cap CV on-time

0xFDF - 0xFF4 - nop

0xFF5 - 0xFFF - ? a few possibly unused opcodes