diff -urp bochs-2.2.6/gdbstub.cc bochs-2.2.6.orig/gdbstub.cc --- bochs-2.2.6.orig/gdbstub.cc 2006-01-17 09:15:29.000000000 -0800 +++ bochs-2.2.6/gdbstub.cc 2006-04-03 13:47:39.000000000 -0700 @@ -672,35 +672,36 @@ case 'g': #if !BX_SUPPORT_X86_64 - registers[0] = EAX; - registers[1] = ECX; - registers[2] = EDX; - registers[3] = EBX; - registers[4] = ESP; - registers[5] = EBP; - registers[6] = ESI; - registers[7] = EDI; + WriteHostDWordToLittleEndian(registers + 0, EAX); + WriteHostDWordToLittleEndian(registers + 1, ECX); + WriteHostDWordToLittleEndian(registers + 2, EDX); + WriteHostDWordToLittleEndian(registers + 3, EBX); + WriteHostDWordToLittleEndian(registers + 4, ESP); + WriteHostDWordToLittleEndian(registers + 5, EBP); + WriteHostDWordToLittleEndian(registers + 6, ESI); + WriteHostDWordToLittleEndian(registers + 7, EDI); if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT) { - registers[8] = EIP + 1; + WriteHostDWordToLittleEndian(registers + 8, EIP + 1); } else { - registers[8] = EIP; + WriteHostDWordToLittleEndian(registers + 8, EIP); } - registers[9] = BX_CPU_THIS_PTR read_eflags(); - registers[10] = - BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value; - registers[11] = - BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value; - registers[12] = - BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value; - registers[13] = - BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value; - registers[14] = - BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value; - registers[15] = - BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value; + WriteHostDWordToLittleEndian(registers + 9, + BX_CPU_THIS_PTR read_eflags()); + WriteHostDWordToLittleEndian(registers + 10, + BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value); + WriteHostDWordToLittleEndian(registers + 11, + BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value); + WriteHostDWordToLittleEndian(registers + 12, + BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value); + WriteHostDWordToLittleEndian(registers + 13, + BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value); + WriteHostDWordToLittleEndian(registers + 14, + BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value); + WriteHostDWordToLittleEndian(registers + 15, + BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value); mem2hex((char *)registers, obuf, NUMREGSBYTES); #else #define PUTREG(buf, val, len) do { \