Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
x87 opened this issue Sep 12, 2023 · 2 comments
Open

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

x87 opened this issue Sep 12, 2023 · 2 comments
Labels

Comments

@x87
Copy link
Collaborator

x87 commented Sep 12, 2023

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)

@x87 x87 added priority:p3 Low priority type:nice-to-have minor enhancements scope:compiler labels Sep 12, 2023
@x87
Copy link
Collaborator Author

x87 commented Sep 12, 2023

also allow float values with & prefix

const f = 2.0
hex
 &1.0 &f
end

@MiranDMC
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants