Browse Source

Fix assembler bug involving extended immediates.

master
Ben Kurtovic 3 years ago
parent
commit
ba701545b2
3 changed files with 5 additions and 3 deletions
  1. 4
    2
      src/assembler/instructions.c
  2. 1
    1
      src/disassembler/mnemonics.c
  3. BIN
      tests/asm/roms.tar.gz

+ 4
- 2
src/assembler/instructions.c View File

@@ -92,9 +92,11 @@ static ASMErrorDesc parse_inst_##mnemonic(                                    \
92 92
     }
93 93
 
94 94
 #define INST_IMM_U16_B1(imm)                                                  \
95
-    ((imm).is_label ? (*symbol = cr_strdup((imm).label), 0) : (imm).uval >> 8)
95
+    ((imm).is_label ?                                                         \
96
+        (*symbol = cr_strdup((imm).label), 0) :                               \
97
+        (imm).uval & 0xFF)
96 98
 #define INST_IMM_U16_B2(imm)                                                  \
97
-    ((imm).is_label ? 0 : (imm).uval & 0xFF)
99
+    ((imm).is_label ? 0 : (imm).uval >> 8)
98 100
 
99 101
 #define INST_INDEX_PREFIX(n) INST_PREFIX_(INST_INDEX(n).reg)
100 102
 

+ 1
- 1
src/disassembler/mnemonics.c View File

@@ -18,7 +18,7 @@ static char* instr_mnemonics[256] = {
18 18
     /* 58 */ "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",
19 19
     /* 60 */ "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",
20 20
     /* 68 */ "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",
21
-    /* 70 */ "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",
21
+    /* 70 */ "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "halt", "ld",
22 22
     /* 78 */ "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",   "ld",
23 23
     /* 80 */ "add",  "add",  "add",  "add",  "add",  "add",  "add",  "add",
24 24
     /* 88 */ "adc",  "adc",  "adc",  "adc",  "adc",  "adc",  "adc",  "adc",

BIN
tests/asm/roms.tar.gz View File


Loading…
Cancel
Save