I'm creating a RISC-V emulator and the instruction formats sometimes encode values in the instructions, called immediates.
Sometimes, the instruction only contains the upper few bits of the immediate value.
E.g.:
Here, only the upper 20 bits are included in the instruction, from bit 31 to 12. and the lower 12 bits of the immediate should be set to 0.
I imagine syntax similar to the one proposed in #36 but with literal values that should occupy some number of bits in the field; e.g.:
It does raise the question of how the setter works when the field has padding.
I imagine it should just mask away the padded section, or simply panic when there are non-zero bits in the padded section.
It shouldn't be too difficult to support internal padding, but I can't imagine a good use case for that.
I understand that this is probably reaching outside the scope of what this package is meant to do, but it would certainly make my code a lot cleaner :).
Somewhat related to #36
I'm creating a RISC-V emulator and the instruction formats sometimes encode values in the instructions, called immediates. Sometimes, the instruction only contains the upper few bits of the immediate value. E.g.: Here, only the upper 20 bits are included in the instruction, from bit 31 to 12. and the lower 12 bits of the immediate should be set to 0. I imagine syntax similar to the one proposed in #36 but with literal values that should occupy some number of bits in the field; e.g.:
It does raise the question of how the setter works when the field has padding. I imagine it should just mask away the padded section, or simply panic when there are non-zero bits in the padded section.
It shouldn't be too difficult to support internal padding, but I can't imagine a good use case for that.
I understand that this is probably reaching outside the scope of what this package is meant to do, but it would certainly make my code a lot cleaner :).