View Single Post
  #974  
Old 12-27-2009, 07:12 PM
b3lha's Avatar
b3lha b3lha is offline
Phil & Belha
 
Join Date: Aug 2001
Location: Alcyone Limited, Buckinghamshire UK
Posts: 2,671
Re: Memory dump of ECU

Quote:
Originally Posted by RoughSilver92 View Post
Sweet. I have run into something like what you are talking about here:


I didn't include it but if A is greater than or equal to 0 e25f is skipped and the value in A is multiplied by hex 5800. So it looks like either A or hex 0000 is multiplied by hex 5800. Then the xab followed by the sta ax, 0x1004 is swapping A and B (necessary because of the way the processor works, I suppose), putting the most significant 16 bit value in A and storing it at 1004. Then the most significant 8 bit value is loaded into bl from 1005. The program then branches to e27f if the zero flag is set, but set by what? Is it set if the value loaded into bl is 0? Or is it looking way up at the mpy to see if that equals zero?
Yes. It's setting a minimum value of 0 to A. ie. Following the subtraction, if A has become negative, set it to zero.

The Z flag gets set if zero is loaded to bl. I think this code wants to end up with a number between 00 and FF in AL. If BL is not zero (ie. the result of the calculation is >= hex 100) then it sets AL to the maximum value of FF.
__________________
Subaru ECU and TCU Website
1992 Alcyone SVX Version L
1992 Alcyone SVX Version L
1994 Alcyone SVX S40-II
2004 Subaru Legacy 2.5 SE Sports Tourer
1996 Subaru Legacy 2.2 GX Wagon
1988 Subaru Justy J12 SL-II
Reply With Quote