![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
PCD mixes up work registers |
Posted: Tue Sep 30, 2008 6:06 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Sep 30, 2008 6:16 am |
|
|
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 |
|
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Tue Sep 30, 2008 1:29 pm |
|
|
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 |
|
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|