I am moving from Tiny to Small in my HC(S)08 project. I need to know the best way to change the Memory Model of an existing project? Just changing the Memory Model type option in the Build Options of the CPU properties is not enough. There are other settings for the command lines of the compiler and assembler that do not get changed automatically. I changed these manually and was able to get the new memory model to build, but...
The issue I am having is the generated code is not using zero page instructions to access the variables anymore. I used #pragma DATA_SEG MY_ZEROPAGE to force my variables into zero page and I confirmed this by looking in the MAP file.
#pragma DATA_SEG MY_ZEROPAGE
byte Test1;
#pragma DATA_SEG DEFAULT
I also checked out the PRM and that looks correct for MY_ZEROPAGE section going to 0x80-0xFF.
SECTIONS
Z_RAM = READ_WRITE 0x0080 TO 0x00FF;
RAM = READ_WRITE 0x0100 TO 0x107F;
ROM = READ_ONLY 0x1900 TO 0xFFAD;
EEPROM = READ_ONLY 0x1400 TO 0x17FF;
END
PLACEMENT
DEFAULT_RAM,
MY_FARDATA /* non-zero page variables */
INTO RAM;
DEFAULT_ROM, ROM_VAR, STRINGS INTO ROM;
_DATA_ZEROPAGE, /* zero page variables */
MY_ZEROPAGE INTO Z_RAM;
END
The address of Test1 is 0x84 according to the MAP file. I would expect the code to be a BSET instruction.
0007 450000 [3] LDHX @Test1
000a f6 [3] LDA ,X
000b aa01 [2] ORA #1
000d f7 [2] STA ,X
There are many places in the code with other variables that are not using the optimized zero page instructions.
Is there another setting somewhere that I am missing?
Solved! Go to Solution.
Hello,
Try the following pragma -
#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE
Since the PRM file is used by the linker, and not the compiler, the compiler does not know that MY_ZEROPAGE is located within page zero, unless you explicitly indicate this via the pragma.
Regards,
Mac
Hello,
Try the following pragma -
#pragma DATA_SEG __SHORT_SEG MY_ZEROPAGE
Since the PRM file is used by the linker, and not the compiler, the compiler does not know that MY_ZEROPAGE is located within page zero, unless you explicitly indicate this via the pragma.
Regards,
Mac
I overlooked the __SHORT_SEG. That took care of the issue. Thanks.