diff --git a/boot/freeldr/freeldr/arch/amd64/int386.S b/boot/freeldr/freeldr/arch/amd64/int386.S index f3bd65a4da7..4e0dfa72d1b 100644 --- a/boot/freeldr/freeldr/arch/amd64/int386.S +++ b/boot/freeldr/freeldr/arch/amd64/int386.S @@ -45,7 +45,6 @@ Int386: sub rsp, 40 //.ENDPROLOG -int386_2: /* Copy the int vector to shared memory */ mov dword ptr [BSS_IntVector], ecx diff --git a/boot/freeldr/freeldr/arch/i386/int386.S b/boot/freeldr/freeldr/arch/i386/int386.S index e1c371956d5..295c47cc109 100644 --- a/boot/freeldr/freeldr/arch/i386/int386.S +++ b/boot/freeldr/freeldr/arch/i386/int386.S @@ -73,6 +73,7 @@ Int386_return: mov ecx, REGS_SIZE / 4 rep movsd + /* Restore all registers + segment registers */ popa pop gs pop fs diff --git a/boot/freeldr/freeldr/arch/realmode/int386.inc b/boot/freeldr/freeldr/arch/realmode/int386.inc index 49a63eb9e37..ea3a822424d 100644 --- a/boot/freeldr/freeldr/arch/realmode/int386.inc +++ b/boot/freeldr/freeldr/arch/realmode/int386.inc @@ -37,13 +37,19 @@ Int386: mov ax, word ptr cs:[BSS_RegisterSet + REGS_GS] mov gs, ax + /* Setup ebp only if EBP != 0, otherwise use it only as output */ + mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EBP] + test eax, eax + jz Int386_set_registers + mov ebp, eax + +Int386_set_registers: mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EAX] mov ebx, dword ptr cs:[BSS_RegisterSet + REGS_EBX] mov ecx, dword ptr cs:[BSS_RegisterSet + REGS_ECX] mov edx, dword ptr cs:[BSS_RegisterSet + REGS_EDX] mov esi, dword ptr cs:[BSS_RegisterSet + REGS_ESI] mov edi, dword ptr cs:[BSS_RegisterSet + REGS_EDI] - // Don't setup ebp, we only use it as output! /* Call the interrupt vector */ /*int Int386_vector*/ @@ -72,6 +78,7 @@ Int386_vector_opcode: pushfd pop dword ptr cs:[BSS_RegisterSet + REGS_EFLAGS] + /* Restore all registers + segment registers */ popad pop gs pop fs