summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-04-21 23:01:49 -0400
committerbd <bdunahu@operationnull.com>2025-04-21 23:01:49 -0400
commit7728beb94092f93f708af42feee3eab327749f32 (patch)
treeec654a27b33d70d6adfb1c553585bf8a21d187e5
parent0d844b06301d8356706b2ac837033a93c0fe256a (diff)
Fix dominative-functions example with simulator feedback
-rw-r--r--input/dominative-functions.asm26
-rw-r--r--input/negative-rabbits.asm18
-rw-r--r--input/there-and-back-again.asm16
3 files changed, 52 insertions, 8 deletions
diff --git a/input/dominative-functions.asm b/input/dominative-functions.asm
index 0931918..2ff242a 100644
--- a/input/dominative-functions.asm
+++ b/input/dominative-functions.asm
@@ -15,22 +15,28 @@ MAIN:
jal SUB23
pop $6
store $6 answer($0)
+ nop
+ nop
+ nop
+ quot $0 $0 $0
SUB23:
push $5 ; push old frame pointer
addi $5 $2 0x0
subi $2 $2 0x1
addi $6 $0 -23
- store $6 -4($5)
+ store $6 -1($5)
- load $7 +4($5) ; access argument
- load $6 -4($5)
+ load $7 +1($5) ; access argument
+ load $6 -1($5)
add $6 $6 $7
+ push $1 ; save off our old ret
push $6
jal ADD76
pop $6 ; retrieve and pass along
- store $6 +4($5)
+ pop $1 ; restore our old ret
+ store $6 +1($5)
addi $2 $5 0x0 ; restore stack pointer
pop $5 ; restore frame pointer
@@ -41,14 +47,18 @@ ADD76:
subi $2 $2 0x1
addi $6 $0 +76
- store $6 -4($5)
+ store $6 -1($5)
- load $7 +4($5) ; access argument
- load $6 -4($5)
+ load $7 +1($5) ; access argument
+ load $6 -1($5)
add $6 $6 $7
- store $6 +4($5)
+ store $6 +1($5)
addi $2 $5 0x0
pop $5
ret
+ nop
+ nop
+ nop
+ nop
diff --git a/input/negative-rabbits.asm b/input/negative-rabbits.asm
new file mode 100644
index 0000000..ac1b14a
--- /dev/null
+++ b/input/negative-rabbits.asm
@@ -0,0 +1,18 @@
+;;;;;;;;
+;;; multiplies numbers until an overflow occurs
+
+.data
+ rabbits 2
+ rate 300
+
+.text
+ load $5 rabbits($0)
+ load $6 rate($0)
+
+BREED:
+ foo
+ mul $5 $5 $4
+ store $5 rabbits($0)
+ bof DONE
+ jrl BREED
+DONE:
diff --git a/input/there-and-back-again.asm b/input/there-and-back-again.asm
new file mode 100644
index 0000000..73bd117
--- /dev/null
+++ b/input/there-and-back-again.asm
@@ -0,0 +1,16 @@
+;;;;;;;;
+;;; tests subroutine calls using the JAL function
+
+.data
+.text
+MAIN:
+ jal PUSHER
+ pop $5
+ quot $0 $0 $0
+PUSHER:
+ push $2
+ ret
+ nop
+ nop
+ nop
+ nop