Writing a (dis-)assembler for 8-bit code in D - blog posts

Steven Schveighoffer schveiguy at gmail.com
Fri Apr 23 12:32:56 UTC 2021


On 4/20/21 6:02 AM, Dukc wrote:
> Even better is if you make a global array of opCodes and pass that to 
> `static foreach`. The opcode array needs to be available in compile 
> time, so mark it `enum` instead of `immutable`, like: `enum opcodes = 
> ["nop", "lxi", "stax", <...>];`

Just FYI, immutables are accessible at compile-time. it can sometimes be 
advantageous to use immutable instead of enum, as an enum doesn't exist 
at runtime (so e.g. every use will construct a new array).

-Steve


More information about the Digitalmars-d mailing list