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 support@ccsinfo.com

Incorrect file registers on assembler listing

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



Joined: 10 May 2008
Posts: 1

View user's profile Send private message

Incorrect file registers on assembler listing
PostPosted: Sat May 10, 2008 12:11 pm     Reply with quote

Hi all,

I've got code that is not working and I've found something which, to me, seems too wrong not to be my fault... This is happening of various lines of the program, but for illustration purposes, I will just show one switch sentence which is failing.

This is the C code:

...
...
for (Pointer=0;Message[Pointer]!='\0';Pointer++){
Message[Pointer]=Symbol;
switch (Symbol){
case '.' : tone(DITC); break;
case '-' : tone(DITC*3); break;
case ' ' : delay_ms(DITS*2); break; // (1+2) DITs between letters
case '&' : delay_ms(DITS*6); break; // (1+6) DITs between words
};
};
...
...

And this is what the .LST has for this code:

...
...
.................... for (Pointer=0;Message[Pointer]!='\0';Pointer++){
0084: CLRF 0A
0085: MOVF 0A,W
0086: CALL 027
0087: XORLW 00
0088: BTFSC 03.2
0089: GOTO 0B4
.................... Message[Pointer]=Symbol;
008A: MOVF 0A,W
008B: CALL 027
008C: MOVWF 08
.................... switch (Symbol){
008D: MOVLW 2E
008E: SUBWF 07,W
008F: BTFSC 03.2
0090: GOTO 09E
0091: MOVLW 2D
0092: SUBWF 07,W
0093: BTFSC 03.2
0094: GOTO 0A2
0095: MOVLW 20
0096: SUBWF 07,W
0097: BTFSC 03.2
0098: GOTO 0A6
0099: MOVLW 26
009A: SUBWF 07,W
009B: BTFSC 03.2
009C: GOTO 0AA
009D: GOTO 0B2
...
...

Note that the compiler is using file register number 8 to store Symbol (008C: MOVWF 08), but after that, it compares the characters with the file register number 7 (008E: SUBWF 07,W)...

Of course, the code does not work as intended because none of the case conditions is ever met.

¿Ant ideas?

Thank you all,
Roberto
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat May 10, 2008 12:21 pm     Reply with quote

What is your PIC and your compiler version ?
Guest








PostPosted: Sat May 10, 2008 12:37 pm     Reply with quote

Version is 4.033 and the device is a 12C508A (I know it's old but I've got lots of them and they are OK for some applications)

Thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 11, 2008 12:56 pm     Reply with quote

I don't have that version of the PCB compiler. I only have 3.249.
I tried to make a test program that would demonstrate your problem,
but I could not get the compiler to generate SUBWF code to do the
comparisons. It generated XORLW statements instead.

It could be that your problem is caused by a compiler bug.
If so, it's a serious bug (in your early version) and it prevents
the compiler from operating. For example, here's a statement
from the CCS versions page:
Quote:
4.036 A problem with some PCM switch statements is fixed

That's regarding the PCM compiler, but it probably applies to PCB as well.
If you don't have current compiler "maintenance" in effect, you could
make the case to CCS that your version is seriously defective in that
switch-case statements don't work, and then request that they upgrade
you to a slightly later version that doesn't have this problem. They
might do it. Be sure to include your User Reference number in your
email so they know you own the compiler.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

PostPosted: Sun May 11, 2008 6:09 pm     Reply with quote

Roberto,

The 12C508A hardly seems big enough to bother with "C". Why not avoid the problem and just use assembler?

Also, it looks like you are generating Morse code, right?

Robert Scott
Real-Time Specialties
Ttelmah
Guest







PostPosted: Mon May 12, 2008 2:00 am     Reply with quote

Worth remembering, that PCB, comes 'with' MPLAB, as a freebie. The versions supplied are older, but don't display this problem, so why not use these?...

Best Wishes
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