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

Beta Testing discussion on mikroPascal PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

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

#1 Post by Dany » 03 Jul 2011 12:34

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
Last edited by Dany on 31 Dec 2011 11:41, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

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

#2 Post by filip » 05 Jul 2011 14:44

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.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

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

#3 Post by Dany » 31 Dec 2011 11:42

Hi, this issue is solved in v5.40 :D :D :D :D

Thanks mE!!!! :D :D :D & Happy Newyear!
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for dsPIC30/33 and PIC24 Beta Testing”