|
|
View previous topic :: View next topic |
Author |
Message |
Ralf
Joined: 21 Feb 2007 Posts: 3
|
Error in memset |
Posted: Tue Feb 27, 2007 4:47 am |
|
|
i have a struct gMenue with a size of 0x128 bytes.
When i compile it, i get the following:
memset(&gMenue, 0, sizeof (T_MENUE));
*
018FC: MOVLW 01
018FE: MOVWF 02
01900: MOVLW 28
01902: MOVWF 01
01904: MOVLW 01
01906: MOVWF FEA
01908: MOVLW C4
0190A: MOVWF FE9
0190C: CLRF FEE
0190E: DECFSZ 01,F
01910: BRA 190C
01912: DECFSZ 02,F
01914: BRA 190C
BUT, only the first 0x28 bytes where cleared (Seeing in the debugger). I think the second "decfsz 02,f" is wrong. The register 02 must be loaded with 02 and not with 01.
Is this correct?
Thanks for your help |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Feb 27, 2007 6:40 am |
|
|
From the Jan-2007 PICC manual: Quote: | MEMSET( )
Syntax: memset (destination, value, n)
Parameters: destination is a pointer to memory, value is a 8 bit int, n is a 8 bit int.
Returns: undefined | Note that the size n parameter is only 8 bit, clearing an area of 0x128 bytes doesn't fit.
Studying the generated assembly code it looks like CCS did partially implement the support for a 16-bit size parameter, except for the 'small' off by 1 error.
Which compiler version are you using?
I guess it is a v4.0xx version as v3.249 generates slightly different code for only an 8 bit variable.
Suggested actions:
1) Report this to CCS as a request for enhancement.
2) Create your own large memset routine until CCS releases the new feature.
Code: | void large_memset(char *destination, int8 value, signed int16 size)
{
while (size > 0)
{
memset(destination, value, (int8)size);
size -= 256;
}
} |
|
|
|
Ralf
Joined: 21 Feb 2007 Posts: 3
|
|
Posted: Tue Feb 27, 2007 6:56 am |
|
|
Thanks for your help. I reported this to CCS. |
|
|
|
|
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
|