assembler: Some r15 fixes
authorMichael Buesch <mb@bu3sch.de>
Sun, 19 Sep 2010 15:19:28 +0000 (17:19 +0200)
committerMichael Buesch <mb@bu3sch.de>
Sun, 19 Sep 2010 15:19:28 +0000 (17:19 +0200)
Signed-off-by: Michael Buesch <mb@bu3sch.de>
assembler/main.c
assembler/scanner.l
disassembler/main.c

index 0d995a4d6ffe0619ecf57e4cc092364d5b11d5ed..309d7c5fed1f95536345efe4f26354d70b97eeb0 100644 (file)
@@ -325,9 +325,21 @@ static unsigned int generate_mem_operand(struct assembler_context *ctx,
        case MEM_DIRECT:
                /* format: 0b0mmm mmmm mmmm */
                off = mem->offset;
-               if (off & ~0x7FF) { //FIXME 4096 words for v15 arch possible?
-                       asm_warn(ctx, "DIRECT memoffset 0x%X too long (> 11 bits)", off);
-                       off &= 0x7FF;
+               switch (ctx->arch) {
+               case 5:
+                       if (off & ~0x7FF) {
+                               asm_warn(ctx, "DIRECT memoffset 0x%X too long (> 11 bits)", off);
+                               off &= 0x7FF;
+                       }
+                       break;
+               case 15:
+                       if (off & ~0xFFF) {
+                               asm_warn(ctx, "DIRECT memoffset 0x%X too long (> 12 bits)", off);
+                               off &= 0xFFF;
+                       }
+                       break;
+               default:
+                       asm_error(ctx, "Internal error: generate_mem_operand invalid arch");
                }
                val |= off;
                break;
@@ -345,9 +357,9 @@ static unsigned int generate_mem_operand(struct assembler_context *ctx,
                        /* Assembler bug. The parser shouldn't pass this value. */
                        asm_error(ctx, "OFFR-nr too big");
                }
-               if (reg == 6) {
+               if (reg == 6 && ctx->arch == 5) {
                        asm_warn(ctx, "Using offset register 6. This register is broken "
-                                "on certain devices. Use off0 to off5 only.");
+                                "on architecture 5 devices. Use off0 to off5 only.");
                }
                val |= off;
                val |= (reg << 6);
index b135552a31a389259fc25c3c6b669c93f613c4f1..a9928da083850235afb3a9d300150c66b10d2315 100644 (file)
@@ -56,7 +56,7 @@ NEWLINE               ((\r)|(\n)|(\r\n))
 ^{WS}*\.text{WS}*$                     { update_lineinfo(); return SECTION_TEXT; }
 ^{WS}*\.initvals/\({IDENTIFIER}\)      { update_lineinfo(); return SECTION_IVALS; }
 
-spr[0-9a-fA-F]{3,3}    { update_lineinfo(); return SPR; }
+spr[0-9a-fA-F]{1,4}    { update_lineinfo(); return SPR; }
 r/([0-9]|([1-5][0-9])|(6[0-3]))        { update_lineinfo(); return GPR; }
 off/[0-6]              { update_lineinfo(); return OFFR; }
 lr/[0-3]               { update_lineinfo(); return LR; }
index e55a5459578f60c84f3203d29a683fd6cd9b96af..43415a1d003575c4b92add7de4e7a5d9cb2368f3 100644 (file)
@@ -94,7 +94,7 @@ static const char * disasm_indirect_mem_operand(unsigned int operand)
 
        ret = xmalloc(12);
        snprintf(ret, 12, "[0x%02X,off%u]",
-                (operand & 0x3F), ((operand >> 6) & 0x7));
+                (operand & 0x3F), ((operand >> 6) & 0x7)); //FIXME r15?
 
        return ret;
 }