AnsweredAssumed Answered

Best way to change the Memory Model of an existing project?

Question asked by Jerry Girard on Nov 7, 2011
Latest reply on Nov 8, 2011 by Jerry Girard

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? 

Outcomes