Title: divison by zero? Post by: masterj on January 12, 2013, 10:51:44 AM Hi, guys!
Just a small question here: how does ME7 (and ME7.5) ecu react to division by zero? For example there's certain situation when I have to set some variable to zero, but only way I can control this variable with is by division: uncontrollable_var / MAP = var_needs_to_be_zero So I was thinking, maybe it is possible to set MAP = 0 to force div by zero... maybe then ecu will set var_needs_to_be_zero = 0? Or it can send something like NaN and result in shutdown?? Title: Re: divison by zero? Post by: rajivc666 on January 12, 2013, 01:17:30 PM This is how the processor reacts, interesting never been in a similar situation, can you give the details.
Condition Flags E Z V C N 0 * S 0 * E Always cleared. Z Set if result equals zero. Cleared otherwise. V Set if an arithmetic overflow occurred, i.e. if the divisor (op1) was zero (the result in MDH and MDL is not valid in this case). Cleared otherwise. C Always cleared. N Set if the most significant bit of the result is set. Cleared otherwise. Title: Re: divison by zero? Post by: masterj on January 12, 2013, 01:37:35 PM This is how the processor reacts, interesting never been in a similar situation, can you give the details. Condition Flags E Z V C N 0 * S 0 * E Always cleared. Z Set if result equals zero. Cleared otherwise. V Set if an arithmetic overflow occurred, i.e. if the divisor (op1) was zero (the result in MDH and MDL is not valid in this case). Cleared otherwise. C Always cleared. N Set if the most significant bit of the result is set. Cleared otherwise. Well, I'm trying to achieve phlsnh = 0. One way is to set UBHS = 0, but that would also kill precat sensor heater voltage thus disabling both sensors completely :) Just found out this today, never thought that one map can be shared between two functions, but looks like UBHS is. So, the other way to set phlsnh = 0 is to somehow circumvent it in the UB_KORR3 subfunction... OR if possible to change ASM code to use constant zero instead of UBHS map... Hm... that might be interesting solution... Code: seg003:54D1A sub_854D1A: Could I just do something like this: Code: seg003:54D30 cmpb rl4, #0 ; set to #0 Title: Re: divison by zero? Post by: rajivc666 on January 12, 2013, 02:02:47 PM If you think it will work then change the hex at 0x54D22 to
4980 cmpb rl4,#0 CC00 nop Title: Re: divison by zero? Post by: masterj on January 12, 2013, 02:10:18 PM If you think it will work then change the hex at 0x54D22 to 4980 cmpb rl4,#0 CC00 nop Thank you! I couldn't figure out how to set constant in asm->hex :) BTW: cmpb is same: 41, 43, 47, 49, no? Also #0 -> 80? How would constant #3 would look in hex? If I wanted say to create UBHS_2 @ 8A6812 and point the said earlier line to this address instead of original UBHS, how would I have to change this code? Title: Re: divison by zero? Post by: masterj on January 18, 2013, 01:28:43 PM One more thing that is very interesting to me:
For example in me7logger ecu file im looking at the: Code: B_hshe , {} , 0x00FD3C, 2, 0x0008, {} , 0, 0, 1, 0, {Bedingung Endstufe Sondenheizung hinter Kat angesteuert} So, B_hshe is @ FD3C (IRAM?)? Also how to decode bitmask? Is it FD3C.3? BTW: How do you rename variable bit in IDA??? Like word_FD3C.1 I want rename to var1, word_FD3C.2 to var2 ... Title: Re: divison by zero? Post by: masterj on January 19, 2013, 02:36:49 PM If you think it will work then change the hex at 0x54D22 to 4980 cmpb rl4,#0 CC00 nop Works as expected. Thank you rajivc666 :) I can confirm now that this patch disables post cat o2 heater flicker ON/OFF in vcds - now it stays off all the time ;) P.s> Address was 54D30 ;) |