Skip to content

expand & syntax to allow constants in hex..end #261

Open

Description

@x87

Currently & prefix can be used to enter decimal numbers in hex..end, e.g.

hex
  &100
end

will produce a byte 64. Similarly we can define a constant and prefix the name:

const a = 100
hex
&a
end

it should not produce any collisions with existing code (today this code triggers error 0024)

Activity

  1. x87 commented on Sep 12, 2023

    @x87
    CollaboratorAuthor

    also allow float values with & prefix

    const f = 2.0
    hex
     &1.0 &f
    end
    
  2. MiranDMC commented on Apr 24, 2024

    @MiranDMC

    What about size of

    const foo = 4
    
    hex
        &foo 
    end
    

    When using constants it means you want to distance yourself from manually typing in bytes and keep actual values somewhere else. Assuming minimal size creates problem of unexpected hex data layout change when modifying constant with value, for example from 300 to 200 (two bytes becomes one).
    Simple solution would be writing all numbers as 4 bytes, but someone might not like this behavior.
    Better way might be to allow defining desired size like for example &foo(4) where 4 bytes are stored. This would also give nice way to manage arrays of strings stored in hex blocks, where texts shorter than requested would be just padded with zero bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p3scope:compilertype:nice-to-have

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions