/* 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;
  NewValue = 0;
  RegSize  = 0;
  while (RegSize < REG_SIZE) {
    TempValue = HexCharToInt (*InBufPtr++);
    if (TempValue < 0) {
      SendError (GDB_EBADMEMDATA);
      return NULL;
    }
    NewValue += (TempValue << (RegSize+4));
    TempValue = HexCharToInt (*InBufPtr++);
    if (TempValue < 0) {
      SendError (GDB_EBADMEMDATA);
      return NULL;
    }
    NewValue += (TempValue << RegSize);
    RegSize   = RegSize + 8;
  }
  *(FindPointerToRegister (SystemContext, RegNumber)) = NewValue;
  return InBufPtr;
}