From 459e7d54b8233fe5429365e4812d34eed438ea6c Mon Sep 17 00:00:00 2001 From: lucic71 Date: Tue, 28 Jun 2022 19:40:51 +0300 Subject: [PATCH] Added comments to reg_dump and deleted junk --- kernel/log/asm/dump.S | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/kernel/log/asm/dump.S b/kernel/log/asm/dump.S index 0d7aef6..77ddd8d 100644 --- a/kernel/log/asm/dump.S +++ b/kernel/log/asm/dump.S @@ -1,16 +1,22 @@ .global reg_dump .extern printf -.text +.text /* * reg_dump: - * --------- + * ------------- * * Save the context of caller in prev_* memory locations and print them. * + * Registers must be saved before calling other routines because they may + * change the registers. + * + * 4 is added to prev_esp because current esp has the return address. eip + * is fetched by dereferencing esp. */ + reg_dump: mov %esp, prev_esp @@ -43,42 +49,36 @@ reg_dump: add $0x08, %esp - push prev_edx push $EDX_FMT call printf add $0x08, %esp - push prev_ebx push $EBX_FMT call printf add $0x08, %esp - push prev_esp push $ESP_FMT call printf add $0x08, %esp - push prev_ebp push $EBP_FMT call printf add $0x08, %esp - push prev_esi push $ESI_FMT call printf add $0x08, %esp - push prev_edi push $EDI_FMT call printf @@ -119,4 +119,3 @@ reg_dump: prev_esi: .skip 4 prev_edi: .skip 4 prev_eip: .skip 4 -