From 32d0ec28e8ffda578fe8de8eef75426d8ef98f9c Mon Sep 17 00:00:00 2001 From: Jonas Hvid Date: Thu, 14 Nov 2019 18:47:05 +0100 Subject: [PATCH] Implement basic return stack --- main.asm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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: -- 2.39.2