	;; reset
0000 strt t
0x01 jmp  $0077

	;; ext int routine
0x03 sel  rb0
0x04 dis  i
0x05 jmp  $030E

	;; timer int routine
0x07 sel  rb0
0x08 mov  @r0,a
0x09 mov  a,r7
0x0a mov  t,a
0x0b djnz r6,$0010
0x0d inc  r6
0x0e inc  r6
0x0f stop tcnt
0x10 jnt1 $001A
0x12 en   i
0x13 djnz r3,$001A
0x15 inc  r3
0x16 anl  p2,#$BF
0x18 orl  p2,#$80
0x1a djnz r2,$0036
0x1c mov  r0,#$26
0x1e mov  a,@r0
0x1f inc  a
0x20 mov  r2,a
0x21 mov  a,r7
0x22 rrc  a
0x23 xch  a,r2
0x24 rlc  a
0x25 xch  a,r2
0x26 rrc  a
0x27 jnc  $0023
0x29 djnz r2,$0029
0x2b orl  p2,#$40
0x2d anl  p2,#$7F
0x2f djnz r5,$0032
0x31 inc  r5
0x32 mov  r0,#$38
0x34 jmp  $005E
0x36 djnz r5,$0063
0x38 mov  r0,#$40
0x3a mov  a,r7
0x3b inc  @r0
0x3c jb1  $003F
0x3e inc  @r0
0x3f mov  a,@r0
0x40 inc  r0
0x41 jb2  $004E
0x43 mov  a,@r0
0x44 jz   $004A
0x46 anl  p1,#$EF
0x48 jmp  $0054
0x4a dec  r0
0x4b mov  @r0,#$FF
0x4d inc  r0
0x4e mov  a,@r0
0x4f cpl  a
0x50 add  a,#$C1
0x52 orl  p1,#$10
0x54 mov  r5,a
0x55 dec  r0
0x56 mov  a,@r0
0x57 swap a
0x58 xchd a,@r0
0x59 anl  a,#$77
0x5b mov  @r0,a
0x5c mov  r0,#$38
0x5e djnz r4,$0061
0x60 inc  r4
0x61 mov  a,@r0
0x62 retr
0x63 djnz r4,$0061
0x65 orl  p1,#$80
0x67 mov  r0,#$2C
0x69 mov  a,@r0
0x6a inc  @r0
0x6b mov  r4,#$2
0x6d call $040B
0x6f mov  r0,#$38
0x71 mov  a,@r0
0x72 retr
	;; END of timer int routine
	

	;; Reset/Trigger routine
0x73 anl  p2,#$47
0x75 jmp  $007B
0x77 jnt1 $0073
0x79 anl  p2,#$87
0x7b mov  r0,#$25
0x7d mov  r1,#$21
0x7f mov  a,@r1
0x80 mov  @r0,a
0x81 inc  r0
0x82 dec  r1
0x83 mov  a,@r1
0x84 mov  @r0,a
0x85 mov  r0,#$28
0x87 mov  a,@r0
0x88 mov  @r1,a
0x89 inc  r0
0x8a inc  r1
0x8b mov  a,@r0
0x8c mov  @r1,a
0x8d mov  r0,#$38
0x8f mov  a,#$FC
0x91 mov  t,a
0x92 mov  r2,a
0x93 inc  r5
0x94 mov  r1,#$40
0x96 mov  a,@r1
0x97 djnz r5,$009C
0x99 inc  r5
0x9a swap a
0x9b xchd a,@r1
0x9c jb2  $00A0
0x9e anl  p1,#$EF
0xa0 call $0325
0xa2 en   tcnti
0xa3 mov  r1,#$3C
0xa5 movx a,@r1
0xa6 xch  a,@r1
0xa7 inc  r1
0xa8 mov  @r1,a
0xa9 mov  r1,#$3E
0xab mov  a,@r1
0xac cpl  a
0xad mov  r1,#$3A
0xaf add  a,@r1
0xb0 jc   $00B4
0xb2 anl  p1,#$DF
0xb4 mov  r1,#$24
0xb6 clr  a
0xb7 xch  a,r6
0xb8 cpl  a
0xb9 mov  @r1,a
0xba mov  a,@r1
0xbb add  a,#$1A
0xbd jnc  $00CF
0xbf mov  a,r7
0xc0 clr  c
0xc1 rlc  a
0xc2 mov  r7,a
0xc3 inc  r1
0xc4 mov  a,@r1
0xc5 clr  c
0xc6 rrc  a
0xc7 mov  @r1,a
0xc8 dec  r1
0xc9 mov  a,r1
0xca cpl  a
0xcb jb4  $00C4
0xcd call $0325
0xcf mov  r1,#$24
0xd1 mov  a,@r1
0xd2 add  a,#$92
0xd4 cpl  f1
0xd5 jc   $00EF
0xd7 add  a,#$41
0xd9 jc   $00DC
0xdb cpl  f1
0xdc mov  a,r7
0xdd jb1  $00EF
0xdf clr  c
0xe0 cpl  c
0xe1 rrc  a
0xe2 mov  r7,a
0xe3 inc  r1
0xe4 mov  a,@r1
0xe5 clr  c
0xe6 rlc  a
0xe7 mov  @r1,a
0xe8 dec  r1
0xe9 mov  a,r1
0xea cpl  a
0xeb jb4  $00E4
0xed call $0325
0xef mov  r1,#$31
0xf1 inc  @r1
0xf2 jmp  $0102
0xf4 nop
0xf5 nop
0xf6 nop
0xf7 nop
0xf8 nop
0xf9 nop
0xfa nop
0xfb nop
0xfc nop
0xfd nop
0xfe movp a,@a
0xff ret
0x100 nop
0x101 inc  @r1
0x102 mov  r1,#$2C
0x104 mov  a,@r1
0x105 anl  a,#$7
0x107 jnz  $0101
0x109 mov  r1,#$33
0x10b mov  a,@r1
0x10c jz   $0137
0x10e mov  a,r7
0x10f jb1  $0135
0x111 mov  r1,#$2C
0x113 mov  a,@r1
0x114 jb7  $0137
0x116 mov  r1,#$32
0x118 jnz  $0127
0x11a mov  a,@r1
0x11b jnz  $0125
0x11d inc  r1
0x11e mov  a,@r1
0x11f dec  r1
0x120 add  a,#$A8
0x122 swap a
0x123 add  a,#$19
0x125 dec  a
0x126 mov  @r1,a
0x127 mov  a,@r1
0x128 anl  a,#$F
0x12a jnz  $0131
0x12c mov  a,@r1
0x12d swap a
0x12e jb3  $0123
0x130 mov  @r1,a
0x131 add  a,#$FD
0x133 jnc  $0137
0x135 orl  p2,#$10
0x137 mov  r1,#$27
0x139 mov  a,r1
0x13a xch  a,@r1
0x13b add  a,#$D9
0x13d jnz  $0146
0x13f mov  a,r7
0x140 clr  c
0x141 rlc  a
0x142 jc   $0140
0x144 jz   $0148
0x146 mov  r7,#$F0
0x148 sel  rb1
0x149 mov  r1,#$24
0x14b mov  a,@r1
0x14c mov  r6,a
0x14d sel  rb0
0x14e mov  a,r7
0x14f jb2  $01B1
0x151 jb3  $016A
0x153 orl  p2,#$10
0x155 mov  r1,#$7F
0x157 mov  @r1,#$2F
0x159 dec  r1
0x15a mov  @r1,#$46
0x15c dec  r1
0x15d mov  @r1,#$31
0x15f dec  r1
0x160 mov  @r1,#$34
0x162 dec  r1
0x163 mov  @r1,#$0
0x165 mov  a,r1
0x166 xrl  a,#$28
0x168 jnz  $0162
0x16a mov  a,#$FF
0x16c orl  p1,#$10
0x16e mov  r1,#$2E
0x170 mov  @r1,a
0x171 mov  r1,#$30
0x173 mov  @r1,a
0x174 mov  r1,#$34
0x176 mov  @r1,#$6
0x178 inc  r1
0x179 mov  @r1,a
0x17a inc  r1
0x17b mov  @r1,a
0x17c mov  r1,#$39
0x17e mov  @r1,#$C8
0x180 mov  a,#$77
0x182 mov  r1,#$3B
0x184 mov  @r1,a
0x185 mov  r1,#$3C
0x187 mov  @r1,a
0x188 inc  r1
0x189 mov  @r1,a
0x18a inc  r1
0x18b mov  @r1,a
0x18c mov  r1,#$2C
0x18e mov  @r1,#$0
0x190 mov  r1,#$2A
0x192 mov  @r1,#$3F
0x194 inc  r1
0x195 mov  @r1,#$1B
0x197 mov  r1,#$22
0x199 mov  @r1,#$A
0x19b inc  r1
0x19c mov  @r1,#$2
0x19e clr  a
0x19f mov  r2,a
0x1a0 mov  r3,a
0x1a1 dis  i
0x1a2 sel  rb1
0x1a3 call $0336
0x1a5 orl  p2,#$40
0x1a7 anl  p2,#$7F
0x1a9 jnt1 $01A5
0x1ab anl  p2,#$BF
0x1ad orl  p2,#$80
0x1af jmp  $01A9
	;; END of trigger/reset routine

	;; timing delay calculation
0x1b1 sel  rb1
0x1b2 mov  r1,#$73
0x1b4 mov  a,@r1
0x1b5 mov  r1,#$3F
0x1b7 add  a,@r1
0x1b8 mov  r3,a
0x1b9 call $0300
0x1bb clr  c
0x1bc rrc  a
0x1bd mov  r1,#$29
0x1bf mov  @r1,a
0x1c0 mov  a,r3
0x1c1 rrc  a
0x1c2 swap a
0x1c3 anl  a,#$F
0x1c5 dec  r1
0x1c6 mov  @r1,a
0x1c7 jmp  $0200
	;; END of timing delay calculation
0x1c9 nop
0x1ca nop
0x1cb nop
0x1cc nop
0x1cd nop
0x1ce nop
0x1cf nop
0x1d0 nop
0x1d1 nop
0x1d2 nop
0x1d3 nop
0x1d4 nop
0x1d5 nop
0x1d6 nop
0x1d7 nop
0x1d8 nop
0x1d9 nop
0x1da nop
0x1db nop
0x1dc nop
0x1dd nop
0x1de nop
0x1df nop
0x1e0 nop
0x1e1 nop
0x1e2 nop
0x1e3 nop
0x1e4 nop
0x1e5 nop
0x1e6 nop
0x1e7 nop
0x1e8 nop
0x1e9 nop
0x1ea nop
0x1eb nop
0x1ec nop
0x1ed nop
0x1ee nop
0x1ef nop
0x1f0 nop
0x1f1 nop
0x1f2 nop
0x1f3 nop
0x1f4 nop
0x1f5 nop
0x1f6 nop
0x1f7 nop
0x1f8 nop
0x1f9 nop
0x1fa nop
0x1fb nop
0x1fc nop
0x1fd nop
0x1fe movp a,@a
0x1ff ret

	;; Blink code calculation
0x200 mov  r1,#$33
0x202 mov  a,@r1
0x203 add  a,#$EE
0x205 jnc  $0215
0x207 add  a,#$EC
0x209 jc   $0215
0x20b mov  r0,#$73
0x20d mov  @r0,#$2D
0x20f mov  r0,#$31
0x211 mov  @r0,#$2
0x213 jmp  $0243
0x215 mov  r0,#$44
0x217 mov  a,#$E4
0x219 add  a,@r0
0x21a jc   $022F
0x21c mov  r0,#$2F
0x21e mov  a,#$89
0x220 add  a,@r0
0x221 mov  r2,#$22
0x223 jc   $022A
0x225 dec  r2
0x226 mov  a,#$FA
0x228 add  a,@r0
0x229 cpl  c
0x22a inc  r0
0x22b call $032A
0x22d jmp  $0243
0x22f mov  r0,#$43
0x231 mov  a,@r0
0x232 cpl  a
0x233 add  a,#$18
0x235 jc   $0243
0x237 mov  r0,#$52
0x239 mov  a,@r0
0x23a add  a,#$BF
0x23c cpl  c
0x23d mov  r2,#$33
0x23f mov  r0,#$30
0x241 call $032A
0x243 mov  r0,#$2E
0x245 mov  a,@r0
0x246 add  a,#$72
0x248 jc   $024C
0x24a mov  @r1,#$12
0x24c mov  a,@r0
0x24d add  a,#$6B
0x24f jnc  $025A
0x251 mov  a,@r1
0x252 xrl  a,#$12
0x254 jnz  $025A
0x256 mov  @r1,a
0x257 mov  r0,#$3A
0x259 mov  @r0,a
0x25a mov  r0,#$41
0x25c mov  a,@r0
0x25d clr  c
0x25e jnz  $0262
0x260 call $02B1
0x262 mov  r0,#$60
0x264 mov  a,@r0
0x265 mov  r2,#$32
0x267 jb7  $027B
0x269 mov  r0,#$44
0x26b mov  a,@r0
0x26c add  a,#$DB
0x26e jnc  $0272
0x270 call $02B1
0x272 mov  r0,#$60
0x274 mov  a,@r0
0x275 dec  r2
0x276 cpl  a
0x277 add  a,#$20
0x279 jc   $027D
0x27b add  a,#$20
0x27d cpl  c
0x27e mov  r0,#$6C
0x280 mov  a,@r0
0x281 jnz  $0289
0x283 mov  r0,#$35
0x285 mov  a,#$64
0x287 call $032C
0x289 mov  r0,#$3C
0x28b mov  a,#$F4
0x28d add  a,@r0
0x28e cpl  c
0x28f mov  r2,#$41
0x291 jc   $0298
0x293 mov  a,#$24
0x295 add  a,@r0
0x296 inc  r2
0x297 mov  a,@r0
0x298 mov  @r0,a
0x299 mov  r0,#$36
0x29b call $032A
0x29d sel  mb1
0x29e call $0500
0x2a0 sel  mb0
0x2a1 call $0336
	;; END of blink code calculation

	;; stack manipulation for housekeeping functions
0x2a3 mov  r1,#$17
0x2a5 mov  @r1,#$8
0x2a7 dec  r1
0x2a8 clr  a
0x2a9 xch  a,@r1
0x2aa jb0  $02AF
0x2ac dec  a
0x2ad dec  a
0x2ae xchd a,@r1
0x2af sel  mb1
0x2b0 ret
0x2b1 mov  r0,#$35
0x2b3 mov  @r0,#$64
0x2b5 ret
0x2b6 nop
0x2b7 nop
0x2b8 nop
0x2b9 nop
0x2ba nop
0x2bb nop
0x2bc nop
0x2bd nop
0x2be nop
0x2bf nop
0x2c0 nop
0x2c1 nop
0x2c2 nop
0x2c3 nop
0x2c4 nop
0x2c5 nop
0x2c6 nop
0x2c7 nop
0x2c8 nop
0x2c9 nop
0x2ca nop
0x2cb nop
0x2cc nop
0x2cd nop
0x2ce nop
0x2cf nop
0x2d0 nop
0x2d1 nop
0x2d2 nop
0x2d3 nop
0x2d4 nop
0x2d5 nop
0x2d6 nop
0x2d7 nop
0x2d8 nop
0x2d9 nop
0x2da nop
0x2db nop
0x2dc nop
0x2dd nop
0x2de nop
0x2df nop
0x2e0 nop
0x2e1 nop
0x2e2 nop
0x2e3 nop
0x2e4 nop
0x2e5 nop
0x2e6 nop
0x2e7 nop
0x2e8 nop
0x2e9 nop
0x2ea nop
0x2eb nop
0x2ec nop
0x2ed nop
0x2ee nop
0x2ef nop
0x2f0 nop
0x2f1 nop
0x2f2 nop
0x2f3 nop
0x2f4 nop
0x2f5 nop
0x2f6 nop
0x2f7 nop
0x2f8 nop
0x2f9 nop
0x2fa nop
0x2fb nop
0x2fc nop
0x2fd nop
0x2fe movp a,@a
0x2ff ret

	;; 8-bit multiply function, 16-bit result
0x300 mov  r5,#$9
0x302 clr  c
0x303 clr  a
0x304 rrc  a
0x305 xch  a,r3
0x306 rrc  a
0x307 xch  a,r3
0x308 jnc  $030B
0x30a add  a,r6
0x30b djnz r5,$0304
0x30d ret
	;; END of 8-bit multiply function

	;; main body of ext int routine
0x30e mov  @r0,a
0x30f mov  r0,#$25
0x311 mov  a,@r0
0x312 inc  a
0x313 mov  r2,a
0x314 mov  r0,#$21
0x316 mov  a,@r0
0x317 inc  a
0x318 mov  r3,a
0x319 mov  a,r7
0x31a swap a
0x31b cpl  a
0x31c add  a,#$A
0x31e mov  r0,a
0x31f djnz r0,$031F
0x321 mov  r0,#$38
0x323 mov  a,@r0
0x324 retr
	;; END ext int routine

	;; initialize r4 with 22h
0x325 mov  r1,#$22
0x327 mov  a,@r1
0x328 mov  r4,a
0x329 ret
	;; END initialize r4 with 22h

	;; Count errors and set 33h blink code
0x32a mov  a,#$3C
0x32c xch  a,@r0
0x32d jnc  $0331
0x32f dec  a
0x330 mov  @r0,a
0x331 jnz  $0335
0x333 mov  a,r2
0x334 mov  @r1,a
0x335 ret
	;; END count errors

	;; diagnostic function (unused?)
0x336 mov  r0,#$80
0x338 mov  r2,#$8
0x33a movx a,@r0
0x33b jb5  $0353
0x33d mov  r2,#$4
0x33f dec  r0
0x340 xch  a,@r0
0x341 swap a
0x342 xch  a,@r0
0x343 xchd a,@r0
0x344 djnz r2,$033F
0x346 jb6  $0352
0x348 jb7  $0352
0x34a inc  r0
0x34b mov  @r0,#$0
0x34d inc  r0
0x34e mov  a,@r0
0x34f anl  a,#$F
0x351 mov  @r0,a
0x352 ret
0x353 clr  f0
0x354 jb7  $0357
0x356 cpl  f0
0x357 mov  r3,#$7F
0x359 jb6  $0368
0x35b jb7  $0381
0x35d mov  r1,#$2C
0x35f mov  a,@r1
0x360 dec  a
0x361 rl   a
0x362 swap a
0x363 anl  a,#$3
0x365 add  a,r3
0x366 mov  r3,a
0x367 clr  f0
0x368 dec  r0
0x369 mov  a,r0
0x36a jb2  $037E
0x36c add  a,#$82
0x36e movp a,@a
0x36f mov  r3,#$7F
0x371 mov  r1,a
0x372 jf0  $0375
0x374 mov  a,@r1
0x375 mov  r4,a
0x376 mov  a,r3
0x377 add  a,r2
0x378 mov  r1,a
0x379 mov  a,r4
0x37a movx @r1,a
0x37b djnz r2,$0368
0x37d ret
0x37e mov  a,@r0
0x37f jmp  $0371
0x381 mov  r1,#$7D
0x383 mov  a,@r1
0x384 jnz  $039D
0x386 clr  f0
0x387 cpl  f0
0x388 call $0368
0x38a call $0390
0x38c mov  r0,#$7C
0x38e mov  @r0,a
0x38f ret
0x390 call $0392
0x392 mov  r0,#$7E
0x394 mov  r1,#$D
0x396 mov  a,@r0
0x397 xchd a,@r1
0x398 inc  r0
0x399 dec  r1
0x39a mov  a,@r0
0x39b mov  @r1,#$FE
0x39d ret
	;; END diagnostic function
0x39e nop
0x39f nop
0x3a0 nop
0x3a1 nop
0x3a2 nop
0x3a3 nop
0x3a4 nop
0x3a5 nop
0x3a6 nop
0x3a7 nop
0x3a8 nop
0x3a9 nop
0x3aa nop
0x3ab nop
0x3ac nop
0x3ad nop
0x3ae nop
0x3af nop
0x3b0 nop
0x3b1 nop
0x3b2 nop
0x3b3 nop
0x3b4 nop
0x3b5 nop
0x3b6 nop
0x3b7 nop
0x3b8 nop
0x3b9 nop
0x3ba nop
0x3bb nop
0x3bc nop
0x3bd nop
0x3be nop
0x3bf nop
0x3c0 nop
0x3c1 nop
0x3c2 nop
0x3c3 nop
0x3c4 nop
0x3c5 nop
0x3c6 nop
0x3c7 nop
0x3c8 nop
0x3c9 nop
0x3ca nop
0x3cb nop
0x3cc nop
0x3cd nop
0x3ce nop
0x3cf nop
0x3d0 nop
0x3d1 nop
0x3d2 nop
0x3d3 nop
0x3d4 nop
0x3d5 nop
0x3d6 nop
0x3d7 nop
0x3d8 nop
0x3d9 nop
0x3da nop
0x3db nop
0x3dc nop
0x3dd nop
0x3de nop
0x3df nop
0x3e0 nop
0x3e1 nop
0x3e2 nop
0x3e3 nop
0x3e4 nop
0x3e5 nop
0x3e6 nop
0x3e7 nop
0x3e8 nop
0x3e9 nop
0x3ea nop
0x3eb nop
0x3ec nop
0x3ed nop
0x3ee nop
0x3ef nop
0x3f0 nop
0x3f1 nop
0x3f2 nop
0x3f3 nop
0x3f4 nop
0x3f5 nop
0x3f6 nop
0x3f7 nop
0x3f8 nop
0x3f9 nop
0x3fa anl  a,#$60
0x3fc add  a,r0
0x3fd orl  a,@r1
0x3fe movp a,@a

	;; ADC routine function table (starts at 0x400)
0x3ff jmp  $040E
0x401 movd p4,a
0x402 movd p4,a
0x403 movd p4,a
0x404 clr  a
0x405 orl  a,r4
0x406 orld p4,a
0x407 anl  bus,#$99
0x409 orld p7,a
	;; END function table
	
0x40a nop

	;; ADC routine jump
0x40b anl  a,#$7
0x40d jmpp @a
	;; END ADC routine jmp

	;; ADC function #1 (address select)
0x40e anl  p1,#$F7
0x410 mov  a,@r0
0x411 dec  a
0x412 jz   $041C
0x414 anl  p1,#$F3
0x416 jb4  $041A
0x418 anl  p1,#$F5
0x41a jb3  $041E
0x41c anl  p1,#$F6
0x41e orl  p2,#$20
0x420 orl  p1,#$8
0x422 anl  p1,#$F5
0x424 orl  p1,#$5
0x426 ret
	;; END ADC function #1

	;; ADC function #3 (knock self-test)
0x427 mov  r0,#$23
0x429 mov  a,@r0
0x42a mov  r4,a
0x42b mov  r0,#$2F
0x42d mov  a,@r0
0x42e add  a,#$C0
0x430 mov  r0,#$31
0x432 jc   $0446
0x434 mov  a,@r0
0x435 jb2  $0438
0x437 ret
0x438 anl  a,#$7
0x43a mov  @r0,a
0x43b ret
	;; END ADC function #3

	;; ADC function #2 (knock self-test)
0x43c add  a,#$7
0x43e movp a,@a
0x43f mov  r0,#$2F
0x441 add  a,@r0
0x442 jc   $044B
0x444 mov  r0,#$31
0x446 mov  a,@r0
0x447 jnz  $044B
0x449 anl  p1,#$7F
0x44b ret
	;; END ADC function #2

	;; ADC function #4 (read ADC ch. 0 - 3)
0x44c movx a,@r0
0x44d orl  p1,#$8
0x44f anl  p1,#$F4
0x451 xch  a,@r0
0x452 jb4  $0480
0x454 jb3  $047B
0x456 xch  a,@r0
0x457 mov  r1,a
0x458 mov  a,@r0
0x459 xrl  a,#$6
0x45b mov  r0,#$2F
0x45d jz   $0476
0x45f mov  a,#$C0
0x461 add  a,r1
0x462 jnc  $0478
0x464 mov  a,r1
0x465 mov  @r0,a
0x466 mov  r1,#$34
0x468 mov  a,@r1
0x469 add  a,#$FA
0x46b jz   $0475
0x46d cpl  a
0x46e jz   $0472
0x470 mov  a,#$FC
0x472 add  a,#$69
0x474 mov  @r0,a
0x475 ret
0x476 mov  r0,#$2D
0x478 mov  a,r1
0x479 mov  @r0,a
0x47a ret
0x47b xch  a,@r0
0x47c mov  r0,#$2E
0x47e mov  @r0,a
0x47f ret
0x480 jb3  $0487
0x482 xch  a,@r0
0x483 mov  r0,#$6F
0x485 nop
0x486 ret
0x487 xch  a,@r0
0x488 mov  r0,#$39
0x48a mov  @r0,a
0x48b ret
	;; END ADC function #4

	;; ADC function #5 (read ch. 5 knock sensor)
0x48c movx a,@r0
0x48d orl  p1,#$8
0x48f anl  p1,#$F7
0x491 orl  p1,#$7
0x493 mov  r0,#$46
0x495 cpl  a
0x496 mov  @r0,a
0x497 ret
	;; END ADC function #5

	;; ADC function #6
0x498 mov  r0,#$52
0x49a movx a,@r0
0x49b add  a,#$A
0x49d mov  r4,a
0x49e cpl  a
0x49f add  a,@r0
0x4a0 mov  r0,#$6C
0x4a2 orl  p1,#$8
0x4a4 anl  p1,#$F7
0x4a6 jnc  $04B1
0x4a8 mov  @r0,#$0
0x4aa mov  r0,#$52
0x4ac mov  a,r4
0x4ad mov  @r0,a
0x4ae mov  r4,#$FF
0x4b0 ret
0x4b1 inc  @r0
0x4b2 mov  a,@r0
0x4b3 jb2  $04A8
0x4b5 mov  r4,#$FF
0x4b7 ret
	;; END ADC function #6
	
0x4b8 nop
0x4b9 nop
0x4ba nop
0x4bb nop
0x4bc nop
0x4bd nop
0x4be nop
0x4bf nop
0x4c0 nop
0x4c1 nop
0x4c2 nop
0x4c3 nop
0x4c4 nop
0x4c5 nop
0x4c6 nop
0x4c7 nop
0x4c8 nop
0x4c9 nop
0x4ca nop
0x4cb nop
0x4cc nop
0x4cd nop
0x4ce nop
0x4cf nop
0x4d0 nop
0x4d1 nop
0x4d2 nop
0x4d3 nop
0x4d4 nop
0x4d5 nop
0x4d6 nop
0x4d7 nop
0x4d8 nop
0x4d9 nop
0x4da nop
0x4db nop
0x4dc nop
0x4dd nop
0x4de nop
0x4df nop
0x4e0 nop
0x4e1 nop
0x4e2 nop
0x4e3 nop
0x4e4 nop
0x4e5 nop
0x4e6 nop
0x4e7 nop
0x4e8 nop
0x4e9 nop
0x4ea nop
0x4eb nop
0x4ec nop
0x4ed nop
0x4ee nop
0x4ef nop
0x4f0 nop
0x4f1 nop
0x4f2 nop
0x4f3 nop
0x4f4 nop
0x4f5 nop
0x4f6 nop
0x4f7 nop
0x4f8 nop
0x4f9 nop
0x4fa nop
0x4fb nop
0x4fc nop
0x4fd nop
0x4fe movp a,@a
0x4ff ret
0x500 nop
0x501 nop
0x502 nop
0x503 nop
0x504 nop
0x505 nop
0x506 nop
0x507 nop
0x508 nop
0x509 nop
0x50a nop
0x50b nop
0x50c nop
0x50d nop
0x50e nop
0x50f nop
0x510 nop
0x511 nop
0x512 nop
0x513 nop
0x514 nop
0x515 nop
0x516 nop
0x517 nop
0x518 nop
0x519 nop
0x51a nop
0x51b nop
0x51c nop
0x51d nop
0x51e nop
0x51f nop
0x520 nop
0x521 nop
0x522 nop
0x523 nop
0x524 nop
0x525 nop
0x526 nop
0x527 nop
0x528 nop
0x529 nop
0x52a nop
0x52b nop
0x52c nop
0x52d nop
0x52e nop
0x52f nop
0x530 nop
0x531 nop
0x532 nop
0x533 nop
0x534 nop
0x535 nop
0x536 nop
0x537 nop
0x538 nop
0x539 nop
0x53a nop
0x53b nop
0x53c nop
0x53d nop
0x53e nop
0x53f nop
0x540 nop
0x541 nop
0x542 nop
0x543 nop
0x544 nop
0x545 nop
0x546 nop
0x547 nop
0x548 nop
0x549 nop
0x54a nop
0x54b nop
0x54c nop
0x54d nop
0x54e nop
0x54f nop
0x550 nop
0x551 nop
0x552 nop
0x553 nop
0x554 nop
0x555 nop
0x556 nop
0x557 nop
0x558 nop
0x559 nop
0x55a nop
0x55b nop
0x55c nop
0x55d nop
0x55e nop
0x55f nop
0x560 nop
0x561 nop
0x562 nop
0x563 nop
0x564 nop
0x565 nop
0x566 nop
0x567 nop
0x568 nop
0x569 nop
0x56a nop
0x56b nop
0x56c nop
0x56d nop
0x56e nop
0x56f nop
0x570 nop
0x571 nop
0x572 nop
0x573 nop
0x574 nop
0x575 nop
0x576 nop
0x577 nop
0x578 nop
0x579 nop
0x57a nop
0x57b nop
0x57c nop
0x57d nop
0x57e nop
0x57f nop
0x580 nop
0x581 nop
0x582 nop
0x583 nop
0x584 nop
0x585 nop
0x586 nop
0x587 nop
0x588 nop
0x589 nop
0x58a nop
0x58b nop
0x58c nop
0x58d nop
0x58e nop
0x58f nop
0x590 nop
0x591 nop
0x592 nop
0x593 nop
0x594 nop
0x595 nop
0x596 nop
0x597 nop
0x598 nop
0x599 nop
0x59a nop
0x59b nop
0x59c nop
0x59d nop
0x59e nop
0x59f nop
0x5a0 nop
0x5a1 nop
0x5a2 nop
0x5a3 nop
0x5a4 nop
0x5a5 nop
0x5a6 nop
0x5a7 nop
0x5a8 nop
0x5a9 nop
0x5aa nop
0x5ab nop
0x5ac nop
0x5ad nop
0x5ae nop
0x5af nop
0x5b0 nop
0x5b1 nop
0x5b2 nop
0x5b3 nop
0x5b4 nop
0x5b5 nop
0x5b6 nop
0x5b7 nop
0x5b8 nop
0x5b9 nop
0x5ba nop
0x5bb nop
0x5bc nop
0x5bd nop
0x5be nop
0x5bf nop
0x5c0 nop
0x5c1 nop
0x5c2 nop
0x5c3 nop
0x5c4 nop
0x5c5 nop
0x5c6 nop
0x5c7 nop
0x5c8 nop
0x5c9 nop
0x5ca nop
0x5cb nop
0x5cc nop
0x5cd nop
0x5ce nop
0x5cf nop
0x5d0 nop
0x5d1 nop
0x5d2 nop
0x5d3 nop
0x5d4 nop
0x5d5 nop
0x5d6 nop
0x5d7 nop
0x5d8 nop
0x5d9 nop
0x5da nop
0x5db nop
0x5dc nop
0x5dd nop
0x5de nop
0x5df nop
0x5e0 nop
0x5e1 nop
0x5e2 nop
0x5e3 nop
0x5e4 nop
0x5e5 nop
0x5e6 nop
0x5e7 nop
0x5e8 nop
0x5e9 nop
0x5ea nop
0x5eb nop
0x5ec nop
0x5ed nop
0x5ee nop
0x5ef nop
0x5f0 nop
0x5f1 nop
0x5f2 nop
0x5f3 nop
0x5f4 nop
0x5f5 nop
0x5f6 nop
0x5f7 nop
0x5f8 nop
0x5f9 nop
0x5fa nop
0x5fb nop
0x5fc nop
0x5fd nop
0x5fe movp a,@a
0x5ff ret
0x600 nop
0x601 nop
0x602 nop
0x603 nop
0x604 nop
0x605 nop
0x606 nop
0x607 nop
0x608 nop
0x609 nop
0x60a nop
0x60b nop
0x60c nop
0x60d nop
0x60e nop
0x60f nop
0x610 nop
0x611 nop
0x612 nop
0x613 nop
0x614 nop
0x615 nop
0x616 nop
0x617 nop
0x618 nop
0x619 nop
0x61a nop
0x61b nop
0x61c nop
0x61d nop
0x61e nop
0x61f nop
0x620 nop
0x621 nop
0x622 nop
0x623 nop
0x624 nop
0x625 nop
0x626 nop
0x627 nop
0x628 nop
0x629 nop
0x62a nop
0x62b nop
0x62c nop
0x62d nop
0x62e nop
0x62f nop
0x630 nop
0x631 nop
0x632 nop
0x633 nop
0x634 nop
0x635 nop
0x636 nop
0x637 nop
0x638 nop
0x639 nop
0x63a nop
0x63b nop
0x63c nop
0x63d nop
0x63e nop
0x63f nop
0x640 nop
0x641 nop
0x642 nop
0x643 nop
0x644 nop
0x645 nop
0x646 nop
0x647 nop
0x648 nop
0x649 nop
0x64a nop
0x64b nop
0x64c nop
0x64d nop
0x64e nop
0x64f nop
0x650 nop
0x651 nop
0x652 nop
0x653 nop
0x654 nop
0x655 nop
0x656 nop
0x657 nop
0x658 nop
0x659 nop
0x65a nop
0x65b nop
0x65c nop
0x65d nop
0x65e nop
0x65f nop
0x660 nop
0x661 nop
0x662 nop
0x663 nop
0x664 nop
0x665 nop
0x666 nop
0x667 nop
0x668 nop
0x669 nop
0x66a nop
0x66b nop
0x66c nop
0x66d nop
0x66e nop
0x66f nop
0x670 nop
0x671 nop
0x672 nop
0x673 nop
0x674 nop
0x675 nop
0x676 nop
0x677 nop
0x678 nop
0x679 nop
0x67a nop
0x67b nop
0x67c nop
0x67d nop
0x67e nop
0x67f nop
0x680 nop
0x681 nop
0x682 nop
0x683 nop
0x684 nop
0x685 nop
0x686 nop
0x687 nop
0x688 nop
0x689 nop
0x68a nop
0x68b nop
0x68c nop
0x68d nop
0x68e nop
0x68f nop
0x690 nop
0x691 nop
0x692 nop
0x693 nop
0x694 nop
0x695 nop
0x696 nop
0x697 nop
0x698 nop
0x699 nop
0x69a nop
0x69b nop
0x69c nop
0x69d nop
0x69e nop
0x69f nop
0x6a0 nop
0x6a1 nop
0x6a2 nop
0x6a3 nop
0x6a4 nop
0x6a5 nop
0x6a6 nop
0x6a7 nop
0x6a8 nop
0x6a9 nop
0x6aa nop
0x6ab nop
0x6ac nop
0x6ad nop
0x6ae nop
0x6af nop
0x6b0 nop
0x6b1 nop
0x6b2 nop
0x6b3 nop
0x6b4 nop
0x6b5 nop
0x6b6 nop
0x6b7 nop
0x6b8 nop
0x6b9 nop
0x6ba nop
0x6bb nop
0x6bc nop
0x6bd nop
0x6be nop
0x6bf nop
0x6c0 nop
0x6c1 nop
0x6c2 nop
0x6c3 nop
0x6c4 nop
0x6c5 nop
0x6c6 nop
0x6c7 nop
0x6c8 nop
0x6c9 nop
0x6ca nop
0x6cb nop
0x6cc nop
0x6cd nop
0x6ce nop
0x6cf nop
0x6d0 nop
0x6d1 nop
0x6d2 nop
0x6d3 nop
0x6d4 nop
0x6d5 nop
0x6d6 nop
0x6d7 nop
0x6d8 nop
0x6d9 nop
0x6da nop
0x6db nop
0x6dc nop
0x6dd nop
0x6de nop
0x6df nop
0x6e0 nop
0x6e1 nop
0x6e2 nop
0x6e3 nop
0x6e4 nop
0x6e5 nop
0x6e6 nop
0x6e7 nop
0x6e8 nop
0x6e9 nop
0x6ea nop
0x6eb nop
0x6ec nop
0x6ed nop
0x6ee nop
0x6ef nop
0x6f0 nop
0x6f1 nop
0x6f2 nop
0x6f3 nop
0x6f4 nop
0x6f5 nop
0x6f6 nop
0x6f7 nop
0x6f8 nop
0x6f9 nop
0x6fa nop
0x6fb nop
0x6fc nop
0x6fd nop
0x6fe movp a,@a
0x6ff ret
0x700 nop
0x701 nop
0x702 nop
0x703 nop
0x704 nop
0x705 nop
0x706 nop
0x707 nop
0x708 nop
0x709 nop
0x70a nop
0x70b nop
0x70c nop
0x70d nop
0x70e nop
0x70f nop
0x710 nop
0x711 nop
0x712 nop
0x713 nop
0x714 nop
0x715 nop
0x716 nop
0x717 nop
0x718 nop
0x719 nop
0x71a nop
0x71b nop
0x71c nop
0x71d nop
0x71e nop
0x71f nop
0x720 nop
0x721 nop
0x722 nop
0x723 nop
0x724 nop
0x725 nop
0x726 nop
0x727 nop
0x728 nop
0x729 nop
0x72a nop
0x72b nop
0x72c nop
0x72d nop
0x72e nop
0x72f nop
0x730 nop
0x731 nop
0x732 nop
0x733 nop
0x734 nop
0x735 nop
0x736 nop
0x737 nop
0x738 nop
0x739 nop
0x73a nop
0x73b nop
0x73c nop
0x73d nop
0x73e nop
0x73f nop
0x740 nop
0x741 nop
0x742 nop
0x743 nop
0x744 nop
0x745 nop
0x746 nop
0x747 nop
0x748 nop
0x749 nop
0x74a nop
0x74b nop
0x74c nop
0x74d nop
0x74e nop
0x74f nop
0x750 nop
0x751 nop
0x752 nop
0x753 nop
0x754 nop
0x755 nop
0x756 nop
0x757 nop
0x758 nop
0x759 nop
0x75a nop
0x75b nop
0x75c nop
0x75d nop
0x75e nop
0x75f nop
0x760 nop
0x761 nop
0x762 nop
0x763 nop
0x764 nop
0x765 nop
0x766 nop
0x767 nop
0x768 nop
0x769 nop
0x76a nop
0x76b nop
0x76c nop
0x76d nop
0x76e nop
0x76f nop
0x770 nop
0x771 nop
0x772 nop
0x773 nop
0x774 nop
0x775 nop
0x776 nop
0x777 nop
0x778 nop
0x779 nop
0x77a nop
0x77b nop
0x77c nop
0x77d nop
0x77e nop
0x77f nop
0x780 nop
0x781 nop
0x782 nop
0x783 nop
0x784 nop
0x785 nop
0x786 nop
0x787 nop
0x788 nop
0x789 nop
0x78a nop
0x78b nop
0x78c nop
0x78d nop
0x78e nop
0x78f nop
0x790 nop
0x791 nop
0x792 nop
0x793 nop
0x794 nop
0x795 nop
0x796 nop
0x797 nop
0x798 nop
0x799 nop
0x79a nop
0x79b nop
0x79c nop
0x79d nop
0x79e nop
0x79f nop
0x7a0 nop
0x7a1 nop
0x7a2 nop
0x7a3 nop
0x7a4 nop
0x7a5 nop
0x7a6 nop
0x7a7 nop
0x7a8 nop
0x7a9 nop
0x7aa nop
0x7ab nop
0x7ac nop
0x7ad nop
0x7ae nop
0x7af nop
0x7b0 nop
0x7b1 nop
0x7b2 nop
0x7b3 nop
0x7b4 nop
0x7b5 nop
0x7b6 nop
0x7b7 nop
0x7b8 nop
0x7b9 nop
0x7ba nop
0x7bb nop
0x7bc nop
0x7bd nop
0x7be nop
0x7bf nop
0x7c0 nop
0x7c1 nop
0x7c2 nop
0x7c3 nop
0x7c4 nop
0x7c5 nop
0x7c6 nop
0x7c7 nop
0x7c8 nop
0x7c9 nop
0x7ca nop
0x7cb nop
0x7cc nop
0x7cd nop
0x7ce nop
0x7cf nop
0x7d0 nop
0x7d1 nop
0x7d2 nop
0x7d3 nop
0x7d4 nop
0x7d5 nop
0x7d6 nop
0x7d7 nop
0x7d8 nop
0x7d9 nop
0x7da nop
0x7db nop
0x7dc nop
0x7dd nop
0x7de nop
0x7df nop
0x7e0 nop
0x7e1 nop
0x7e2 nop
0x7e3 nop
0x7e4 nop
0x7e5 nop
0x7e6 nop
0x7e7 nop
0x7e8 nop
0x7e9 nop
0x7ea nop
0x7eb nop
0x7ec nop
0x7ed nop
0x7ee nop
0x7ef nop
0x7f0 nop
0x7f1 nop
0x7f2 nop
0x7f3 nop
0x7f4 nop
0x7f5 nop
0x7f6 nop
0x7f7 nop
0x7f8 nop
0x7f9 nop
0x7fa nop
0x7fb nop
0x7fc nop
0x7fd nop
0x7fe movp a,@a
0x7ff ret

	;; housekeeping function list
0x800 call $020F
0x802 call $028D
0x804 call $0257
0x806 call $0282
0x808 nop
0x809 nop
0x80a call $029E
0x80c call $0100
0x80e nop
0x80f nop
0x810 call $0012
0x812 jmp  $0012
	;; END housekeeping function list
0x814 nop
0x815 nop
0x816 nop
0x817 nop
0x818 nop
0x819 nop
0x81a nop
0x81b nop
0x81c nop
0x81d nop
0x81e nop
0x81f nop
0x820 nop
0x821 nop
0x822 nop
0x823 nop
0x824 nop
0x825 nop
0x826 nop
0x827 nop
0x828 nop
0x829 nop
0x82a nop
0x82b nop
0x82c nop
0x82d nop
0x82e nop
0x82f nop
0x830 nop
0x831 nop
0x832 nop
0x833 nop
0x834 nop
0x835 nop
0x836 nop
0x837 nop
0x838 nop
0x839 nop
0x83a nop
0x83b nop
0x83c nop
0x83d nop
0x83e nop
0x83f nop
0x840 nop
0x841 nop
0x842 nop
0x843 nop
0x844 nop
0x845 nop
0x846 nop
0x847 nop
0x848 nop
0x849 nop
0x84a nop
0x84b nop
0x84c nop
0x84d nop
0x84e nop
0x84f nop
0x850 nop
0x851 nop
0x852 nop
0x853 nop
0x854 nop
0x855 nop
0x856 nop
0x857 nop
0x858 nop
0x859 nop
0x85a nop
0x85b nop
0x85c nop
0x85d nop
0x85e nop
0x85f nop
0x860 nop
0x861 nop
0x862 nop
0x863 nop
0x864 nop
0x865 nop
0x866 nop
0x867 nop
0x868 nop
0x869 nop
0x86a nop
0x86b nop
0x86c nop
0x86d nop
0x86e nop
0x86f nop
0x870 nop
0x871 nop
0x872 nop
0x873 nop
0x874 nop
0x875 nop
0x876 nop
0x877 nop
0x878 nop
0x879 nop
0x87a nop
0x87b nop
0x87c nop
0x87d nop
0x87e nop
0x87f nop
0x880 nop
0x881 nop
0x882 nop
0x883 nop
0x884 nop
0x885 nop
0x886 nop
0x887 nop
0x888 nop
0x889 nop
0x88a nop
0x88b nop
0x88c nop
0x88d nop
0x88e nop
0x88f nop
0x890 nop
0x891 nop
0x892 nop
0x893 nop
0x894 nop
0x895 nop
0x896 nop
0x897 nop
0x898 nop
0x899 nop
0x89a nop
0x89b nop
0x89c nop
0x89d nop
0x89e nop
0x89f nop
0x8a0 nop
0x8a1 nop
0x8a2 nop
0x8a3 nop
0x8a4 nop
0x8a5 nop
0x8a6 nop
0x8a7 nop
0x8a8 nop
0x8a9 nop
0x8aa nop
0x8ab nop
0x8ac nop
0x8ad nop
0x8ae nop
0x8af nop
0x8b0 nop
0x8b1 nop
0x8b2 nop
0x8b3 nop
0x8b4 nop
0x8b5 nop
0x8b6 nop
0x8b7 nop
0x8b8 nop
0x8b9 nop
0x8ba nop
0x8bb nop
0x8bc nop
0x8bd nop
0x8be nop
0x8bf nop
0x8c0 nop
0x8c1 nop
0x8c2 nop
0x8c3 nop
0x8c4 nop
0x8c5 nop
0x8c6 nop
0x8c7 nop
0x8c8 nop
0x8c9 nop
0x8ca nop
0x8cb nop
0x8cc nop
0x8cd nop
0x8ce nop
0x8cf nop
0x8d0 nop
0x8d1 nop
0x8d2 nop
0x8d3 nop
0x8d4 nop
0x8d5 nop
0x8d6 nop
0x8d7 nop
0x8d8 nop
0x8d9 nop
0x8da nop
0x8db nop
0x8dc nop
0x8dd nop
0x8de nop
0x8df nop
0x8e0 nop
0x8e1 nop
0x8e2 nop
0x8e3 nop
0x8e4 nop
0x8e5 nop
0x8e6 nop
0x8e7 nop
0x8e8 nop
0x8e9 nop
0x8ea nop
0x8eb nop
0x8ec nop
0x8ed nop
0x8ee nop
0x8ef nop
0x8f0 nop
0x8f1 nop
0x8f2 nop
0x8f3 nop
0x8f4 nop
0x8f5 nop
0x8f6 nop
0x8f7 nop
0x8f8 nop
0x8f9 nop
0x8fa nop
0x8fb nop
0x8fc nop
0x8fd nop
0x8fe movp a,@a
0x8ff ret
	;; read maps (rpm and PID gain)
0x900 mov  r1,#$44
0x902 mov  a,@r1
0x903 rl   a
0x904 swap a
0x905 anl  a,#$7
0x907 inc  a
0x908 mov  r5,a
0x909 mov  r2,#$25
0x90b mov  a,r2
0x90c movp a,@a
0x90d jz   $0919
0x90f mov  r1,a
0x910 mov  a,r2
0x911 add  a,#$9
0x913 xch  a,r2
0x914 add  a,r5
0x915 movp a,@a
0x916 mov  @r1,a
0x917 jmp  $010B
0x919 mov  r1,#$43
0x91b mov  a,@r1
0x91c anl  a,#$18
0x91e add  a,r2
0x91f add  a,r5
0x920 movp a,@a
0x921 mov  r1,#$6B
0x923 mov  @r1,a
0x924 ret
	;; END read maps

	;; RPM maps
0x925 xch  a,r2
0x926 .db   0x9b
0x927 .db   0x9b
0x928 cpl  f0
0x929 jb4  $0991
0x92b orl  p2,#$83
0x92d addc a,r7
0x92e xch  a,r3
0x92f movd p5,a
0x930 xchd a,@r1
0x931 xchd a,@r0
0x932 xchd a,@r0
0x933 xchd a,@r0
0x934 xchd a,@r0
0x935 xchd a,@r0
0x936 cpl  a
0x937 swap a
0x938 jmp  $0244
0x93a strt t
0x93b .db   0x66
0x93c .db   0x66
0x93d .db   0x66
0x93e .db   0x66
0x93f .db   0x66
0x940 orl  a,r2
0x941 jmp  $0350
0x943 movd p6,a
0x944 jb1  $0924
0x946 inc  r4
0x947 call $000C
0x949 anl  a,@r0
0x94a en   tcnti
0x94b inc  r7
0x94c inc  r4
0x94d inc  r1
0x94e dis  i
0x94f jb0  $090F
0x951 movd a,p4
0x952 orl  a,r6
0x953 addc a,r5
0x954 jmp  $0351
0x956 jmp  $0238
0x958 xch  a,r3
0x959 inc  r7
0x95a inc  r1
0x95b orl  a,r3
0x95c jb0  $0912
0x95e jb0  $0912
0x960 jb0  $0912
0x962 jb0  $0912
0x964 orl  a,r0
0x965 xch  a,@r0
0x966 xch  a,@r0
0x967 xch  a,@r0
0x968 inc  r3
0x969 inc  r3
0x96a inc  r3
0x96b inc  r1
0x96c inc  @r0
0x96d orl  a,r4
0x96e movx a,@r0
0x96f movx a,@r0
0x970 movx a,@r0
0x971 movx a,@r0
0x972 movx a,@r0
0x973 movx a,@r0
0x974 movx a,@r0
0x975 movx a,@r0
0x976 movd p6,a
0x977 mov  a,t
0x978 mov  a,t
0x979 mov  a,t
0x97a mov  a,t
0x97b mov  a,t
0x97c mov  a,t
0x97d mov  a,t
0x97e mov  a,t
0x97f strt cnt
0x980 in   a,p2
0x981 in   a,p2
0x982 in   a,p2
0x983 in   a,p2
0x984 in   a,p2
0x985 in   a,p2
0x986 in   a,p2
0x987 in   a,p2
0x988 add  a,r1
0x989 jmp  $0004
0x98b jmp  $0004
0x98d jmp  $0004
0x98f jmp  $0004
0x991 nop
	;; END rpm maps

	;; PID gain 8x4 map (rpm/throttle)
0x992 djnz r1,$09E9
0x994 jnc  $09E6
0x996 djnz r2,$09E7
0x998 movp3 a,@a
0x999 movp3 a,@a
0x99a dec  r1
0x99b mov  r1,a
0x99c .db   0xa6
0x99d jni  $098A
0x99f cpl  c
0x9a0 .db   0xc3
0x9a1 movp3 a,@a
0x9a2 mov  r1,a
0x9a3 orl  p1,#$86
0x9a5 .db   0x66
0x9a6 add  a,r2
0x9a7 rrc  a
0x9a8 ret
0x9a9 movp3 a,@a
0x9aa dec  r1
0x9ab mov  r1,a
0x9ac jni  $0966
0x9ae add  a,r2
0x9af rrc  a
0x9b0 movp a,@a
0x9b1 movp3 a,@a
	;; PID gain 8x4 map
0x9b2 nop
0x9b3 nop
0x9b4 nop
0x9b5 nop
0x9b6 nop
0x9b7 nop
0x9b8 nop
0x9b9 nop
0x9ba nop
0x9bb nop
0x9bc nop
0x9bd nop
0x9be nop
0x9bf nop
0x9c0 nop
0x9c1 nop
0x9c2 nop
0x9c3 nop
0x9c4 nop
0x9c5 nop
0x9c6 nop
0x9c7 nop
0x9c8 nop
0x9c9 nop
0x9ca nop
0x9cb nop
0x9cc nop
0x9cd nop
0x9ce nop
0x9cf nop
0x9d0 nop
0x9d1 nop
0x9d2 nop
0x9d3 nop
0x9d4 nop
0x9d5 nop
0x9d6 nop
0x9d7 nop
0x9d8 nop
0x9d9 nop
0x9da nop
0x9db nop
0x9dc nop
0x9dd nop
0x9de nop
0x9df nop
0x9e0 nop
0x9e1 nop
0x9e2 nop
0x9e3 nop
0x9e4 nop
0x9e5 nop
0x9e6 nop
0x9e7 nop
0x9e8 nop
0x9e9 nop
0x9ea nop
0x9eb nop
0x9ec nop
0x9ed nop
0x9ee nop
0x9ef nop
0x9f0 nop
0x9f1 nop
0x9f2 nop
0x9f3 nop
0x9f4 nop
0x9f5 nop
0x9f6 nop
0x9f7 nop
0x9f8 nop
0x9f9 nop
0x9fa nop
0x9fb nop
0x9fc nop
0x9fd nop
0x9fe movp a,@a
0x9ff ret

	;; RPM axis map
0xa00 .db   0x01
0xa01 .db   0x01
0xa02 outl bus,a
0xa03 .db   0x01
0xa04 .db   0x01
0xa05 outl bus,a
0xa06 outl bus,a
0xa07 outl bus,a
0xa08 outl bus,a
0xa09 outl bus,a
0xa0a add  a,#$3
0xa0c add  a,#$4
	;; END RPM axis map

	;; read throttle angle calculation (not sure where exactly it begins)
0xa0e jmp  $00B9
0xa10 movd p4,a
0xa11 mov  a,@r1
0xa12 cpl  a
0xa13 inc  r1
0xa14 add  a,@r1
0xa15 mov  r1,#$3F
0xa17 jc   $0A1F
0xa19 add  a,#$6
0xa1b jc   $0A1F
0xa1d mov  @r1,#$B
0xa1f mov  a,@r1
0xa20 jz   $0A23
0xa22 dec  a
0xa23 anl  a,#$F
0xa25 mov  @r1,a
0xa26 mov  r1,#$3C
0xa28 mov  a,@r1
0xa29 mov  r6,a
0xa2a dec  r1
0xa2b mov  a,@r1
0xa2c mov  r3,a
0xa2d sel  mb0
0xa2e call $0300
0xa30 sel  mb1
0xa31 dec  r1
0xa32 mov  @r1,a
0xa33 add  a,#$CB
0xa35 jc   $0A38
0xa37 clr  a
0xa38 mov  r1,#$43
0xa3a mov  @r1,a
0xa3b mov  a,#$E3
0xa3d add  a,@r1
0xa3e jnc  $0A42
0xa40 mov  @r1,#$1C
0xa42 mov  r1,#$39
0xa44 mov  a,@r1
0xa45 mov  r6,a
0xa46 mov  r1,#$3B
0xa48 mov  a,@r1
0xa49 mov  r3,a
0xa4a sel  mb0
0xa4b call $0300
0xa4d sel  mb1
0xa4e add  a,#$A3
0xa50 jz   $0A56
0xa52 cpl  a
0xa53 inc  a
0xa54 add  a,@r1
0xa55 mov  @r1,a
0xa56 ret
	;; END throttle angle calculation

	;; read rpm axis function
0xa57 mov  r1,#$44
0xa59 mov  r0,#$24
0xa5b mov  r6,#$0
0xa5d mov  a,@r0
0xa5e cpl  a
0xa5f mov  r4,a
0xa60 sel  rb0
0xa61 mov  a,r7
0xa62 sel  rb1
0xa63 cpl  a
0xa64 jb1  $0A7C
0xa66 cpl  a
0xa67 add  a,#$38
0xa69 add  a,r4
0xa6a mov  r4,a
0xa6b jc   $0A77
0xa6d inc  r6
0xa6e mov  a,r6
0xa6f rrc  a
0xa70 clr  c
0xa71 rrc  a
0xa72 movp a,@a
0xa73 add  a,r4
0xa74 mov  r4,a
0xa75 jnc  $0A6D
0xa77 mov  a,#$C4
0xa79 add  a,r6
0xa7a jnc  $0A7F
0xa7c mov  r6,#$3C
0xa7e clr  a
0xa7f xch  a,r6
0xa80 mov  @r1,a
0xa81 ret
	;; END read rpm axis function

	;; read CV feedforward map
0xa82 mov  r0,#$43
0xa84 mov  r1,#$44
0xa86 clr  f1
0xa87 call $0480
0xa89 mov  r1,#$68
0xa8b mov  @r1,a
0xa8c ret
	;; END read CV feedforward map

	;; read target boost map
0xa8d mov  r0,#$43
0xa8f mov  r1,#$44
0xa91 clr  f1
0xa92 cpl  f1
0xa93 call $0480
0xa95 cpl  a
0xa96 mov  r1,#$57
0xa98 add  a,@r1
0xa99 cpl  a
0xa9a mov  r1,#$51
0xa9c mov  @r1,a
0xa9d ret
	;; END read target boost map

	;; calculate ADC angles 1 & 2
0xa9e mov  r0,#$2A
0xaa0 mov  r1,#$22
0xaa2 call $0380
0xaa4 mov  @r1,a
0xaa5 mov  r0,#$2B
0xaa7 inc  r1
0xaa8 call $0380
0xaaa add  a,#$F8
0xaac mov  @r1,a
0xaad ret
	;; END calculate ADC angles
	
0xaae nop
0xaaf nop
0xab0 nop
0xab1 nop
0xab2 nop
0xab3 nop
0xab4 nop
0xab5 nop
0xab6 nop
0xab7 nop
0xab8 nop
0xab9 nop
0xaba nop
0xabb nop
0xabc nop
0xabd nop
0xabe nop
0xabf nop
0xac0 nop
0xac1 nop
0xac2 nop
0xac3 nop
0xac4 nop
0xac5 nop
0xac6 nop
0xac7 nop
0xac8 nop
0xac9 nop
0xaca nop
0xacb nop
0xacc nop
0xacd nop
0xace nop
0xacf nop
0xad0 nop
0xad1 nop
0xad2 nop
0xad3 nop
0xad4 nop
0xad5 nop
0xad6 nop
0xad7 nop
0xad8 nop
0xad9 nop
0xada nop
0xadb nop
0xadc nop
0xadd nop
0xade nop
0xadf nop
0xae0 nop
0xae1 nop
0xae2 nop
0xae3 nop
0xae4 nop
0xae5 nop
0xae6 nop
0xae7 nop
0xae8 nop
0xae9 nop
0xaea nop
0xaeb nop
0xaec nop
0xaed nop
0xaee nop
0xaef nop
0xaf0 nop
0xaf1 nop
0xaf2 nop
0xaf3 nop
0xaf4 nop
0xaf5 nop
0xaf6 nop
0xaf7 nop
0xaf8 nop
0xaf9 nop
0xafa nop
0xafb nop
0xafc nop
0xafd nop
0xafe movp a,@a
0xaff ret

	;; CV feedforward aka open-loop map (rpm/throttle)
0xb00 jnt0 $0B26
0xb02 jnt0 $0B26
0xb04 jnt0 $0B26
0xb06 jnt0 $0B26
0xb08 jnt0 $0B26
0xb0a jnt0 $0B26
0xb0c jnt0 $0B26
0xb0e jnt0 $0B26
0xb10 xchd a,@r0
0xb11 xchd a,@r0
0xb12 xchd a,@r0
0xb13 jt0  $0B36
0xb15 outl p1,a
0xb16 outl p1,a
0xb17 outl p1,a
0xb18 outl p1,a
0xb19 outl p1,a
0xb1a outl p1,a
0xb1b outl p1,a
0xb1c outl p1,a
0xb1d outl p1,a
0xb1e outl p1,a
0xb1f outl p1,a
0xb20 outl p2,a
0xb21 outl p2,a
0xb22 movd p5,a
0xb23 orl  a,#$45
0xb25 orl  a,r1
0xb26 orl  a,r1
0xb27 orl  a,r4
0xb28 orl  a,r4
0xb29 orl  a,r4
0xb2a orl  a,r4
0xb2b orl  a,r4
0xb2c orl  a,r4
0xb2d orl  a,r4
0xb2e orl  a,r4
0xb2f orl  a,r4
0xb30 anl  a,@r1
0xb31 anl  a,@r1
0xb32 anl  a,@r1
0xb33 call $025A
0xb35 add  a,@r0
0xb36 jmp  $0368
0xb38 add  a,r2
0xb39 add  a,r4
0xb3a add  a,r5
0xb3b .db   0x73
0xb3c .db   0x73
0xb3d .db   0x73
0xb3e .db   0x73
0xb3f .db   0x73
0xb40 .db   0x73
0xb41 .db   0x73
0xb42 .db   0x73
0xb43 rr   a
0xb44 addc a,r3
0xb45 addc a,r7
0xb46 ret
0xb47 jni  $0B8A
0xb49 orld p6,a
0xb4a jb4  $0B9A
0xb4c anl  p2,#$9A
0xb4e anl  p2,#$9A
0xb50 jnz  $0B92
0xb52 orld p6,a
0xb53 jb4  $0B96
0xb55 anld p5,a
0xb56 mov  @r1,a
0xb57 clr  f1
0xb58 mov  r1,a
0xb59 mov  r5,a
0xb5a jf0  $0BBF
0xb5c mov  r7,#$BF
0xb5e mov  r7,#$BF
0xb60 jnz  $0B92
0xb62 orld p6,a
0xb63 jb4  $0B96
0xb65 anld p5,a
0xb66 mov  @r1,a
0xb67 clr  f1
0xb68 mov  r1,a
0xb69 mov  r5,a
0xb6a jf0  $0BBF
0xb6c mov  r7,#$BF
0xb6e mov  r7,#$BF
0xb70 jnz  $0B92
0xb72 orld p6,a
0xb73 jb4  $0B96
0xb75 anld p5,a
0xb76 mov  @r1,a
0xb77 clr  f1
0xb78 mov  r1,a
0xb79 mov  r5,a
0xb7a jf0  $0BBF
0xb7c mov  r7,#$BF
0xb7e mov  r7,#$BF
	;; END CV feedforward map

	;; multiply @r0 by RPM value
0xb80 mov  a,@r0
0xb81 mov  r3,a
0xb82 mov  r0,#$24
0xb84 mov  a,@r0
0xb85 mov  r6,a
0xb86 sel  mb0
0xb87 call $0300
0xb89 sel  mb1
0xb8a ret
0xb8b jmp  $04FE
	;; END multiply @r0 by RPM
	
0xb8d nop
0xb8e nop
0xb8f nop
0xb90 nop
0xb91 nop
0xb92 nop
0xb93 nop
0xb94 nop
0xb95 nop
0xb96 nop
0xb97 nop
0xb98 nop
0xb99 nop
0xb9a nop
0xb9b nop
0xb9c nop
0xb9d nop
0xb9e nop
0xb9f nop
0xba0 nop
0xba1 nop
0xba2 nop
0xba3 nop
0xba4 nop
0xba5 nop
0xba6 nop
0xba7 nop
0xba8 nop
0xba9 nop
0xbaa nop
0xbab nop
0xbac nop
0xbad nop
0xbae nop
0xbaf nop
0xbb0 nop
0xbb1 nop
0xbb2 nop
0xbb3 nop
0xbb4 nop
0xbb5 nop
0xbb6 nop
0xbb7 nop
0xbb8 nop
0xbb9 nop
0xbba nop
0xbbb nop
0xbbc nop
0xbbd nop
0xbbe nop
0xbbf nop
0xbc0 nop
0xbc1 nop
0xbc2 nop
0xbc3 nop
0xbc4 nop
0xbc5 nop
0xbc6 nop
0xbc7 nop
0xbc8 nop
0xbc9 nop
0xbca nop
0xbcb nop
0xbcc nop
0xbcd nop
0xbce nop
0xbcf nop
0xbd0 nop
0xbd1 nop
0xbd2 nop
0xbd3 nop
0xbd4 nop
0xbd5 nop
0xbd6 nop
0xbd7 nop
0xbd8 nop
0xbd9 nop
0xbda nop
0xbdb nop
0xbdc nop
0xbdd nop
0xbde nop
0xbdf nop
0xbe0 nop
0xbe1 nop
0xbe2 nop
0xbe3 nop
0xbe4 nop
0xbe5 nop
0xbe6 nop
0xbe7 nop
0xbe8 nop
0xbe9 nop
0xbea nop
0xbeb nop
0xbec nop
0xbed nop
0xbee nop
0xbef nop
0xbf0 nop
0xbf1 nop
0xbf2 nop
0xbf3 nop
0xbf4 nop
0xbf5 nop
0xbf6 nop
0xbf7 nop
0xbf8 nop
0xbf9 nop
0xbfa nop
0xbfb nop
0xbfc jf1  $0B8B
0xbfe movp a,@a
0xbff ret

	;; target boost map (rpm/throttle)
0xc00 anl  bus,#$98
0xc02 anl  bus,#$96
0xc04 jnz  $0C96
0xc06 call $0494
0xc08 call $0492
0xc0a jb4  $0C91
0xc0c movx @r1,a
0xc0d movx @r0,a
0xc0e orld p5,a
0xc0f orl  p1,#$9E
0xc11 anld p6,a
0xc12 anld p6,a
0xc13 anld p6,a
0xc14 anld p6,a
0xc15 anld p6,a
0xc16 anld p6,a
0xc17 anld p6,a
0xc18 anld p6,a
0xc19 anld p5,a
0xc1a anld p5,a
0xc1b anl  p2,#$97
0xc1d movx @r1,a
0xc1e orld p5,a
0xc1f .db   0x8b
0xc20 clr  f1
0xc21 clr  f1
0xc22 clr  f1
0xc23 .db   0xa6
0xc24 cpl  c
0xc25 cpl  c
0xc26 cpl  c
0xc27 mov  r2,a
0xc28 mov  r2,a
0xc29 cpl  c
0xc2a cpl  c
0xc2b jmp  $059D
0xc2d call $048D
0xc2f .db   0x8b
0xc30 mov  r3,a
0xc31 mov  r3,a
0xc32 mov  r3,a
0xc33 mov  r6,a
0xc34 mov  r7,a
0xc35 mov  @r0,#$B1
0xc37 call $05B4
0xc39 call $05B4
0xc3b mov  @r1,#$AA
0xc3d anld p7,a
0xc3e orld p6,a
0xc3f orld p5,a
0xc40 call $05B4
0xc42 jf0  $0CB8
0xc44 mov  r2,#$BC
0xc46 mov  r7,#$C1
0xc48 .db   0xc1
0xc49 .db   0xc1
0xc4a .db   0xc1
0xc4b .db   0xc1
0xc4c mov  r6,#$AB
0xc4e movx @r1,a
0xc4f orld p7,a
0xc50 mov  r1,#$B9
0xc52 mov  r4,#$C1
0xc54 jz   $0CCA
0xc56 dec  r6
0xc57 dec  r7
0xc58 dec  r7
0xc59 xrl  a,@r0
0xc5a xrl  a,@r1
0xc5b xrl  a,@r0
0xc5c dec  r6
0xc5d call $0598
0xc5f movx @r1,a
0xc60 mov  r1,#$B9
0xc62 mov  r4,#$C1
0xc64 jz   $0CCA
0xc66 dec  r6
0xc67 dec  r7
0xc68 dec  r7
0xc69 xrl  a,@r0
0xc6a xrl  a,@r1
0xc6b xrl  a,@r0
0xc6c dec  r6
0xc6d call $0598
0xc6f movx @r1,a
0xc70 mov  r1,#$B9
0xc72 mov  r4,#$C1
0xc74 jz   $0CCA
0xc76 dec  r6
0xc77 dec  r7
0xc78 dec  r7
0xc79 xrl  a,@r0
0xc7a xrl  a,@r1
0xc7b xrl  a,@r0
0xc7c dec  r6
0xc7d call $0598
0xc7f movx @r1,a
0xc80 mov  a,@r1
	;; END target boost map

	;; read boost/cv feedforward map
0xc81 rrc  a
0xc82 rrc  a
0xc83 anl  a,#$F
0xc85 mov  r2,a
0xc86 mov  a,@r0
0xc87 rlc  a
0xc88 rlc  a
0xc89 anl  a,#$F0
0xc8b add  a,r2
0xc8c mov  r2,a
0xc8d mov  a,@r0
0xc8e anl  a,#$3
0xc90 inc  a
0xc91 dec  r0
0xc92 mov  @r0,a
0xc93 clr  a
0xc94 mov  r5,a
0xc95 mov  r7,a
0xc96 mov  r4,#$4
0xc98 mov  a,r4
0xc99 cpl  a
0xc9a add  a,@r0
0xc9b mov  a,r2
0xc9c jnc  $0CA0
0xc9e add  a,#$10
0xca0 mov  r3,a
0xca1 call $03FC
0xca3 add  a,r5
0xca4 mov  r5,a
0xca5 jnc  $0CA8
0xca7 inc  r7
0xca8 mov  a,@r1
0xca9 rrc  a
0xcaa mov  a,r3
0xcab jnc  $0CAE
0xcad inc  a
0xcae call $03FC
0xcb0 add  a,r5
0xcb1 mov  r5,a
0xcb2 jnc  $0CB5
0xcb4 inc  r7
0xcb5 mov  a,@r1
0xcb6 inc  r3
0xcb7 jb1  $0CBA
0xcb9 dec  r3
0xcba mov  a,r3
0xcbb call $03FC
0xcbd add  a,r5
0xcbe mov  r5,a
0xcbf jnc  $0CC2
0xcc1 inc  r7
0xcc2 mov  a,r3
0xcc3 call $03FC
0xcc5 add  a,r5
0xcc6 mov  r5,a
0xcc7 jnc  $0CCA
0xcc9 inc  r7
0xcca djnz r4,$0C98
0xccc mov  a,r7
0xccd anl  a,#$F
0xccf xch  a,r5
0xcd0 mov  r0,#$1D
0xcd2 xchd a,@r0
0xcd3 swap a
0xcd4 ret
	;; END read boost/cv feedforward map
	
0xcd5 nop
0xcd6 nop
0xcd7 nop
0xcd8 nop
0xcd9 nop
0xcda nop
0xcdb nop
0xcdc nop
0xcdd nop
0xcde nop
0xcdf nop
0xce0 nop
0xce1 nop
0xce2 nop
0xce3 nop
0xce4 nop
0xce5 nop
0xce6 nop
0xce7 nop
0xce8 nop
0xce9 nop
0xcea nop
0xceb nop
0xcec nop
0xced nop
0xcee nop
0xcef nop
0xcf0 nop
0xcf1 nop
0xcf2 nop
0xcf3 nop
0xcf4 nop
0xcf5 nop
0xcf6 nop
0xcf7 nop
0xcf8 nop
0xcf9 nop
0xcfa nop
0xcfb nop
0xcfc nop
0xcfd nop
0xcfe movp a,@a
0xcff ret

	;; Detect knock
0xd00 mov  r0,#$7A
0xd02 mov  r1,#$45
0xd04 mov  a,@r1
0xd05 cpl  a
0xd06 add  a,@r0
0xd07 jc   $0D0B
0xd09 mov  a,@r1
0xd0a mov  @r0,a
0xd0b mov  r1,#$47
0xd0d mov  r2,#$0
0xd0f mov  a,@r0
0xd10 mov  r0,a
0xd11 mov  r4,a
0xd12 rlc  a
0xd13 call $07C1
0xd15 call $07C1
0xd17 call $07BD
0xd19 call $07BD
0xd1b mov  a,@r1
0xd1c swap a
0xd1d xchd a,@r1
0xd1e dec  r1
0xd1f mov  a,@r1
0xd20 cpl  a
0xd21 add  a,r4
0xd22 jc   $0D29
0xd24 mov  r2,#$9
0xd26 mov  a,@r1
0xd27 rrc  a
0xd28 mov  @r1,a
0xd29 mov  r0,#$73
0xd2b mov  r1,#$49
0xd2d mov  r3,#$4
0xd2f clr  f0
0xd30 cpl  f0
0xd31 call $0798
0xd33 mov  r0,#$6F
0xd35 mov  r3,#$4
0xd37 inc  r0
0xd38 xch  a,@r0
0xd39 djnz r3,$0D37
0xd3b mov  r1,#$3A
0xd3d mov  a,@r1
0xd3e mov  r5,a
0xd3f add  a,#$F0
0xd41 jc   $0D4B
0xd43 mov  r1,#$33
0xd45 mov  a,@r1
0xd46 add  a,#$EF
0xd48 jnz  $0D4B
0xd4a mov  @r1,a
0xd4b mov  r1,#$48
0xd4d mov  a,@r1
0xd4e cpl  a
0xd4f add  a,r5
0xd50 mov  r1,#$31
0xd52 mov  a,@r1
0xd53 mov  r7,a
0xd54 djnz r7,$0D74
0xd56 mov  @r1,#$2
0xd58 inc  r2
0xd59 mov  a,#$6
0xd5b mov  r0,#$34
0xd5d xch  a,@r0
0xd5e djnz r2,$0D62
0xd60 dec  a
0xd61 mov  @r0,a
0xd62 jnz  $0D68
0xd64 mov  r1,#$33
0xd66 mov  @r1,#$23
0xd68 mov  r0,#$7B
0xd6a mov  a,@r0
0xd6b mov  r3,a
0xd6c dec  r0
0xd6d mov  a,@r0
0xd6e mov  r6,#$74
0xd70 call $07AB
0xd72 jmp  $0589
0xd74 clr  a
0xd75 jnc  $0D7E
0xd77 mov  a,r2
0xd78 jz   $0D7C
0xd7a anl  p1,#$BF
0xd7c mov  a,@r0
0xd7d add  a,r2
0xd7e mov  @r0,a
0xd7f mov  r0,#$7A
0xd81 mov  r1,#$46
0xd83 mov  r6,#$74
0xd85 mov  r7,#$4
0xd87 call $07A9
0xd89 mov  r0,#$5E
0xd8b mov  r1,#$73
0xd8d mov  r6,#$58
0xd8f mov  r7,#$4
0xd91 call $07A9
0xd93 mov  r0,#$57
0xd95 mov  r1,#$2C
0xd97 mov  a,@r1
0xd98 anl  a,#$38
0xd9a mov  r4,a
0xd9b jnz  $0DA5
0xd9d mov  r1,#$4F
0xd9f mov  r3,#$1
0xda1 cpl  f0
0xda2 call $0798
0xda4 mov  @r0,a
0xda5 mov  r1,#$4C
0xda7 mov  a,@r1
0xda8 swap a
0xda9 cpl  a
0xdaa mov  r2,a
0xdab orl  a,#$F0
0xdad inc  a
0xdae mov  r1,#$58
0xdb0 add  a,@r1
0xdb1 jnc  $0DBA
0xdb3 jnz  $0DBA
0xdb5 inc  r1
0xdb6 mov  a,r2
0xdb7 orl  a,#$F
0xdb9 add  a,@r1
0xdba mov  r1,#$4D
0xdbc mov  a,@r1
0xdbd jf0  $0DC0
0xdbf inc  @r1
0xdc0 jnz  $0DCE
0xdc2 mov  @r1,a
0xdc3 jnc  $0DCE
0xdc5 mov  a,@r0
0xdc6 add  a,#$5
0xdc8 mov  @r0,a
0xdc9 inc  r1
0xdca mov  a,@r1
0xdcb cpl  a
0xdcc dec  r1
0xdcd mov  @r1,a
0xdce mov  r2,#$4D
0xdd0 mov  a,@r0
0xdd1 cpl  a
0xdd2 add  a,r2
0xdd3 jc   $0DD7
0xdd5 mov  a,r2
0xdd6 mov  @r0,a
0xdd7 mov  r0,#$6B
0xdd9 mov  a,r4
0xdda clr  f0
0xddb cpl  f0
0xddc jmp  $0600
	;; END detect knock

	;; filter target boost
0xdde mov  a,@r0
0xddf anl  a,#$3
0xde1 add  a,#$1
0xde3 mov  r6,a
0xde4 mov  r7,a
0xde5 mov  r0,#$53
0xde7 mov  r1,#$55
0xde9 call $05F1
0xdeb mov  a,r6
0xdec mov  r7,a
0xded mov  r0,#$55
0xdef mov  r1,#$51
0xdf1 call $0608
0xdf3 mov  @r0,a
0xdf4 inc  r0
0xdf5 xch  a,r3
0xdf6 mov  @r0,a
0xdf7 ret
	;; END filter target boost
	
0xdf8 nop
0xdf9 nop
0xdfa nop
0xdfb nop
0xdfc nop
0xdfd nop
0xdfe movp a,@a
0xdff ret

	;; select PID function
0xe00 jb4  $0E82
0xe02 jb3  $0E30
0xe04 nop
0xe05 nop
0xe06 jmp  $05DE
	;; END select PID function

	;; exponential smoothing function
0xe08 mov  a,r7
0xe09 mov  r4,a
0xe0a mov  a,@r0
0xe0b mov  r2,a
0xe0c inc  r0
0xe0d mov  a,@r0
0xe0e mov  r3,a
0xe0f call $07CB
0xe11 mov  a,r4
0xe12 mov  r7,a
0xe13 mov  a,r3
0xe14 cpl  a
0xe15 add  a,#$1
0xe17 mov  r5,a
0xe18 mov  a,r2
0xe19 cpl  a
0xe1a addc a,#$0
0xe1c mov  r4,a
0xe1d mov  a,@r1
0xe1e mov  r2,a
0xe1f mov  r3,#$0
0xe21 call $07CB
0xe23 mov  a,@r0
0xe24 add  a,r5
0xe25 mov  r5,a
0xe26 dec  r0
0xe27 mov  a,@r0
0xe28 addc a,r4
0xe29 mov  r4,a
0xe2a mov  a,r5
0xe2b add  a,r3
0xe2c mov  r3,a
0xe2d mov  a,r4
0xe2e addc a,r2
0xe2f ret
	;; END exponential smoothing function

	;; PID derivative function
0xe30 mov  r1,#$52
0xe32 mov  a,@r1
0xe33 cpl  a
0xe34 dec  r1
0xe35 add  a,@r1
0xe36 mov  r1,#$64
0xe38 jnc  $0E56
0xe3a mov  r2,a
0xe3b cpl  a
0xe3c add  a,@r1
0xe3d mov  a,@r1
0xe3e jnz  $0E47
0xe40 inc  r1
0xe41 mov  a,@r1
0xe42 dec  r1
0xe43 jnz  $0E4B
0xe45 mov  a,r2
0xe46 mov  @r1,a
0xe47 mov  a,r2
0xe48 jc   $0E4B
0xe4a mov  @r1,a
0xe4b clr  c
0xe4c rlc  a
0xe4d jc   $0E58
0xe4f rlc  a
0xe50 jc   $0E58
0xe52 cpl  a
0xe53 add  a,@r1
0xe54 jnc  $0E58
0xe56 mov  @r1,#$0
0xe58 mov  a,@r1
0xe59 jz   $0E73
0xe5b mov  r0,#$6B
0xe5d mov  a,@r0
0xe5e rr   a
0xe5f rr   a
0xe60 anl  a,#$3
0xe62 add  a,#$1
0xe64 mov  r7,a
0xe65 mov  r0,#$65
0xe67 mov  a,@r0
0xe68 cpl  a
0xe69 inc  a
0xe6a add  a,@r1
0xe6b clr  c
0xe6c rrc  a
0xe6d clr  c
0xe6e rlc  a
0xe6f jb7  $0E7E
0xe71 djnz r7,$0E6E
0xe73 add  a,#$80
0xe75 mov  r0,#$62
0xe77 mov  @r0,a
0xe78 mov  r7,#$6
0xe7a mov  r0,#$65
0xe7c jmp  $05F1
0xe7e mov  a,#$7F
0xe80 jmp  $0673
	;; END PID derivative function

	;; PID proportional/integral function
0xe82 jb3  $0EF6
0xe84 mov  r1,#$52
0xe86 mov  a,@r1
0xe87 cpl  a
0xe88 inc  r1
0xe89 add  a,@r1
0xe8a mov  r4,a
0xe8b jc   $0E8F
0xe8d cpl  f0
0xe8e cpl  a
0xe8f add  a,#$FC
0xe91 mov  r1,#$6A
0xe93 mov  r0,#$61
0xe95 jc   $0E9B
0xe97 mov  a,@r1
0xe98 inc  @r1
0xe99 jnz  $0ED0
0xe9b dec  r1
0xe9c mov  a,@r1
0xe9d cpl  a
0xe9e inc  r1
0xe9f mov  @r1,a
0xea0 inc  @r0
0xea1 jf0  $0EA7
0xea3 mov  a,@r0
0xea4 add  a,#$FE
0xea6 mov  @r0,a
0xea7 mov  r1,#$62
0xea9 mov  a,@r1
0xeaa add  a,#$60
0xeac jnc  $0EB0
0xeae mov  @r0,#$80
0xeb0 mov  a,#$BB
0xeb2 mov  r3,a
0xeb3 cpl  a
0xeb4 add  a,@r0
0xeb5 jc   $0EBE
0xeb7 mov  a,#$44
0xeb9 mov  r3,a
0xeba cpl  a
0xebb add  a,@r0
0xebc jc   $0ED0
0xebe mov  r1,#$67
0xec0 mov  a,@r1
0xec1 jnz  $0EC5
0xec3 clr  c
0xec4 cpl  c
0xec5 cpl  a
0xec6 jz   $0EC9
0xec8 inc  @r1
0xec9 jc   $0ECE
0xecb cpl  a
0xecc dec  a
0xecd mov  @r1,a
0xece mov  a,r3
0xecf mov  @r0,a
0xed0 mov  r1,#$6B
0xed2 mov  a,@r1
0xed3 jb4  $0ED9
0xed5 mov  a,r4
0xed6 clr  c
0xed7 rrc  a
0xed8 mov  r4,a
0xed9 mov  a,r4
0xeda clr  c
0xedb rlc  a
0xedc mov  r4,a
0xedd jb7  $0EE5
0xedf add  a,#$C0
0xee1 jnc  $0EE5
0xee3 mov  r4,#$40
0xee5 mov  a,r4
0xee6 mov  r1,#$60
0xee8 mov  @r1,a
0xee9 add  a,@r0
0xeea inc  r0
0xeeb add  a,@r0
0xeec inc  r0
0xeed jnc  $0EF1
0xeef jb7  $0EF3
0xef1 mov  @r0,a
0xef2 ret
0xef3 mov  @r0,#$7F
0xef5 ret
0xef6 jmp  $0700
	;; END PID proportional/integral function
	
0xef8 nop
0xef9 nop
0xefa nop
0xefb nop
0xefc nop
0xefd nop
0xefe movp a,@a
0xeff ret

	;; final CV output calculation
0xf00 mov  r1,#$63
0xf02 mov  a,@r1
0xf03 mov  r6,a
0xf04 cpl  a
0xf05 jb7  $0F0A
0xf07 inc  a
0xf08 mov  r6,a
0xf09 cpl  f0
0xf0a mov  a,@r0
0xf0b orl  a,#$1F
0xf0d mov  r3,a
0xf0e sel  mb0
0xf0f call $0300
0xf11 sel  mb1
0xf12 mov  r3,#$B1
0xf14 jf0  $0F19
0xf16 cpl  a
0xf17 mov  r3,#$0
0xf19 mov  r4,a
0xf1a mov  r1,#$67
0xf1c mov  a,@r1
0xf1d clr  c
0xf1e rlc  a
0xf1f mov  r1,#$68
0xf21 add  a,@r1
0xf22 mov  r1,#$6F
0xf24 mov  @r1,a
0xf25 add  a,r4
0xf26 mov  r4,a
0xf27 jf0  $0F2A
0xf29 cpl  c
0xf2a jc   $0F33
0xf2c cpl  a
0xf2d add  a,r3
0xf2e jf0  $0F31
0xf30 cpl  c
0xf31 jc   $0F3F
0xf33 mov  a,r3
0xf34 mov  r4,a
0xf35 mov  r1,#$67
0xf37 mov  a,@r1
0xf38 dec  a
0xf39 dec  a
0xf3a jb7  $0F3E
0xf3c add  a,#$4
0xf3e mov  @r1,a
0xf3f mov  r2,#$22
0xf41 call $07D5
0xf43 mov  r1,#$43
0xf45 mov  a,@r1
0xf46 jz   $0F81
0xf48 add  a,#$FF
0xf4a jc   $0F4F
0xf4c mov  a,@r0
0xf4d jz   $0F81
0xf4f inc  r1
0xf50 mov  a,@r1
0xf51 add  a,#$C4
0xf53 jc   $0F81
0xf55 add  a,#$0
0xf57 jnc  $0F5C
0xf59 mov  a,@r0
0xf5a jz   $0F81
0xf5c mov  r1,#$4B
0xf5e mov  a,@r1
0xf5f mov  r2,a
0xf60 mov  r1,#$33
0xf62 mov  a,@r1
0xf63 jz   $0F69
0xf65 add  a,#$EF
0xf67 jnz  $0F81
0xf69 mov  a,r4
0xf6a mov  @r0,a
0xf6b mov  r0,#$6F
0xf6d mov  r4,#$4
0xf6f inc  r0
0xf70 mov  a,@r0
0xf71 cpl  a
0xf72 add  a,r2
0xf73 jc   $0F7E
0xf75 mov  a,r2
0xf76 mov  @r0,a
0xf77 mov  r1,#$33
0xf79 mov  a,@r1
0xf7a jnz  $0F7E
0xf7c mov  @r1,#$11
0xf7e djnz r4,$0F6F
0xf80 ret
	;; END cv final output calculation

	;; limp mode function
0xf81 clr  a
0xf82 mov  r3,#$10
0xf84 mov  r1,#$57
0xf86 mov  @r1,a
0xf87 inc  r1
0xf88 djnz r3,$0F86
0xf8a mov  @r1,#$80
0xf8c mov  r1,#$61
0xf8e mov  @r1,#$80
0xf90 mov  r1,#$52
0xf92 mov  a,@r1
0xf93 inc  r1
0xf94 mov  @r1,a
0xf95 clr  a
0xf96 jmp  $076A
	;; END limp mode function

	;; count cycles for cylinders
0xf98 inc  @r1
0xf99 mov  a,@r1
0xf9a jnz  $0FA1
0xf9c inc  r1
0xf9d mov  a,@r1
0xf9e cpl  a
0xf9f dec  r1
0xfa0 mov  @r1,a
0xfa1 add  a,r3
0xfa2 mov  a,@r0
0xfa3 jnc  $0FA8
0xfa5 jz   $0FA8
0xfa7 dec  a
0xfa8 ret
	;; end count cycles

	;; call exp. smoothing and rotate 16-bit values
0xfa9 call $0608
0xfab call $07B0
0xfad call $07B0
0xfaf ret
0xfb0 xch  a,r6
0xfb1 mov  r0,a
0xfb2 xch  a,r6
0xfb3 xch  a,r3
0xfb4 mov  r7,#$4
0xfb6 xch  a,@r0
0xfb7 inc  r0
0xfb8 xch  a,@r0
0xfb9 inc  r0
0xfba djnz r7,$0FB6
0xfbc ret
0xfbd mov  a,r0
0xfbe clr  c
0xfbf rrc  a
0xfc0 mov  r0,a
0xfc1 xch  a,@r1
0xfc2 rlc  a
0xfc3 xch  a,@r1
0xfc4 jnc  $0FC9
0xfc6 add  a,r4
0xfc7 xch  a,r4
0xfc8 ret
0xfc9 mov  a,r0
0xfca ret
0xfcb mov  a,r2
0xfcc clr  c
0xfcd rrc  a
0xfce mov  r2,a
0xfcf mov  a,r3
0xfd0 rrc  a
0xfd1 mov  r3,a
0xfd2 djnz r7,$0FCB
0xfd4 ret
	;; end call exp. smoothing/rotate values

	;; prep CV output
0xfd5 mov  r0,#$41
0xfd7 mov  a,r4
0xfd8 add  a,#$40
0xfda jnc  $0FDE
0xfdc mov  r4,#$BF
0xfde ret
	;; end prep CV output
	
0xfdf nop
0xfe0 nop
0xfe1 nop
0xfe2 nop
0xfe3 nop
0xfe4 nop
0xfe5 nop
0xfe6 nop
0xfe7 nop
0xfe8 nop
0xfe9 nop
0xfea nop
0xfeb nop
0xfec nop
0xfed nop
0xfee nop
0xfef nop
0xff0 nop
0xff1 nop
0xff2 nop
0xff3 nop
0xff4 nop
0xff5 jb1  $0F32
0xff7 jb1  $0F43
0xff9 orl  a,#$43
0xffb jb1  $0F32
0xffd jb1  $0F20
0xfff dis  i
