Skip to content

Commit

Permalink
asm-macros: SAVE_ALL_REGS32 in protected mode
Browse files Browse the repository at this point in the history
In protected mode, like in head.S, we want to be able to save all
registers. {SAVE,RESTORE}_ALL_REGS32 should therefore always be working
on 32-bit registers and not be build-dependent.

Signed-off-by: Johannes Wikner <[email protected]>
  • Loading branch information
sktt authored and wipawel committed Aug 29, 2023
1 parent d162ce1 commit a5a2a96
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions include/arch/x86/asm-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,33 @@
.endm

.macro SAVE_ALL_REGS32
push %eax
push %ebx
push %ecx
push %edx
push %esi
push %edi
push %ebp
.endm

.macro RESTORE_ALL_REGS32
pop %ebp
pop %edi
pop %esi
pop %edx
pop %ecx
pop %ebx
pop %eax
.endm

.macro SAVE_ALL_REGS
push %_ASM_AX
push %_ASM_BX
push %_ASM_CX
push %_ASM_DX
push %_ASM_SI
push %_ASM_DI
push %_ASM_BP
.endm

.macro RESTORE_ALL_REGS32
pop %_ASM_BP
pop %_ASM_DI
pop %_ASM_SI
pop %_ASM_DX
pop %_ASM_CX
pop %_ASM_BX
pop %_ASM_AX
.endm

.macro SAVE_ALL_REGS
SAVE_ALL_REGS32
#if defined(__x86_64__)
push %r8
push %r9
Expand All @@ -113,7 +119,13 @@
pop %r9
pop %r8
#endif
RESTORE_ALL_REGS32
pop %_ASM_BP
pop %_ASM_DI
pop %_ASM_SI
pop %_ASM_DX
pop %_ASM_CX
pop %_ASM_BX
pop %_ASM_AX
.endm

.macro SAVE_CALLEE_SAVED_REGS
Expand Down

0 comments on commit a5a2a96

Please sign in to comment.