diff options
author | Siddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com> | 2025-04-12 13:06:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-12 13:06:51 -0400 |
commit | fc20e7e7276b712f1e8db773b9215f900e877169 (patch) | |
tree | caecdd1499d2e391cd5bd2dcde3aebfade002a09 /input/dominative-functions.asm | |
parent | 5dbf0b63988b42c112ca0087cbbbb090566df5c1 (diff) | |
parent | 639098b1ea82be82bd18a4af415458fcbaf5e20b (diff) |
Merge pull request #8 from bdunahu/bdunahu
Add write raw bytes stage
Diffstat (limited to 'input/dominative-functions.asm')
-rw-r--r-- | input/dominative-functions.asm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/input/dominative-functions.asm b/input/dominative-functions.asm new file mode 100644 index 0000000..530717d --- /dev/null +++ b/input/dominative-functions.asm @@ -0,0 +1,55 @@ +;;;;;;;; +;;; 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 + +.text +MAIN: + addi $5 $2 0x0 ; establish frame pointer + + addi $6 $0 -11 + + push $6 + ;; jal SUB23 + pop $6 + store $6 answer($0) +SUB23: + push $5 ; push old frame pointer + addi $5 $2 0x0 + subi $2 $2 0x4 + + addi $6 $0 -23 + store $6 -4($5) + + load $7 +4($5) ; access argument + load $6 -4($5) + + add $6 $6 $7 + push $6 + ;; jal ADD76 + pop $6 ; retrieve and pass along + store $6 +4($5) + + addi $2 $5 0x0 ; restore stack pointer + pop $5 ; restore frame pointer + ret +ADD76: + push $5 + addi $5 $2 0x0 + subi $2 $2 0x4 + + addi $6 $0 +76 + store $6 -4($5) + + load $7 +4($5) ; access argument + load $6 -4($5) + + add $6 $6 $7 + store $6 +4($5) + + addi $2 $5 0x0 + pop $5 + ret |