Well this what I felt like working through the ECU
code. It was tough enough learning Motorola's assembler syntax, the
68HC11's architecture, and trying to figure out how all this code played
together to have numerous errors in the code. You assume that the
code is correct so when you run into something that doesn't make sense
you assume it is a lack of understanding on your part. Well in a
lot of the cases it was, but with this many errors sprinkled through the
code a person is always doubting yourself.
Most of these errors are fairly trivial. Some
just poor technique. Some may only be germane to my #3516 code set (tables
with all the same entries that of coarse always come up with the same results -
your code set may contain something different in these tables so beware). Most are left over from some other application.
This code is obviously leveraged from another application, as is with the
ECU itself, so there is a lot of unnecessary routines that are never called
or are always skipped. I'll quickly go through the mistakes I found
and briefly explain what I did to work around them. Searching on
the "misx" label you can locate the are of concern in the code. All
the affected code may not be shown here so for more details you will need to
study the main body of the code.
; * mis1: mis2: ; The code that modifies L0043 checks for roll. Even if all byte values ; are 255 there is no way for the value to ever get over 255....Pretty clear as to what happened here. The fix was to just skip those tests.
if not mis1x mis1: tsta ; overflow in A ? beq L8e96 ; nope - never can be either ldab #$ff endif ; ------------------------------- if not mis2x mis2: tsta ; overflow into A ? beq L8d9b ; nope - and never can be either !!! ldab #$ff endif
; * mis3: ; The code that detects the narrow #1 cylinder timing pulse does not work.This is a big one. I'll explain what was done to fix this else where.
; * mis10: ; Bit 1xxxxxxx of L005b is set but never used.Its stuff like this that drives a person nuts looking for where it was used.
; if not mis10x mis10: bset L005b %10000000 ; NEVER USED ???????????????? endif ;
; * mis11: ; A push/pop that does nothing.....Several Push/Pops that served no purpose. Maybe there was code in between at one time ?
; if not mis11x pshb ; on stack.... pulb ; off again ??? endif ; ------------------------------- if not mis11x psha ; ?? pula endif ; ------------------------------- if not mis11x psha pula endif ; ------------------------------- if not mis11x pshb pulb endif ;
; * mis12: ; Will never take this branch because a compare of zero and a BCS..This is one of those where the value in the Calibration portion of the code never allows a branch to be taken.
if not mis12x cmpa Lf580 ; below 0 volts ??????? mis12: bcs L9261 ; will never take this jump !!!!!!!!!! endif
; * mis13: ; Bit xxxx1xxx of L005d (ram_005d) is cleared but never tested anywhereProbably left over from some other application.
if not mis13x mis13: bclr endif
; * mis4: ; L0038 is cleared but never used anywhere.Another one........
if not mis4x mis4: std L0038 ; Not Used ?????? endif
; * mis5: ; L003e is cleared twice almost in a row.Needless duplication....
if not mis5x mis5: std L003e ; clear current timing_period - AGAIN ???? endif
; * mis6: ; The xxxxx11x bits of L00bc are tested but are never set anywhere.So if you are going to test for them please set them...
if not mis6x ldaa L00bc ; get the serial flags mis6: anda #%00000110 ; these bits are always zero ????????? bne L82d0 ; never take this branch then ???????? endif
; * mis7: ; Will always take this branch because they are comparing a zero to a ; value and jumping on carry-clear, which it can never set Carry.Not clear what they were doing here. Another case of a Calibration value that forces a certain condition. Even if this value was such that it could possibly take this branch, both optional lookup tables are the same so the end results are always going to be the same. Beside the below code there are also various other locations that 'mis7x' clears.
if not mis7x ldx L007c ; get warm up timer cpx Lf576 ; has it been bumped yet ? 0000 mis7: bcc L8a90 ; will always take this jump ! ???????? ; Make no different if above jmp is taken or not because both tables ; are the same.... !!!!!! ldx #Lf187 bra L8a93 endif
; * mis8: ; Bits xxxxx1xx and xxxxxx1x of L00ba are set but never used anywhere.More bit chasing that leads now where !
if not mis8x mis8: bclr L00ba %00000110 ; clear what - Never used Anywhere endif ; if not mis8x ; mis8: bclr L00ba %00000010 ; ???? Never Used Anywhere ! bset L00ba %00000100 ; ???? Never Used Anywhere ! endif ; ------------------------------- if not mis8x ; mis8: brset L00ba %10000000 Ld25d ; bit never set here - maybe controller ? endif ; ------------------------------- if not mis8x ; mis8: cmpa Lf679 ; MAP below ~21" (ADC=55) ? bcc Ldb2d ; yes bset L00ba %00010000 ; signal so - Never Used Anywhere bra Ldb30 ; Ldb2d: bclr L00ba %00010000 ; MAP below 21" ; endif ; ------------------------------- if not mis8x ; mis8: bset L00ba %00001000 ; Never tested anywhere ? cmpa L001c ; throttle plates closed ? bls Ldb41 ; yes cmpa Lf50a ; over 4.7 volts ? 240 bhi Ldb41 ; yes bclr L00ba %00001000 ; Never Tested anywhere ? endif ;
; * mis9: ; Cannot find this target label and jump being used anywhere.A stray branch that never gets taken.
if not mis9x mis9: L8cf5: jmp L9644 ; trouble - do a restart - NOT FOUND ?????? endif
; * mis14: mis14a: mis14b: ; Never execute this code because above tests always by-passes it.These errors cut out quite a bit of code which is too long to list here. Things like jumping to this code when the water temperature is over 300 degrees. I guess we can loose this code until I get my ceramic block.
; * mis15: ; A mess of code in the IAC computations is useless because of what the ; tables are set at. Goes through a whole bunch of work to always come ; up with the exact same results.All these routines go through numerous lines of calculations, several table lookups, just to be forced to come up with the same 6.666 ms total IAC period. Maybe this was code was used for some other kind of IAC motor but it is totally useless in our application.
; * mis16: ; Never take some code because A is loaded with a zero followed by BEQ.Another case of a Calibration value forcing a branch.
if not mis16x mis16: ldaa Lf580 ; 0 - load a zero ??? beq Ld48e ; of coarse will always take this jump mis24: ldaa Lf56a ; reset O2 sensor error counter 255 staa L0077 ; never get here ???????????? Ld48e: jmp Ld688 ; can't do closed loop yet else Ld48ex: jmp Ld688 ; can't do closed loop yet endif
; * mis17: ; Looks like this code to fire the injectors (maybe during starting) ; never gets called...Here is a whole sub-routine that never gets called. It looks like it could have been code that was intended for starting purposes only. Maybe extra fuel and cold start enrichment ?
; Can Not find anywhere that calls this sub-routine ; ; if not mis17x mis17: Lda4b: brclr L005a %00001111 Lda50 rts ; Lda50: pshb ldx #Lf3dc ; point to coolant temp to pulse width mapping ldab L0003 ; get TH2O - Water Temperature (adjusted) jsr Ld9f6 ; lookup injector pulse width clrb ; make word std L0025 ; stash new Injector Pulse Width pulb jsr Lda66 ldab #$02 jsr Lda66 rts ; ; B = 0 thru 3 ; Lda66: ldx #Lff4a abx ldaa $00,X oraa L005a staa L005a lslb ; address are words ldx #Lff38 ; point to the 6840 timer's data registers abx ; point to address of the injector timer ldd L0025 ; get Injector Pulse Width if not mis51x mis51b: ldy L0025 ; mistake !!! - not used endif jsr Lda7e ; fire the Injector rts endif ;
; * mis18: ; Will never take this jump. No byte can be higher than the 255 constant.Yet another case of a Calibration value forcing a branch.
if not mis18x ldab L0015 ; get revolution counter cmpb Lf4a5 ; 255 mis18: bhi L8c37 ; will NEVER take this branch ????? endif
; * mis19: mis20: ; Couple place that will always take a jump needlesslyWith the Calibration values specified there is no way that these branches can ever be taken.
if not mis19x mis19: bcc Ld632 ; of coarse it won't carry ! clrb endif ; ------------------------------- if not mis20x mis20: bcc Ld647 ; of coarse it is clear ldab #$ff endif
; * mis21: mis56: ; Will always take this branch because comparing zero to a non-zero ; number followed with a bhi. Comparing a zero will always clear carry.More forced branches that skip sections of code.
if not mis21x cmpb Lf517 ; 0 mis21: bhi L9104 ; will always take this jump ????? !!!!! ; ; Never do any of the following code ever.................................... ; ; Looks like what would have happened here is that every time the firing ; sequencer was zero then bits in 005d would bump so that every 4th time ; we would bump the revolution counter which would have been every 8 engine ; revolutions... ; ldab L0044 ; get the sequencer bne L911a ; not at zero brclr L005d %00000110 L910f ; can't take because we set xxxxx1xx brclr L005d %00000100 L9114 ; for same reason as above brclr L005d %00000010 L910f bclr L005d %00000110 bra L910a ; dec the revolution counter endif ; ------------------------------ if not mis56x brclr L0058 %00100000 L8beb ; not in a fuel cutoff situation ldx #$0000 ; set pulse width to zero bra L8c03 ; L8beb: brclr L0058 %00010000 L8c03 ; not in fuel reduction situation ????? mis66: ldaa Lf4e3 ; 255 jsr Ld8a5 ; D = (A*IX)/256 std L0048 ; stash new injector pulse width ldx L0048 cpx Lf4e4 ; 0000 ? mis56: bcc L8c03 ; will always take this jump ldx Lf4e4 ; 0000 - injector pulse width to zero stx L0048 else brclr L0058 %00100000 L8c03 ; not in a fuel cutoff situation ldx #$0000 ; set pulse width to zero endif
; * mis22: ; Stashed something into L0000 then a few lines later stashed something ; else into it. ; 09/03/99 - This may be needed because the next instructions turns on the ; interrupts so maybe to assure some value stash now ?Another case of stashing something into RAM then a few lines later stashing something else into it.
; mis22: stab L0000 ; hold here - why ????????????? ; cli ; interrupts on ; if not mis49x tba ; put a copy of MAP into A mis49e: jsr Ldc2a ; add in slope/offset correction to ADC reading staa L0000 ; stash slope/offset corrected MAP ADC value endif
; * mis23: mis24: mis48: ; Can never take these branchesMore locations that branches can never be taken.
mis23: bls L84ae ; Will never take this jump because min L0000 ; ; can ever be is 7 ; ------------------------------ mis16: ldaa Lf580 ; 0 - load a zero ??? beq Ld48e ; of coarse will always take this jump mis24: ldaa Lf56a ; reset O2 sensor error counter 255 staa L0077 ; never get here ???????????? ; ------------------------------ if not mis48x ldaa L0006w ; get work Spark Angle ldab Lf4f9 ; 0 - min spark angle allowed suba Lf4f7 ; 0 mis48: bcs L8a23 ; Never take this branch cba ; A-B B=0 so A-0 always NC bcc L8a24 ; will always take this branch L8a23: tba ; would have set min spark angle L8a24: staa L0006w ; stash new work Spark Angle endif
; * mis25: mis46: ; more piss-poor logic and needless testsThe logic here escapes me. It is so hard to follow code that does this kind of thing to your brain.
; More smart stuff here. If the water is cooler than 105 degrees and over ; 90 seconds ok, and if it is hotter than 105 degrees and over 90 seconds ; it is still ok ???????? ; mis25: Ld491: if not mis25x ldaa L0003 ; get TH2O - Water Temperature cmpa #$80 ; cooler than ~105 degrees ? bls Ld4a1 ; yes ldd L007c ; get warmup timer subd Lf572 ; been over 90 seconds ? 687*131ms bcc Ld4a8 ; yes Ld49e: jmp Ld688 ; not yet - bail ; Ld4a1: ldd L007c subd Lf574 ; been over 90 seconds ? 687*131ms bcs Ld49e ; not yet - bail else ; ldd L007c subd Lf574 ; been over 90 seconds ? 687*131ms bcs Ld48ex ; not yet - bail ; endif ; ------------------------------- ; No matter if rpm > 3500 or over 3 minutes because the same tests and the ; same branches are always taken.............................................. ; mis46: cmpa #$8c ; above 3,500 RPM ? 140*25=3500 bhi L8485 ; yes brset L0058 %00000010 L8485 ; water is hot / over 3 minutes running cmpb Lf560 ; 197 3.8 volts 82 degrees TPS bhi L8498 bra L848a ; .............................................................................
; * mis26: ; multiply a number by 16 then divide it by 16 ????? - makes senseI guess they were trying to build in some extra flexibility here. Just wastes our time.
if not mis26x Ld5d5: ldab L0076 ; time to further adjust rate of change value ? bne Ld5e7 ; not yet ; ; The below does nothing except multiply by 16 then divide by 16..... ; mis26: ldab Lf587 ; 16 mul ; multiply by 16 then divide by 16 ?????? lsrd ; / 2 lsrd ; / 4 lsrd ; / 8 lsrd ; / 16 tsta ; overflow ? beq Ld5e6 ; nope ldab #$ff ; 255 max Ld5e6: tba ; result into A endif
; * mis27: mis28: mis30 ; these stashs are not used anywhere in the following calculationsWhat happened here was two lookup tables where checked then the outputs were compared and a decision was made on the results of this compare. The problem is that both sets of tables are the exactly the same so the results where always the same. Needless work was being performed.
; * mis29: mis31: ; a bunch of calculations that always result in zero......Well the comments below pretty well say it all....
; What look like what is happening is they are getting the difference between ; the output of the two tables, multiplying by MAP ADC-21", then dividing ; by ~4". Add this to the output of the 21" table. Of coarse all of ; this is Bull S... because both tables are exactly the same so we multiply ; zero and just get the output of the first......??????? ; mis29: ldx #$0000 ; clear IX ldab Lf56c ; ~4" vacuum 31 abx ; IX = 31 ldab L0000 ; get adjusted MAP ADC value subb Lf56d ; less ~21" vacuum (in ADC counts) 51 suba L000cw ; get difference between the two bcs Ld5c0 ; first was higher mul ; times MAP ADC idiv ; divided by 31 xgdx ; result into D cpd #$00ff ; overflow ? bls Ld5b7 ; nope ldd #$00ff ; 255 max Ld5b7: ldaa L000cw ; get output of 21" table
; * mis32: mis33: ; more bs because tables contain all the same entries......More of the same double table lookup with both tables being exactly the same. A lot of work that leads to the same results.
; * mis34: mis35: ; don't need to do these calculations - just use constantHere we are going through several calculations when it would be much more efficient to just use a constant.
if mis34x ldx #$0091 else mis34: ldx #L0098-$fe-2 ; point to timing period (RPM) table Lff98 ldab #$fe ; seems strange ???? subb Lf703 ; less rows-1 5 abx ; IX = $0091 ???? - just use this then..... endif ; ------------------------------ if mis35x ldx #$0079 else mis35: ldx #L0080-$fe-2 ; point to the timing period table (RPM) Lff80 ldab #$fe ; -2 subb Lf701 ; 5 abx ; IX = $0079 endif
; * mis36: ; more useless lookup because table has all the same entriesBy this point you should be seeing a pattern here. The above comment says it all.
; * mis37: mis37a: ; section of code assumes that the A reg still contains the spark angleThis one could have been bad one. The code is assuming that the A register has the results of a previous calculation but in fact it had been trashed by some code just in front of it. If it wasn't for the fact that the value of several Calibration constants being what they are, this code would probably cause some big time troubles.
; BIG mistake here. The below code assumes that 'A' still contains the current ; spark angle. That would be true if we came from the above code that ended at ; L8808, but if we got here from the branch that tested the MAP ADC (which ; trashed the A register) just below L87de the 'A' register does not contain ; the current spark angle value and we end up storing the MAP ADC value ; instead. ; ; 01/03/99 - Makes no difference anyhow because the value at Lf4fb is 128 ; which 128 gets subtracted from it leaving 0 to add/subtract !! ; ; mis37: ldab L0042 ; get the timing_period / 16 cmpb L0017 ; below dashpot threshold rpm ? bcc L882b ; yes - skip this spark angle adjustment mis37a: ldab Lf4fb ; 128 subb #$80 ; remove bias bcc L8824 ; positive modifier negb ; change sign sba ; adjust spark angle bcc L8829 ; didn't go below zero clra ; it did bra L8829 ;
; * mis38: mis39: ; stash that does nothing because only a zero ever gets loadedThese are a little hard to follow because other mistakes makes these stashes useless.
; * mis40: ; bit x1xxxxxx of L005c gets set but is never cleared anywhere ; Left because low usage and not absolutely sure why they did thisNot sure what is happening here. My gut feeling is that we could loose this one.
; * mis41: ; bit 1xxxxxxx of L005c gets set but is never cleared anywhere ; Left because low usage and absolutely sure why they did thisSame as mis40: above.
; * mis42: (several locations) ; with constants used adding a 1 to L0014 will never roll.With the Calibration constants used (a one) and the range of values these constants are added to it is not possible for the results to ever overflow.
ldab L0014 ; lowest MAP ADC (highest VAC) ever read addb Lf4df ; 1 if not mis42x bcc L92e6 ; mis42: ldab #$ff endif
; * mis43: ; with constant used result will always be zeroAnother case of Calibration constant forcing predictable results.
; if not mis43x mis43: subb Lf487 ; subtracting 255 from B will always result bcc Ld142 ; in zero or less than zero which gives us.... endif ; clrb ; .... zero !
; * mis44: ; L0073 never gets used. Where it is bumped never gets calledPretty much says it all...
mis44: ldaa L0073 ; bump useless counter
; * mis45: ; storing and loading back the same registerStore the value of the B register into a stash then the next line load the B register from the same stash.
Ld0ea: stab L000ew ; stash index ; if not mis45x mis45: ldab L000ew ; needless load endif
; * mis47: ; bit 1xxxxxxx of L0058 useless because of mis38:A case of embedded mistakes. Error mis38: causes the clearing/setting of this bit to never happen.
; * mis49: mis49a: mis49b: mis49c: mis49d: mis49e: ; problems with the MAP offset that gets loaded into L0008 and applied ; to L0000. The whole MAP correction may not do anything !!!!! ; This would mean all the corrected values I applied with L0000 ; are wrong ! ; 12/28/98 - They are. L0008 is always zero !!!!!!!! ; 09/03/99 - Well it looks like I was wrong. The initial value computed ; is a valid altitude compression value. ; 09/04/99 - There still is a problem with some of the code were it looks ; like it is trying to re-compute this compression factor ; while the motor is running. The TPS values choosen will ; always by-pass this section of code. ;Here is a frustrating one. You spend many hours follow threads in the code just to find later that some stupid error negated all that you thought was happening. This affected the MAP so it was important. An offset in stash L0008 was applied to the MAP ADC readings, or at least it was supposed to be.
09/03/99 - Well it looks like this whole L0008 thing needs to be revisited. What looks like is happening is that the value in L0008 is a altitude compression factor that is applied to the MAP ADC value. The initial call to Ldc0e: at key on checks how high we are at and computes an altitude compression correction factor in L0008. Where I mad my error is in thinking only in terms of a low lander (sea level operation) where the value in L0008 is always zero. At higher initial key-on altitudes this will not always be the case. The routine at L84c2: is disabled though. This routine is in the main Calibration loop. It checks to see if the current RPM is between two windows, either 1670-2070 or 2460-2620, and if it is then it checks the TPS for a certain threshold value. If it passes all these tests it will then recompute the altitude compression factor in L0008. The problem is that the TPS check values are 255. Well the TPS ADC will never get that high so the recomputations done by Ldc0e: will never happen and the initial turn on value in L0008 will remain the same. So this all boils down to that the L0008 stash has a valid number in it and the routine at L84c2: is usless... ; ; ----------------------------------------------------------------------------- ; Add the MAP ADC correction factor (slope/offset) to the ADC reading. ; If results larger than 255 then return 255 ; Entry: A - value to add correction to ; Return: A - adjusted value ; ; NOTE: Look at mis49: L0008 is always zero so no correction is ever applied ! ; if not mis49x mis49c: Ldc2a: ldab L0008 ; get the slope/offset correction factor aba ; A = A + B bcc Ldc31 ; not too large ldaa #$ff ; max at 255 Ldc31: rts endif ;
; * mis50: ; why calculate when just get the darn thing ; 01/03/99 - left because low usage and might be neededNeedless calculations, but I did leave in just in case I may need later.
mis50: ldx #Lf047 ; point to the highest Load in lookup table ldab Lf018 ; 10 lslb ; * 2 --> 20 (words) abx ; IX = $f047+20 = $f05b ldd $00,X ; D=2765 = -3"
; ; * mis51: mis51a: mis51b: ; needless loads into IYHere they loaded some number into IY and called a routine (injector timers) that never used it.
if not mis51x mis51: ldy L0025 ; IY also - why ??? - not used endif
; * mis52: mis53: ; needless clcIt looks like who ever coded this did not understand the how the flags work on the 68HC11 MPU.
if not mis52x clc ; mis52: - don't need to clear CY here endif ; addd L0025 ; plus current Injector Pulse Width bcc L9396 ; didn't overflow - stash new pulse width ; ------------------------------ if not mis53x mis53: clc ; needless endif ; lsld ; * 2 lsld ; * 4 lsld ; * 8
; * mis54: ; I believe this bit will always be zero at this point because prev clear ; 01/03/99 - Left because it may affect a situation where the motor was ; running then stopped without loosing power to EMU. ;One of those that I don't totatly understand but doesn't look right.
; * mis55: ; bit xxxxx1xx of L0058 useless because never tested anywhereWhy set it if you don't use it. Just makes me look harder and longer for some meaning.
if mis55x bset L0058 %01000000 ; signal been thru Calibration else ldaa L0058 ; get flags oraa #%01000000 ; signal been thru Calibration atleast once mis55: eora #%00000100 ; toggle been thru Cal bit staa L0058 endif
; * mis57: ; xor with a 0 does nothing....More Calibration constants follies.
if not mis57x eora Lf01d ; 0 endif
; * mis58: mis58a: mis58b: mis58c: ; with values used can never take branchWith the internal values used for the MAP there is no way to these registers. If there was some dramatic change in how the code work these tests may need to be re-instated but I doubt it.
L9065: ldab Lf4ab ; 56% (9/16) 9 mul ; D = (current_MAP - last_MAP) * 9 lsrd ; / 2 lsrd ; / 4 lsrd ; / 8 lsrd ; / 16 ; if not mis58x mis58a: tsta ; never be this large bne L9074 ; never will take this branch endif
; * mis59: mis59a: mis59c: mis59d: ; can jump around these calculations because results are always zeroLooks like you can save some multiplying time when you know that the results are going to be zero.
cmpa Lf4aa ; less than a ~.25" differenece ? 2 bcc L9065 ; nope - more mis59c: clra ; yes - make like no change ; L9065: ldab Lf4ab ; 56% (9/16) 9 mul ; D = (current_MAP - last_MAP) * 9 lsrd ; / 2 lsrd ; / 4 lsrd ; / 8 lsrd ; / 16
; * mis60: mis60a: ; why test when load sets the flagsAnother case of not understanding how the 68HC11 flags work.
L9076: ldaa L004e ; if not mis60x mis60: tsta endif ; ----------------------------- ldaa L004f ; if not mis60x mis60a: tsta endif
; * mis61: mis61a: ; with L004e and L004f limited to +-127 and the scaling multipliers used ; the results can never be this high.With the Calibration values such as they are there is no need for these test because the results can never get this high.
; if not mis61x mis61: cmpa #$3f ; below 16,127 ? bcs L9350 ; yes - always (max = 2286) ldaa #$ff ; make negative bra L9354 endif
; * mis62: ; subtract zero from a valueSubtracting a zero from a value.
if not mis62x mis62: subb Lf4a9 ; 0 endif
; * mis63: ; don't think need to clear this work stash......Unnecessarily clearing a temp work stash. This stash will get trashed a few lines later.
if not mis63x mis63: std L0054w ; un-necessary endif
; * mis64: ; subtracting zero then branching on carry ; 01/03/99 - left this as I may experiment with itThis one was left in. Looked like it might have something to do with testing the TPS rate of change. Might use this one later.
mis64: subd Lf4a3 ; less decay rate ???? 0000
; * mis65: ; not needed register setHere the IY register was set to the 68HC11 register base but is never used any place.
if not mis65x mis65: ldy #register_base ; just forget it endif
; * mis66: ; bunch of do nothing codeA bunch of code that does nothing useful. It is in the middle of a another group of code that never gets run because of mis56.
; * mis67: ; another sub-routine that is never calledAnother sub-routine that never gets called by anyone.
; never called !!!!!!!! ; if not mis67x mis67: Ld8bb: pshx tsx ldab $01,X staa $01,X mul stab L000bw ldab $00,X staa $00,X ldaa $01,X mul addb $00,X adca #$00 pulx rts endif
; * mis68: ; now that I see where L6000 comes from it can be wired aroundTest and branches were taken on the state of the PAL latch at $6000. Now that I see that the state of this latch never can change there is no need to every do any of this code.
if not L6000_skip ldab L0003 ; get TH2O - Water Temperature cmpb Lf685 ; below 120 degrees ? 140 bcs L8af8 ; yes - use it as is ldab L6000 ; read the PAL status (L9112D) bitb #%00000100 ; J1-21 pulled high ? bne L8af8 ; nope - use table value suba Lf4e2 ; 23 bcc L8af8 ; didn't go below 0 ldaa #$00 ; min 00 endif
; mis69: ; The COP system is not being enabled. The NOCOP bit in the CONFIG ; register is set to one (1) disabling the COP watch dog timer !!!! ; 12/13/98 - read the CONFIG register = 00001101 ; 01/03/99 - Left it in for the time being.Here is a good one. The COP system is not enabled. This is the watch dog timer. It is supposed to restart the code at the top if a major failure occurs somewhere. Several things have to be set to enable the COP. One of them is disabling the NOCOP bit in the MPU's CONFIG register. The CONFIG register is in EEPROM and changes made to it will only take effect after a system reset. Well no one ever clears the NOCOP bit so it is permanently dis-abled and all the code handling the watchdog functions is useless. I left the code in for the time being because I may enable the COP system.
; The whole COP thing is useless because of mis69: !!!!!!!!!!!!!!!!!!!!!!!!!! ; coprst_register equ $103a ; COPRST - COP arm/reset register ; ; Write $55 to this register to arm the COP ; ; timer, then immediately write $AA to it ; ; to clear the timer. If this sequence isn't ; ; performed within the specified timer rate ; ; period a system reset will occur. ; cop_arm equ $55 ; to arm COP cop_reset equ $AA ; to reset the COP
; mis70: ; If the only difference in the first dist trigger path decision (over ; 4,500 rpm is that #1 shutter is looked at maybe can reduce code lines.This one looks like the code can be optimized some more. Two paths exist in the distributor trigger handler, one below 4500 RPM and one above. It looks like the only difference in these fairly large bodies of code is the #1 shutter detect code. I think with a little rearranging things can be made more efficient.
; mis71: ; Might check and see how often L004e and L004f are zero. If a lot then ; maybe be able to skip some code here. If these stash are used alot ; then maybe not.I guess the comment says it all.
; mis72: ; The branch at L8a67 branches to the next line. Does absolutely ; nothing. L8a65: staa L0006w ; stash new Spark Angle (work stash) L8a67: brclr L0058 %01000000 L8a6b ; haven't made it thru Calibration yet L8a6b: ldab L0003 ; get TH2O - Water Temperature
; mis73: ; Found another bad error. The code just below L9644: where the IC1F ; ignition timer and Dist trigger conditions are set, well the fools ; forgot to set the IY register to the rebister base. This routine has ; several entries, none of which set the IY register and all have the ; register set at some meaningless value. This NEED TO BE FIXED !!!! L9644: ldaa #%00000101 ; signal we have had a dist trig and ; pulse width > $8000 staa L005d mis73: if mis73x ldy #register_base ; need to set IY to something endif bclr $23,Y %11111011 ; clear IC1F - Ignition timer - Dist trigger lds #ram_base+$ff ; reset the stack to top of ram jmp L812a ; back to top of restart loop10/03/99 - L9644: has several entry points none of which set the IY register to the correct value pointing to the 68HC11's register base.