CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PCD mixes up work registers

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PCD mixes up work registers
PostPosted: Tue Sep 30, 2008 6:06 am     Reply with quote

Hello,

in the below code detail, PCD is returning 2*addr rather than the required expression in the first case and the correct expression in the second case.
Code:

   switch (valid_address(addr)) {
..
..
       case 1:
          return ((int16*)(&Monitor_sect)+addr-ADDR_MONITOR);
021C0:  MOV     #866,W5
021C2:  MOV     1550,W4
021C4:  MUL.UU  W4,#2,W0
021C6:  ADD     W0,W5,W6
021C8:  MOV     W0,0  ; should use W6 instead !!
021CA:  BRA     2210
       case 2:
          return ((int16*)(&TTU_unreg_sect)+addr-ADDR_TTU_UNREG);
021CC:  MOV     #91A,W5
021CE:  MOV     1550,W4
021D0:  MUL.UU  W4,#2,W0
021D2:  ADD     W0,W5,W6
021D4:  MOV     #C8,W4
021D6:  SUB     W6,W4,W0
021D8:  MOV     W0,0
021DA:  BRA     2210

The different treatment is most likely caused by a zero value of the constant ADDR_MONITOR in first case.

Regards,
Frank
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Sep 30, 2008 6:16 am     Reply with quote

This way, PCD generated correct code:
Code:
       case 1:
 #if ADDR_MONITOR == 0
          return ((int16*)(&Monitor_sect)+addr);
021C0:  MOV     #866,W5
021C2:  MOV     1550,W4
021C4:  MUL.UU  W4,#2,W0
021C6:  ADD     W0,W5,W0
021C8:  MOV     W0,0
021CA:  BRA     2210
 #else         
          return ((int16*)(&Monitor_sect)+addr-ADDR_MONITOR);
 #endif         
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Tue Sep 30, 2008 1:29 pm     Reply with quote

And there are more PCD coding errors. Here with comparing an int32 variable value with a pointer referenced structure element.
Code:
                if (recvdata == pt->snr)
02600:  MOV     #0,W0      ; offset snr
02602:  ADD     15B2,W0   ; pt
02604:  MOV     #0,W4
; THIS IS THE BUG
02606:  MOV     [W0++],[W4++]   ; W0 gets overwritten
02608:  MOV     [W0++],[W4++]
0260A:  CP      1470          ; recvdata low word
0260C:  BRA     NZ,2636
0260E:  MOV     1472,W4   ; recvdata high word
02610:  CP      W4,W1
02612:  BRA     NZ,2636
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group