Menu

Aliasing variables

Help
miniTesla
2026-05-05
2026-05-08
  • miniTesla

    miniTesla - 2026-05-05

    The documentation regarding aliasing variables isn't entire clear to me. So here my question. I setup an array CMD(4) and then I want to alias four variables to each of the four elements of the array. Is this the correct way?

    DIM CMD(4) AS BYTE
    DIM CMD0 AS BYTE ALIAS CMD(1)
    DIM CMD1 AS BYTE ALIAS CMD(2)
    DIM CMD2 AS BYTE ALIAS CMD(3)
    DIM CMD3 AS BYTE ALIAS CMD(4)
    
     

    Last edit: miniTesla 2026-05-05
    • Anobium

      Anobium - 2026-05-06

      Yes, this is correct.

      The optimiser will create aliases automatically if the address of the array elements is a constant. So, uses the alias does make use of the array elements easier but it will not improve code size.

      Best to look at the ASM. There is an alias section.

       
      • miniTesla

        miniTesla - 2026-05-08

        Perhaps this can be added as example in the aliasing section. Also this example that is already in the docu

        Dim my_variable as LONG
        Dim ByteOne   as Byte alias my_variable_E
        Dim ByteTwo   as Byte alias my_variable_U
        Dim ByteThree as Byte alias my_variable_H
        Dim ByteFour  as Byte alias my_variable
        

        would benefit from an explantion of what my_variable_E, my_variable_U, my_variable_H are because they are not defined.

         
  • Anobium

    Anobium - 2026-05-08

    Where?

    If you can provide the location in the help ( the page in the CHM ... use the properties of the page to tell you the source file name, it will look like /_alias.html

    And, the words you recommend then we can just drop in.

     
    • miniTesla

      miniTesla - 2026-05-08
       
      • Anobium

        Anobium - 2026-05-08

        And, the words you recommend then we can just drop in and where in the document?

         
        • miniTesla

          miniTesla - 2026-05-08

          The example that is there isn't mine. I have no idea what my_variable_E is. Explain it. My example from above for an array doesn't need more than something like "accessing array elements via aliasing"

           
  • Anobium

    Anobium - 2026-05-08
     
    • miniTesla

      miniTesla - 2026-05-08

      This is good and much better than what is currently there. My main confusion came from the E, U, H naming convention that is now explained.

       

Log in to post a comment.

MongoDB Logo MongoDB