/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr  */
CHAR8* BasicWriteRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr)
/* Adds the RegNumber-th register's value to the output buffer, starting at the given OutBufPtr  */
CHAR8* BasicWriteRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr)
{
  UINTN   RegSize;
  UINTN   TempValue;
  UINT32  NewValue;
  if (gRegisterOffsets[RegNumber] > 0xF00) {
    return InBufPtr + 8;
  }
  NewValue = 0;
  RegSize  = 0;
  while (RegSize < 32) {
    TempValue = HexCharToInt (*InBufPtr++);
    if ((INTN)TempValue < 0) {
      SendError (GDB_EBADMEMDATA);
      return NULL;
    }
    NewValue += (TempValue << (RegSize+4));
    TempValue = HexCharToInt (*InBufPtr++);
    if ((INTN)TempValue < 0) {
      SendError (GDB_EBADMEMDATA);
      return NULL;
    }
    NewValue += (TempValue << RegSize);
    RegSize   = RegSize + 8;
  }
  *(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
  return InBufPtr;
}