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

Correct Behavior of long int (int16)?

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







Correct Behavior of long int (int16)?
PostPosted: Tue Apr 01, 2003 8:46 am     Reply with quote

I am using an older version of the PCM compiler (2.674) but the newer ones may function the same way. When defining a long and then assigning various values the long appears to work correctly but when attempting to increment a long (e.g. count++) only the lower byte gets updated and it functions as though it were just an int (int8). Is this a bug or a feature?!
___________________________
This message was ported from CCS's old forum
Original Post ID: 13284
Steve H.
Guest







2.685 Works Correctly
PostPosted: Tue Apr 01, 2003 9:02 am     Reply with quote


___________________________
This message was ported from CCS's old forum
Original Post ID: 13286
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Correct Behavior of long int (int16)?
PostPosted: Tue Apr 01, 2003 12:48 pm     Reply with quote

:=I am using an older version of the PCM compiler (2.674) but the newer ones may function the same way. When defining a long and then assigning various values the long appears to work correctly but when attempting to increment a long (e.g. count++) only the lower byte gets updated and it functions as though it were just an int (int8). Is this a bug or a feature?!
-----------------------------------------------------------
I installed PCM vs. 2.674 and it works OK for me.

The following sample program has this output:

12fe
12ff
1300
1301


<PRE>
#include "c:\picc\test\16F877.H"
#fuses HS, NOWDT, NOPROTECT, PUT, BROWNOUT, NOLVP
#use Delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
<BR>
//====================================================
void main()
{
long k;
<BR>
<BR>
k = 0x12FE;
printf("\%lx\n\r", k);
k++;
printf("\%lx\n\r", k);
k++;
printf("\%lx\n\r", k);
k++;
printf("\%lx\n\r", k);
<BR>
<BR>
while(1);
}
</PRE>
___________________________
This message was ported from CCS's old forum
Original Post ID: 13290
Jerry Finsen
Guest







Re: Correct Behavior of long int (int16)?
PostPosted: Tue Apr 01, 2003 3:52 pm     Reply with quote

I have recently reported a related problem. I have a program that has a statement in the form:

X += Y * Z that does not work, while the form X = X + (Y * Z) does work. All variables unsigned int16. Errors on the first form appear after 255 is reached. Below that all is OK. The errors are not consistant at 255, sometimes 260-280 -- I really don't understand that.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13293
Keith Ward
Guest







Re: Correct Behavior of long int (int16)?
PostPosted: Tue Apr 01, 2003 8:04 pm     Reply with quote

Ok, here it is. As much as I hate to admit it the sanity checks from all of your responses told me it was not a bug. The problem was that I'm using a 16C84 and not a 16F84 ... that alone fixed it!

I hate it when this sort of thing creeps in. It really keeps you from the "real" project. I really should learn when I'm too tired to work on things and just go to bed!


:=I am using an older version of the PCM compiler (2.674) but the newer ones may function the same way. When defining a long and then assigning various values the long appears to work correctly but when attempting to increment a long (e.g. count++) only the lower byte gets updated and it functions as though it were just an int (int8). Is this a bug or a feature?!
___________________________
This message was ported from CCS's old forum
Original Post ID: 13299
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