/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr  */
CHAR8* BasicReadRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr  */
CHAR8* BasicReadRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
{
  UINTN  RegSize;
  CHAR8  Char;
  if (gRegisterOffsets[RegNumber] > 0xF00) {
    AsciiSPrint (OutBufPtr, 9, "00000000");
    OutBufPtr += 8;
    return OutBufPtr;
  }
  RegSize = 0;
  while (RegSize < 32) {
    Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
    if ((Char >= 'A') && (Char <= 'F')) {
      Char = Char - 'A' + 'a';
    }
    *OutBufPtr++ = Char;
    Char = mHexToStr[(UINT8)((*FindPointerToRegister (SystemContext, RegNumber) >> RegSize) & 0xf)];
    if ((Char >= 'A') && (Char <= 'F')) {
      Char = Char - 'A' + 'a';
    }
    *OutBufPtr++ = Char;
    RegSize = RegSize + 8;
  }
  return OutBufPtr;
}