From b38078886daeb7bf33578778f53a9b0d661c2975 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Fri, 6 Dec 2019 02:22:38 +0000 Subject: [PATCH] agssim: document mar register use some instructions read or write mar implicitly. --- agssim.c | 148 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/agssim.c b/agssim.c index dd16bd5..40a4b52 100644 --- a/agssim.c +++ b/agssim.c @@ -18,82 +18,83 @@ enum RegisterAccess { struct regaccess_info { /* enum RegisterAccess */ unsigned char ra_reg1; /* enum RegisterAccess */ unsigned char ra_reg2; + /* enum RegisterAccess */ unsigned char ra_mar; } __attribute__((packed)); static const struct regaccess_info regaccess_info[] = { - [0] = {RA_NONE, RA_NONE}, - [SCMD_ADD] = {RA_READWRITE, RA_NONE}, - [SCMD_SUB] = {RA_READWRITE, RA_NONE}, - [SCMD_REGTOREG] = {RA_READ, RA_WRITE}, - [SCMD_WRITELIT] = {RA_NONE, RA_NONE}, // TODO - [SCMD_RET] = {RA_NONE, RA_NONE}, - [SCMD_LITTOREG] = {RA_WRITE, RA_NONE}, - [SCMD_MEMREAD] = {RA_WRITE, RA_NONE}, - [SCMD_MEMWRITE] = {RA_READ, RA_NONE}, - [SCMD_MULREG] = {RA_READWRITE, RA_READ}, - [SCMD_DIVREG] = {RA_READWRITE, RA_READ}, - [SCMD_ADDREG] = {RA_READWRITE, RA_READ}, - [SCMD_SUBREG] = {RA_READWRITE, RA_READ}, - [SCMD_BITAND] = {RA_READWRITE, RA_READ}, - [SCMD_BITOR] = {RA_READWRITE, RA_READ}, - [SCMD_ISEQUAL] = {RA_READWRITE, RA_READ}, - [SCMD_NOTEQUAL] = {RA_READWRITE, RA_READ}, - [SCMD_GREATER] = {RA_READWRITE, RA_READ}, - [SCMD_LESSTHAN] = {RA_READWRITE, RA_READ}, - [SCMD_GTE] = {RA_READWRITE, RA_READ}, - [SCMD_LTE] = {RA_READWRITE, RA_READ}, - [SCMD_AND] = {RA_READWRITE, RA_READ}, /*logical*/ - [SCMD_OR] = {RA_READWRITE, RA_READ}, - [SCMD_CALL] = {RA_READ, RA_NONE}, - [SCMD_MEMREADB] = {RA_WRITE, RA_NONE}, - [SCMD_MEMREADW] = {RA_WRITE, RA_NONE}, - [SCMD_MEMWRITEB] = {RA_READ, RA_NONE}, - [SCMD_MEMWRITEW] = {RA_READ, RA_NONE}, - [SCMD_JZ] = {RA_READ, RA_NONE}, - [SCMD_PUSHREG] = {RA_READ, RA_NONE}, - [SCMD_POPREG] = {RA_WRITE, RA_NONE}, - [SCMD_JMP] = {RA_READ, RA_NONE}, - [SCMD_MUL] = {RA_READWRITE, RA_NONE}, - [SCMD_CALLEXT] = {RA_READ, RA_NONE}, - [SCMD_PUSHREAL] = {RA_READ, RA_NONE}, - [SCMD_SUBREALSTACK] = {RA_READ, RA_NONE}, - [SCMD_LINENUM] = {RA_NONE, RA_NONE}, - [SCMD_CALLAS] = {RA_READ, RA_NONE}, - [SCMD_THISBASE] = {RA_NONE, RA_NONE}, - [SCMD_NUMFUNCARGS] = {RA_NONE, RA_NONE}, - [SCMD_MODREG] = {RA_READWRITE, RA_READ}, - [SCMD_XORREG] = {RA_READWRITE, RA_READ}, - [SCMD_NOTREG] = {RA_READWRITE, RA_READ}, - [SCMD_SHIFTLEFT] = {RA_READWRITE, RA_READ}, - [SCMD_SHIFTRIGHT] = {RA_READWRITE, RA_READ}, - [SCMD_CALLOBJ] = {RA_READ, RA_NONE}, - [SCMD_CHECKBOUNDS] = {RA_READ, RA_NONE}, - [SCMD_MEMWRITEPTR] = {RA_NONE, RA_NONE}, //TODO - [SCMD_MEMREADPTR] = {RA_NONE, RA_NONE}, //TODO - [SCMD_MEMZEROPTR] = {RA_NONE, RA_NONE}, - [SCMD_MEMINITPTR] = {RA_NONE, RA_NONE}, //TODO - [SCMD_LOADSPOFFS] = {RA_NONE, RA_NONE}, - [SCMD_CHECKNULL] = {RA_NONE, RA_NONE}, - [SCMD_FADD] = {RA_READWRITE, RA_NONE}, - [SCMD_FSUB] = {RA_READWRITE, RA_NONE}, - [SCMD_FMULREG] = {RA_READWRITE, RA_READ}, - [SCMD_FDIVREG] = {RA_READWRITE, RA_READ}, - [SCMD_FADDREG] = {RA_READWRITE, RA_READ}, - [SCMD_FSUBREG] = {RA_READWRITE, RA_READ}, - [SCMD_FGREATER] = {RA_READWRITE, RA_READ}, - [SCMD_FLESSTHAN] = {RA_READWRITE, RA_READ}, - [SCMD_FGTE] = {RA_READWRITE, RA_READ}, - [SCMD_FLTE] = {RA_READWRITE, RA_READ}, - [SCMD_ZEROMEMORY] = {RA_NONE, RA_NONE}, - [SCMD_CREATESTRING] = {RA_NONE, RA_NONE}, //TODO - [SCMD_STRINGSEQUAL] = {RA_READWRITE, RA_READ}, - [SCMD_STRINGSNOTEQ] = {RA_READWRITE, RA_READ}, - [SCMD_CHECKNULLREG] = {RA_NONE, RA_NONE}, //TODO - [SCMD_LOOPCHECKOFF] = {RA_NONE, RA_NONE}, - [SCMD_MEMZEROPTRND] = {RA_NONE, RA_NONE}, - [SCMD_JNZ] = {RA_NONE, RA_NONE}, - [SCMD_DYNAMICBOUNDS] = {RA_NONE, RA_NONE}, //TODO - [SCMD_NEWARRAY] = {RA_NONE, RA_NONE}, //TODO + [0] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_ADD] = {RA_READWRITE, RA_NONE, RA_NONE}, + [SCMD_SUB] = {RA_READWRITE, RA_NONE, RA_NONE}, + [SCMD_REGTOREG] = {RA_READ, RA_WRITE, RA_NONE}, + [SCMD_WRITELIT] = {RA_NONE, RA_NONE, RA_READ}, + [SCMD_RET] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_LITTOREG] = {RA_WRITE, RA_NONE, RA_NONE}, + [SCMD_MEMREAD] = {RA_WRITE, RA_NONE, RA_READ}, + [SCMD_MEMWRITE] = {RA_READ, RA_NONE, RA_READ}, + [SCMD_MULREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_DIVREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_ADDREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_SUBREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_BITAND] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_BITOR] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_ISEQUAL] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_NOTEQUAL] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_GREATER] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_LESSTHAN] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_GTE] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_LTE] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_AND] = {RA_READWRITE, RA_READ, RA_NONE}, /*logical*/ + [SCMD_OR] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_CALL] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_MEMREADB] = {RA_WRITE, RA_NONE, RA_READ}, + [SCMD_MEMREADW] = {RA_WRITE, RA_NONE, RA_READ}, + [SCMD_MEMWRITEB] = {RA_READ, RA_NONE, RA_READ}, + [SCMD_MEMWRITEW] = {RA_READ, RA_NONE, RA_READ}, + [SCMD_JZ] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_PUSHREG] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_POPREG] = {RA_WRITE, RA_NONE, RA_NONE}, + [SCMD_JMP] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_MUL] = {RA_READWRITE, RA_NONE, RA_NONE}, + [SCMD_CALLEXT] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_PUSHREAL] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_SUBREALSTACK] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_LINENUM] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_CALLAS] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_THISBASE] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_NUMFUNCARGS] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_MODREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_XORREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_NOTREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_SHIFTLEFT] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_SHIFTRIGHT] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_CALLOBJ] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_CHECKBOUNDS] = {RA_READ, RA_NONE, RA_NONE}, + [SCMD_MEMWRITEPTR] = {RA_NONE, RA_NONE, RA_NONE}, //TODO + [SCMD_MEMREADPTR] = {RA_NONE, RA_NONE, RA_NONE}, //TODO + [SCMD_MEMZEROPTR] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_MEMINITPTR] = {RA_NONE, RA_NONE, RA_NONE}, //TODO + [SCMD_LOADSPOFFS] = {RA_NONE, RA_NONE, RA_WRITE}, + [SCMD_CHECKNULL] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_FADD] = {RA_READWRITE, RA_NONE, RA_NONE}, + [SCMD_FSUB] = {RA_READWRITE, RA_NONE, RA_NONE}, + [SCMD_FMULREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FDIVREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FADDREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FSUBREG] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FGREATER] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FLESSTHAN] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FGTE] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_FLTE] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_ZEROMEMORY] = {RA_NONE, RA_NONE, RA_READ}, + [SCMD_CREATESTRING] = {RA_NONE, RA_NONE, RA_NONE}, //TODO + [SCMD_STRINGSEQUAL] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_STRINGSNOTEQ] = {RA_READWRITE, RA_READ, RA_NONE}, + [SCMD_CHECKNULLREG] = {RA_NONE, RA_NONE, RA_NONE}, //TODO + [SCMD_LOOPCHECKOFF] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_MEMZEROPTRND] = {RA_NONE, RA_NONE, RA_READ}, + [SCMD_JNZ] = {RA_NONE, RA_NONE, RA_NONE}, + [SCMD_DYNAMICBOUNDS] = {RA_NONE, RA_NONE, RA_NONE}, //TODO + [SCMD_NEWARRAY] = {RA_NONE, RA_NONE, RA_NONE}, //TODO }; #ifndef MAX @@ -253,6 +254,7 @@ static void vm_update_register_usage(int *eip) { const struct regaccess_info *ri = ®access_info[*eip]; if(ri->ra_reg1) change_reg_usage(eip[1], ri->ra_reg1); if(ri->ra_reg2) change_reg_usage(eip[2], ri->ra_reg2); + if(ri->ra_mar) change_reg_usage(AR_MAR, ri->ra_mar); } static void write_mem1(int off, int val) { -- 2.11.4.GIT