expand & syntax to allow constants in hex..end
x87 opened this issue · 2 comments
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)
also allow float values with & prefix
const f = 2.0
hex
&1.0 &f
end
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.