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

Having to Cast a pointer for 8 bits??

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



Joined: 23 Jun 2011
Posts: 31
Location: UK

View user's profile Send private message

Having to Cast a pointer for 8 bits??
PostPosted: Wed Aug 31, 2011 11:01 am     Reply with quote

Hi.

18F4620
V4.124

I'm accessing stored data in ROM using a pointer and the

Code:
rom int8 scale[69]= { 0x45,0x5A ... }; etc.


method of storing in ROM (Program Memory).

I'm passing the pointer address to a function as follows :-

Code:
void draw_sprite (rom int8 * sprite_ptr);


and copying the data at the location of the pointer to an int8 variable called gfx_data as follows:-

Code:
gfx_data = *sprite_ptr;


This worked in version V4.099 (old I know!)

but now I have to change the code to...

Code:
gfx_data = (int8)*sprite_ptr;


to get it to work (if not, the next address after gfx_data is overwritten!)

is this part of the change made to suit ANSI as in the readme file? i.e.

Code:
Users that have old code with expresions of the form:
            *(&data + i)
need to change them to:
            *((int8 *)(&data) + i)
A compiler change was made to be ANSI compliant.



Thanks,

Tom


Last edited by Tom Jetland on Thu Sep 01, 2011 2:00 am; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Aug 31, 2011 12:10 pm     Reply with quote

I got the same thing. I made a test program for you. I found the failure
starts at vs. 4.122 and continues through vs. 4.124. The compiler is
treating it as a word pointer. I even tried casting it to (rom int8 *) in
various places and it didn't help. You should email a bug report to CCS
support. I tested this in MPLAB simulator and put a breakpoint on the
delay_cycles(1) line, and looked at gfx_data and temp in a watch window.
Code:

#include <18F4620.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4M)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

rom int8 scale[6]= {0x45,0x5A,0x41,0x42,0x43,0x44};

void draw_sprite (rom int8 *sprite_ptr)
{
int8 gfx_data;
int8 temp;

gfx_data = 0;
temp = 0;

gfx_data = *sprite_ptr;

delay_cycles(1);
}

//======================================
void main(void)
{
draw_sprite(scale);

while(1);
}
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