hlorenzi / customasm

💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Apache License 2.0
719 stars 56 forks source link

Allow Constants as Slice Sizes #189

Closed eignnx closed 11 months ago

eignnx commented 11 months ago

As a new user of customasm, I expected this to be possible:

#const MWordSz = 12
#const RegI = (1 << 0)`MWordSz

But I get this error:

customasm v0.13.4 (2023-11-04, x86_64-pc-windows-msvc)
assembling `microlark.customasm`...
error: expected number
 --> microlark.customasm:7:24:
7 | #const RegI = (1 << 0)` MWordSz
  |                        ^

Is there a better way to do this? Or could this feature be added?

hlorenzi commented 11 months ago

For some reason, I made the slice size operand require a number literal, probably to facilitate some feature in an old architecture of the program, but I think it should be easy to lift this restriction now.