minivmac4ios/Mini vMac/mnvm_core/M68KITAB.c

1 line
61 KiB
C
Raw Normal View History

2016-05-01 17:05:36 +00:00
/* M68KITAB.c Copyright (C) 2007 Paul C. Pratt You can redistribute this file and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. You should have received a copy of the license along with this file; see the file COPYING. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /* Motorola 68K Instructions TABle */ #ifndef AllFiles #include "SYSDEPNS.h" #endif #include "MYOSGLUE.h" #include "EMCONFIG.h" #include "GLOBGLUE.h" #include "M68KITAB.h" struct WorkR { /* expected size : 8 bytes */ ui5b opcode; ui5b opsize; ui4r MainClass; #if WantCycByPriOp ui4r Cycles; #endif DecOpR DecOp; }; typedef struct WorkR WorkR; #define b76(p) ((p->opcode >> 6) & 3) #define b8(p) ((p->opcode >> 8) & 1) #define mode(p) ((p->opcode >> 3) & 7) #define reg(p) (p->opcode & 7) #define md6(p) ((p->opcode >> 6) & 7) #define rg9(p) ((p->opcode >> 9) & 7) enum { kAddrValidAny, kAddrValidData, kAddrValidDataAlt, kAddrValidControl, kAddrValidControlAlt, kAddrValidAltMem, kNumAddrValids }; #define kAddrValidMaskAny (1 << kAddrValidAny) #define kAddrValidMaskData (1 << kAddrValidData) #define kAddrValidMaskDataAlt (1 << kAddrValidDataAlt) #define kAddrValidMaskControl (1 << kAddrValidControl) #define kAddrValidMaskControlAlt (1 << kAddrValidControlAlt) #define kAddrValidMaskAltMem (1 << kAddrValidAltMem) #define CheckInSet(v, m) (0 != ((1 << (v)) & (m))) #define kMyAvgCycPerInstr (10 * kCycleScale + (40 * kCycleScale / 64)) LOCALFUNC MayNotInline ui3r GetArgkRegSz(WorkR *p) { ui3r CurArgk; switch (p->opsize) { case 1: CurArgk = kArgkRegB; break; case 2: default: /* keep compiler happy */ CurArgk = kArgkRegW; break; case 4: CurArgk = kArgkRegL; break; } return CurArgk; } LOCALFUNC MayNotInline ui3r GetArgkMemSz(WorkR *p) { ui3r CurArgk; switch (p->opsize) { case 1: CurArgk = kArgkMemB; break; case 2: default: /* keep compiler happy */ CurArgk = kArgkMemW; break; case 4: CurArgk = kArgkMemL; break; } return CurArgk; } #if WantCycByPriOp LOCALFUNC MayNotInline ui4r OpEACalcCyc(WorkR *p, ui3r m, ui3r r) { ui4r v; switch (m) { case 0: case 1: v = 0; break; case 2: v = ((4 == p->opsize) ? (8 * kCycleScale + 2 * RdAvgXtraCyc) : (4 * kCycleScale + RdAvgXtraCyc)); break; case 3: v = ((4 == p->opsize) ? (8 * kCycleScale + 2 * RdAvgXtraCyc) : (4 * kCycleScale + RdAvgXtraCyc)); break; case 4: v = ((4 == p->opsize) ? (10 * kCycleScale + 2 * RdAvgXtraCyc) : (6 * kCycleScale + RdAvgXtraCyc)); break; case 5: v = ((4 == p->opsize) ? (12 * kCycleScale + 3 * RdAvgXtraCyc) : (8 * kCycleScale + 2 * RdAvgXtraCyc)); break; case 6: v = ((4 == p->opsize) ? (14 * kCycleScale + 3 * RdAvgXtraCyc) : (10 * kCycleScale + 2 * RdAvgXtraCyc)); break; case 7: switch (r) { case 0: v = ((4 == p->opsize) ? (12 * kCycleScale + 3 * RdAvgXtraCyc) : (8 * kCycleScale + 2 * RdAvgXtraCyc)); break; case 1: v = ((4 == p->opsize) ? (16 * kCycleScale + 4 * RdAvgXtraCyc) : (12 * kCycleScale + 3 * RdAvgXtraCyc)); break; case 2: v = ((4 == p->opsize) ? (12 * kCycleScale + 3 * RdAvgXtraCyc) : (8 * kCycleScale + 2 * RdAvgXtraCyc)); break; case 3: v = ((4 == p->opsize) ? (14 * kCycleScale + 3 * RdAvgXtraCyc) : (10 * kCycleScale + 2 * RdAvgXtraCyc)); break; case 4: v = ((4 == p->opsize) ? (8 * kCycleScale + 2 * RdAvgXtraCyc) : (4 * kCycleScale + RdAvgXtraCyc)); break; default: v = 0; break; } break; default: /* keep compiler happy */ v = 0; break; } return v; } #endif #if WantCycByPriOp LOCALFUNC MayNotInline ui4r OpEADestCalcCyc(WorkR *p, ui3r m, ui3r r) { ui4r v; switch (m) { case 0: ca