@Override
protected void onActivityResult(int RequestCode, int ResultCode, Intent Data) {
super.onActivityResult(RequestCode, ResultCode, Data);
if (Data == null) return;
Validate(Data.getStringExtra("Data"));
}
private void Validate(Object __Data) {
Object _Data = Data.Instruction + " " + __Data;
int i;
if (_Data != null && !_Data.toString().equals(" ")) {
String[] Temp = _Data.toString().split(",");
if (Temp.length > 2) {
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(1);
} else {
String Source = Temp[1].trim();
String Destination = Temp[0].split(" ")[1].toLowerCase().trim();
if (Source != null) {
int x = 0, y = 0; String SDest = new String();
if (Arrays.asList(Data.Registers).contains(Source)) {
if (Source.equals("eax")) {
if (Destination.equals("eax")) {
x = Data.EAX;
y = Data.EAX;
SDest = "eax";
}
else if (Destination.equals("ebx")) {
x = Data.EAX;
y = Data.EBX;
SDest = "ebx";
}
else if (Destination.equals("ecx")) {
x = Data.EAX;
y = Data.ECX;
SDest = "ecx";
}
else if (Destination.equals("edx")) {
x = Data.EAX;
y = Data.EDX;
SDest = "edx";
}
}
else if (Source.equals("ebx")) {
if (Destination.equals("eax")) {
x = Data.EBX;
y = Data.EAX;
SDest = "eax";
}
else if (Destination.equals("ebx")) {
x = Data.EBX;
y = Data.EBX;
SDest = "ebx";
}
else if (Destination.equals("ecx")) {
x = Data.EBX;
y = Data.ECX;
SDest = "ecx";
}
else if (Destination.equals("edx")) {
x = Data.EBX;
y = Data.EDX;
SDest = "edx";
}
}
else if (Source.equals("ecx")) {
if (Destination.equals("eax")) {
x = Data.ECX;
y = Data.EAX;
SDest = "eax";
}
else if (Destination.equals("ebx")) {
x = Data.ECX;
y = Data.EBX;
SDest = "ebx";
}
else if (Destination.equals("ecx")) {
x = Data.ECX;
y = Data.ECX;
SDest = "ecx";
}
else if (Destination.equals("edx")) {
x = Data.ECX;
y = Data.EDX;
SDest = "edx";
}
}
else if (Source.equals("edx")) {
if (Destination.equals("eax")) {
x = Data.EDX;
y = Data.EAX;
SDest = "eax";
}
else if (Destination.equals("ebx")) {
x = Data.EDX;
y = Data.EBX;
SDest = "ebx";
}
else if (Destination.equals("ecx")) {
x = Data.EDX;
y = Data.ECX;
SDest = "ecx";
}
else if (Destination.equals("edx")) {
x = Data.EDX;
y = Data.EDX;
SDest = "edx";
}
}
}
else {
if (Destination.equals("eax")) {
x = Integer.parseInt(Source);
y = Data.EAX;
SDest = "eax";
}
else if (Destination.equals("ebx")) {
x = Integer.parseInt(Source);
y = Data.EBX;
SDest = "ebx";
}
else if (Destination.equals("ecx")) {
x = Integer.parseInt(Source);
y = Data.ECX;
SDest = "ecx";
}
else if (Destination.equals("edx")) {
x = Integer.parseInt(Source);
y = Data.EDX;
SDest = "edx";
}
}
int z = 0, a = x, b = y;
if (Data.Instruction.equals("mov")) z = a;
else if (Data.Instruction.equals("add")) z = b + a;
else if (Data.Instruction.equals("sub")) z = b - a;
else if (Data.Instruction.equals("int")) z = b;
if (SDest == "eax") Data.EAX = z;
else if (SDest == "ebx") Data.EBX = z;
else if (SDest == "ecx") Data.ECX = z;
else if (SDest == "edx") Data.EDX = z;
txtRegEAX.setText(String.valueOf(Data.EAX));
txtRegEBX.setText(String.valueOf(Data.EBX));
txtRegECX.setText(String.valueOf(Data.ECX));
txtRegEDX.setText(String.valueOf(Data.EDX));
}
}
}
}