]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EbcDxe/EbcExecute.c
Improve coding style in MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcExecute.c
index 721ee71197af810f8dbd6b5f739437d74c9b37f0..85fa58fb25915cfa47abec3cb06ab139a9849477 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Contains code that implements the virtual machine.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
+Copyright (c) 2006 - 2010, Intel Corporation. <BR>\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -1445,7 +1445,7 @@ EbcExecute (
     StackCorrupted = 1;\r
   }\r
 \r
-  VmPtr->FramePtr = (VOID *) ((UINT8 *) (UINTN) VmPtr->R[0] + 8);\r
+  VmPtr->FramePtr = (VOID *) ((UINT8 *) (UINTN) VmPtr->Gpr[0] + 8);\r
 \r
   //\r
   // Try to get the debug support for EBC\r
@@ -1517,7 +1517,7 @@ EbcExecute (
       EbcDebugSignalException (EXCEPT_EBC_STACK_FAULT, EXCEPTION_FLAG_FATAL, VmPtr);\r
       StackCorrupted = 1;\r
     }\r
-    if ((StackCorrupted == 0) && ((UINT64)VmPtr->R[0] <= (UINT64)(UINTN) VmPtr->StackTop)) {\r
+    if ((StackCorrupted == 0) && ((UINT64)VmPtr->Gpr[0] <= (UINT64)(UINTN) VmPtr->StackTop)) {\r
       EbcDebugSignalException (EXCEPT_EBC_STACK_FAULT, EXCEPTION_FLAG_FATAL, VmPtr);\r
       StackCorrupted = 1;\r
     }\r
@@ -1682,7 +1682,7 @@ ExecuteMOVxx (
     //\r
     // Indirect form @R2. Compute address of operand2\r
     //\r
-    Source = (UINTN) (VmPtr->R[OPERAND2_REGNUM (Operands)] + Index64Op2);\r
+    Source = (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);\r
     //\r
     // Now get the data from the source. Always 0-extend and let the compiler\r
     // sign-extend where required.\r
@@ -1718,7 +1718,7 @@ ExecuteMOVxx (
     //\r
     // Not indirect source: MOVxx {@}Rx, Ry [Index]\r
     //\r
-    Data64 = VmPtr->R[OPERAND2_REGNUM (Operands)] + Index64Op2;\r
+    Data64 = VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2;\r
     //\r
     // Did Operand2 have an index? If so, treat as two signed values since\r
     // indexes are signed values.\r
@@ -1754,7 +1754,7 @@ ExecuteMOVxx (
     //\r
     // Reuse the Source variable to now be dest.\r
     //\r
-    Source = (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index64Op1);\r
+    Source = (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index64Op1);\r
     //\r
     // Do the write based on the size\r
     //\r
@@ -1802,7 +1802,7 @@ ExecuteMOVxx (
     // Direct storage in register. Clear unused bits and store back to\r
     // register.\r
     //\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = Data64 & DataMask;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Data64 & DataMask;\r
   }\r
   //\r
   // Advance the instruction pointer\r
@@ -1851,7 +1851,7 @@ ExecuteBREAK (
     //  16-8  = Major version\r
     //  7-0   = Minor version\r
     //\r
-    VmPtr->R[7] = GetVmVersion ();\r
+    VmPtr->Gpr[7] = GetVmVersion ();\r
     break;\r
 \r
   //\r
@@ -1881,8 +1881,8 @@ ExecuteBREAK (
   // After we're done, *(UINT64 *)R7 will be the address of the new thunk.\r
   //\r
   case 5:\r
-    Offset            = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->R[7]);\r
-    U64EbcEntryPoint  = (UINT64) (VmPtr->R[7] + Offset + 4);\r
+    Offset            = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->Gpr[7]);\r
+    U64EbcEntryPoint  = (UINT64) (VmPtr->Gpr[7] + Offset + 4);\r
     EbcEntryPoint     = (VOID *) (UINTN) U64EbcEntryPoint;\r
 \r
     //\r
@@ -1896,14 +1896,14 @@ ExecuteBREAK (
     //\r
     // Finally replace the EBC entry point memory with the thunk address\r
     //\r
-    VmWriteMem64 (VmPtr, (UINTN) VmPtr->R[7], (UINT64) (UINTN) Thunk);\r
+    VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[7], (UINT64) (UINTN) Thunk);\r
     break;\r
 \r
   //\r
   // Compiler setting version per value in R7\r
   //\r
   case 6:\r
-    VmPtr->CompilerVersion = (UINT32) VmPtr->R[7];\r
+    VmPtr->CompilerVersion = (UINT32) VmPtr->Gpr[7];\r
     //\r
     // Check compiler version against VM version?\r
     //\r
@@ -2251,12 +2251,12 @@ ExecuteMOVI (
       Mask64 = (UINT64)~0;\r
     }\r
 \r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = ImmData64 & Mask64;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = ImmData64 & Mask64;\r
   } else {\r
     //\r
     // Get the address then write back based on size of the move\r
     //\r
-    Op1 = (UINT64) VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16;\r
+    Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;\r
     if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH8) {\r
       VmWriteMem8 (VmPtr, (UINTN) Op1, (UINT8) ImmData64);\r
     } else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH16) {\r
@@ -2361,12 +2361,12 @@ ExecuteMOVIn (
       return EFI_UNSUPPORTED;\r
     }\r
 \r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = ImmedIndex64;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = ImmedIndex64;\r
   } else {\r
     //\r
     // Get the address\r
     //\r
-    Op1 = (UINT64) VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16;\r
+    Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;\r
     VmWriteMemN (VmPtr, (UINTN) Op1, (INTN) ImmedIndex64);\r
   }\r
   //\r
@@ -2460,14 +2460,14 @@ ExecuteMOVREL (
       return EFI_UNSUPPORTED;\r
     }\r
 \r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = (VM_REGISTER) Op2;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (VM_REGISTER) Op2;\r
   } else {\r
     //\r
     // Get the address = [Rx] + Index16\r
     // Write back the result. Always a natural size write, since\r
     // we're talking addresses here.\r
     //\r
-    Op1 = (UINT64) VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16;\r
+    Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;\r
     VmWriteMemN (VmPtr, (UINTN) Op1, (UINTN) Op2);\r
   }\r
   //\r
@@ -2551,7 +2551,7 @@ ExecuteMOVsnw (
   //\r
   // Get the data from the source.\r
   //\r
-  Op2 = (INT64) ((INTN) (VmPtr->R[OPERAND2_REGNUM (Operands)] + Op2Index));\r
+  Op2 = (INT64) ((INTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index));\r
   if (OPERAND2_INDIRECT (Operands)) {\r
     Op2 = (INT64) (INTN) VmReadMemN (VmPtr, (UINTN) Op2);\r
   }\r
@@ -2559,9 +2559,9 @@ ExecuteMOVsnw (
   // Now write back the result.\r
   //\r
   if (!OPERAND1_INDIRECT (Operands)) {\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = Op2;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;\r
   } else {\r
-    VmWriteMemN (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);\r
+    VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);\r
   }\r
   //\r
   // Advance the instruction pointer\r
@@ -2644,7 +2644,7 @@ ExecuteMOVsnd (
   //\r
   // Get the data from the source.\r
   //\r
-  Op2 = (INT64) ((INTN) (VmPtr->R[OPERAND2_REGNUM (Operands)] + Op2Index));\r
+  Op2 = (INT64) ((INTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index));\r
   if (OPERAND2_INDIRECT (Operands)) {\r
     Op2 = (INT64) (INTN) VmReadMemN (VmPtr, (UINTN) Op2);\r
   }\r
@@ -2652,9 +2652,9 @@ ExecuteMOVsnd (
   // Now write back the result.\r
   //\r
   if (!OPERAND1_INDIRECT (Operands)) {\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = Op2;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;\r
   } else {\r
-    VmWriteMemN (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);\r
+    VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Op1Index), (UINTN) Op2);\r
   }\r
   //\r
   // Advance the instruction pointer\r
@@ -2710,15 +2710,15 @@ ExecutePUSHn (
   // Get the data to push\r
   //\r
   if (OPERAND1_INDIRECT (Operands)) {\r
-    DataN = VmReadMemN (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16));\r
+    DataN = VmReadMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));\r
   } else {\r
-    DataN = (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16);\r
+    DataN = (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16);\r
   }\r
   //\r
   // Adjust the stack down.\r
   //\r
-  VmPtr->R[0] -= sizeof (UINTN);\r
-  VmWriteMemN (VmPtr, (UINTN) VmPtr->R[0], DataN);\r
+  VmPtr->Gpr[0] -= sizeof (UINTN);\r
+  VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], DataN);\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -2770,29 +2770,29 @@ ExecutePUSH (
   //\r
   if ((Opcode & PUSHPOP_M_64) != 0) {\r
     if (OPERAND1_INDIRECT (Operands)) {\r
-      Data64 = VmReadMem64 (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16));\r
+      Data64 = VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));\r
     } else {\r
-      Data64 = (UINT64) VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16;\r
+      Data64 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;\r
     }\r
     //\r
     // Adjust the stack down, then write back the data\r
     //\r
-    VmPtr->R[0] -= sizeof (UINT64);\r
-    VmWriteMem64 (VmPtr, (UINTN) VmPtr->R[0], Data64);\r
+    VmPtr->Gpr[0] -= sizeof (UINT64);\r
+    VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], Data64);\r
   } else {\r
     //\r
     // 32-bit data\r
     //\r
     if (OPERAND1_INDIRECT (Operands)) {\r
-      Data32 = VmReadMem32 (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16));\r
+      Data32 = VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));\r
     } else {\r
-      Data32 = (UINT32) VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16;\r
+      Data32 = (UINT32) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;\r
     }\r
     //\r
     // Adjust the stack down and write the data\r
     //\r
-    VmPtr->R[0] -= sizeof (UINT32);\r
-    VmWriteMem32 (VmPtr, (UINTN) VmPtr->R[0], Data32);\r
+    VmPtr->Gpr[0] -= sizeof (UINT32);\r
+    VmWriteMem32 (VmPtr, (UINTN) VmPtr->Gpr[0], Data32);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -2843,15 +2843,15 @@ ExecutePOPn (
   //\r
   // Read the data off the stack, then adjust the stack pointer\r
   //\r
-  DataN = VmReadMemN (VmPtr, (UINTN) VmPtr->R[0]);\r
-  VmPtr->R[0] += sizeof (UINTN);\r
+  DataN = VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);\r
+  VmPtr->Gpr[0] += sizeof (UINTN);\r
   //\r
   // Do the write-back\r
   //\r
   if (OPERAND1_INDIRECT (Operands)) {\r
-    VmWriteMemN (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16), DataN);\r
+    VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);\r
   } else {\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) ((UINTN) DataN + Index16);\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) ((UINTN) DataN + Index16);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -2907,29 +2907,29 @@ ExecutePOP (
     //\r
     // Read the data off the stack, then adjust the stack pointer\r
     //\r
-    Data64 = VmReadMem64 (VmPtr, (UINTN) VmPtr->R[0]);\r
-    VmPtr->R[0] += sizeof (UINT64);\r
+    Data64 = VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);\r
+    VmPtr->Gpr[0] += sizeof (UINT64);\r
     //\r
     // Do the write-back\r
     //\r
     if (OPERAND1_INDIRECT (Operands)) {\r
-      VmWriteMem64 (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16), Data64);\r
+      VmWriteMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data64);\r
     } else {\r
-      VmPtr->R[OPERAND1_REGNUM (Operands)] = Data64 + Index16;\r
+      VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Data64 + Index16;\r
     }\r
   } else {\r
     //\r
     // 32-bit pop. Read it off the stack and adjust the stack pointer\r
     //\r
-    Data32 = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->R[0]);\r
-    VmPtr->R[0] += sizeof (UINT32);\r
+    Data32 = (INT32) VmReadMem32 (VmPtr, (UINTN) VmPtr->Gpr[0]);\r
+    VmPtr->Gpr[0] += sizeof (UINT32);\r
     //\r
     // Do the write-back\r
     //\r
     if (OPERAND1_INDIRECT (Operands)) {\r
-      VmWriteMem32 (VmPtr, (UINTN) (VmPtr->R[OPERAND1_REGNUM (Operands)] + Index16), Data32);\r
+      VmWriteMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), Data32);\r
     } else {\r
-      VmPtr->R[OPERAND1_REGNUM (Operands)] = (INT64) Data32 + Index16;\r
+      VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) Data32 + Index16;\r
     }\r
   }\r
 \r
@@ -3004,11 +3004,11 @@ ExecuteCALL (
   // put our return address and frame pointer on the VM stack.\r
   //\r
   if ((Operands & OPERAND_M_NATIVE_CALL) == 0) {\r
-    VmPtr->R[0] -= 8;\r
-    VmWriteMemN (VmPtr, (UINTN) VmPtr->R[0], (UINTN) FramePtr);\r
-    VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->R[0];\r
-    VmPtr->R[0] -= 8;\r
-    VmWriteMem64 (VmPtr, (UINTN) VmPtr->R[0], (UINT64) (UINTN) (VmPtr->Ip + Size));\r
+    VmPtr->Gpr[0] -= 8;\r
+    VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);\r
+    VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];\r
+    VmPtr->Gpr[0] -= 8;\r
+    VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));\r
   }\r
   //\r
   // If 64-bit data, then absolute jump only\r
@@ -3023,7 +3023,7 @@ ExecuteCALL (
       //\r
       // Call external function, get the return value, and advance the IP\r
       //\r
-      EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->R[0], FramePtr, Size);\r
+      EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->Gpr[0], FramePtr, Size);\r
     }\r
   } else {\r
     //\r
@@ -3032,7 +3032,7 @@ ExecuteCALL (
     // Compiler should take care of upper bits if 32-bit machine.\r
     //\r
     if (OPERAND1_REGNUM (Operands) != 0) {\r
-      Immed64 = (UINT64) (UINTN) VmPtr->R[OPERAND1_REGNUM (Operands)];\r
+      Immed64 = (UINT64) (UINTN) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
     }\r
     //\r
     // Get final address\r
@@ -3060,13 +3060,13 @@ ExecuteCALL (
       // Native call. Relative or absolute?\r
       //\r
       if ((Operands & OPERAND_M_RELATIVE_ADDR) != 0) {\r
-        EbcLLCALLEX (VmPtr, (UINTN) (Immed64 + VmPtr->Ip + Size), (UINTN) VmPtr->R[0], FramePtr, Size);\r
+        EbcLLCALLEX (VmPtr, (UINTN) (Immed64 + VmPtr->Ip + Size), (UINTN) VmPtr->Gpr[0], FramePtr, Size);\r
       } else {\r
         if ((VmPtr->StopFlags & STOPFLAG_BREAK_ON_CALLEX) != 0) {\r
           CpuBreakpoint ();\r
         }\r
 \r
-        EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->R[0], FramePtr, Size);\r
+        EbcLLCALLEX (VmPtr, (UINTN) Immed64, (UINTN) VmPtr->Gpr[0], FramePtr, Size);\r
       }\r
     }\r
   }\r
@@ -3095,14 +3095,14 @@ ExecuteRET (
   // If we're at the top of the stack, then simply set the done\r
   // flag and return\r
   //\r
-  if (VmPtr->StackRetAddr == (UINT64) VmPtr->R[0]) {\r
+  if (VmPtr->StackRetAddr == (UINT64) VmPtr->Gpr[0]) {\r
     VmPtr->StopFlags |= STOPFLAG_APP_DONE;\r
   } else {\r
     //\r
     // Pull the return address off the VM app's stack and set the IP\r
     // to it\r
     //\r
-    if (!IS_ALIGNED ((UINTN) VmPtr->R[0], sizeof (UINT16))) {\r
+    if (!IS_ALIGNED ((UINTN) VmPtr->Gpr[0], sizeof (UINT16))) {\r
       EbcDebugSignalException (\r
         EXCEPT_EBC_ALIGNMENT_CHECK,\r
         EXCEPTION_FLAG_FATAL,\r
@@ -3112,10 +3112,10 @@ ExecuteRET (
     //\r
     // Restore the IP and frame pointer from the stack\r
     //\r
-    VmPtr->Ip = (VMIP) (UINTN) VmReadMem64 (VmPtr, (UINTN) VmPtr->R[0]);\r
-    VmPtr->R[0] += 8;\r
-    VmPtr->FramePtr = (VOID *) VmReadMemN (VmPtr, (UINTN) VmPtr->R[0]);\r
-    VmPtr->R[0] += 8;\r
+    VmPtr->Ip = (VMIP) (UINTN) VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);\r
+    VmPtr->Gpr[0] += 8;\r
+    VmPtr->FramePtr = (VOID *) VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);\r
+    VmPtr->Gpr[0] += 8;\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -3155,7 +3155,7 @@ ExecuteCMP (
   //\r
   // Get the register data we're going to compare to\r
   //\r
-  Op1 = VmPtr->R[OPERAND1_REGNUM (Operands)];\r
+  Op1 = VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
   //\r
   // Get immediate data\r
   //\r
@@ -3176,15 +3176,15 @@ ExecuteCMP (
   //\r
   if (OPERAND2_INDIRECT (Operands)) {\r
     if ((Opcode & OPCODE_M_64BIT) != 0) {\r
-      Op2 = (INT64) VmReadMem64 (VmPtr, (UINTN) (VmPtr->R[OPERAND2_REGNUM (Operands)] + Index16));\r
+      Op2 = (INT64) VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16));\r
     } else {\r
       //\r
       // 32-bit operations. 0-extend the values for all cases.\r
       //\r
-      Op2 = (INT64) (UINT64) ((UINT32) VmReadMem32 (VmPtr, (UINTN) (VmPtr->R[OPERAND2_REGNUM (Operands)] + Index16)));\r
+      Op2 = (INT64) (UINT64) ((UINT32) VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16)));\r
     }\r
   } else {\r
-    Op2 = VmPtr->R[OPERAND2_REGNUM (Operands)] + Index16;\r
+    Op2 = VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;\r
   }\r
   //\r
   // Now do the compare\r
@@ -3327,7 +3327,7 @@ ExecuteCMPI (
   //\r
   // Get operand1 data we're going to compare to\r
   //\r
-  Op1 = (INT64) VmPtr->R[OPERAND1_REGNUM (Operands)];\r
+  Op1 = (INT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
   if (OPERAND1_INDIRECT (Operands)) {\r
     //\r
     // Indirect operand1. Fetch 32 or 64-bit value based on compare size.\r
@@ -4165,7 +4165,7 @@ ExecuteDataManip (
   //\r
   // Now get operand2 (source). It's of format {@}R2 {Index16|Immed16}\r
   //\r
-  Op2 = (UINT64) VmPtr->R[OPERAND2_REGNUM (Operands)] + Index16;\r
+  Op2 = (UINT64) VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index16;\r
   if (OPERAND2_INDIRECT (Operands)) {\r
     //\r
     // Indirect form: @R2 Index16. Fetch as 32- or 64-bit data\r
@@ -4195,7 +4195,7 @@ ExecuteDataManip (
   // Get operand1 (destination and sometimes also an actual operand)\r
   // of form {@}R1\r
   //\r
-  Op1 = VmPtr->R[OPERAND1_REGNUM (Operands)];\r
+  Op1 = VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
   if (OPERAND1_INDIRECT (Operands)) {\r
     if ((Opcode & DATAMANIP_M_64) != 0) {\r
       Op1 = VmReadMem64 (VmPtr, (UINTN) Op1);\r
@@ -4238,7 +4238,7 @@ ExecuteDataManip (
   // Write back the result.\r
   //\r
   if (OPERAND1_INDIRECT (Operands)) {\r
-    Op1 = VmPtr->R[OPERAND1_REGNUM (Operands)];\r
+    Op1 = VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
     if ((Opcode & DATAMANIP_M_64) != 0) {\r
       VmWriteMem64 (VmPtr, (UINTN) Op1, Op2);\r
     } else {\r
@@ -4249,9 +4249,9 @@ ExecuteDataManip (
     // Storage back to a register. Write back, clearing upper bits (as per\r
     // the specification) if 32-bit operation.\r
     //\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = Op2;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = Op2;\r
     if ((Opcode & DATAMANIP_M_64) == 0) {\r
-      VmPtr->R[OPERAND1_REGNUM (Operands)] &= 0xFFFFFFFF;\r
+      VmPtr->Gpr[OPERAND1_REGNUM (Operands)] &= 0xFFFFFFFF;\r
     }\r
   }\r
   //\r
@@ -4298,7 +4298,7 @@ ExecuteLOADSP (
     // Spec states that this instruction will not modify reserved bits in\r
     // the flags register.\r
     //\r
-    VmPtr->Flags = (VmPtr->Flags &~VMFLAGS_ALL_VALID) | (VmPtr->R[OPERAND2_REGNUM (Operands)] & VMFLAGS_ALL_VALID);\r
+    VmPtr->Flags = (VmPtr->Flags &~VMFLAGS_ALL_VALID) | (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] & VMFLAGS_ALL_VALID);\r
     break;\r
 \r
   default:\r
@@ -4351,14 +4351,14 @@ ExecuteSTORESP (
     //\r
     // Retrieve the value in the flags register, then clear reserved bits\r
     //\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = (UINT64) (VmPtr->Flags & VMFLAGS_ALL_VALID);\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64) (VmPtr->Flags & VMFLAGS_ALL_VALID);\r
     break;\r
 \r
   //\r
   // Get IP -- address of following instruction\r
   //\r
   case 1:\r
-    VmPtr->R[OPERAND1_REGNUM (Operands)] = (UINT64) (UINTN) VmPtr->Ip + 2;\r
+    VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (UINT64) (UINTN) VmPtr->Ip + 2;\r
     break;\r
 \r
   default:\r