Page 1 of 1

mP v5.00: Problem when SSA optimisation is on [Solved]

Posted: 03 Jul 2011 12:34
by Dany
Hi, I encountered another problem when SSA optimisation is on.

Consider the following code:

Code: Select all

type TTimeDate =
     record
       Hours, Mins, Secs, WeekDay, Day, Month: byte;
       Year: word;
     end;

var Str, Str2: string[20];
     TimDat: TTimeDate;
...

procedure BcdByteToStr_(Val_: byte; S: ^byte);
begin
  S^ := (Val_ shr 4)   + Ord('0');
  inc(S);
  S^ := (Val_ and $0F) + Ord('0');
end;

procedure RTCC_TimeDateStr(var TimeDate: TTimeDate; var Ts: string[8]; var Ds: string[10]);
begin
  
  // ------------ time --------------------
  // hours
  BcdByteToStr_(TimeDate.Hours, @Ts[0]);
  Ts[2] := ':';

  // minutes
  BcdByteToStr_(TimeDate.Mins, @Ts[3]);
  Ts[5] := ':';

  // seconds
  BcdByteToStr_(TimeDate.Secs, @Ts[6]);
  
  Ts[8] := 0;
  
  // ------------ date --------------------
  // day
  BcdByteToStr_(TimeDate.Day, @Ds[0]);
  Ds[2] := '/';

  // month
  BcdByteToStr_(TimeDate.Month, @Ds[3]);
  Ds[5] := '/';

  // year
  BcdByteToStr_(hi(TimeDate.Year), @Ds[6]);  // <---- here Ds[6] and Ds[7] seem to get a wrong value
  BcdByteToStr_(lo(TimeDate.Year), @Ds[8]);
  
  Ds[10] := 0;
end;

procedure RTCC_Fill_TimeDate(var TimeDate: TTimeDate; Hours, Mins, Secs, WeekDay, Day, Month: byte; Year: word);
begin
  TimeDate.Hours   := Hours;
  TimeDate.Mins    := Mins;
  TimeDate.Secs    := Secs;
  TimeDate.WeekDay := WeekDay;
  TimeDate.Day     := Day;
  TimeDate.Month   := Month;
  TimeDate.Year    := Year;
end;

....
// call to procedure 

  RTCC_Fill_TimeDate(TimDat, $18, $30, $15, $4, $25, $11, $2011);
  RTCC_TimeDateStr(TimDat, Str, Str2);
After the call to "RTCC_TimeDateStr" (last line of the code), "Str" is assumed to hold the string representation of the time, which is correct ('18:30:15'). No problem there.
The "Str2" however is assumed to hold the string representation of the date (should be "25/11/2011"), but it is wrong: the "20" of the "year" is something else, like '??' (so "25/11/??11"). Always Str2[6] and Str2[7] are wrong, the others are always correct.

The problem goes away if
- SSA is switched off
- I make a procedure which only handles the date, not the time (so the first part of RTCC_TimeDateStr is deleted).

Thanks in advance! :D

Solved in v5.40 :D :D :D :D

Re: mP v5.00: Problem when SSA optimisation is on.

Posted: 05 Jul 2011 14:44
by filip
Hi,

Indeed, this seems to be a bug.
I have reported it to our developers and it should be fixed as soon as possible.

I apologize for the inconvenience.

Regards,
Filip.

Re: mP v5.00: Problem when SSA optimisation is on [Solved]

Posted: 31 Dec 2011 11:42
by Dany
Hi, this issue is solved in v5.40 :D :D :D :D

Thanks mE!!!! :D :D :D & Happy Newyear!