Fix stack growing direction in GDT being swapped

In the GDT, the direction in which the stack grows in x86 has been
ignored; for reserving space on the stack, the ESP register was added
to and for cleaning up that space, ESP was subtracted from. That is
obviously wrong and is fixed with this commit.
This commit is contained in:
Eric-Paul Ickhorn 2024-08-17 16:46:23 +02:00
parent 95faf0cc5a
commit 21ba34f526
Signed by: epickh
GPG Key ID: 1358818BAA38B104
1 changed files with 5 additions and 5 deletions

View File

@ -27,7 +27,7 @@ GDT_ENTRY_COUNT equ 3
make_regular_data_segment_in_gdt:
.prolog:
push esi
add esp, 64
sub esp, 64
mov esi, esp
mov [esi + (64 - 4)], eax
@ -98,7 +98,7 @@ make_regular_data_segment_in_gdt:
mov ebx, [esi + (64 - 8)]
mov eax, [esi + (64 - 4)]
sub esp, 64
add esp, 64
pop esi
ret
@ -134,7 +134,7 @@ make_regular_data_segment_in_gdt:
make_code_segment_in_gdt:
.prolog:
push esi
add esp, 64
sub esp, 64
mov esi, esp
mov [esi + (64 - 4)], eax
@ -205,7 +205,7 @@ make_code_segment_in_gdt:
mov ebx, [esi + (64 - 8)]
mov eax, [esi + (64 - 4)]
sub esp, 64
add esp, 64
pop esi
ret
@ -224,7 +224,7 @@ make_code_segment_in_gdt:
load_flat_gdt:
.prolog:
push esi
add esp, 64
sub esp, 64
mov esi, esp
mov [esi + (64 - 4)], eax