support added for many vector operations, associated functional units and prefetches
This commit is contained in:
parent
a0f7fb276d
commit
aed6b8ea20
|
@ -215,6 +215,18 @@ void sendTimerPacket(int tid, bool compulsory) {
|
|||
}
|
||||
}
|
||||
}
|
||||
bool isThreadBeyondNumberOfCores(int threadID)
|
||||
{
|
||||
int index;
|
||||
for(index=0; index < MaxNumActiveThreads; index++)
|
||||
{
|
||||
if(threadMapping[index] == (unsigned int)threadID)
|
||||
return false;
|
||||
if(isThreadActive[index] == false)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
int findThreadMapping(unsigned int id)
|
||||
{
|
||||
int index;
|
||||
|
@ -223,9 +235,10 @@ int findThreadMapping(unsigned int id)
|
|||
if(threadMapping[index] == id)
|
||||
return index;
|
||||
}
|
||||
cout<<"FATAL ERROR : ThreadMapping cannot resolve";
|
||||
fflush(stdout);
|
||||
exit(0);
|
||||
// cout<<"FATAL ERROR : ThreadMapping cannot resolve " << id << endl;
|
||||
return 1;
|
||||
// fflush(stdout);
|
||||
// exit(0);
|
||||
}
|
||||
#define cmp(a) (rtn_name->find(a) != string::npos)
|
||||
|
||||
|
@ -257,10 +270,19 @@ int findParentSegment(long parent)
|
|||
return index;
|
||||
}
|
||||
cout<<"FATAL ERROR--- cannot find parent\n";
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) {
|
||||
cout << "threadstart() : tid = " << threadid << " " << isThreadBeyondNumberOfCores((int)threadid) << endl;
|
||||
if(isThreadBeyondNumberOfCores((int)threadid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(threadid != 45) {
|
||||
return;
|
||||
}
|
||||
|
||||
PIN_MutexLock(&mainLockForPintool);
|
||||
numThreads++;
|
||||
livethreads++;
|
||||
|
@ -294,6 +316,7 @@ VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) {
|
|||
fflush(stdout);
|
||||
pumpingStatus[i] = true;
|
||||
threadid = findThreadMapping(threadid);
|
||||
cout << "app thread mapped to tejas thread " << threadid << endl;
|
||||
tst->onThread_start(threadid);
|
||||
while (tst->analysisFn(threadid, parent, CHILD_START, PIN_GetParentTid()) == -1) {
|
||||
PIN_Yield();
|
||||
|
@ -324,6 +347,9 @@ VOID ThreadFini(THREADID tid, const CONTEXT *ctxt, INT32 flags, VOID *v) {
|
|||
|
||||
//Pass a memory read record
|
||||
VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) {
|
||||
|
||||
if(tid != 45)
|
||||
return;
|
||||
tid= findThreadMapping(tid);
|
||||
if (!isActive(tid))
|
||||
return;
|
||||
|
@ -350,6 +376,9 @@ VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) {
|
|||
// Pass a memory write record
|
||||
VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) {
|
||||
|
||||
if(tid != 45)
|
||||
return;
|
||||
|
||||
tid= findThreadMapping(tid);
|
||||
if (!isActive(tid))
|
||||
return;
|
||||
|
@ -374,6 +403,9 @@ VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) {
|
|||
}
|
||||
|
||||
VOID BrnFun(THREADID tid, ADDRINT tadr, BOOL taken, VOID *ip) {
|
||||
|
||||
if(tid != 45)
|
||||
return;
|
||||
tid= findThreadMapping(tid);
|
||||
if (!isActive(tid))
|
||||
return;
|
||||
|
@ -538,7 +570,23 @@ VOID printip(THREADID tid, VOID *ip, char *asmString) {
|
|||
instructionIgnorePhase = true;
|
||||
}
|
||||
|
||||
if(numInsToSimulate > 0 && totalNumCISC >= (numInsToIgnore + numInsToSimulate))
|
||||
if(numInsToSimulate > 0)
|
||||
{
|
||||
bool subsetDone = false;
|
||||
// for(int i = 0; i < MaxNumActiveThreads; i++)
|
||||
// {
|
||||
// if(numCISC[i] >= (numInsToIgnore + numInsToSimulate))
|
||||
// {
|
||||
// subsetDone = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
if(numCISC[0] >= (numInsToIgnore + numInsToSimulate))
|
||||
{
|
||||
subsetDone = true;
|
||||
}
|
||||
|
||||
if(subsetDone)
|
||||
{
|
||||
// Now, we will write -2 packet in shared memory.
|
||||
// This will ensure that complete emulator (PIN) gets stopped.
|
||||
|
@ -554,6 +602,7 @@ VOID printip(THREADID tid, VOID *ip, char *asmString) {
|
|||
waitForThreadsAndTerminatePin();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(totalNumCISC >= sliceArray[currentSlice] * 3000000)
|
||||
|
@ -664,8 +713,13 @@ void Image(IMG img,VOID *v) {
|
|||
// Pin calls this function every time a new instruction is encountered
|
||||
VOID Instruction(INS ins, VOID *v) {
|
||||
|
||||
//int tid = IARG_THREAD_ID;
|
||||
int tid = IARG_THREAD_ID;
|
||||
//cout << "thread = " << tid << endl;
|
||||
if(isThreadBeyondNumberOfCores(tid))
|
||||
return;
|
||||
|
||||
if(tid != 45)
|
||||
return;
|
||||
|
||||
char *asmChar = NULL;
|
||||
if(traceMethod==File) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class AES implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class BitScan implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
|
||||
public class CPUID implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class FMA implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class FloatVectorALU implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class FloatVectorMul implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class IntegerVectorALU implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class IntegerVectorMul implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class LEA implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
|
||||
public class LFence implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class LoadAGU implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
|
||||
public class MFence implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
|
||||
public class ReadPrefetch implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
long memoryReadAddress;
|
||||
memoryReadAddress = dynamicInstructionBuffer.
|
||||
getSingleLoadAddress(microOp.getCISCProgramCounter());
|
||||
|
||||
if(memoryReadAddress != -1)
|
||||
{
|
||||
microOp.setSourceOperand1MemValue(memoryReadAddress);
|
||||
return ++microOpIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
|
||||
public class SFence implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class StoreAGU implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class VectorFMA implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class VectorShuffle implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionTable;
|
||||
|
||||
public class VectorString implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
//nothing to be done in such cases
|
||||
return ++microOpIndex;
|
||||
}
|
||||
}
|
|
@ -12,14 +12,31 @@ public class VisaHandlerSelector
|
|||
private static DynamicInstructionHandler floatALU;
|
||||
private static DynamicInstructionHandler floatMul;
|
||||
private static DynamicInstructionHandler floatDiv;
|
||||
private static DynamicInstructionHandler integerVectorALU;
|
||||
private static DynamicInstructionHandler integerVectorMul;
|
||||
private static DynamicInstructionHandler floatVectorALU;
|
||||
private static DynamicInstructionHandler floatVectorMul;
|
||||
private static DynamicInstructionHandler FMA;
|
||||
private static DynamicInstructionHandler vectorFMA;
|
||||
private static DynamicInstructionHandler loadAGU;
|
||||
private static DynamicInstructionHandler load;
|
||||
private static DynamicInstructionHandler storeAGU;
|
||||
private static DynamicInstructionHandler store;
|
||||
private static DynamicInstructionHandler jump;
|
||||
private static DynamicInstructionHandler branch;
|
||||
private static DynamicInstructionHandler mov;
|
||||
private static DynamicInstructionHandler xchg;
|
||||
private static DynamicInstructionHandler AES;
|
||||
private static DynamicInstructionHandler vectorString;
|
||||
private static DynamicInstructionHandler bitScan;
|
||||
private static DynamicInstructionHandler vectorShuffle;
|
||||
private static DynamicInstructionHandler LEA;
|
||||
private static DynamicInstructionHandler acceleratedOp;
|
||||
private static DynamicInstructionHandler nop;
|
||||
private static DynamicInstructionHandler cpuid;
|
||||
private static DynamicInstructionHandler mfence;
|
||||
private static DynamicInstructionHandler sfence;
|
||||
private static DynamicInstructionHandler lfence;
|
||||
private static DynamicInstructionHandler readprefetch;
|
||||
private static DynamicInstructionHandler writeprefetch;
|
||||
private static DynamicInstructionHandler interrupt;
|
||||
|
||||
public static DynamicInstructionHandler selectHandler(OperationType operationType)
|
||||
|
@ -54,9 +71,33 @@ public class VisaHandlerSelector
|
|||
case floatDiv:
|
||||
return floatDiv;
|
||||
|
||||
case integerVectorALU:
|
||||
return integerVectorALU;
|
||||
|
||||
case integerVectorMul:
|
||||
return integerVectorMul;
|
||||
|
||||
case floatVectorALU:
|
||||
return floatVectorALU;
|
||||
|
||||
case floatVectorMul:
|
||||
return floatVectorMul;
|
||||
|
||||
case FMA:
|
||||
return FMA;
|
||||
|
||||
case vectorFMA:
|
||||
return vectorFMA;
|
||||
|
||||
case loadAGU:
|
||||
return loadAGU;
|
||||
|
||||
case load:
|
||||
return load;
|
||||
|
||||
case storeAGU:
|
||||
return storeAGU;
|
||||
|
||||
case store:
|
||||
return store;
|
||||
|
||||
|
@ -66,15 +107,42 @@ public class VisaHandlerSelector
|
|||
case branch:
|
||||
return branch;
|
||||
|
||||
case mov:
|
||||
return mov;
|
||||
case AES:
|
||||
return AES;
|
||||
|
||||
case xchg:
|
||||
return xchg;
|
||||
case vectorString:
|
||||
return vectorString;
|
||||
|
||||
case bitScan:
|
||||
return bitScan;
|
||||
|
||||
case vectorShuffle:
|
||||
return vectorShuffle;
|
||||
|
||||
case LEA:
|
||||
return LEA;
|
||||
|
||||
case acceleratedOp:
|
||||
return acceleratedOp;
|
||||
|
||||
case cpuid:
|
||||
return cpuid;
|
||||
|
||||
case mfence:
|
||||
return mfence;
|
||||
|
||||
case sfence:
|
||||
return sfence;
|
||||
|
||||
case lfence:
|
||||
return lfence;
|
||||
|
||||
case read_prefetch:
|
||||
return readprefetch;
|
||||
|
||||
case write_prefetch:
|
||||
return writeprefetch;
|
||||
|
||||
case nop:
|
||||
return nop;
|
||||
|
||||
|
@ -97,14 +165,31 @@ public class VisaHandlerSelector
|
|||
floatALU = new FloatALU();
|
||||
floatMul = new FloatMul();
|
||||
floatDiv = new FloatDiv();
|
||||
integerVectorALU = new IntegerVectorALU();
|
||||
integerVectorMul = new IntegerVectorMul();
|
||||
floatVectorALU = new FloatVectorALU();
|
||||
floatVectorMul = new FloatVectorMul();
|
||||
FMA = new FMA();
|
||||
vectorFMA = new VectorFMA();
|
||||
loadAGU = new LoadAGU();
|
||||
load = new Load();
|
||||
storeAGU = new StoreAGU();
|
||||
store = new Store();
|
||||
jump = new Jump();
|
||||
branch = new Branch();
|
||||
mov = new Mov();
|
||||
xchg = new Xchg();
|
||||
AES = new AES();
|
||||
vectorString = new VectorString();
|
||||
bitScan = new BitScan();
|
||||
vectorShuffle = new VectorShuffle();
|
||||
LEA = new LEA();
|
||||
acceleratedOp = new AcceleratedOp();
|
||||
nop = new NOP();
|
||||
cpuid = new CPUID();
|
||||
mfence = new MFence();
|
||||
sfence = new SFence();
|
||||
lfence = new LFence();
|
||||
readprefetch = new ReadPrefetch();
|
||||
writeprefetch = new WritePrefetch();
|
||||
interrupt = new Interrupt();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package emulatorinterface.translator.visaHandler;
|
||||
|
||||
import emulatorinterface.DynamicInstructionBuffer;
|
||||
import generic.Instruction;
|
||||
|
||||
public class WritePrefetch implements DynamicInstructionHandler
|
||||
{
|
||||
public int handle(int microOpIndex,
|
||||
Instruction microOp, DynamicInstructionBuffer dynamicInstructionBuffer)
|
||||
{
|
||||
long memoryWriteAddress;
|
||||
memoryWriteAddress = dynamicInstructionBuffer.
|
||||
getSingleStoreAddress(microOp.getCISCProgramCounter());
|
||||
|
||||
if(memoryWriteAddress!=-1)
|
||||
{
|
||||
microOp.setSourceOperand1MemValue(memoryWriteAddress);
|
||||
return ++microOpIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class AES implements X86StaticInstructionHandler{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 != null && operand1.isFloatRegisterOperand()
|
||||
&& operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand())
|
||||
&& (operand3 == null || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand())
|
||||
&& (!(operand2.isMemoryOperand() && operand3.isMemoryOperand())))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
if(operand3 == null)
|
||||
{
|
||||
srcOpnd1 = operand1;
|
||||
if(operand2.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd1 = operand2;
|
||||
if(operand3.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
}
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getAES(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
else if(operand1 != null && operand1.isFloatRegisterOperand()
|
||||
&& operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand())
|
||||
&& operand3 == null)
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
destOpnd = operand1;
|
||||
if(operand2.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd1 = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd1 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
srcOpnd2 = null;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getAES(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("AES with two source operands ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class AccumulatorAdjustments implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if((operand1==null || operand1.isImmediateOperand()) && operand2==null && operand3==null)
|
||||
{
|
||||
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
||||
|
||||
//Perform integer alu operation
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
||||
null, accumulatorRegister, accumulatorRegister));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("accumulator adjustments ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class BitScan implements X86StaticInstructionHandler{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 != null && operand1.isFloatRegisterOperand()
|
||||
&& operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand())
|
||||
&& operand3 == null)
|
||||
{
|
||||
Operand srcOpnd1, destOpnd;
|
||||
|
||||
destOpnd = operand1;
|
||||
if(operand2.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd1 = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd1 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getBitScan(srcOpnd1, destOpnd));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("bit scan ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,20 +21,19 @@
|
|||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class FloatingPointComplexOperation implements X86StaticInstructionHandler
|
||||
public class CPUID implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
InstructionList instructionArrayList, TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//TODO : Must do something !!
|
||||
instructionArrayList.appendInstruction(Instruction.getCPUIDInstruction());
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.InstructionList;
|
||||
import generic.Operand;
|
||||
|
@ -41,14 +42,14 @@ public class Call implements X86StaticInstructionHandler
|
|||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//push the next instruction pointer on to the stack
|
||||
//TODO Check if the NEXT_INSTRUCTION can be computed
|
||||
Operand nextInstruction = Operand.getImmediateOperand();
|
||||
new Push().handle(instructionPointer, nextInstruction, null, null, instructionArrayList, tempRegisterNum);
|
||||
|
||||
if((operand1.isImmediateOperand() || operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand())
|
||||
&& operand2==null && operand3==null)
|
||||
{
|
||||
//push the next instruction pointer on to the stack
|
||||
//TODO Check if the NEXT_INSTRUCTION can be computed
|
||||
Operand nextInstruction = Registers.getInstructionPointer();
|
||||
new Push().handle(instructionPointer, nextInstruction, null, null, instructionArrayList, tempRegisterNum);
|
||||
|
||||
//Unconditional jump to a new location
|
||||
(new UnconditionalJump()).handle(instructionPointer, operand1, null, null, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class CmpExchange implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||
(operand2.isIntegerRegisterOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
Operand operand1ValueOperand;
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1ValueOperand = operand1;
|
||||
}
|
||||
|
||||
//compare
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1ValueOperand, operand2, Registers.getEFlagsRegister()));
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* currently implementing both the success and failure outcomes of the comparison
|
||||
* in reality, only one of the outcomes can happen dynamically
|
||||
*/
|
||||
|
||||
//if equal
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, null, operand1));
|
||||
}
|
||||
|
||||
//if not equal
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
OperandTranslator.processSourceMemoryOperand(operand1, Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, null, Registers.getAccumulatorRegister()));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class CmpExchangeByte implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isMemoryOperand()) &&
|
||||
(operand2 == null) &&
|
||||
(operand3==null))
|
||||
{
|
||||
Operand operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
//compare
|
||||
Operand tempComparisonResult = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getAccumulatorRegister(), operand1ValueOperand, tempComparisonResult));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), tempComparisonResult, Registers.getEFlagsRegister()));
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* currently implementing both the success and failure outcomes of the comparison
|
||||
* in reality, only one of the outcomes can happen dynamically
|
||||
*/
|
||||
|
||||
//if equal
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getCounterRegister(), operand1, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getBaseIndexRegister(), operand1, instructionArrayList, tempRegisterNum);
|
||||
|
||||
//if not equal
|
||||
OperandTranslator.processSourceMemoryOperand(operand1, Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(operand1, Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
@ -40,14 +41,13 @@ public class ConditionalJump implements X86StaticInstructionHandler
|
|||
&& operand2==null && operand3==null)
|
||||
{
|
||||
jumpLocation = operand1;
|
||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation));
|
||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation, Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else if(operand1.isMemoryOperand() && operand2==null && operand3==null)
|
||||
{
|
||||
jumpLocation = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, jumpLocation));
|
||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation));
|
||||
jumpLocation = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation, Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class ConditionalLoop implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1.isImmediateOperand() && operand2==null && operand3==null)
|
||||
{
|
||||
Operand counterRegister = Registers.getCounterRegister();
|
||||
|
||||
//cx=cx-1
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(counterRegister,
|
||||
Registers.getEFlagsRegister(), counterRegister));
|
||||
|
||||
//Perform a conditional jump
|
||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(operand1, Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Loop", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
|
@ -42,7 +44,7 @@ public class ConditionalMove implements X86StaticInstructionHandler
|
|||
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1, operand2));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, Registers.getEFlagsRegister(), operand1));
|
||||
}
|
||||
|
||||
//if operand1 = register and operand2 = memory - load
|
||||
|
@ -50,25 +52,26 @@ public class ConditionalMove implements X86StaticInstructionHandler
|
|||
operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand1));
|
||||
Operand sourceOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceOperand, Registers.getEFlagsRegister(), operand1));
|
||||
}
|
||||
|
||||
//if operand1 = memory and operand2 = memory - store
|
||||
else if((operand1.isMemoryOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand2, operand1));
|
||||
}
|
||||
|
||||
//TODO I doubt if this is a valid instruction !! Anyways found this in an object-code
|
||||
//operand1 can be a data-stored in memory and operand2 can be immediate/register.
|
||||
//first, we load the value at location into temporary register
|
||||
//Then we will store op2 to [temporary-register]
|
||||
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() && operand3==null)
|
||||
{
|
||||
misc.Error.invalidOperation("Conditional Move", operand1, operand2, operand3);
|
||||
}
|
||||
// //if operand1 = memory and operand2 = memory - store
|
||||
// else if((operand1.isMemoryOperand()) &&
|
||||
// (operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) &&
|
||||
// (operand3==null))
|
||||
// {
|
||||
// instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand2, operand1));
|
||||
// }
|
||||
//
|
||||
// //TODO I doubt if this is a valid instruction !! Anyways found this in an object-code
|
||||
// //operand1 can be a data-stored in memory and operand2 can be immediate/register.
|
||||
// //first, we load the value at location into temporary register
|
||||
// //Then we will store op2 to [temporary-register]
|
||||
// else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() && operand3==null)
|
||||
// {
|
||||
// misc.Error.invalidOperation("Conditional Move", operand1, operand2, operand3);
|
||||
// }
|
||||
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
|
@ -17,14 +18,14 @@ public class ConditionalSet implements X86StaticInstructionHandler
|
|||
if((operand1.isIntegerRegisterOperand()) &&
|
||||
operand2==null && operand3==null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1,
|
||||
Operand.getImmediateOperand()));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(),
|
||||
Operand.getImmediateOperand(), operand1));
|
||||
}
|
||||
|
||||
else if(operand1.isMemoryOperand())
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1,
|
||||
Operand.getImmediateOperand()));
|
||||
Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.InstructionList;
|
||||
|
@ -36,39 +37,46 @@ public class Exchange implements X86StaticInstructionHandler
|
|||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//operand1 is a register and operand2 is also a register
|
||||
if((operand1.isIntegerRegisterOperand()) &&
|
||||
(operand2.isIntegerRegisterOperand())&&
|
||||
operand3==null)
|
||||
if((operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand())
|
||||
&& (operand2 == null || operand2.isIntegerRegisterOperand())
|
||||
&& operand3 == null
|
||||
&& (!(operand1.isMemoryOperand() && operand2 == null)))
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getExchangeInstruction(operand1, operand2));
|
||||
Operand operand1Value;
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1Value = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1Value = operand1;
|
||||
}
|
||||
|
||||
//operand1 is memory operand and operand2 is a register
|
||||
else if((operand1.isMemoryOperand() || operand1.isIntegerRegisterOperand()) &&
|
||||
(operand2.isMemoryOperand() || operand2.isIntegerRegisterOperand()) &&
|
||||
operand3==null)
|
||||
Operand operand2Reg;
|
||||
if(operand2.isIntegerRegisterOperand())
|
||||
{
|
||||
Operand memLocation = null, tempRegister = null, register = null;
|
||||
|
||||
tempRegister = Registers.getTempIntReg(tempRegisterNum);
|
||||
|
||||
if(operand1.isMemoryOperand() && !operand2.isMemoryOperand()) {
|
||||
memLocation = operand1;
|
||||
register = operand2;
|
||||
} else if(operand2.isMemoryOperand() && !operand1.isMemoryOperand()) {
|
||||
memLocation = operand2;
|
||||
register = operand1;
|
||||
} else {
|
||||
misc.Error.invalidOperation("Exchange", operand1, operand2, operand3);
|
||||
operand2Reg = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2Reg = Registers.getAccumulatorRegister();
|
||||
}
|
||||
|
||||
//temp = mem
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(memLocation, tempRegister));
|
||||
//mem = reg
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(memLocation, register));
|
||||
// reg = temp
|
||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(register, tempRegister));
|
||||
Operand temp = Registers.getTempIntReg(tempRegisterNum);
|
||||
|
||||
//temp = operand2
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2Reg, null, temp));
|
||||
//operand2 = operand1
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1Value, null, operand2Reg));
|
||||
//operand1 = temp
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(temp, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(temp, null, operand1));
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -22,8 +22,11 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class ExchangeAndAdd implements X86StaticInstructionHandler
|
||||
|
@ -34,12 +37,39 @@ public class ExchangeAndAdd implements X86StaticInstructionHandler
|
|||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//TODO Check if the add should be performed before exchange ??
|
||||
Exchange exchange = new Exchange();
|
||||
exchange.handle(instructionPointer, operand1, operand2, operand3, instructionArrayList, tempRegisterNum);
|
||||
if(operand1.isMemoryOperand() && operand2.isIntegerRegisterOperand() && operand3 == null)
|
||||
{
|
||||
Operand memoryOpnd = operand1;
|
||||
Operand registerOpnd = operand2;
|
||||
|
||||
//Perhaps the order will now change.
|
||||
IntegerALUImplicitDestination addOperation = new IntegerALUImplicitDestination();
|
||||
addOperation.handle(instructionPointer, operand2, operand1, operand3, instructionArrayList, tempRegisterNum);
|
||||
// memValueTemp = [memoryOpnd]
|
||||
Operand memValueTemp = OperandTranslator.processSourceMemoryOperand(memoryOpnd, instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
// sumTemp = registerOpnd + memValueTemp
|
||||
Operand sumTemp = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(registerOpnd, memValueTemp, sumTemp));
|
||||
|
||||
// [memoryOpnd] = sumTemp
|
||||
OperandTranslator.processDestinationMemoryOperand(sumTemp, memoryOpnd, instructionArrayList, tempRegisterNum);
|
||||
|
||||
// registerOpnd = memValueTemp
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(memValueTemp, null, registerOpnd));
|
||||
}
|
||||
else if(operand1.isIntegerRegisterOperand() && operand2.isIntegerRegisterOperand() && operand3 == null) /*both operands are registers*/
|
||||
{
|
||||
// sumTemp = sourceReg + destReg
|
||||
Operand sumTemp = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, operand2, sumTemp));
|
||||
|
||||
// sourceReg = destReg
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, null, operand2));
|
||||
|
||||
// destReg = sumTemp
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sumTemp, null, operand1));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Exchange and Add ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,9 @@ import emulatorinterface.translator.x86.registers.Registers;
|
|||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionLinkedList;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class SingleOperandIntALUImplicitAccumulator implements X86StaticInstructionHandler
|
||||
public class ExtendEAXToEDX implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -38,26 +37,19 @@ public class SingleOperandIntALUImplicitAccumulator implements X86StaticInstruct
|
|||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
if((operand1==null || operand1.isImmediateOperand()) && operand2==null && operand3==null)
|
||||
{
|
||||
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
||||
|
||||
//Perform integer alu operation
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
||||
null, accumulatorRegister, Registers.getDataRegister()));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
||||
null, accumulatorRegister, accumulatorRegister));
|
||||
}
|
||||
else if(operand1.isImmediateOperand() && operand2==null && operand3==null)
|
||||
|
||||
{
|
||||
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
||||
|
||||
//Perform integer alu operation
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
||||
operand1, accumulatorRegister, accumulatorRegister));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer ALU Operation involving an implicit accumulator", operand1, operand2, operand3);
|
||||
misc.Error.invalidOperation("extending eax to edx:eax ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class FMA implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFMA(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFMA(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Scalar FMA ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
import generic.Operand;
|
||||
|
||||
public class FlagsLoad implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 == null && operand2 == null && operand3 == null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getAccumulatorRegister(), null, Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Flags Load ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
import generic.Operand;
|
||||
|
||||
public class FlagsModWithSrc implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 == null && operand2 == null && operand3 == null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), null, Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Flags Mod With Src", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
import generic.Operand;
|
||||
|
||||
public class FlagsModWithoutSrc implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 == null && operand2 == null && operand3 == null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(null, null, Registers.getEFlagsRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Flags Mod Without Src", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
import generic.Operand;
|
||||
|
||||
public class FlagsStore implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 == null && operand2 == null && operand3 == null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(), null, Registers.getAccumulatorRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Flags Store ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class FloatALU implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Float ALU ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class FloatCmp implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = Registers.getEFlagsRegister();
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("float compare ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class FloatDiv implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Float Div ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,13 +23,14 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class Move implements X86StaticInstructionHandler
|
||||
public class FloatMove implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -38,30 +39,30 @@ public class Move implements X86StaticInstructionHandler
|
|||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if( (operand1.isIntegerRegisterOperand()) &&
|
||||
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||
if( (operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) &&
|
||||
(operand2.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1, operand2));
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand2, null, operand1));
|
||||
}
|
||||
|
||||
|
||||
//if operand1 is register and operand2 is a memory-operand, we will use load operation
|
||||
else if((operand1.isIntegerRegisterOperand()) &&
|
||||
else if((operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) &&
|
||||
operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
//Obtain value at the memory location [operand2]
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand1));
|
||||
OperandTranslator.processSourceMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
//if the operand1 is a memory location and operand2 is a register/immediate then
|
||||
//it is a store operation
|
||||
else if((operand1.isMemoryOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isFloatRegisterOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, operand2));
|
||||
OperandTranslator.processDestinationMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
//TODO I doubt if this is a valid instruction !! Anyways found this in an object-code
|
||||
|
@ -72,12 +73,12 @@ public class Move implements X86StaticInstructionHandler
|
|||
operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
misc.Error.invalidOperation("Move", operand1, operand2, operand3);
|
||||
misc.Error.invalidOperation("Float Move", operand1, operand2, operand3);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Move", operand1, operand2, operand3);
|
||||
misc.Error.invalidOperation("Float Move", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class FloatMul implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointMultiplication(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointMultiplication(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Float Mul ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,18 +23,26 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
public enum InstructionClass
|
||||
{
|
||||
INTEGER_ALU_IMPLICIT_DESTINATION,
|
||||
INTEGER_ALU_NO_IMPLICIT_DESTINATION,
|
||||
SINGLE_OPERAND_INTEGER_ALU,
|
||||
SINGLE_OPERAND_INTEGER_ALU_IMPLICIT_ACCUMULATOR,
|
||||
INTEGER_ALU,
|
||||
INTEGER_ALU_NO_FLAG_MOD,
|
||||
INTEGER_ALU_USES_FLAGS,
|
||||
INTEGER_COMPARE_TEST,
|
||||
INTEGER_COMPARE_TEST_SET,
|
||||
EXTEND_EAX_TO_EDX,
|
||||
ACCUMULATOR_ADJUSTMENTS,
|
||||
SHIFT_OPERATION_THREE_OPERANDS,
|
||||
MOVE,
|
||||
INTEGER_MOVE,
|
||||
INTEGER_MOVE_ACCUMULATOR,
|
||||
FLOAT_MOVE,
|
||||
CONDITIONAL_MOVE,
|
||||
EXCHANGE,
|
||||
CMP_XCHG,
|
||||
CMP_XCHG_BYTE,
|
||||
EXCHANGE_AND_ADD,
|
||||
CONDITIONAL_JUMP,
|
||||
UNCONDITIONAL_JUMP,
|
||||
LOOP,
|
||||
CONDITIONAL_LOOP,
|
||||
UNCONDITIONAL_LOOP,
|
||||
NOP,
|
||||
INTEGER_MULTIPLICATION,
|
||||
INTEGER_DIVISION,
|
||||
|
@ -45,7 +53,11 @@ public enum InstructionClass
|
|||
|
||||
//Stack Operations
|
||||
PUSH,
|
||||
PUSH_ALL,
|
||||
PUSH_FLAGS,
|
||||
POP,
|
||||
POP_ALL,
|
||||
POP_FLAGS,
|
||||
CALL,
|
||||
RETURN,
|
||||
LEAVE,
|
||||
|
@ -53,8 +65,16 @@ public enum InstructionClass
|
|||
|
||||
//String Operations
|
||||
STRING_MOVE,
|
||||
STRING_LOAD,
|
||||
STRING_STORE,
|
||||
STRING_COMPARE,
|
||||
STRING_COMPARE_ACCUMULATOR,
|
||||
|
||||
//flag mods
|
||||
FLAGS_MOD_WITHOUT_SRC,
|
||||
FLAGS_MOD_WITH_SRC,
|
||||
FLAGS_STORE,
|
||||
FLAGS_LOAD,
|
||||
|
||||
//Floating Point operations
|
||||
FLOATING_POINT_LOAD_CONSTANT,
|
||||
|
@ -63,28 +83,65 @@ public enum InstructionClass
|
|||
FLOATING_POINT_MULTIPLICATION,
|
||||
FLOATING_POINT_DIVISION,
|
||||
FLOATING_POINT_ALU,
|
||||
FLOATING_POINT_SINGLE_OPERAND_ALU,
|
||||
FLOATING_POINT_NO_OPERAND_ALU,
|
||||
FLOATING_POINT_EXCHANGE,
|
||||
FLOATING_POINT_COMPLEX_OPERATION,
|
||||
FLOATING_POINT_COMPARE,
|
||||
FLOATING_POINT_CONDITIONAL_MOVE,
|
||||
FLOATING_POINT_LOAD_CONTROL_WORD,
|
||||
FLOATING_POINT_STORE_CONTROL_WORD,
|
||||
FLOATING_POINT_EXAMINE,
|
||||
|
||||
//Convert operations
|
||||
CONVERT_FLOAT_TO_PACKED_INTEGER,
|
||||
CONVERT_FLOAT_TO_INTEGER,
|
||||
CONVERT_PACKED_INTEGER_TO_FLOAT,
|
||||
CONVERT_INTEGER_TO_FLOAT,
|
||||
CONVERT_FLOAT_TO_FLOAT,
|
||||
|
||||
//Not Handled
|
||||
REPEAT,
|
||||
LOCK,
|
||||
|
||||
//TODO SSE Instructions
|
||||
SSE_MOVE,
|
||||
SSE_ALU,
|
||||
SSE_MULTIPLICATION,
|
||||
SSE_DIVISION,
|
||||
SSE_COMPARE_PACKED_DATA,
|
||||
//SSE Instructions
|
||||
SSE_INTEGER,
|
||||
SSE_INTEGER_MUL_ADD,
|
||||
SSE_INTEGER_COMPARE,
|
||||
SSE_INTEGER_MUL,
|
||||
SSE_STORE,
|
||||
SSE_FLOAT,
|
||||
SSE_FMA,
|
||||
SSE_FLOAT_COMPARE,
|
||||
SSE_FLOAT_MUL,
|
||||
SSE_FLOAT_DIV,
|
||||
|
||||
//Float
|
||||
FLOAT_ALU,
|
||||
FMA,
|
||||
FLOAT_COMPARE,
|
||||
FLOAT_COMPARE_EXPLICIT_DEST,
|
||||
FLOAT_MUL,
|
||||
FLOAT_DIV,
|
||||
LOAD_MXCSR,
|
||||
STORE_MXCSR,
|
||||
|
||||
AES,
|
||||
VECTOR_STRING_DEST_ECX,
|
||||
VECTOR_STRING_DEST_XMM0,
|
||||
BIT_SCAN,
|
||||
VECTOR_SHUFFLE,
|
||||
SQRT,
|
||||
|
||||
CPUID,
|
||||
INTERRUPT_RETURN,
|
||||
MFENCE,
|
||||
SFENCE,
|
||||
LFENCE,
|
||||
|
||||
READ_PREFETCH_L1,
|
||||
READ_PREFETCH_L2,
|
||||
READ_PREFETCH_L3,
|
||||
WRITE_PREFETCH,
|
||||
|
||||
INVALID,
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,127 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerALU implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()))
|
||||
{
|
||||
Operand operand1ValueOperand;
|
||||
Operand operand2ValueOperand;
|
||||
Operand operand3ValueOperand;
|
||||
|
||||
//get value-operand for operand1
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1ValueOperand = operand1;
|
||||
}
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand2 != null)
|
||||
{
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2ValueOperand = operand2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2ValueOperand = null;
|
||||
}
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand3 != null)
|
||||
{
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
operand3ValueOperand = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand3ValueOperand = operand3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operand3ValueOperand = null;
|
||||
}
|
||||
|
||||
//Perform integer alu operation
|
||||
if(operand3ValueOperand == null)
|
||||
{
|
||||
/* TODO using integer ALU to set flags is not entirely right */
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand1ValueOperand, Registers.getEFlagsRegister()));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand1ValueOperand, operand1ValueOperand));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TODO using integer ALU to set flags is not entirely right */
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand3ValueOperand, Registers.getEFlagsRegister()));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand3ValueOperand, operand1ValueOperand));
|
||||
}
|
||||
|
||||
|
||||
//If operand1 is a memory operand, then perform a store operation too
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(operand1ValueOperand, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerALUNoFlagMod implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()))
|
||||
{
|
||||
Operand operand1ValueOperand;
|
||||
Operand operand2ValueOperand;
|
||||
Operand operand3ValueOperand;
|
||||
|
||||
//get value-operand for operand1
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1ValueOperand = operand1;
|
||||
}
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand2 != null)
|
||||
{
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2ValueOperand = operand2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2ValueOperand = null;
|
||||
}
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand3 != null)
|
||||
{
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
operand3ValueOperand = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand3ValueOperand = operand3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operand3ValueOperand = null;
|
||||
}
|
||||
|
||||
//Perform integer alu operation
|
||||
if(operand3ValueOperand == null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand1ValueOperand, operand1ValueOperand));
|
||||
}
|
||||
else
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand3ValueOperand, operand1ValueOperand));
|
||||
}
|
||||
|
||||
|
||||
//If operand1 is a memory operand, then perform a store operation too
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(operand1ValueOperand, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,127 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerALUUsesFlags implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()))
|
||||
{
|
||||
Operand operand1ValueOperand;
|
||||
Operand operand2ValueOperand;
|
||||
Operand operand3ValueOperand;
|
||||
|
||||
//get value-operand for operand1
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1ValueOperand = operand1;
|
||||
}
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand2 != null)
|
||||
{
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2ValueOperand = operand2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operand2ValueOperand = null;
|
||||
}
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand3 != null)
|
||||
{
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
operand3ValueOperand = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand3ValueOperand = operand3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
operand3ValueOperand = null;
|
||||
}
|
||||
|
||||
//Perform integer alu operation
|
||||
if(operand3ValueOperand == null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand1ValueOperand, operand1ValueOperand));
|
||||
/* TODO using integer ALU to use flags is not entirely right */
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(),
|
||||
operand1ValueOperand, operand1ValueOperand));
|
||||
}
|
||||
else
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand3ValueOperand, operand1ValueOperand));
|
||||
/* TODO using integer ALU to use flags is not entirely right */
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(),
|
||||
operand1ValueOperand, operand1ValueOperand));
|
||||
}
|
||||
|
||||
|
||||
//If operand1 is a memory operand, then perform a store operation too
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(operand1ValueOperand, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer operation ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,13 +24,14 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerALUExplicitDestination implements X86StaticInstructionHandler
|
||||
public class IntegerCompareTest implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -49,20 +50,17 @@ public class IntegerALUExplicitDestination implements X86StaticInstructionHandle
|
|||
//get value-operand for operand1
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1ValueOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, operand1ValueOperand));
|
||||
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1ValueOperand = operand1;
|
||||
}
|
||||
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
operand2ValueOperand = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand2ValueOperand));
|
||||
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,11 +68,11 @@ public class IntegerALUExplicitDestination implements X86StaticInstructionHandle
|
|||
}
|
||||
|
||||
//Perform integer alu operation
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, null));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, Registers.getEFlagsRegister()));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer ALU operation with no implicit destination operand", operand1, operand2, operand3);
|
||||
misc.Error.invalidOperation("Integer compare or test ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,16 +22,16 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerALUImplicitDestination implements X86StaticInstructionHandler
|
||||
public class IntegerCompareTestSet implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -40,7 +40,7 @@ public class IntegerALUImplicitDestination implements X86StaticInstructionHandle
|
|||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||
(operand1.isImmediateOperand() || operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
|
@ -50,20 +50,17 @@ public class IntegerALUImplicitDestination implements X86StaticInstructionHandle
|
|||
//get value-operand for operand1
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
operand1ValueOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, operand1ValueOperand));
|
||||
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
operand1ValueOperand = operand1;
|
||||
}
|
||||
|
||||
|
||||
//get value-operand for operand2
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
operand2ValueOperand = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand2ValueOperand));
|
||||
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -71,20 +68,24 @@ public class IntegerALUImplicitDestination implements X86StaticInstructionHandle
|
|||
}
|
||||
|
||||
//Perform integer alu operation
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
||||
operand1ValueOperand, operand1ValueOperand));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, Registers.getEFlagsRegister()));
|
||||
|
||||
|
||||
//If operand1 is a memory operand, then perform a store operation too
|
||||
/* using a second intALU micro-op to set the destination
|
||||
* this is an approximation
|
||||
*/
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, operand1ValueOperand));
|
||||
//instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, operand1ValueOperand));
|
||||
OperandTranslator.processDestinationMemoryOperand(operand1ValueOperand, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer operation with implicit operands", operand1, operand2, operand3);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, operand1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer test and set ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -48,19 +48,20 @@ public class IntegerDivision implements X86StaticInstructionHandler
|
|||
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
dividend = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
|
||||
//dividend = [operand1]
|
||||
instructionArrayList.appendInstruction(
|
||||
Instruction.getLoadInstruction(operand1, dividend));
|
||||
dividend = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
dividend = operand1;
|
||||
}
|
||||
|
||||
/*
|
||||
* divide EDX:EAX by dividend
|
||||
* quotient in EAX
|
||||
* remainder in EDX
|
||||
*/
|
||||
instructionArrayList.appendInstruction(Instruction.getIntegerDivisionInstruction
|
||||
(dividend, accumulatorRegister, accumulatorRegister));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(accumulatorRegister, Registers.getDataRegister(), Registers.getDataRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerMove implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if( (operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) &&
|
||||
(operand2.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, null, operand1));
|
||||
}
|
||||
|
||||
|
||||
//if operand1 is register and operand2 is a memory-operand, we will use load operation
|
||||
else if((operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) &&
|
||||
operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
//Obtain value at the memory location [operand2]
|
||||
OperandTranslator.processSourceMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
//if the operand1 is a memory location and operand2 is a register/immediate then
|
||||
//it is a store operation
|
||||
else if((operand1.isMemoryOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isFloatRegisterOperand()) &&
|
||||
(operand3==null))
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(operand2, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
//TODO I doubt if this is a valid instruction !! Anyways found this in an object-code
|
||||
//operand1 can be a data-stored in memory and operand2 can be immediate/register.
|
||||
//first, we load the value at location into temporary register
|
||||
//Then we will store op2 to [temporary-register]
|
||||
else if(operand1.isMemoryOperand() &&
|
||||
operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
misc.Error.invalidOperation("Integer Move", operand1, operand2, operand3);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer Move", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class IntegerMoveAccumulator implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if( (operand1.isMemoryOperand()) &&
|
||||
(operand2 == null) &&
|
||||
(operand3==null))
|
||||
{
|
||||
OperandTranslator.processSourceMemoryOperand(operand1, Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer Move Accumulator ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -49,8 +49,7 @@ public class IntegerMultiplication implements X86StaticInstructionHandler
|
|||
//if operand1 is a memory operand, then we must first fetch the value at its location
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
multiplier = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, multiplier));
|
||||
multiplier = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -59,22 +58,28 @@ public class IntegerMultiplication implements X86StaticInstructionHandler
|
|||
|
||||
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
||||
|
||||
/*
|
||||
* EAX is multiplied by multiplier
|
||||
* lower significant bits in EAX
|
||||
* higher significant bits in EDX
|
||||
*/
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction
|
||||
(accumulatorRegister, multiplier, accumulatorRegister));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(accumulatorRegister, multiplier, Registers.getDataRegister()));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isIntegerRegisterOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
operand3==null)
|
||||
(operand3==null || operand3.isImmediateOperand()))
|
||||
{
|
||||
multiplicand = operand1;
|
||||
|
||||
//if operand1 is a memory operand, then we must first fetch the value at its location
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
multiplier = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, multiplier));
|
||||
multiplier = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -85,31 +90,7 @@ public class IntegerMultiplication implements X86StaticInstructionHandler
|
|||
//perform multiplication operation and store the result in operand1
|
||||
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction
|
||||
(multiplicand, multiplier, multiplicand));
|
||||
}
|
||||
|
||||
|
||||
//If all the three operands are valid, then the operand1 is a general register,
|
||||
//operand2 is a general register or memory-value and operand3 must be an immediate value
|
||||
else if(
|
||||
(operand1.isIntegerRegisterOperand()) &&
|
||||
(operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
operand3.isImmediateOperand())
|
||||
{
|
||||
multiplier = operand3;
|
||||
|
||||
//if operand1 is a memory operand, then we must first fetch the value at its location
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
multiplicand = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, multiplicand));
|
||||
}
|
||||
else
|
||||
{
|
||||
multiplicand = operand2;
|
||||
}
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction(
|
||||
multiplicand, multiplier, operand1));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(multiplicand, multiplier, multiplicand));
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class InterruptReturn implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if ((operand1 == null || operand1.isImmediateOperand())
|
||||
&& operand2 == null && operand3 == null)
|
||||
{
|
||||
// Create stack-pointer and [stack-pointer]
|
||||
(new Pop()).handle(instructionPointer, Registers.getInstructionPointer(), null, null, instructionArrayList, tempRegisterNum);
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getCPUIDInstruction());
|
||||
/*
|
||||
* FIXME: not handling the case of parameterized number of words popped from the stack
|
||||
*/
|
||||
// perform an unconditional jump to the new location
|
||||
(new UnconditionalJump()).handle(instructionPointer,
|
||||
Registers.getInstructionPointer(), null, null, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
else {
|
||||
|
||||
misc.Error.invalidOperation("Return Operation", operand1, operand2,
|
||||
operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class LFence implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList, TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getLFenceInstruction());
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ public class Leave implements X86StaticInstructionHandler
|
|||
Operand basePointer = Registers.getBasePointer();
|
||||
|
||||
//stack-pointer=base-pointer
|
||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(stackPointer, basePointer));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(basePointer, null, stackPointer));
|
||||
|
||||
//pop top of stack to base-pointer
|
||||
(new Pop()).handle(instructionPointer, basePointer, null, null, instructionArrayList, tempRegisterNum);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import main.CustomObjectPool;
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
|
@ -40,18 +39,13 @@ public class LoadEffectiveAddress implements X86StaticInstructionHandler
|
|||
if((operand1.isIntegerRegisterOperand()) &&
|
||||
operand2.isMemoryOperand() && operand3==null)
|
||||
{
|
||||
if(operand2.getMemoryLocationSecondOperand()==null)
|
||||
{
|
||||
//If b is invalid operand, operand1 = a
|
||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1,
|
||||
operand2.getMemoryLocationFirstOperand()));
|
||||
}
|
||||
else
|
||||
{
|
||||
//operand1=a+b
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2.getMemoryLocationFirstOperand(),
|
||||
operand2.getMemoryLocationSecondOperand(), operand1));
|
||||
}
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
destOpnd = operand1;
|
||||
srcOpnd1 = operand2.getMemoryLocationFirstOperand();
|
||||
srcOpnd2 = operand2.getMemoryLocationSecondOperand();
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getLEA(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class LoadMXCSR implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isMemoryOperand()) &&
|
||||
(operand2 == null) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
OperandTranslator.processSourceMemoryOperand(operand1, Registers.getMXCSR(), instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Load MXCSR ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,8 +45,7 @@ public class Loop implements X86StaticInstructionHandler
|
|||
Operand.getImmediateOperand(), counterRegister));
|
||||
|
||||
//Perform a conditional jump
|
||||
ConditionalJump conditionalJump = new ConditionalJump();
|
||||
conditionalJump.handle(instructionPointer, operand1, null, null, instructionArrayList, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(operand1, null));
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class MFence implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList, TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getMFenceInstruction());
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
|
@ -46,18 +47,13 @@ public class Pop implements X86StaticInstructionHandler
|
|||
{
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
Operand temporaryIntegerRegister = Registers.getTempIntReg(tempRegisterNum);
|
||||
|
||||
//stack to temporary-register
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(stackPointerLocation, temporaryIntegerRegister));
|
||||
|
||||
//temporary-register to memory
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, temporaryIntegerRegister));
|
||||
Operand temporaryIntegerRegister = OperandTranslator.processSourceMemoryOperand(stackPointerLocation, instructionArrayList, tempRegisterNum, true);
|
||||
OperandTranslator.processDestinationMemoryOperand(temporaryIntegerRegister, stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
//stack to operand1 directly
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(stackPointerLocation, operand1));
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
//stack-pointer = stack-pointer - 4
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class PopAll implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
// Create stack-pointer and [stack-pointer]
|
||||
Operand stackPointer = Registers.getStackPointer();
|
||||
Operand stackPointerLocation = Operand.getMemoryOperand(stackPointer, null);
|
||||
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getSourceIndexRegister(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getBasePointer(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getStackPointer(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getBaseIndexRegister(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getDataRegister(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getCounterRegister(), instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum);
|
||||
|
||||
//stack-pointer = stack-pointer - immediate
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class PopFlags implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
// Create stack-pointer and [stack-pointer]
|
||||
Operand stackPointer = Registers.getStackPointer();
|
||||
Operand stackPointerLocation = Operand.getMemoryOperand(stackPointer, null);
|
||||
|
||||
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, Registers.getEFlagsRegister(), instructionArrayList, tempRegisterNum);
|
||||
|
||||
//stack-pointer = stack-pointer - 4
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||
}
|
||||
}
|
|
@ -50,10 +50,7 @@ public class Push implements X86StaticInstructionHandler
|
|||
|
||||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
valueToPush = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
|
||||
instructionArrayList.appendInstruction(
|
||||
Instruction.getLoadInstruction(operand1,valueToPush));
|
||||
valueToPush = OperandTranslator.processSourceMemoryOperand(stackPointerLocation, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -64,7 +61,7 @@ public class Push implements X86StaticInstructionHandler
|
|||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||
|
||||
//perform a store to the top of the stack
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(stackPointerLocation, valueToPush));
|
||||
OperandTranslator.processDestinationMemoryOperand(valueToPush, stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class PushAll implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//get stack-pointer and [stack-pointer]
|
||||
Operand stackPointer = Registers.getStackPointer();
|
||||
Operand stackPointerLocation = Operand.getMemoryOperand(stackPointer, null);
|
||||
|
||||
//Increment the stack-pointer
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||
|
||||
//perform a store to the top of the stack
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getAccumulatorRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getCounterRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getDataRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getBaseIndexRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getStackPointer(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getBasePointer(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getSourceIndexRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getDestinationIndexRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class PushFlags implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//get stack-pointer and [stack-pointer]
|
||||
Operand stackPointer = Registers.getStackPointer();
|
||||
Operand stackPointerLocation = Operand.getMemoryOperand(stackPointer, null);
|
||||
|
||||
//Increment the stack-pointer
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||
|
||||
//perform a store to the top of the stack
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getEFlagsRegister(), stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.OperandType;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class ReadPrefetchL1 implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if(operand1.isMemoryOperand() && operand2 == null && operand3==null)
|
||||
{
|
||||
Operand operandAddressOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadAGUInstruction(operand1.getMemoryLocationFirstOperand(), operand1.getMemoryLocationSecondOperand(), operandAddressOperand));
|
||||
Operand cacheLevelToPrefetchTo = new Operand(OperandType.immediate, 1);
|
||||
instructionArrayList.appendInstruction(Instruction.getReadPrefetch(operandAddressOperand, cacheLevelToPrefetchTo));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Read Prefetch L1", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.OperandType;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class ReadPrefetchL2 implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if(operand1.isMemoryOperand() && operand2 == null && operand3==null)
|
||||
{
|
||||
Operand operandAddressOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadAGUInstruction(operand1.getMemoryLocationFirstOperand(), operand1.getMemoryLocationSecondOperand(), operandAddressOperand));
|
||||
Operand cacheLevelToPrefetchTo = new Operand(OperandType.immediate, 2);
|
||||
instructionArrayList.appendInstruction(Instruction.getReadPrefetch(operandAddressOperand, cacheLevelToPrefetchTo));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Read Prefetch L2", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.OperandType;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class ReadPrefetchL3 implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if(operand1.isMemoryOperand() && operand2 == null && operand3==null)
|
||||
{
|
||||
Operand operandAddressOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadAGUInstruction(operand1.getMemoryLocationFirstOperand(), operand1.getMemoryLocationSecondOperand(), operandAddressOperand));
|
||||
Operand cacheLevelToPrefetchTo = new Operand(OperandType.immediate, 3);
|
||||
instructionArrayList.appendInstruction(Instruction.getReadPrefetch(operandAddressOperand, cacheLevelToPrefetchTo));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Read Prefetch L3", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,44 +40,18 @@ public class ReturnOp implements X86StaticInstructionHandler
|
|||
&& operand2 == null && operand3 == null)
|
||||
{
|
||||
// Create stack-pointer and [stack-pointer]
|
||||
Operand stackPointer = Registers.getStackPointer();
|
||||
Operand stackPointerLocation = Operand.getMemoryOperand(stackPointer, null);
|
||||
|
||||
Operand newInstructionPointer;
|
||||
newInstructionPointer = Registers.getInstructionPointer();
|
||||
|
||||
// load the new instruction-pointer from the stack
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(stackPointerLocation, newInstructionPointer));
|
||||
|
||||
(new Pop()).handle(instructionPointer, Registers.getInstructionPointer(), null, null, instructionArrayList, tempRegisterNum);
|
||||
/*
|
||||
* FIXME: not handling the case of parameterized number of words popped from the stack
|
||||
*/
|
||||
// perform an unconditional jump to the new location
|
||||
(new UnconditionalJump()).handle(instructionPointer,
|
||||
newInstructionPointer, null, null, instructionArrayList, tempRegisterNum);
|
||||
|
||||
if(operand1==null) {
|
||||
|
||||
//stack-pointer = stack-pointer - 4
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||
|
||||
} else if (operand1 != null && operand1.isImmediateOperand()) {
|
||||
//stack-pointer = stack-pointer - (operand1+4)
|
||||
|
||||
Operand tempRegister = Registers.getTempIntReg(tempRegisterNum);
|
||||
|
||||
//temp = operand1 + 4
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand1, Operand.getImmediateOperand(), tempRegister));
|
||||
|
||||
// stack-pointer = stack-pointer + temp-Register
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(stackPointer, tempRegister, stackPointer));
|
||||
} else {
|
||||
Registers.getInstructionPointer(), null, null, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
else {
|
||||
|
||||
misc.Error.invalidOperation("Return Operation", operand1, operand2,
|
||||
operand3);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Return Operation", operand1, operand2,
|
||||
operand3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class SFence implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList, TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getSFenceInstruction());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEFMA implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getVectorFMA(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getVectorFMA(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Vector FMA ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEFloat implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatVectorALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatVectorALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Float vector ALU ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEFloatCmp implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = Registers.getEFlagsRegister();
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatVectorALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Float vector compare ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEFloatMul implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatVectorMul(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatVectorMul(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Float vector mul ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEInteger implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntVectorALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntVectorALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer vector ALU ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEIntegerCmp implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = Registers.getEFlagsRegister();
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntVectorALU(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer vector compare ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEIntegerMul implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
|
||||
if(operand2.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntVectorMul(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2 == null || operand2.isImmediateOperand() || operand2.isFloatRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||
(operand3 == null || operand3.isImmediateOperand() || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand()))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand2;
|
||||
|
||||
if(operand3.isMemoryOperand())
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntVectorMul(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer vector mul ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class SSEStore implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isFloatRegisterOperand()) &&
|
||||
(operand2.isImmediateOperand() || operand2.isFloatRegisterOperand()) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
Operand value = Registers.getTempFloatReg(tempRegisterNum);
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntVectorALU(operand1, operand2, value));
|
||||
|
||||
OperandTranslator.processDestinationMemoryOperand(value, Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Integer vector store ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class StoreMXCSR implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(
|
||||
(operand1.isMemoryOperand()) &&
|
||||
(operand2 == null) &&
|
||||
(operand3 == null))
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getMXCSR(), operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Load MXCSR ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,6 +22,7 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
|
@ -42,52 +43,39 @@ public class StringCompare implements X86StaticInstructionHandler
|
|||
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
{
|
||||
sourceLocation = Operand.getMemoryOperand(Registers.getSourceIndexRegister(),
|
||||
null);
|
||||
sourceLocation = OperandTranslator.processSourceMemoryOperand(Registers.getSourceIndexRegister(), instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
destinationLocation = Operand.getMemoryOperand(Registers.getDestinationIndexRegister(),
|
||||
null);
|
||||
destinationLocation = OperandTranslator.processSourceMemoryOperand(Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
//Load the value at the sourceLocation in a temporary register
|
||||
Operand sourceIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, sourceIndex));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceLocation, destinationLocation, Registers.getEFlagsRegister()));
|
||||
|
||||
|
||||
//Load the value at the destination Location in a temporary register
|
||||
Operand destinationIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(destinationLocation, destinationIndex));
|
||||
|
||||
//Perform compare operation
|
||||
IntegerALUExplicitDestination integerALUExplicitDestination =
|
||||
new IntegerALUExplicitDestination();
|
||||
|
||||
integerALUExplicitDestination.handle(instructionPointer, sourceIndex,
|
||||
destinationIndex, null, instructionArrayList, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getSourceIndexRegister(), Operand.getImmediateOperand(), Registers.getSourceIndexRegister()));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), Operand.getImmediateOperand(), Registers.getDestinationIndexRegister()));
|
||||
}
|
||||
|
||||
|
||||
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
sourceLocation = operand2;
|
||||
destinationLocation = operand1;
|
||||
|
||||
//Load the value at the sourceLocation in a temporary register
|
||||
Operand sourceIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, sourceIndex));
|
||||
|
||||
//Load the value at the destination Location in a temporary register
|
||||
Operand destinationIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(destinationLocation, destinationIndex));
|
||||
|
||||
//Perform compare operation
|
||||
// IntegerALUExplicitDestination integerALUExplicitDestination =
|
||||
// new IntegerALUExplicitDestination();
|
||||
// else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
||||
// operand3==null)
|
||||
// {
|
||||
// sourceLocation = operand2;
|
||||
// destinationLocation = operand1;
|
||||
//
|
||||
// integerALUExplicitDestination.handle(instructionPointer, sourceIndex,
|
||||
// destinationIndex, null, instructionArrayList, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceIndex, destinationIndex, destinationIndex));
|
||||
}
|
||||
// //Load the value at the sourceLocation in a temporary register
|
||||
// Operand sourceIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
// instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, sourceIndex));
|
||||
//
|
||||
// //Load the value at the destination Location in a temporary register
|
||||
// Operand destinationIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
// instructionArrayList.appendInstruction(Instruction.getLoadInstruction(destinationLocation, destinationIndex));
|
||||
//
|
||||
// //Perform compare operation
|
||||
//// IntegerALUExplicitDestination integerALUExplicitDestination =
|
||||
//// new IntegerALUExplicitDestination();
|
||||
////
|
||||
//// integerALUExplicitDestination.handle(instructionPointer, sourceIndex,
|
||||
//// destinationIndex, null, instructionArrayList, tempRegisterNum);
|
||||
// instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceIndex, destinationIndex, destinationIndex));
|
||||
// }
|
||||
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class StringCompareAccumulator implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
Operand sourceLocation;
|
||||
Operand destinationLocation;
|
||||
|
||||
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
{
|
||||
sourceLocation = Registers.getAccumulatorRegister();
|
||||
|
||||
destinationLocation = OperandTranslator.processSourceMemoryOperand(Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceLocation, destinationLocation, Registers.getEFlagsRegister()));
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), Operand.getImmediateOperand(), Registers.getDestinationIndexRegister()));
|
||||
}
|
||||
|
||||
|
||||
// else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
||||
// operand3==null)
|
||||
// {
|
||||
// sourceLocation = operand2;
|
||||
// destinationLocation = operand1;
|
||||
//
|
||||
// //Load the value at the sourceLocation in a temporary register
|
||||
// Operand sourceIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
// instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, sourceIndex));
|
||||
//
|
||||
// //Load the value at the destination Location in a temporary register
|
||||
// Operand destinationIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||
// instructionArrayList.appendInstruction(Instruction.getLoadInstruction(destinationLocation, destinationIndex));
|
||||
//
|
||||
// //Perform compare operation
|
||||
//// IntegerALUExplicitDestination integerALUExplicitDestination =
|
||||
//// new IntegerALUExplicitDestination();
|
||||
////
|
||||
//// integerALUExplicitDestination.handle(instructionPointer, sourceIndex,
|
||||
//// destinationIndex, null, instructionArrayList, tempRegisterNum);
|
||||
// instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceIndex, destinationIndex, destinationIndex));
|
||||
// }
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("String Compare Accumulator ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class StringLoad implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
{
|
||||
OperandTranslator.processSourceMemoryOperand(Operand.getMemoryOperand(Registers.getSourceIndexRegister(), null), Registers.getAccumulatorRegister(), instructionArrayList, tempRegisterNum);
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getSourceIndexRegister(), Operand.getImmediateOperand(), Registers.getSourceIndexRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("String Load", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,10 +22,11 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class StringMove implements X86StaticInstructionHandler
|
||||
|
@ -36,36 +37,24 @@ public class StringMove implements X86StaticInstructionHandler
|
|||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
Operand sourceLocation, destinationLocation;
|
||||
Operand sourceLocation;
|
||||
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
{
|
||||
sourceLocation = Operand.getMemoryOperand(Registers.getSourceIndexRegister(),
|
||||
null);
|
||||
sourceLocation = OperandTranslator.processSourceMemoryOperand(Operand.getMemoryOperand(Registers.getSourceIndexRegister(), null), instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
destinationLocation = Operand.getMemoryOperand(Registers.getDestinationIndexRegister(),
|
||||
null);
|
||||
OperandTranslator.processDestinationMemoryOperand(sourceLocation, Operand.getMemoryOperand(Registers.getDestinationIndexRegister(), null), instructionArrayList, tempRegisterNum);
|
||||
|
||||
//Load the value at the sourceLocation in a temporary register
|
||||
Operand tempRegister = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, tempRegister));
|
||||
|
||||
//Store the value in tempRegister in destination location
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(destinationLocation, tempRegister));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getSourceIndexRegister(), Operand.getImmediateOperand(), Registers.getSourceIndexRegister()));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), Operand.getImmediateOperand(), Registers.getDestinationIndexRegister()));
|
||||
}
|
||||
|
||||
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
||||
operand3==null)
|
||||
{
|
||||
sourceLocation = operand2;
|
||||
destinationLocation = operand1;
|
||||
sourceLocation = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||
|
||||
//Load the value at the sourceLocation in a temporary register
|
||||
Operand tempRegister = Registers.getTempIntReg(tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, tempRegister));
|
||||
|
||||
//Store the value in tempRegister in destination location
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(destinationLocation, tempRegister));
|
||||
OperandTranslator.processDestinationMemoryOperand(sourceLocation, operand1, instructionArrayList, tempRegisterNum);
|
||||
}
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class StringStore implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
{
|
||||
OperandTranslator.processDestinationMemoryOperand(Registers.getAccumulatorRegister(), Operand.getMemoryOperand(Registers.getDestinationIndexRegister(), null), instructionArrayList, tempRegisterNum);
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), Operand.getImmediateOperand(), Registers.getDestinationIndexRegister()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("String Store", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,8 +44,7 @@ public class UnconditionalJump implements X86StaticInstructionHandler
|
|||
if(operand1.isMemoryOperand())
|
||||
{
|
||||
//far jump : jumpLocation = [operand1]
|
||||
jumpLocation = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, jumpLocation));
|
||||
jumpLocation = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class VectorShuffle implements X86StaticInstructionHandler{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 != null && operand1.isFloatRegisterOperand()
|
||||
&& operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand())
|
||||
&& (operand3 == null || operand3.isFloatRegisterOperand() || operand3.isMemoryOperand())
|
||||
&& (!(operand2.isMemoryOperand() && operand3.isMemoryOperand())))
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
destOpnd = operand1;
|
||||
|
||||
if(operand3 == null)
|
||||
{
|
||||
srcOpnd1 = operand1;
|
||||
if(operand2.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd1 = operand2;
|
||||
if(operand3.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd2 = operand3;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand3, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
}
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getVectorShuffle(srcOpnd1, srcOpnd2, destOpnd));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("AES with two source operands ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class VectorStringDestECX implements X86StaticInstructionHandler{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 != null && operand1.isFloatRegisterOperand()
|
||||
&& operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand())
|
||||
&& operand3 == null)
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
destOpnd = Registers.getCounterRegister();
|
||||
if(operand2.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getVectorString(srcOpnd1, srcOpnd2, destOpnd));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(srcOpnd1, srcOpnd2, Registers.getEFlagsRegister()));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("vector string dest ECX ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class VectorStringDestXMM0 implements X86StaticInstructionHandler{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
if(operand1 != null && operand1.isFloatRegisterOperand()
|
||||
&& operand2 != null && (operand2.isFloatRegisterOperand() || operand2.isMemoryOperand())
|
||||
&& operand3 == null)
|
||||
{
|
||||
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||
|
||||
srcOpnd1 = operand1;
|
||||
destOpnd = Operand.getFloatRegister(0);
|
||||
if(operand2.isFloatRegisterOperand())
|
||||
{
|
||||
srcOpnd2 = operand2;
|
||||
}
|
||||
else
|
||||
{
|
||||
srcOpnd2 = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, false);
|
||||
}
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getVectorString(srcOpnd1, srcOpnd2, destOpnd));
|
||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(srcOpnd1, srcOpnd2, Registers.getEFlagsRegister()));
|
||||
}
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("vector string dest xmm0 ", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
|
||||
public class WritePrefetch implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||
if(operand1.isMemoryOperand() && operand2 == null && operand3==null)
|
||||
{
|
||||
Operand operandAddressOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
||||
instructionArrayList.appendInstruction(Instruction.getStoreAGUInstruction(operand1.getMemoryLocationFirstOperand(), operand1.getMemoryLocationSecondOperand(), operandAddressOperand));
|
||||
instructionArrayList.appendInstruction(Instruction.getWritePrefetch(operandAddressOperand));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Write Prefetch", operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,13 +23,14 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class FloatingPointALU implements X86StaticInstructionHandler
|
||||
public class X87FloatingPointALU implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -64,11 +65,7 @@ public class FloatingPointALU implements X86StaticInstructionHandler
|
|||
{
|
||||
Operand st0 = Registers.getTopFPRegister();
|
||||
|
||||
Operand tempFloatRegister;
|
||||
tempFloatRegister=Registers.getTempFloatReg(tempRegisterNum);
|
||||
|
||||
//tempFloatRegister = [operand1]
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, tempFloatRegister));
|
||||
Operand tempFloatRegister = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, false);
|
||||
|
||||
//st(0) = st(0) + tempFloatRegister
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(tempFloatRegister, st0, st0));
|
|
@ -2,13 +2,14 @@ package emulatorinterface.translator.x86.instruction;
|
|||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class FloatingPointCompare implements X86StaticInstructionHandler
|
||||
public class X87FloatingPointCompare implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -23,7 +24,7 @@ public class FloatingPointCompare implements X86StaticInstructionHandler
|
|||
Operand st0 = Registers.getTopFPRegister();
|
||||
Operand st1 = Registers.getSecondTopFPRegister();
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, st1, null));
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, st1, Registers.getFloatingPointControlWord()));
|
||||
}
|
||||
|
||||
else if(operand1.isFloatRegisterOperand() && operand2==null && operand3==null)
|
||||
|
@ -31,25 +32,23 @@ public class FloatingPointCompare implements X86StaticInstructionHandler
|
|||
//First implicit operand is implicitly st0 and second operand is passed as argument.
|
||||
Operand st0 = Registers.getTopFPRegister();
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, operand1, null));
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, operand1, Registers.getFloatingPointControlWord()));
|
||||
}
|
||||
|
||||
else if(operand1.isFloatRegisterOperand() && operand2.isFloatRegisterOperand() && operand3==null)
|
||||
{
|
||||
//Both the operands are passed as operands to the command.
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand1, operand2, null));
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand1, operand2, Registers.getFloatingPointControlWord()));
|
||||
}
|
||||
|
||||
else if(operand1.isMemoryOperand() && operand2==null && operand3==null)
|
||||
{
|
||||
//First implicit operand is implicitly st0 and second operand is passed as argument.
|
||||
Operand st0 = Registers.getTopFPRegister();
|
||||
Operand tempFloatRegister;
|
||||
tempFloatRegister=Registers.getTempFloatReg(tempRegisterNum);
|
||||
Operand tempFloatRegister = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, false);
|
||||
|
||||
//tempFloatRegister = [operand1]
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, tempFloatRegister));
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, tempFloatRegister, null));
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, tempFloatRegister, Registers.getFloatingPointControlWord()));
|
||||
}
|
||||
|
||||
else
|
|
@ -0,0 +1,42 @@
|
|||
/*****************************************************************************
|
||||
Tejas Simulator
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright [2010] [Indian Institute of Technology, Delhi]
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Contributors: Prathmesh Kallurkar
|
||||
*****************************************************************************/
|
||||
|
||||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.Instruction;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class X87FloatingPointComplexOperation implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(Registers.getTopFPRegister(), null, Registers.getTopFPRegister()));
|
||||
}
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
import generic.Instruction;
|
||||
|
||||
public class FloatingPointConditionalMove implements X86StaticInstructionHandler
|
||||
public class X87FloatingPointConditionalMove implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -13,18 +15,16 @@ public class FloatingPointConditionalMove implements X86StaticInstructionHandler
|
|||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
//TODO Must do something !!
|
||||
|
||||
if(operand1.isFloatRegisterOperand() && operand2==null
|
||||
&& operand3==null)
|
||||
{
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand1, Registers.getFloatingPointControlWord(), Registers.getTopFPRegister()));
|
||||
}
|
||||
|
||||
else if(operand1.isFloatRegisterOperand() && operand2.isFloatRegisterOperand()
|
||||
&& operand3==null)
|
||||
{
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand2, Registers.getFloatingPointControlWord(), operand1));
|
||||
}
|
||||
|
||||
else
|
|
@ -22,13 +22,14 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class FloatingPointDivision implements X86StaticInstructionHandler
|
||||
public class X87FloatingPointDivision implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
|
@ -63,11 +64,7 @@ public class FloatingPointDivision implements X86StaticInstructionHandler
|
|||
{
|
||||
Operand st0 = Registers.getTopFPRegister();
|
||||
|
||||
Operand tempFloatRegister;
|
||||
tempFloatRegister = Registers.getTempFloatReg(tempRegisterNum);
|
||||
|
||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1,
|
||||
tempFloatRegister));
|
||||
Operand tempFloatRegister = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, false);
|
||||
|
||||
//st(0) = st(0) + tempFloatRegister
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(st0,
|
|
@ -0,0 +1,33 @@
|
|||
package emulatorinterface.translator.x86.instruction;
|
||||
|
||||
|
||||
import emulatorinterface.translator.InvalidInstructionException;
|
||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||
import emulatorinterface.translator.x86.registers.Registers;
|
||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||
import generic.Instruction;
|
||||
import generic.Operand;
|
||||
import generic.InstructionList;
|
||||
|
||||
public class X87FloatingPointExamine implements X86StaticInstructionHandler
|
||||
{
|
||||
public void handle(long instructionPointer,
|
||||
Operand operand1, Operand operand2, Operand operand3,
|
||||
InstructionList instructionArrayList,
|
||||
TempRegisterNum tempRegisterNum)
|
||||
throws InvalidInstructionException
|
||||
{
|
||||
|
||||
if(operand1==null && operand2==null && operand3==null)
|
||||
{
|
||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(Registers.getTopFPRegister(), null, Registers.getFloatingPointControlWord()));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
misc.Error.invalidOperation("Floating Point Compare for ip="
|
||||
+ instructionPointer
|
||||
, operand1, operand2, operand3);
|
||||
}
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue