From a42be1a2947422a12123c74956ef9a6d42b7240c Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Thu, 25 Feb 2021 23:06:35 -0500 Subject: [PATCH] tweaked function entry and exit logic --- .gitignore | 1 + main.s | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 .gitignore 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 -- 2.49.0