DATA_SEG doesnt work as written

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DATA_SEG doesnt work as written

4,021 Views
sureshkumar
Contributor I
Hi Experts,
 
   I have problem in placing a variable in zeropage to use in direct addressing mode. But, when compile and debug in full chip mode, I found all my variable are still in RAM( need to use exended mode to access this) which i dont prefer for timing reason. My codes are;
 
#pragma DATA_SEG directPAGE
 
char var1;
int var2;
 
#pragma DATA_SEG DEFAULT
 
char others[20];
 
In PRM file, I have this:
 
SEGMENTS
ROM     = READ_ONLY  0x8000 TO 0xFDFF;
RAM     = READ_WRITE 0x100 TO 0x34F;
Z_RAM = READ_WRITE 0x0050 TO 0x00FF;
END
 
PLACEMENT
    DEFAULT_RAM                                                               INTO  RAM;
    DEFAULT_ROM, ROM_VAR, STRINGS                        INTO  ROM;
    directPAGE                                                                      INTO  Z_RAM;
END
 
I also confirm that all my directPAGE variable doesnt exceed the allocation.
 
Thanks
Labels (1)
0 Kudos
4 Replies

378 Views
CompilerGuru
NXP Employee
NXP Employee
Are the variables in directPAGE actually allocated in the zero page?

I see a problem in your code that the #pragma DATA_SEG does not have a SHORT_SEG qualifier. Placing any variables in the prm file into the zero page works, but it wont cause that the compiler is using direct addressing unless you allow the compiler to do that with an explicit SHORT_SEG qualifier.
So please try this pragma instead:

#pragma DATA_SEG SHORT_SEG directPAGE

Daniel
0 Kudos

378 Views
sureshkumar
Contributor I
Thanks, Its work now. Its that possible if you can explain a further what is SHORT_SEG means in pragma means. Thanks again.
 

Suresh
0 Kudos

378 Views
CrasyCat
Specialist III
Hello
 
I assume you are using CodeWarrior for HC08 V5.1 or V5.0.
 
Please take a look at {Install}\Help\PDF\Compiler_HC08.pdf,
Chapter "Using the Compiler", section "Compiler Pragmas" -> "Pragma Details" -> "#pragma DATA_SEG: Data Segment definition" provides you with more information on what _SHORT_SEG is doing.
 
Chapter  "Using the Compiler", section "HC(S)08 Backend" -> "Call Protocol and calling Convention" -> "Segmentation" provides additional information around that.
 
I hope it helps.
 
CrasyCat
0 Kudos

378 Views
sureshkumar
Contributor I
Thanks Crasy. I will browse it.
0 Kudos