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

int32

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



Joined: 13 Mar 2004
Posts: 2

View user's profile Send private message

int32
PostPosted: Sat Mar 13, 2004 11:55 pm     Reply with quote

does anyone understand why this wont work? it seems i cant initialze leds to hex 4000.
thanks ahead - matt

#case
#include <16f876.h>
#device *=16 ICD=TRUE
#use delay( clock=11059000 )
int32 leds = 1;
void main() {
leds = 0x4000;
}
Ttelmah
Guest







Re: int32
PostPosted: Sun Mar 14, 2004 3:42 am     Reply with quote

mattmab wrote:
does anyone understand why this wont work? it seems i cant initialze leds to hex 4000.
thanks ahead - matt

#case
#include <16f876.h>
#device *=16 ICD=TRUE
#use delay( clock=11059000 )
int32 leds = 1;
void main() {
leds = 0x4000;
}


Should work. Try declaring the constant as a long - so:
leds= 0x4000L;

Sometimes the compiler is less than 'intelligent' about such things...

Best Wishes
mattmab



Joined: 13 Mar 2004
Posts: 2

View user's profile Send private message

int32a
PostPosted: Sun Mar 14, 2004 9:59 pm     Reply with quote

Sad Sad Sad
nope,4000L dont work either, it takes it as a 16 bit. it works if i use make32(), but that seems like a poor way. does 32 bit math work? i never checked...
thankws - matt
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 14, 2004 10:51 pm     Reply with quote

It actually does work. If I take your code here,
Code:
#case
#include <16f876.h>
#device *=16 ICD=TRUE
#use delay( clock=11059000 )
int32 leds = 1;
void main() {
leds = 0x4000;
}

and compile it with PCM vs. 3.184, I get this result in the .LST file:
Code:
0011 01A3       00277 CLRF   23
0012 01A2       00278 CLRF   22
0013 3040       00279 MOVLW  40
0014 00A1       00280 MOVWF  21
0015 01A0       00281 CLRF   20

The symbol table shows that 'leds' is at address 0x20:
Code:
leds       00000020

The ASM code is setting the memory locations as follows:
0x23 = 0
0x22 = 0
0x21 = 0x40
0x20 = 0
Since CCS stores variables in Intel Lo-Hi format, this means
that 'leds' = 00 00 40 00 which is correct.

I suspect that the problem is in how you are viewing the 'leds' variable.
For example, if you're using printf, you need to specify the format
string as "%lx", and not "%x", in order to display a 16 or 32-bit number.
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