Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/15/00 09:22
Read: times


 
#4409 - RE: code or xdata spec
Hi, everyone,

I asked not enough clearly when saying "string constant", actually
it's string array(that is variable but is not varied).
It might mislead somone. Sorry, if so.

Thank you very much for your comments, Allen,

>The code keyword causes your constants to be stored in code space and
>therefore your code size should always increase by the number of bytes
>stored.
Sorry, not clear. Where are the constants in case of xdata? As far as
see code constants are formed in time of compilation by PC(a byte takes
size of byte), but "constants" stored at xram requires some bytes of
an instruction(that contains this data byte too) to move it to RAM. Am
I not right?

>If your code size went down by moving the constants from xdata to code
>it is not because of constant storage reasons. Most likely it is the
>data accesses to the constants.
>All movc instructions are one byte instructions, some mov instructions
>are 2 bytes and one is 3 bytes. So depending on how the compiler sets
>up the assembly code to move xdata versus code could cause smaller code
>from the movc versus the mov and movx combinations.
>In any event, if you add constants to code you code size increases by
>the number of byte constants stored.
>Allen
At Philips 80C51 and DALLAS derevatives both movc and movx takes a byte.
Preparation may differs a liitle. Anyway in both cases we need to pre-
load the DPTR, and some manipulatoin with ACC, if movc. We could lost
some amount of bytes while reading a code constant, but we find space
by the unused movx to initialize the objects.


Thank you very much for your comments, Chris.

>Are the character arrays within your structure fully populated, or are
>they being initialized with strings that are significantly shorter
>(>20%(?)) than the character arrays themselves. If this is the case,
>could it be that your array of structures is taking up more code space
>because of the memory allocations for the character arrays than is
>required by the init code to copy the initialization data (which
>should be very compact) from code to xdata?
>Just a thought.
>Chris
Yes, It's the reason. The structures are populated partly. After your
message receiving I played more with that. There is no importance for
code size, is the structure array initialized fully, partly or not at
all. All the object is filled anyway by a data or zero values.
BUT, of course it's size important while secondary initializing is
made at main program body. That's my mistake.

So, it's probably right for any object, that initialization should be
made while its declaration to save code size. And it is actual not for
code specifier only, for xdata variables too.

Thanks a lot for everyone taking time for it.
Best regards,
Oleg

List of 6 messages in thread
TopicAuthorDate
code or xdata spec            01/01/70 00:00      
RE: code or xdata spec            01/01/70 00:00      
RE: code or xdata spec            01/01/70 00:00      
RE: code or xdata spec            01/01/70 00:00      
RE: code or xdata spec            01/01/70 00:00      
RE: code or xdata spec            01/01/70 00:00      

Back to Subject List