diff --git a/amd64/Development/cc_amd64.S b/amd64/Development/cc_amd64.S index 66c8d84..6934a54 100644 --- a/amd64/Development/cc_amd64.S +++ b/amd64/Development/cc_amd64.S @@ -135,7 +135,7 @@ zero_loop: # Therefore we will allocate an extra space on heap and use part of it for user stack mov rax, 0x800000 # Allocate 8 MiB for user stack call malloc - mov [rip+user_stack], rax # Save user stack + mov [rip+user_stack], rax # Set user stack call exit_uefi_stack # Switch to user stack mov r15, 0 # Not writing to stderr yet @@ -169,11 +169,10 @@ Done: # program completed Successfully mov rax, 0 # Set exit code 0 Done_1: - # Free pool + call enter_uefi_stack # Switch back to UEFI stack push rax # save exit code - call enter_uefi_stack # Switch back to UEFI stack - + # Free pool mov rcx, [rip+malloc_pool] # arg1 = malloc_pool call free_pool # system->boot->free_pool(malloc_pool) diff --git a/amd64/cc_amd64.M1 b/amd64/cc_amd64.M1 index 68f096e..bd95edb 100644 --- a/amd64/cc_amd64.M1 +++ b/amd64/cc_amd64.M1 @@ -319,7 +319,7 @@ DEFINE NULL 0000000000000000 # Therefore we will allocate an extra space on heap and use part of it for user stack mov_rax, %0x800000 # Allocate 8 MiB for user stack call %malloc - mov_[rip+DWORD],rax %user_stack # Save user stack + mov_[rip+DWORD],rax %user_stack # Set user stack call %exit_uefi_stack # Switch to user stack mov_r15, %0 # Not writing to stderr yet @@ -353,11 +353,10 @@ DEFINE NULL 0000000000000000 # program completed Successfully mov_rax, %0 # Set exit code 0 :Done_1 - # Free pool + call %enter_uefi_stack # Switch back to UEFI stack push_rax # save exit code - call %enter_uefi_stack # Switch back to UEFI stack - + # Free pool mov_rcx,[rip+DWORD] %malloc_pool # arg1 = malloc_pool call %free_pool # system->boot->free_pool(malloc_pool)