From: Jonas Hvid Date: Thu, 14 Nov 2019 17:47:05 +0000 (+0100) Subject: Implement basic return stack X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=32d0ec28e8ffda578fe8de8eef75426d8ef98f9c;p=rrq%2Fjonasforth.git Implement basic return stack --- diff --git a/main.asm b/main.asm index 537796d..e95d9fd 100644 --- a/main.asm +++ b/main.asm @@ -12,9 +12,29 @@ macro next { jmp qword [rax] ; Jump to the codeword of the current word } +;; pushr and popr work on the return stack, whose location is stored in the +;; register RBP. +macro pushr x { + sub rbp, 8 + mov [rbp], x +} +macro popr x { + mov x, [rbp] + add rbp, 8 +} + segment readable executable start: + ;; Initialize return stack + mov rbp, return_stack_top + jmp $ segment readable + +segment readable writable + +;; Return stack +rq $2000 +return_stack_top: