|
|
|
|
|
by beagle3
4069 days ago
|
|
Thanks, seems like the thing I'm looking for. If you look at line 531 of the CPU source code (as of today, anyway), there are multiple 256 byte tables that give instruction encodings, lengths, and cycle counts. What I was asking is: "Is it possible to put these as a parameter of the 'op' macro so that it builds these tables automatically" The answer might be "No" if e.g. a single op has multiple instruction encodings. But assume that there is only one encoding per op. An equivalent question is - can static: sections assign to an array that will be available at runtime? From your example, the answer appears to be yes. |
|
The answer is yes, but it's a tad trickier than just accessing the compile-time list from run-time code (which doesn't make sense, and is illegal). Instead, use a macro to generate a bunch of run-time checks against a specific value. Eg:
Note: This will inject a bunch of 'if' statements for each call to 'checkDefined', which might bloat your code.. it's probably better to make a macro which defines a proc, then just call that to check run-time values.. but I left those kinds of details out of this illustration for the sake of simplicity.