summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-17 19:39:06 -0400
committerbd <bdunahu@operationnull.com>2025-04-17 19:39:06 -0400
commit7ad6093d69afa90de243e72868f0d463dcd5eae7 (patch)
treebca1b4259ccdcfd4ac8d188383a922b88efaed1a
parent3b8a36443a6d83b54fc698a774ef50705f36dcb9 (diff)
Add new push/pop test case, ensure generated files end in .rv
-rw-r--r--.gitignore1
-rw-r--r--input/dominative-functions.asm5
-rw-r--r--input/stacktopia.asm20
-rw-r--r--src/util.lisp2
4 files changed, 24 insertions, 4 deletions
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."