t-edson/P65Pas

The compiler seems to have a problem with initialized variables

Closed this issue · 1 comments

As you can see on the screenshot below I have number of variables - local, global, parameters and hex that is array with initial value for total of 16 elements. I have defined few bytes from Zero Page as available to see how the compiler is using it. So there are 2 problems:

  • the compiler try to put initialized variables in Zero Page
  • the compiler doesn't account the length that hex variable need!
    image

As I commented the error: "Cannot initialize absolute variable "hex" in this location.". It is because of it's not allowed to initialize variables allocated in a memory block separated from the main code block, because P65pas is using *.prg format and in this format you cannot write in separated blocks of memory.
The error about allocating variables seems to be caused because you are not using $CLEAR_STATE_RAM. It's mandatory when defining RAM state. According to documentation: "IMPORTANT: The IDE maintains the previous state of $SET_STATE_RAM. It's recommended to include $CLEAR_STATE_RAM, always before any directive $SET_STATE_RAM."