]> git.mdlowis.com Git - proto/alvm.git/commitdiff
tweaked function entry and exit logic
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 26 Feb 2021 04:06:35 +0000 (23:06 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 26 Feb 2021 04:06:35 +0000 (23:06 -0500)
.gitignore [new file with mode: 0644]
main.s

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..cba7efc
--- /dev/null
@@ -0,0 +1 @@
+a.out
diff --git a/main.s b/main.s
index 9ba7050974b6f06dfad5406af6a40d1ad594c830..6be8a68828bb5e642de8d93c76d69e9960174fdc 100644 (file)
--- 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