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

Big / Little Endian EE

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







Big / Little Endian EE
PostPosted: Thu Jun 26, 2008 8:45 am     Reply with quote

Has the format for memory storage changed from Big Endian to Little Endian?

I noticed in the current version of CCS (4.071) -- it stores my float in EE Little Endian (MSB in upper address). And have also confirmed this using the CCS PConvert program.

For example a float value of 1 is now stored in 0x0000007F

but used to be stored 0x7F000000

I have older programs that rely on reading EE being stored Big Endian.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 26, 2008 11:31 am     Reply with quote

Post the older CCS compiler version that you previously used.
guest2008
Guest







PostPosted: Thu Jun 26, 2008 1:02 pm     Reply with quote

CCS PCH C Compiler, Version 4.011
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 26, 2008 1:23 pm     Reply with quote

I wouldn't use 4.011 as the basis for anything. But I can test it for you
if you post your PIC.
Guest2008
Guest







PostPosted: Thu Jun 26, 2008 2:47 pm     Reply with quote

Quote:
I wouldn't use 4.011 as the basis for anything. But I can test it for you
if you post your PIC.



What do you need -- the PIC part# or the Code?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 26, 2008 3:20 pm     Reply with quote

The PIC.
Guest2008
Guest







PostPosted: Fri Jun 27, 2008 6:41 am     Reply with quote

The PIC I am using now is the 16F887.

The original PIC I was using for a different project was the 18F4520.
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Fri Jun 27, 2008 6:51 am     Reply with quote

Didn't CCS change from a proprietary float format to the IEEE standard with V4.xxx ?

Ken
Ttelmah
Guest







PostPosted: Fri Jun 27, 2008 7:34 am     Reply with quote

Nope.
PConvert, allows you to put values in, using Microchip float32, or IEEE float32. The result, doesn't just result in a byte order reversal (3F800000, versus 0000007F).
The change doesn't come with V4. The Pconvert, with 4.027 for example, gives 7F000000, as does the one with 4.051.
The 'help', still shows the exponent in the first byte, with 7F offset.
As far as I can tell, no change has occurred. It is just that Pconvert has switched to showing the bytes in the order they would appear as a number on paper, not the order in memory.
If you generate a line loading a float:
Code:

:                   float val=1;
  00A6    0E7F     MOVLW 0x7f
  00A8    6E08     MOVWF 0x8, ACCESS
  00AA    6A09     CLRF 0x9, ACCESS
  00AC    6A0A     CLRF 0xa, ACCESS
  00AE    6A0B     CLRF 0xb, ACCESS

The compiler is still putting the exponent byte first in memory.
I have code that transfers values to IEEE, and uses my own code at the PC end to do this, and it is still working fine, which would not be the case if the byte order had reversed.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 27, 2008 3:37 pm     Reply with quote

I ran tests on both compiler versions, and in each case the compiler
is putting 0x7F into the lowest byte address of the 4 bytes used to
store a floating point value. There is no difference between the
two compiler versions.


16F887 compiled with vs. 4.071. The .LST file is shown in both symbolic
format and standard CCS format:
Code:

... float array[1] = 1.0;
0017:  MOVLW  7F
0018:  BCF    STATUS.RP1
0019:  MOVWF  array
001A:  CLRF   array+1
001B:  CLRF   array+2
001C:  CLRF   array+3

... float array[1] = 1.0;
0017:  MOVLW  7F
0018:  BCF    03.6
0019:  MOVWF  21
001A:  CLRF   22
001B:  CLRF   23
001C:  CLRF   24


The test program for the .LST file shown above:
Code:
#include <16F887.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

//=========================
void main()
{
float array[1] = 1.0;

while(1); 
}




Now for the 18F4520 with vs. 4.011, shown in both symbolic format
and CCS format:
Code:

... float array[1] = 1.0;
0018:  MOVLW  7F
001A:  MOVWF  array
001C:  CLRF   array+1
001E:  CLRF   array+2
0020:  CLRF   array+3

... float array[1] = 1.0;
0018:  MOVLW  7F
001A:  MOVWF  06
001C:  CLRF   07
001E:  CLRF   08
0020:  CLRF   09


Here is the test program for vs. 4.011:
Code:
#include <18F4520.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
//=========================
void main()
{
float array[1] = 1.0;
 
while(1);
}
Ken Johnson



Joined: 23 Mar 2006
Posts: 197
Location: Lewisburg, WV

View user's profile Send private message

PostPosted: Sat Jun 28, 2008 8:22 am     Reply with quote

From ***PCD*** help:

"The CCS PCD compiler uses the IEEE format for all the floating point number operations"

I should have looked further before posting - so little time . . .

Ken
Ttelmah
Guest







PostPosted: Sat Jun 28, 2008 10:09 am     Reply with quote

Yes, there are a couple of 'fixes' to keep compatibility in the math.h file, because of this.
But as both PCM Programmer and myself have said, PCB/M/H, have kept the same format. If the poster is having a byte order problem, something else is causing it. Perhaps as one suggestion, the change to the way pointers are handled for example, so if you want to advance 'byte by byte' through a number, you must cast the pointer to a byte sized type. This would give 'screwy' results if not done, resulting in unexpected return values...

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