From 7ad6093d69afa90de243e72868f0d463dcd5eae7 Mon Sep 17 00:00:00 2001 From: bd Date: Thu, 17 Apr 2025 19:39:06 -0400 Subject: Add new push/pop test case, ensure generated files end in .rv --- .gitignore | 1 + input/dominative-functions.asm | 5 ++--- input/stacktopia.asm | 20 ++++++++++++++++++++ src/util.lisp | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 input/stacktopia.asm diff --git a/.gitignore b/.gitignore index ab65a90..7366cb7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ manifest.scm # generated bin/ output/ +input/*.rv diff --git a/input/dominative-functions.asm b/input/dominative-functions.asm index d11ddcb..0931918 100644 --- a/input/dominative-functions.asm +++ b/input/dominative-functions.asm @@ -1,7 +1,6 @@ ;;;;;;;; ;;; makes use of a designated function to add two numbers together ;;; uses a stack-based paradigm with a base pointer to manage argument passing -;;; TODO this file is incomplete due to remaining ISA subroutine design issues .data answer 0 @@ -19,7 +18,7 @@ MAIN: SUB23: push $5 ; push old frame pointer addi $5 $2 0x0 - subi $2 $2 0x4 + subi $2 $2 0x1 addi $6 $0 -23 store $6 -4($5) @@ -39,7 +38,7 @@ SUB23: ADD76: push $5 addi $5 $2 0x0 - subi $2 $2 0x4 + subi $2 $2 0x1 addi $6 $0 +76 store $6 -4($5) diff --git a/input/stacktopia.asm b/input/stacktopia.asm new file mode 100644 index 0000000..5eef33b --- /dev/null +++ b/input/stacktopia.asm @@ -0,0 +1,20 @@ +;;;;;;;; +;;; demonstrates the push/pop functions by pushing and popping various values + +.data +.text +MAIN: + addi $5 $0 1 + push $5 + addi $5 $5 1 + push $5 + addi $5 $5 1 + push $5 + addi $5 $5 1 + push $5 + pop $5 + pop $6 + pop $7 + pop $8 + nop + nop diff --git a/src/util.lisp b/src/util.lisp index d0e32c4..14e5d74 100644 --- a/src/util.lisp +++ b/src/util.lisp @@ -22,7 +22,7 @@ (defun generate-file-name (file) "Given a .asm file, generates an identically named .rv file." - (subseq file 0 (- (length file) 4))) + (concatenate 'string (subseq file 0 (- (length file) 3)) "rv")) (defun format-as-binary (num len) "Formats NUM as a binary number, and pads to LEN with zeros." -- cgit v1.2.3