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 findThreadMapping(unsigned int id)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
|
@ -223,9 +235,10 @@ int findThreadMapping(unsigned int id)
|
||||||
if(threadMapping[index] == id)
|
if(threadMapping[index] == id)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
cout<<"FATAL ERROR : ThreadMapping cannot resolve";
|
// cout<<"FATAL ERROR : ThreadMapping cannot resolve " << id << endl;
|
||||||
fflush(stdout);
|
return 1;
|
||||||
exit(0);
|
// fflush(stdout);
|
||||||
|
// exit(0);
|
||||||
}
|
}
|
||||||
#define cmp(a) (rtn_name->find(a) != string::npos)
|
#define cmp(a) (rtn_name->find(a) != string::npos)
|
||||||
|
|
||||||
|
@ -257,10 +270,19 @@ int findParentSegment(long parent)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
cout<<"FATAL ERROR--- cannot find parent\n";
|
cout<<"FATAL ERROR--- cannot find parent\n";
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) {
|
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);
|
PIN_MutexLock(&mainLockForPintool);
|
||||||
numThreads++;
|
numThreads++;
|
||||||
livethreads++;
|
livethreads++;
|
||||||
|
@ -294,6 +316,7 @@ VOID ThreadStart(THREADID threadid, CONTEXT *ctxt, INT32 flags, VOID *v) {
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
pumpingStatus[i] = true;
|
pumpingStatus[i] = true;
|
||||||
threadid = findThreadMapping(threadid);
|
threadid = findThreadMapping(threadid);
|
||||||
|
cout << "app thread mapped to tejas thread " << threadid << endl;
|
||||||
tst->onThread_start(threadid);
|
tst->onThread_start(threadid);
|
||||||
while (tst->analysisFn(threadid, parent, CHILD_START, PIN_GetParentTid()) == -1) {
|
while (tst->analysisFn(threadid, parent, CHILD_START, PIN_GetParentTid()) == -1) {
|
||||||
PIN_Yield();
|
PIN_Yield();
|
||||||
|
@ -324,6 +347,9 @@ VOID ThreadFini(THREADID tid, const CONTEXT *ctxt, INT32 flags, VOID *v) {
|
||||||
|
|
||||||
//Pass a memory read record
|
//Pass a memory read record
|
||||||
VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) {
|
VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) {
|
||||||
|
|
||||||
|
if(tid != 45)
|
||||||
|
return;
|
||||||
tid= findThreadMapping(tid);
|
tid= findThreadMapping(tid);
|
||||||
if (!isActive(tid))
|
if (!isActive(tid))
|
||||||
return;
|
return;
|
||||||
|
@ -350,6 +376,9 @@ VOID RecordMemRead(THREADID tid, VOID * ip, VOID * addr) {
|
||||||
// Pass a memory write record
|
// Pass a memory write record
|
||||||
VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) {
|
VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) {
|
||||||
|
|
||||||
|
if(tid != 45)
|
||||||
|
return;
|
||||||
|
|
||||||
tid= findThreadMapping(tid);
|
tid= findThreadMapping(tid);
|
||||||
if (!isActive(tid))
|
if (!isActive(tid))
|
||||||
return;
|
return;
|
||||||
|
@ -374,6 +403,9 @@ VOID RecordMemWrite(THREADID tid, VOID * ip, VOID * addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID BrnFun(THREADID tid, ADDRINT tadr, BOOL taken, VOID *ip) {
|
VOID BrnFun(THREADID tid, ADDRINT tadr, BOOL taken, VOID *ip) {
|
||||||
|
|
||||||
|
if(tid != 45)
|
||||||
|
return;
|
||||||
tid= findThreadMapping(tid);
|
tid= findThreadMapping(tid);
|
||||||
if (!isActive(tid))
|
if (!isActive(tid))
|
||||||
return;
|
return;
|
||||||
|
@ -538,20 +570,37 @@ VOID printip(THREADID tid, VOID *ip, char *asmString) {
|
||||||
instructionIgnorePhase = true;
|
instructionIgnorePhase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(numInsToSimulate > 0 && totalNumCISC >= (numInsToIgnore + numInsToSimulate))
|
if(numInsToSimulate > 0)
|
||||||
{
|
{
|
||||||
// Now, we will write -2 packet in shared memory.
|
bool subsetDone = false;
|
||||||
// This will ensure that complete emulator (PIN) gets stopped.
|
// for(int i = 0; i < MaxNumActiveThreads; i++)
|
||||||
while (tst->onSubset_finish((int)tid, (numCISC[tid])) == -1) {
|
// {
|
||||||
PIN_Yield();
|
// if(numCISC[i] >= (numInsToIgnore + numInsToSimulate))
|
||||||
|
// {
|
||||||
|
// subsetDone = true;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if(numCISC[0] >= (numInsToIgnore + numInsToSimulate))
|
||||||
|
{
|
||||||
|
subsetDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout<<"subset finish called by thread "<<tid<<endl;
|
if(subsetDone)
|
||||||
fflush(stdout);
|
{
|
||||||
|
// Now, we will write -2 packet in shared memory.
|
||||||
|
// This will ensure that complete emulator (PIN) gets stopped.
|
||||||
|
while (tst->onSubset_finish((int)tid, (numCISC[tid])) == -1) {
|
||||||
|
PIN_Yield();
|
||||||
|
}
|
||||||
|
|
||||||
tst->setSubsetsimComplete(true);
|
cout<<"subset finish called by thread "<<tid<<endl;
|
||||||
// threadAlive[tid] = false;
|
fflush(stdout);
|
||||||
waitForThreadsAndTerminatePin();
|
|
||||||
|
tst->setSubsetsimComplete(true);
|
||||||
|
// threadAlive[tid] = false;
|
||||||
|
waitForThreadsAndTerminatePin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -664,8 +713,13 @@ void Image(IMG img,VOID *v) {
|
||||||
// Pin calls this function every time a new instruction is encountered
|
// Pin calls this function every time a new instruction is encountered
|
||||||
VOID Instruction(INS ins, VOID *v) {
|
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;
|
char *asmChar = NULL;
|
||||||
if(traceMethod==File) {
|
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 floatALU;
|
||||||
private static DynamicInstructionHandler floatMul;
|
private static DynamicInstructionHandler floatMul;
|
||||||
private static DynamicInstructionHandler floatDiv;
|
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 load;
|
||||||
|
private static DynamicInstructionHandler storeAGU;
|
||||||
private static DynamicInstructionHandler store;
|
private static DynamicInstructionHandler store;
|
||||||
private static DynamicInstructionHandler jump;
|
private static DynamicInstructionHandler jump;
|
||||||
private static DynamicInstructionHandler branch;
|
private static DynamicInstructionHandler branch;
|
||||||
private static DynamicInstructionHandler mov;
|
private static DynamicInstructionHandler AES;
|
||||||
private static DynamicInstructionHandler xchg;
|
private static DynamicInstructionHandler vectorString;
|
||||||
|
private static DynamicInstructionHandler bitScan;
|
||||||
|
private static DynamicInstructionHandler vectorShuffle;
|
||||||
|
private static DynamicInstructionHandler LEA;
|
||||||
private static DynamicInstructionHandler acceleratedOp;
|
private static DynamicInstructionHandler acceleratedOp;
|
||||||
private static DynamicInstructionHandler nop;
|
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;
|
private static DynamicInstructionHandler interrupt;
|
||||||
|
|
||||||
public static DynamicInstructionHandler selectHandler(OperationType operationType)
|
public static DynamicInstructionHandler selectHandler(OperationType operationType)
|
||||||
|
@ -54,9 +71,33 @@ public class VisaHandlerSelector
|
||||||
case floatDiv:
|
case floatDiv:
|
||||||
return 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:
|
case load:
|
||||||
return load;
|
return load;
|
||||||
|
|
||||||
|
case storeAGU:
|
||||||
|
return storeAGU;
|
||||||
|
|
||||||
case store:
|
case store:
|
||||||
return store;
|
return store;
|
||||||
|
|
||||||
|
@ -66,15 +107,42 @@ public class VisaHandlerSelector
|
||||||
case branch:
|
case branch:
|
||||||
return branch;
|
return branch;
|
||||||
|
|
||||||
case mov:
|
case AES:
|
||||||
return mov;
|
return AES;
|
||||||
|
|
||||||
case xchg:
|
case vectorString:
|
||||||
return xchg;
|
return vectorString;
|
||||||
|
|
||||||
|
case bitScan:
|
||||||
|
return bitScan;
|
||||||
|
|
||||||
|
case vectorShuffle:
|
||||||
|
return vectorShuffle;
|
||||||
|
|
||||||
|
case LEA:
|
||||||
|
return LEA;
|
||||||
|
|
||||||
case acceleratedOp:
|
case acceleratedOp:
|
||||||
return 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:
|
case nop:
|
||||||
return nop;
|
return nop;
|
||||||
|
|
||||||
|
@ -97,14 +165,31 @@ public class VisaHandlerSelector
|
||||||
floatALU = new FloatALU();
|
floatALU = new FloatALU();
|
||||||
floatMul = new FloatMul();
|
floatMul = new FloatMul();
|
||||||
floatDiv = new FloatDiv();
|
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();
|
load = new Load();
|
||||||
|
storeAGU = new StoreAGU();
|
||||||
store = new Store();
|
store = new Store();
|
||||||
jump = new Jump();
|
jump = new Jump();
|
||||||
branch = new Branch();
|
branch = new Branch();
|
||||||
mov = new Mov();
|
AES = new AES();
|
||||||
xchg = new Xchg();
|
vectorString = new VectorString();
|
||||||
|
bitScan = new BitScan();
|
||||||
|
vectorShuffle = new VectorShuffle();
|
||||||
|
LEA = new LEA();
|
||||||
acceleratedOp = new AcceleratedOp();
|
acceleratedOp = new AcceleratedOp();
|
||||||
nop = new NOP();
|
nop = new NOP();
|
||||||
|
cpuid = new CPUID();
|
||||||
|
mfence = new MFence();
|
||||||
|
sfence = new SFence();
|
||||||
|
lfence = new LFence();
|
||||||
|
readprefetch = new ReadPrefetch();
|
||||||
|
writeprefetch = new WritePrefetch();
|
||||||
interrupt = new Interrupt();
|
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;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class FloatingPointComplexOperation implements X86StaticInstructionHandler
|
public class CPUID implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
InstructionList instructionArrayList,
|
InstructionList instructionArrayList, TempRegisterNum tempRegisterNum)
|
||||||
TempRegisterNum tempRegisterNum)
|
|
||||||
throws InvalidInstructionException
|
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.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
|
@ -41,14 +42,14 @@ public class Call implements X86StaticInstructionHandler
|
||||||
TempRegisterNum tempRegisterNum)
|
TempRegisterNum tempRegisterNum)
|
||||||
throws InvalidInstructionException
|
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())
|
if((operand1.isImmediateOperand() || operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand())
|
||||||
&& operand2==null && operand3==null)
|
&& 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
|
//Unconditional jump to a new location
|
||||||
(new UnconditionalJump()).handle(instructionPointer, operand1, null, null, instructionArrayList, tempRegisterNum);
|
(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.InvalidInstructionException;
|
||||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
@ -40,14 +41,13 @@ public class ConditionalJump implements X86StaticInstructionHandler
|
||||||
&& operand2==null && operand3==null)
|
&& operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
jumpLocation = operand1;
|
jumpLocation = operand1;
|
||||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation));
|
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation, Registers.getEFlagsRegister()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(operand1.isMemoryOperand() && operand2==null && operand3==null)
|
else if(operand1.isMemoryOperand() && operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
jumpLocation = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
jumpLocation = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, jumpLocation));
|
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation, Registers.getEFlagsRegister()));
|
||||||
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(jumpLocation));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
|
@ -42,7 +44,7 @@ public class ConditionalMove implements X86StaticInstructionHandler
|
||||||
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||||
(operand3==null))
|
(operand3==null))
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1, operand2));
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2, Registers.getEFlagsRegister(), operand1));
|
||||||
}
|
}
|
||||||
|
|
||||||
//if operand1 = register and operand2 = memory - load
|
//if operand1 = register and operand2 = memory - load
|
||||||
|
@ -50,25 +52,26 @@ public class ConditionalMove implements X86StaticInstructionHandler
|
||||||
operand2.isMemoryOperand() &&
|
operand2.isMemoryOperand() &&
|
||||||
operand3==null)
|
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
|
// //if operand1 = memory and operand2 = memory - store
|
||||||
else if((operand1.isMemoryOperand()) &&
|
// else if((operand1.isMemoryOperand()) &&
|
||||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) &&
|
// (operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) &&
|
||||||
(operand3==null))
|
// (operand3==null))
|
||||||
{
|
// {
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand2, operand1));
|
// instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand2, operand1));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
//TODO I doubt if this is a valid instruction !! Anyways found this in an object-code
|
// //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.
|
// //operand1 can be a data-stored in memory and operand2 can be immediate/register.
|
||||||
//first, we load the value at location into temporary register
|
// //first, we load the value at location into temporary register
|
||||||
//Then we will store op2 to [temporary-register]
|
// //Then we will store op2 to [temporary-register]
|
||||||
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() && operand3==null)
|
// else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() && operand3==null)
|
||||||
{
|
// {
|
||||||
misc.Error.invalidOperation("Conditional Move", operand1, operand2, operand3);
|
// misc.Error.invalidOperation("Conditional Move", operand1, operand2, operand3);
|
||||||
}
|
// }
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package emulatorinterface.translator.x86.instruction;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
|
@ -17,14 +18,14 @@ public class ConditionalSet implements X86StaticInstructionHandler
|
||||||
if((operand1.isIntegerRegisterOperand()) &&
|
if((operand1.isIntegerRegisterOperand()) &&
|
||||||
operand2==null && operand3==null)
|
operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1,
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getEFlagsRegister(),
|
||||||
Operand.getImmediateOperand()));
|
Operand.getImmediateOperand(), operand1));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(operand1.isMemoryOperand())
|
else if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1,
|
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1,
|
||||||
Operand.getImmediateOperand()));
|
Registers.getEFlagsRegister()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
package emulatorinterface.translator.x86.instruction;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
@ -36,39 +37,46 @@ public class Exchange implements X86StaticInstructionHandler
|
||||||
TempRegisterNum tempRegisterNum)
|
TempRegisterNum tempRegisterNum)
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
//operand1 is a register and operand2 is also a register
|
if((operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand())
|
||||||
if((operand1.isIntegerRegisterOperand()) &&
|
&& (operand2 == null || operand2.isIntegerRegisterOperand())
|
||||||
(operand2.isIntegerRegisterOperand())&&
|
&& operand3 == null
|
||||||
operand3==null)
|
&& (!(operand1.isMemoryOperand() && operand2 == null)))
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getExchangeInstruction(operand1, operand2));
|
Operand operand1Value;
|
||||||
}
|
if(operand1.isMemoryOperand())
|
||||||
|
{
|
||||||
//operand1 is memory operand and operand2 is a register
|
operand1Value = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
else if((operand1.isMemoryOperand() || operand1.isIntegerRegisterOperand()) &&
|
}
|
||||||
(operand2.isMemoryOperand() || operand2.isIntegerRegisterOperand()) &&
|
else
|
||||||
operand3==null)
|
{
|
||||||
{
|
operand1Value = operand1;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//temp = mem
|
Operand operand2Reg;
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(memLocation, tempRegister));
|
if(operand2.isIntegerRegisterOperand())
|
||||||
//mem = reg
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(memLocation, register));
|
operand2Reg = operand2;
|
||||||
// reg = temp
|
}
|
||||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(register, tempRegister));
|
else
|
||||||
|
{
|
||||||
|
operand2Reg = Registers.getAccumulatorRegister();
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
else
|
||||||
|
|
|
@ -22,8 +22,11 @@
|
||||||
package emulatorinterface.translator.x86.instruction;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
|
import generic.Instruction;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class ExchangeAndAdd implements X86StaticInstructionHandler
|
public class ExchangeAndAdd implements X86StaticInstructionHandler
|
||||||
|
@ -34,12 +37,39 @@ public class ExchangeAndAdd implements X86StaticInstructionHandler
|
||||||
TempRegisterNum tempRegisterNum)
|
TempRegisterNum tempRegisterNum)
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
//TODO Check if the add should be performed before exchange ??
|
if(operand1.isMemoryOperand() && operand2.isIntegerRegisterOperand() && operand3 == null)
|
||||||
Exchange exchange = new Exchange();
|
{
|
||||||
exchange.handle(instructionPointer, operand1, operand2, operand3, instructionArrayList, tempRegisterNum);
|
Operand memoryOpnd = operand1;
|
||||||
|
Operand registerOpnd = operand2;
|
||||||
|
|
||||||
//Perhaps the order will now change.
|
// memValueTemp = [memoryOpnd]
|
||||||
IntegerALUImplicitDestination addOperation = new IntegerALUImplicitDestination();
|
Operand memValueTemp = OperandTranslator.processSourceMemoryOperand(memoryOpnd, instructionArrayList, tempRegisterNum, true);
|
||||||
addOperation.handle(instructionPointer, operand2, operand1, operand3, instructionArrayList, tempRegisterNum);
|
|
||||||
|
// 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 emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionLinkedList;
|
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class SingleOperandIntALUImplicitAccumulator implements X86StaticInstructionHandler
|
public class ExtendEAXToEDX implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -38,26 +37,19 @@ public class SingleOperandIntALUImplicitAccumulator implements X86StaticInstruct
|
||||||
TempRegisterNum tempRegisterNum)
|
TempRegisterNum tempRegisterNum)
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
if(operand1==null && operand2==null && operand3==null)
|
if((operand1==null || operand1.isImmediateOperand()) && operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
||||||
|
|
||||||
//Perform integer alu operation
|
//Perform integer alu operation
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
||||||
|
null, accumulatorRegister, Registers.getDataRegister()));
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(
|
||||||
null, accumulatorRegister, accumulatorRegister));
|
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
|
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.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
|
|
||||||
public class Move implements X86StaticInstructionHandler
|
public class FloatMove implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -38,30 +39,30 @@ public class Move implements X86StaticInstructionHandler
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
//if operand1 is a register and operand2 is a register/immediate, we will use normal move operation
|
||||||
if( (operand1.isIntegerRegisterOperand()) &&
|
if( (operand1.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand()) &&
|
||||||
(operand2.isIntegerRegisterOperand() || operand2.isImmediateOperand()) &&
|
(operand2.isIntegerRegisterOperand() || operand1.isFloatRegisterOperand() || operand2.isImmediateOperand()) &&
|
||||||
(operand3==null))
|
(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
|
//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() &&
|
operand2.isMemoryOperand() &&
|
||||||
operand3==null)
|
operand3==null)
|
||||||
{
|
{
|
||||||
//Obtain value at the memory location [operand2]
|
//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
|
//if the operand1 is a memory location and operand2 is a register/immediate then
|
||||||
//it is a store operation
|
//it is a store operation
|
||||||
else if((operand1.isMemoryOperand()) &&
|
else if((operand1.isMemoryOperand()) &&
|
||||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand()) &&
|
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isFloatRegisterOperand()) &&
|
||||||
(operand3==null))
|
(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
|
//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() &&
|
operand2.isMemoryOperand() &&
|
||||||
operand3==null)
|
operand3==null)
|
||||||
{
|
{
|
||||||
misc.Error.invalidOperation("Move", operand1, operand2, operand3);
|
misc.Error.invalidOperation("Float Move", operand1, operand2, operand3);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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
|
public enum InstructionClass
|
||||||
{
|
{
|
||||||
INTEGER_ALU_IMPLICIT_DESTINATION,
|
INTEGER_ALU,
|
||||||
INTEGER_ALU_NO_IMPLICIT_DESTINATION,
|
INTEGER_ALU_NO_FLAG_MOD,
|
||||||
SINGLE_OPERAND_INTEGER_ALU,
|
INTEGER_ALU_USES_FLAGS,
|
||||||
SINGLE_OPERAND_INTEGER_ALU_IMPLICIT_ACCUMULATOR,
|
INTEGER_COMPARE_TEST,
|
||||||
|
INTEGER_COMPARE_TEST_SET,
|
||||||
|
EXTEND_EAX_TO_EDX,
|
||||||
|
ACCUMULATOR_ADJUSTMENTS,
|
||||||
SHIFT_OPERATION_THREE_OPERANDS,
|
SHIFT_OPERATION_THREE_OPERANDS,
|
||||||
MOVE,
|
INTEGER_MOVE,
|
||||||
|
INTEGER_MOVE_ACCUMULATOR,
|
||||||
|
FLOAT_MOVE,
|
||||||
CONDITIONAL_MOVE,
|
CONDITIONAL_MOVE,
|
||||||
EXCHANGE,
|
EXCHANGE,
|
||||||
|
CMP_XCHG,
|
||||||
|
CMP_XCHG_BYTE,
|
||||||
EXCHANGE_AND_ADD,
|
EXCHANGE_AND_ADD,
|
||||||
CONDITIONAL_JUMP,
|
CONDITIONAL_JUMP,
|
||||||
UNCONDITIONAL_JUMP,
|
UNCONDITIONAL_JUMP,
|
||||||
LOOP,
|
CONDITIONAL_LOOP,
|
||||||
|
UNCONDITIONAL_LOOP,
|
||||||
NOP,
|
NOP,
|
||||||
INTEGER_MULTIPLICATION,
|
INTEGER_MULTIPLICATION,
|
||||||
INTEGER_DIVISION,
|
INTEGER_DIVISION,
|
||||||
|
@ -45,7 +53,11 @@ public enum InstructionClass
|
||||||
|
|
||||||
//Stack Operations
|
//Stack Operations
|
||||||
PUSH,
|
PUSH,
|
||||||
|
PUSH_ALL,
|
||||||
|
PUSH_FLAGS,
|
||||||
POP,
|
POP,
|
||||||
|
POP_ALL,
|
||||||
|
POP_FLAGS,
|
||||||
CALL,
|
CALL,
|
||||||
RETURN,
|
RETURN,
|
||||||
LEAVE,
|
LEAVE,
|
||||||
|
@ -53,8 +65,16 @@ public enum InstructionClass
|
||||||
|
|
||||||
//String Operations
|
//String Operations
|
||||||
STRING_MOVE,
|
STRING_MOVE,
|
||||||
|
STRING_LOAD,
|
||||||
|
STRING_STORE,
|
||||||
STRING_COMPARE,
|
STRING_COMPARE,
|
||||||
|
STRING_COMPARE_ACCUMULATOR,
|
||||||
|
|
||||||
|
//flag mods
|
||||||
|
FLAGS_MOD_WITHOUT_SRC,
|
||||||
|
FLAGS_MOD_WITH_SRC,
|
||||||
|
FLAGS_STORE,
|
||||||
|
FLAGS_LOAD,
|
||||||
|
|
||||||
//Floating Point operations
|
//Floating Point operations
|
||||||
FLOATING_POINT_LOAD_CONSTANT,
|
FLOATING_POINT_LOAD_CONSTANT,
|
||||||
|
@ -63,28 +83,65 @@ public enum InstructionClass
|
||||||
FLOATING_POINT_MULTIPLICATION,
|
FLOATING_POINT_MULTIPLICATION,
|
||||||
FLOATING_POINT_DIVISION,
|
FLOATING_POINT_DIVISION,
|
||||||
FLOATING_POINT_ALU,
|
FLOATING_POINT_ALU,
|
||||||
FLOATING_POINT_SINGLE_OPERAND_ALU,
|
FLOATING_POINT_NO_OPERAND_ALU,
|
||||||
FLOATING_POINT_EXCHANGE,
|
FLOATING_POINT_EXCHANGE,
|
||||||
FLOATING_POINT_COMPLEX_OPERATION,
|
FLOATING_POINT_COMPLEX_OPERATION,
|
||||||
FLOATING_POINT_COMPARE,
|
FLOATING_POINT_COMPARE,
|
||||||
FLOATING_POINT_CONDITIONAL_MOVE,
|
FLOATING_POINT_CONDITIONAL_MOVE,
|
||||||
FLOATING_POINT_LOAD_CONTROL_WORD,
|
FLOATING_POINT_LOAD_CONTROL_WORD,
|
||||||
FLOATING_POINT_STORE_CONTROL_WORD,
|
FLOATING_POINT_STORE_CONTROL_WORD,
|
||||||
|
FLOATING_POINT_EXAMINE,
|
||||||
|
|
||||||
//Convert operations
|
//Convert operations
|
||||||
|
CONVERT_FLOAT_TO_PACKED_INTEGER,
|
||||||
CONVERT_FLOAT_TO_INTEGER,
|
CONVERT_FLOAT_TO_INTEGER,
|
||||||
|
CONVERT_PACKED_INTEGER_TO_FLOAT,
|
||||||
CONVERT_INTEGER_TO_FLOAT,
|
CONVERT_INTEGER_TO_FLOAT,
|
||||||
|
CONVERT_FLOAT_TO_FLOAT,
|
||||||
|
|
||||||
//Not Handled
|
//Not Handled
|
||||||
REPEAT,
|
REPEAT,
|
||||||
LOCK,
|
LOCK,
|
||||||
|
|
||||||
//TODO SSE Instructions
|
//SSE Instructions
|
||||||
SSE_MOVE,
|
SSE_INTEGER,
|
||||||
SSE_ALU,
|
SSE_INTEGER_MUL_ADD,
|
||||||
SSE_MULTIPLICATION,
|
SSE_INTEGER_COMPARE,
|
||||||
SSE_DIVISION,
|
SSE_INTEGER_MUL,
|
||||||
SSE_COMPARE_PACKED_DATA,
|
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,
|
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.InvalidInstructionException;
|
||||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
|
|
||||||
public class IntegerALUExplicitDestination implements X86StaticInstructionHandler
|
public class IntegerCompareTest implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -49,20 +50,17 @@ public class IntegerALUExplicitDestination implements X86StaticInstructionHandle
|
||||||
//get value-operand for operand1
|
//get value-operand for operand1
|
||||||
if(operand1.isMemoryOperand())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
operand1ValueOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, operand1ValueOperand));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operand1ValueOperand = operand1;
|
operand1ValueOperand = operand1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//get value-operand for operand2
|
//get value-operand for operand2
|
||||||
if(operand2.isMemoryOperand())
|
if(operand2.isMemoryOperand())
|
||||||
{
|
{
|
||||||
operand2ValueOperand = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand2ValueOperand));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -70,11 +68,11 @@ public class IntegerALUExplicitDestination implements X86StaticInstructionHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
//Perform integer alu operation
|
//Perform integer alu operation
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, null));
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, Registers.getEFlagsRegister()));
|
||||||
}
|
}
|
||||||
else
|
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;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
|
|
||||||
public class IntegerALUImplicitDestination implements X86StaticInstructionHandler
|
public class IntegerCompareTestSet implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -40,7 +40,7 @@ public class IntegerALUImplicitDestination implements X86StaticInstructionHandle
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
if(
|
if(
|
||||||
(operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
(operand1.isImmediateOperand() || operand1.isIntegerRegisterOperand() || operand1.isMemoryOperand()) &&
|
||||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||||
(operand3==null))
|
(operand3==null))
|
||||||
{
|
{
|
||||||
|
@ -50,20 +50,17 @@ public class IntegerALUImplicitDestination implements X86StaticInstructionHandle
|
||||||
//get value-operand for operand1
|
//get value-operand for operand1
|
||||||
if(operand1.isMemoryOperand())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
operand1ValueOperand = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
operand1ValueOperand = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, operand1ValueOperand));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operand1ValueOperand = operand1;
|
operand1ValueOperand = operand1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//get value-operand for operand2
|
//get value-operand for operand2
|
||||||
if(operand2.isMemoryOperand())
|
if(operand2.isMemoryOperand())
|
||||||
{
|
{
|
||||||
operand2ValueOperand = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
operand2ValueOperand = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, operand2ValueOperand));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -71,20 +68,24 @@ public class IntegerALUImplicitDestination implements X86StaticInstructionHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
//Perform integer alu operation
|
//Perform integer alu operation
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2ValueOperand,
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, Registers.getEFlagsRegister()));
|
||||||
operand1ValueOperand, operand1ValueOperand));
|
|
||||||
|
|
||||||
|
/* using a second intALU micro-op to set the destination
|
||||||
//If operand1 is a memory operand, then perform a store operation too
|
* this is an approximation
|
||||||
|
*/
|
||||||
if(operand1.isMemoryOperand())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, operand1ValueOperand));
|
//instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, operand1ValueOperand));
|
||||||
|
OperandTranslator.processDestinationMemoryOperand(operand1ValueOperand, operand1, instructionArrayList, tempRegisterNum);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( operand2ValueOperand, operand1ValueOperand, operand1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
misc.Error.invalidOperation("Integer operation with implicit operands", operand1, operand2, operand3);
|
misc.Error.invalidOperation("Integer test and set ", operand1, operand2, operand3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -48,19 +48,20 @@ public class IntegerDivision implements X86StaticInstructionHandler
|
||||||
|
|
||||||
if(operand1.isMemoryOperand())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
dividend = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
dividend = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
|
|
||||||
//dividend = [operand1]
|
|
||||||
instructionArrayList.appendInstruction(
|
|
||||||
Instruction.getLoadInstruction(operand1, dividend));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dividend = operand1;
|
dividend = operand1;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* divide EDX:EAX by dividend
|
||||||
|
* quotient in EAX
|
||||||
|
* remainder in EDX
|
||||||
|
*/
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntegerDivisionInstruction
|
instructionArrayList.appendInstruction(Instruction.getIntegerDivisionInstruction
|
||||||
(dividend, accumulatorRegister, accumulatorRegister));
|
(dividend, accumulatorRegister, accumulatorRegister));
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(accumulatorRegister, Registers.getDataRegister(), Registers.getDataRegister()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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 is a memory operand, then we must first fetch the value at its location
|
||||||
if(operand1.isMemoryOperand())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
multiplier = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
multiplier = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, multiplier));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -59,22 +58,28 @@ public class IntegerMultiplication implements X86StaticInstructionHandler
|
||||||
|
|
||||||
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
Operand accumulatorRegister = Registers.getAccumulatorRegister();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* EAX is multiplied by multiplier
|
||||||
|
* lower significant bits in EAX
|
||||||
|
* higher significant bits in EDX
|
||||||
|
*/
|
||||||
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction
|
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction
|
||||||
(accumulatorRegister, multiplier, accumulatorRegister));
|
(accumulatorRegister, multiplier, accumulatorRegister));
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(accumulatorRegister, multiplier, Registers.getDataRegister()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(
|
else if(
|
||||||
(operand1.isIntegerRegisterOperand()) &&
|
(operand1.isIntegerRegisterOperand()) &&
|
||||||
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
(operand2.isImmediateOperand() || operand2.isIntegerRegisterOperand() || operand2.isMemoryOperand()) &&
|
||||||
operand3==null)
|
(operand3==null || operand3.isImmediateOperand()))
|
||||||
{
|
{
|
||||||
multiplicand = operand1;
|
multiplicand = operand1;
|
||||||
|
|
||||||
//if operand1 is a memory operand, then we must first fetch the value at its location
|
//if operand1 is a memory operand, then we must first fetch the value at its location
|
||||||
if(operand2.isMemoryOperand())
|
if(operand2.isMemoryOperand())
|
||||||
{
|
{
|
||||||
multiplier = OperandTranslator.getLocationToStoreValue(operand2, tempRegisterNum);
|
multiplier = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand2, multiplier));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -85,31 +90,7 @@ public class IntegerMultiplication implements X86StaticInstructionHandler
|
||||||
//perform multiplication operation and store the result in operand1
|
//perform multiplication operation and store the result in operand1
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction
|
instructionArrayList.appendInstruction(Instruction.getIntegerMultiplicationInstruction
|
||||||
(multiplicand, multiplier, multiplicand));
|
(multiplicand, multiplier, multiplicand));
|
||||||
}
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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();
|
Operand basePointer = Registers.getBasePointer();
|
||||||
|
|
||||||
//stack-pointer=base-pointer
|
//stack-pointer=base-pointer
|
||||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(stackPointer, basePointer));
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(basePointer, null, stackPointer));
|
||||||
|
|
||||||
//pop top of stack to base-pointer
|
//pop top of stack to base-pointer
|
||||||
(new Pop()).handle(instructionPointer, basePointer, null, null, instructionArrayList, tempRegisterNum);
|
(new Pop()).handle(instructionPointer, basePointer, null, null, instructionArrayList, tempRegisterNum);
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
package emulatorinterface.translator.x86.instruction;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import main.CustomObjectPool;
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
|
@ -40,18 +39,13 @@ public class LoadEffectiveAddress implements X86StaticInstructionHandler
|
||||||
if((operand1.isIntegerRegisterOperand()) &&
|
if((operand1.isIntegerRegisterOperand()) &&
|
||||||
operand2.isMemoryOperand() && operand3==null)
|
operand2.isMemoryOperand() && operand3==null)
|
||||||
{
|
{
|
||||||
if(operand2.getMemoryLocationSecondOperand()==null)
|
Operand srcOpnd1, srcOpnd2, destOpnd;
|
||||||
{
|
|
||||||
//If b is invalid operand, operand1 = a
|
destOpnd = operand1;
|
||||||
instructionArrayList.appendInstruction(Instruction.getMoveInstruction(operand1,
|
srcOpnd1 = operand2.getMemoryLocationFirstOperand();
|
||||||
operand2.getMemoryLocationFirstOperand()));
|
srcOpnd2 = operand2.getMemoryLocationSecondOperand();
|
||||||
}
|
|
||||||
else
|
instructionArrayList.appendInstruction(Instruction.getLEA(srcOpnd1, srcOpnd2, destOpnd));
|
||||||
{
|
|
||||||
//operand1=a+b
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(operand2.getMemoryLocationFirstOperand(),
|
|
||||||
operand2.getMemoryLocationSecondOperand(), operand1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
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));
|
Operand.getImmediateOperand(), counterRegister));
|
||||||
|
|
||||||
//Perform a conditional jump
|
//Perform a conditional jump
|
||||||
ConditionalJump conditionalJump = new ConditionalJump();
|
instructionArrayList.appendInstruction(Instruction.getBranchInstruction(operand1, null));
|
||||||
conditionalJump.handle(instructionPointer, operand1, null, null, instructionArrayList, tempRegisterNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
|
@ -46,18 +47,13 @@ public class Pop implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
if(operand1.isMemoryOperand())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
Operand temporaryIntegerRegister = Registers.getTempIntReg(tempRegisterNum);
|
Operand temporaryIntegerRegister = OperandTranslator.processSourceMemoryOperand(stackPointerLocation, instructionArrayList, tempRegisterNum, true);
|
||||||
|
OperandTranslator.processDestinationMemoryOperand(temporaryIntegerRegister, stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||||
//stack to temporary-register
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(stackPointerLocation, temporaryIntegerRegister));
|
|
||||||
|
|
||||||
//temporary-register to memory
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(operand1, temporaryIntegerRegister));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//stack to operand1 directly
|
//stack to operand1 directly
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(stackPointerLocation, operand1));
|
OperandTranslator.processSourceMemoryOperand(stackPointerLocation, operand1, instructionArrayList, tempRegisterNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//stack-pointer = stack-pointer - 4
|
//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())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
valueToPush = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
valueToPush = OperandTranslator.processSourceMemoryOperand(stackPointerLocation, instructionArrayList, tempRegisterNum, true);
|
||||||
|
|
||||||
instructionArrayList.appendInstruction(
|
|
||||||
Instruction.getLoadInstruction(operand1,valueToPush));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -64,7 +61,7 @@ public class Push implements X86StaticInstructionHandler
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( stackPointer, Operand.getImmediateOperand(), stackPointer));
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction( stackPointer, Operand.getImmediateOperand(), stackPointer));
|
||||||
|
|
||||||
//perform a store to the top of the stack
|
//perform a store to the top of the stack
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(stackPointerLocation, valueToPush));
|
OperandTranslator.processDestinationMemoryOperand(valueToPush, stackPointerLocation, instructionArrayList, tempRegisterNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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,42 +40,16 @@ public class ReturnOp implements X86StaticInstructionHandler
|
||||||
&& operand2 == null && operand3 == null)
|
&& operand2 == null && operand3 == null)
|
||||||
{
|
{
|
||||||
// Create stack-pointer and [stack-pointer]
|
// Create stack-pointer and [stack-pointer]
|
||||||
Operand stackPointer = Registers.getStackPointer();
|
(new Pop()).handle(instructionPointer, Registers.getInstructionPointer(), null, null, instructionArrayList, tempRegisterNum);
|
||||||
Operand stackPointerLocation = Operand.getMemoryOperand(stackPointer, null);
|
/*
|
||||||
|
* FIXME: not handling the case of parameterized number of words popped from the stack
|
||||||
Operand newInstructionPointer;
|
*/
|
||||||
newInstructionPointer = Registers.getInstructionPointer();
|
|
||||||
|
|
||||||
// load the new instruction-pointer from the stack
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(stackPointerLocation, newInstructionPointer));
|
|
||||||
|
|
||||||
// perform an unconditional jump to the new location
|
// perform an unconditional jump to the new location
|
||||||
(new UnconditionalJump()).handle(instructionPointer,
|
(new UnconditionalJump()).handle(instructionPointer,
|
||||||
newInstructionPointer, null, null, instructionArrayList, tempRegisterNum);
|
Registers.getInstructionPointer(), 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 {
|
|
||||||
|
|
||||||
misc.Error.invalidOperation("Return Operation", operand1, operand2,
|
|
||||||
operand3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
misc.Error.invalidOperation("Return Operation", operand1, operand2,
|
misc.Error.invalidOperation("Return Operation", operand1, operand2,
|
||||||
operand3);
|
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;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
|
@ -42,52 +43,39 @@ public class StringCompare implements X86StaticInstructionHandler
|
||||||
|
|
||||||
if(operand1==null && operand2==null && operand3==null)
|
if(operand1==null && operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
sourceLocation = Operand.getMemoryOperand(Registers.getSourceIndexRegister(),
|
sourceLocation = OperandTranslator.processSourceMemoryOperand(Registers.getSourceIndexRegister(), instructionArrayList, tempRegisterNum, true);
|
||||||
null);
|
|
||||||
|
|
||||||
destinationLocation = Operand.getMemoryOperand(Registers.getDestinationIndexRegister(),
|
destinationLocation = OperandTranslator.processSourceMemoryOperand(Registers.getDestinationIndexRegister(), instructionArrayList, tempRegisterNum, true);
|
||||||
null);
|
|
||||||
|
|
||||||
//Load the value at the sourceLocation in a temporary register
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceLocation, destinationLocation, Registers.getEFlagsRegister()));
|
||||||
Operand sourceIndex = Registers.getTempIntReg(tempRegisterNum);
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, sourceIndex));
|
|
||||||
|
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getSourceIndexRegister(), Operand.getImmediateOperand(), Registers.getSourceIndexRegister()));
|
||||||
//Load the value at the destination Location in a temporary register
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), Operand.getImmediateOperand(), Registers.getDestinationIndexRegister()));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
// else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
||||||
operand3==null)
|
// operand3==null)
|
||||||
{
|
// {
|
||||||
sourceLocation = operand2;
|
// sourceLocation = operand2;
|
||||||
destinationLocation = operand1;
|
// 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,
|
// //Load the value at the sourceLocation in a temporary register
|
||||||
// destinationIndex, null, instructionArrayList, tempRegisterNum);
|
// Operand sourceIndex = Registers.getTempIntReg(tempRegisterNum);
|
||||||
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(sourceIndex, destinationIndex, destinationIndex));
|
// 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
|
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;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
|
import generic.Instruction;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class StringMove implements X86StaticInstructionHandler
|
public class StringMove implements X86StaticInstructionHandler
|
||||||
|
@ -36,36 +37,24 @@ public class StringMove implements X86StaticInstructionHandler
|
||||||
TempRegisterNum tempRegisterNum)
|
TempRegisterNum tempRegisterNum)
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
Operand sourceLocation, destinationLocation;
|
Operand sourceLocation;
|
||||||
|
|
||||||
if(operand1==null && operand2==null && operand3==null)
|
if(operand1==null && operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
sourceLocation = Operand.getMemoryOperand(Registers.getSourceIndexRegister(),
|
sourceLocation = OperandTranslator.processSourceMemoryOperand(Operand.getMemoryOperand(Registers.getSourceIndexRegister(), null), instructionArrayList, tempRegisterNum, true);
|
||||||
null);
|
|
||||||
|
|
||||||
destinationLocation = Operand.getMemoryOperand(Registers.getDestinationIndexRegister(),
|
OperandTranslator.processDestinationMemoryOperand(sourceLocation, Operand.getMemoryOperand(Registers.getDestinationIndexRegister(), null), instructionArrayList, tempRegisterNum);
|
||||||
null);
|
|
||||||
|
|
||||||
//Load the value at the sourceLocation in a temporary register
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getSourceIndexRegister(), Operand.getImmediateOperand(), Registers.getSourceIndexRegister()));
|
||||||
Operand tempRegister = Registers.getTempIntReg(tempRegisterNum);
|
instructionArrayList.appendInstruction(Instruction.getIntALUInstruction(Registers.getDestinationIndexRegister(), Operand.getImmediateOperand(), Registers.getDestinationIndexRegister()));
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(sourceLocation, tempRegister));
|
|
||||||
|
|
||||||
//Store the value in tempRegister in destination location
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getStoreInstruction(destinationLocation, tempRegister));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
else if(operand1.isMemoryOperand() && operand2.isMemoryOperand() &&
|
||||||
operand3==null)
|
operand3==null)
|
||||||
{
|
{
|
||||||
sourceLocation = operand2;
|
sourceLocation = OperandTranslator.processSourceMemoryOperand(operand2, instructionArrayList, tempRegisterNum, true);
|
||||||
destinationLocation = operand1;
|
|
||||||
|
|
||||||
//Load the value at the sourceLocation in a temporary register
|
OperandTranslator.processDestinationMemoryOperand(sourceLocation, operand1, instructionArrayList, tempRegisterNum);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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())
|
if(operand1.isMemoryOperand())
|
||||||
{
|
{
|
||||||
//far jump : jumpLocation = [operand1]
|
//far jump : jumpLocation = [operand1]
|
||||||
jumpLocation = OperandTranslator.getLocationToStoreValue(operand1, tempRegisterNum);
|
jumpLocation = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, true);
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, jumpLocation));
|
|
||||||
}
|
}
|
||||||
else
|
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.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class FloatingPointALU implements X86StaticInstructionHandler
|
public class X87FloatingPointALU implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -64,11 +65,7 @@ public class FloatingPointALU implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
Operand st0 = Registers.getTopFPRegister();
|
Operand st0 = Registers.getTopFPRegister();
|
||||||
|
|
||||||
Operand tempFloatRegister;
|
Operand tempFloatRegister = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, false);
|
||||||
tempFloatRegister=Registers.getTempFloatReg(tempRegisterNum);
|
|
||||||
|
|
||||||
//tempFloatRegister = [operand1]
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, tempFloatRegister));
|
|
||||||
|
|
||||||
//st(0) = st(0) + tempFloatRegister
|
//st(0) = st(0) + tempFloatRegister
|
||||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(tempFloatRegister, st0, st0));
|
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(tempFloatRegister, st0, st0));
|
|
@ -2,13 +2,14 @@ package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class FloatingPointCompare implements X86StaticInstructionHandler
|
public class X87FloatingPointCompare implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -23,7 +24,7 @@ public class FloatingPointCompare implements X86StaticInstructionHandler
|
||||||
Operand st0 = Registers.getTopFPRegister();
|
Operand st0 = Registers.getTopFPRegister();
|
||||||
Operand st1 = Registers.getSecondTopFPRegister();
|
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)
|
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.
|
//First implicit operand is implicitly st0 and second operand is passed as argument.
|
||||||
Operand st0 = Registers.getTopFPRegister();
|
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)
|
else if(operand1.isFloatRegisterOperand() && operand2.isFloatRegisterOperand() && operand3==null)
|
||||||
{
|
{
|
||||||
//Both the operands are passed as operands to the command.
|
//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)
|
else if(operand1.isMemoryOperand() && operand2==null && operand3==null)
|
||||||
{
|
{
|
||||||
//First implicit operand is implicitly st0 and second operand is passed as argument.
|
//First implicit operand is implicitly st0 and second operand is passed as argument.
|
||||||
Operand st0 = Registers.getTopFPRegister();
|
Operand st0 = Registers.getTopFPRegister();
|
||||||
Operand tempFloatRegister;
|
Operand tempFloatRegister = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, false);
|
||||||
tempFloatRegister=Registers.getTempFloatReg(tempRegisterNum);
|
|
||||||
|
|
||||||
//tempFloatRegister = [operand1]
|
//tempFloatRegister = [operand1]
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1, tempFloatRegister));
|
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, tempFloatRegister, Registers.getFloatingPointControlWord()));
|
||||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(st0, tempFloatRegister, null));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
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;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
import generic.Instruction;
|
||||||
|
|
||||||
public class FloatingPointConditionalMove implements X86StaticInstructionHandler
|
public class X87FloatingPointConditionalMove implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -13,18 +15,16 @@ public class FloatingPointConditionalMove implements X86StaticInstructionHandler
|
||||||
TempRegisterNum tempRegisterNum)
|
TempRegisterNum tempRegisterNum)
|
||||||
throws InvalidInstructionException
|
throws InvalidInstructionException
|
||||||
{
|
{
|
||||||
//TODO Must do something !!
|
|
||||||
|
|
||||||
if(operand1.isFloatRegisterOperand() && operand2==null
|
if(operand1.isFloatRegisterOperand() && operand2==null
|
||||||
&& operand3==null)
|
&& operand3==null)
|
||||||
{
|
{
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand1, Registers.getFloatingPointControlWord(), Registers.getTopFPRegister()));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(operand1.isFloatRegisterOperand() && operand2.isFloatRegisterOperand()
|
else if(operand1.isFloatRegisterOperand() && operand2.isFloatRegisterOperand()
|
||||||
&& operand3==null)
|
&& operand3==null)
|
||||||
{
|
{
|
||||||
|
instructionArrayList.appendInstruction(Instruction.getFloatingPointALU(operand2, Registers.getFloatingPointControlWord(), operand1));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
|
@ -22,13 +22,14 @@
|
||||||
package emulatorinterface.translator.x86.instruction;
|
package emulatorinterface.translator.x86.instruction;
|
||||||
|
|
||||||
import emulatorinterface.translator.InvalidInstructionException;
|
import emulatorinterface.translator.InvalidInstructionException;
|
||||||
|
import emulatorinterface.translator.x86.operand.OperandTranslator;
|
||||||
import emulatorinterface.translator.x86.registers.Registers;
|
import emulatorinterface.translator.x86.registers.Registers;
|
||||||
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
import emulatorinterface.translator.x86.registers.TempRegisterNum;
|
||||||
import generic.Instruction;
|
import generic.Instruction;
|
||||||
import generic.Operand;
|
import generic.Operand;
|
||||||
import generic.InstructionList;
|
import generic.InstructionList;
|
||||||
|
|
||||||
public class FloatingPointDivision implements X86StaticInstructionHandler
|
public class X87FloatingPointDivision implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
public void handle(long instructionPointer,
|
public void handle(long instructionPointer,
|
||||||
Operand operand1, Operand operand2, Operand operand3,
|
Operand operand1, Operand operand2, Operand operand3,
|
||||||
|
@ -63,11 +64,7 @@ public class FloatingPointDivision implements X86StaticInstructionHandler
|
||||||
{
|
{
|
||||||
Operand st0 = Registers.getTopFPRegister();
|
Operand st0 = Registers.getTopFPRegister();
|
||||||
|
|
||||||
Operand tempFloatRegister;
|
Operand tempFloatRegister = OperandTranslator.processSourceMemoryOperand(operand1, instructionArrayList, tempRegisterNum, false);
|
||||||
tempFloatRegister = Registers.getTempFloatReg(tempRegisterNum);
|
|
||||||
|
|
||||||
instructionArrayList.appendInstruction(Instruction.getLoadInstruction(operand1,
|
|
||||||
tempFloatRegister));
|
|
||||||
|
|
||||||
//st(0) = st(0) + tempFloatRegister
|
//st(0) = st(0) + tempFloatRegister
|
||||||
instructionArrayList.appendInstruction(Instruction.getFloatingPointDivision(st0,
|
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