summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormrb0nk500 <b0nk@b0nk.xyz>2022-01-18 10:54:23 -0400
committermrb0nk500 <b0nk@b0nk.xyz>2022-01-18 10:54:23 -0400
commit734584c6a75cfba5c3ebf456c3bb03269157536b (patch)
tree260e614ce6f6fdcb9b806f91a02a73d3224231a8
parentbb9dba22d81c5a2af6754a4377377cb3b38c7c37 (diff)
opcode-bitmask-gen: Invert the addressing mode bitmask
after all bits have been found, if inverting is enabled.
-rw-r--r--opcode-bitmask-gen.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/opcode-bitmask-gen.c b/opcode-bitmask-gen.c
index c4fa446..f59969f 100644
--- a/opcode-bitmask-gen.c
+++ b/opcode-bitmask-gen.c
@@ -417,24 +417,28 @@ void set_extension(int *ext, int ext2, int force, const char *reason, ...) {
}
uint32_t get_addr_mode_bits(const char **list, int *ext) {
+ const int is_inv = (list[0][0] == '~');
+ const uint32_t ext_mask = (AM_ORTHO|AM_ORTHO2|AM_EIND|AM_EIND2|AM_AIND|AM_AINDX|AM_AINDY);
const uint32_t max_addr_mode_mask = -(uint32_t)1 >> (32-AMT_LEN);
- uint32_t addr_modes = 0;
int is_ext = 0;
+ uint32_t addr_modes = 0;
+ uint32_t bits = 0;
+
for (int i = 0; list[i] != NULL; ++i) {
- const int is_inv = (list[i][0] == '~');
- const char *str = list[i]+is_inv;
- const uint32_t ext_mask = (AM_ORTHO|AM_ORTHO2|AM_EIND|AM_EIND2|AM_AIND|AM_AINDX|AM_AINDY);
- uint32_t bits = 0;
+ const int inv = (!i) ? is_inv : 0;
+ const char *str = list[i]+inv;
for (int j = 0; j < AMT_LEN; ++j) {
if (!strcasecmp(str, adrmode[j])) {
//printf("i: %i, str: %s, adrmode: %s\n", i, str, adrmode[i]);
bits |= (1 << j);
}
}
- is_ext = (bits & ext_mask) ? 1 : is_ext;
- addr_modes |= (is_inv) ? ~(bits) & (max_addr_mode_mask & (is_ext) ? -1 : ~ext_mask) : bits;
- addr_modes &= (is_ext && (bits & ~(AM_ORTHO|AM_ORTHO2))) ? ~(AM_ORTHO|AM_ORTHO2) : -1;
}
+
+ is_ext = (bits & ext_mask) ? 1 : is_ext;
+ addr_modes |= (is_inv) ? ~(bits) & (max_addr_mode_mask & (is_ext) ? -1 : ~ext_mask) : bits;
+ addr_modes &= (is_ext && (bits & ~(AM_ORTHO|AM_ORTHO2))) ? ~(AM_ORTHO|AM_ORTHO2) : -1;
+
if (is_ext) {
const int ext2 = (addr_modes & AM_ORTHO) ? ORTHO : EXT;
const char *addr_mode_reason = (ext2 == ORTHO) ? "was set to ortho" : "is a base extension addressing mode";