From: Michael D. Lowis Date: Fri, 26 Feb 2021 17:20:58 +0000 (-0500) Subject: fixed tabs/spaces X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=19bc741b50e8f361afa6db6fcf761dbcbb83c0bf;p=proto%2Falvm.git fixed tabs/spaces --- diff --git a/main.s b/main.s index 6be8a68..f93ae8a 100644 --- a/main.s +++ b/main.s @@ -2,8 +2,8 @@ // Register Usage //--------------------------------------------------------------------- // %rsi Program Counter -// %rsp Argument Stack Pointer -// %rbp Stack Frame Pointer +// %rsp Stack Pointer +// %rbp Frame Pointer // %rax Accumulator Register // %rbx Temporary Register @@ -14,7 +14,7 @@ // Execute next instruction .macro NEXT lodsq - jmpq *(%rax) + jmpq *(%rax) .endm // Macro to define a primitive @@ -25,8 +25,8 @@ \name : .quad code_\name .text - .globl code_\name - .p2align 4, 0x90 + .globl code_\name + .p2align 4, 0x90 code_\name : // ...the code goes here... .endm @@ -43,8 +43,8 @@ code_\name : // Main Interpreter Definition .text - .globl EXEC_FUN - .p2align 4, 0x90 + .globl EXEC_FUN + .p2align 4, 0x90 EXEC_FUN: pushq %rsi pushq %rbp @@ -97,10 +97,18 @@ defcode OP_localsn // Push the Nth argument onto the stack defcode OP_ldargn + lodsq + addq $16, %rax + neg %rax + movq (%rbp, %rax, 8), %rax + pushq %rax NEXT // Push the Nth local onto the stack defcode OP_ldlocn + lodsq + movq (%rbp, %rax, 8), %rax + pushq %rax NEXT // Pop top of stack and store to the Nth argument slot @@ -115,15 +123,15 @@ defcode OP_stlocn // Main Routine //--------------------------------------------------------------------- .text - .global _main - .global main - .p2align 4, 0x90 + .global _main + .global main + .p2align 4, 0x90 _main: main: pushq %rax movq %rsp, %rbp - leaq cold_start(%rip), %rsi - NEXT + leaq cold_start(%rip), %rsi + NEXT // First instructions to execute by the interpreter .data