Skip to content

Instantly share code, notes, and snippets.

@bosley
Created June 15, 2020 02:59
Show Gist options
  • Save bosley/bf60862e0057673d26645eaa82606b2e to your computer and use it in GitHub Desktop.
Save bosley/bf60862e0057673d26645eaa82606b2e to your computer and use it in GitHub Desktop.
; ASM File for the Nabla VM
; https://github.com/NablaVM
; - This file utilizes the special functionality of functional units along
; side yield's reentry functionality as a POC
; for using them together as a memory storage unit
.file "memory_play"
.init main
.int64 exitflag 0
.int64 commandspace 0
<main:
; Setup memoru
call memory
mov r0 $10
stw $8(gs) r0
mov r8 $1
mov r9 $10
call_loop:
; Action
call memory
; -- Loop a few times to call memory
add r8 r8 $1
bne r8 r9 call_loop
; Close out memory
mov r0 $1
stw $0(gs) r0
call memory
exit
>
<memory:
; Init space
mov r0 $0
mov r1 $0
mov r2 $10
init_top:
; zeroize stack space
pushw ls r0
; Add to counter, loop until fin
add r1 r1 $1
blt r1 r2 init_top
execute_top:
mov r1 $1 ; Check for exit flag
ldw r0 $0(gs) ; Load flag
; If memory space for exitflag is not 1, we continue
bne r0 r1 continue
; If debug out shows this, we were asked to clear memory
mov r0 $777
; If the flag is 1, then we return and everything is cleared
ret
continue:
; load command
ldw r0 $8(gs)
; Do some stuff specific to memory
yield
; Reentry should bring us here and will jump to execute_top
mov r0 $500 ; Just to show in debug we reached here
jmp execute_top
; We should never get here
mov r0 $255
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment