From d15276557c65de2a1941632ec9024dea261cce26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedikt=20B=C3=B6hm?= Date: Tue, 7 Jul 2009 09:46:27 +0200 Subject: make instruction 64-bit wide to support more than 32 registers --- src/emu/asm.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'src/emu/asm.c') diff --git a/src/emu/asm.c b/src/emu/asm.c index 4548b48..85f3293 100644 --- a/src/emu/asm.c +++ b/src/emu/asm.c @@ -1,54 +1,52 @@ #include #include +#include #include "cpu.h" #include "log.h" #include "opc.h" -#define REGa(x) (((x) & 0x1F) << 21) -#define REGb(x) (((x) & 0x1F) << 16) -#define REGc(x) (((x) & 0x1F) << 11) -#define IMMc(x) ((x) & 0xFFFF) +#define REGa(x) (((x) & 0x1FFF) << 45) +#define REGb(x) (((x) & 0x1FFF) << 32) +#define REGc(x) (((x) & 0x1FFF) << 19) +#define IMMc(x) ((x) & 0xFFFFFFFF) -uint32_t compile(const char *line) +inst_t compile(const char *line) { char mnem[5]; - int32_t a = 0, b = 0, c = 0; - static size_t regs = 0; + int64_t a = 0, b = 0, c = 0; /* register file size */ - if (sscanf(line, ".REGS %d", &a) == 1) { - regs = a; + if (sscanf(line, ".REGS %"SCNi64"", &a) == 1) return a; - } /* ADD, SUB, MUL, DIV, MOD, AND, OR */ - if (sscanf(line, "%4s r%d, r%d, r%d", mnem, &a, &b, &c) == 4) + if (sscanf(line, "%4s r%"SCNi64", r%"SCNi64", r%"SCNi64"", mnem, &a, &b, &c) == 4) return mnemonic2opc(mnem) | REGa(a) | REGb(b) | REGc(c); /* LW, SW */ - if (sscanf(line, "%4s r%d, r%d, %d", mnem, &a, &b, &c) == 4) + if (sscanf(line, "%4s r%"SCNi64", r%"SCNi64", %"SCNi64"", mnem, &a, &b, &c) == 4) return mnemonic2opc(mnem) | REGa(a) | REGb(b) | IMMc(c); /* CMP */ - if (sscanf(line, "%4s r%d, r%d", mnem, &a, &b) == 3) + if (sscanf(line, "%4s r%"SCNi64", r%"SCNi64"", mnem, &a, &b) == 3) return mnemonic2opc(mnem) | REGa(a) | REGb(b); /* MOV, BEZ */ - if (sscanf(line, "%4s r%2d, %d", mnem, &a, &c) == 3) + if (sscanf(line, "%4s r%"SCNi64", %"SCNi64"", mnem, &a, &c) == 3) return mnemonic2opc(mnem) | REGa(a) | IMMc(c); /* EQ, NE, LT, LE, GE, GT, PUSH, POP */ - if (sscanf(line, "%4s r%d", mnem, &a) == 2) + if (sscanf(line, "%4s r%"SCNi64"", mnem, &a) == 2) return mnemonic2opc(mnem) | REGa(a); /* JMP, CALL */ - if (sscanf(line, "%4s %d", mnem, &c) == 2) + if (sscanf(line, "%4s %"SCNi64"", mnem, &c) == 2) return mnemonic2opc(mnem) | IMMc(c); /* RET, SYS */ if (sscanf(line, "%4s", mnem) == 1) return mnemonic2opc(mnem); - return 0xFFFFFFFF; + return 0xFFFFFFFFFFFFFFFF; } -- cgit v1.2.3