From: Michael D. Lowis Date: Fri, 26 Feb 2021 04:06:35 +0000 (-0500) Subject: tweaked function entry and exit logic X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=a42be1a2947422a12123c74956ef9a6d42b7240c;p=proto%2Falvm.git tweaked function entry and exit logic --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cba7efc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +a.out diff --git a/main.s b/main.s index 9ba7050..6be8a68 100644 --- a/main.s +++ b/main.s @@ -1,9 +1,11 @@ //--------------------------------------------------------------------- // Register Usage //--------------------------------------------------------------------- -// %rax Accumulator Register // %rsi Program Counter // %rsp Argument Stack Pointer +// %rbp Stack Frame Pointer +// %rax Accumulator Register +// %rbx Temporary Register //--------------------------------------------------------------------- // Main Routine @@ -45,7 +47,6 @@ code_\name : .p2align 4, 0x90 EXEC_FUN: pushq %rsi - pushq %rsp pushq %rbp leaq 8(%rax), %rsi movq %rsp, %rbp @@ -62,11 +63,9 @@ defcode OP_halt // Exit a function, returning to the caller defcode OP_return - popq %rbx lodsq - movq %rbp, %rsp + popq %rbx popq %rbp - popq %rsp popq %rsi leaq (%rsp, %rax, 8), %rsp pushq %rbx