~nch/onward

fba7b21d98070cad822960e9e2ab327b1a07c50a — nc 4 years ago 8e3c6f8
added enter subroutine. it's basically a forth now :)
1 files changed, 23 insertions(+), 3 deletions(-)

M onward.s
M onward.s => onward.s +23 -3
@@ 23,6 23,12 @@ macro defcode name {
name:
}

macro defword wordname {
    align ADDR_SIZE
wordname:
    jmp docol
}

;; push/pop data stack
macro pushd r {
    lea rsp, [rsp + ADDR_SIZE]


@@ 47,10 53,20 @@ var_STATE: db IMMEDIATE

section '.text' ; readable executable

docol:
    push rsi
    add rax, 5 ; size of shortjmp
    mov rsi, rax
    next

    defcode drop
    popd rax
    next

    defcode exitword
    pop rsi
    next

    defcode swap
    popd rax
    popd rbx


@@ 123,13 139,17 @@ section '.text' ; readable executable
    add esi, [esi]
    next

    defword starloop
    dq lit, '*'
    dq emit
    dq branch, -32
    dq exitword

start:
    cld
    mov rsi, instrs
    next

instrs:
    dq lit, '*'
    dq emit
    dq branch, -32
    dq starloop
    dq exit