diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2024-05-29 14:19:43 -0400 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2024-05-29 14:19:43 -0400 |
| commit | 843806d7c80bfec8fcea5fae81961fa35c91a804 (patch) | |
| tree | 32700c4a323d3fd9a81ba7f6d1663a5f7dfa28d0 /tests/fibtest.asm | |
| parent | 05d10fb3a941aa384340d2999033aacb31e5f32f (diff) | |
ELF Implementation
Diffstat (limited to 'tests/fibtest.asm')
| -rwxr-xr-x | tests/fibtest.asm | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/fibtest.asm b/tests/fibtest.asm new file mode 100755 index 0000000..bd053b9 --- /dev/null +++ b/tests/fibtest.asm @@ -0,0 +1,70 @@ +.data + +str: + .asciiz "Fibinacci Number " + +str2: + .asciiz " is: " + +fib: + .space 40 + +.text + +main: + addi $t0, $zero, 0 + addi $t1, $zero, 1 + add $t3, $zero, $zero + la $t6, fib + addi $t5, $zero, 9 + + loop: + add $t2, $t1, $t0 + add $t1, $zero, $t0 + add $t0, $zero, $t2 + sw $t2, 00($t6) + addi $t3, $t3, 1 + addi $t6, $t6, 4 + bne $t3, $t5, loop + nop + addi $t6, $t6, -4 + loop2: + la $a0, str + jal PrintStr + nop + + add $a0, $zero, $t3 + jal PrintInt + nop + + la $a0, str2 + jal PrintStr + nop + + lw $a0, 00($t6) + jal PrintInt + nop + + addi $a0, $zero, 10 + addi $v0, $zero, 11 + syscall + + addi $t3, $t3, -1 + addi $t6, $t6, -4 + bne $t3, $zero, loop2 + nop + + addi $v0, $zero, 10 + syscall + +PrintInt: + addi $v0, $zero, 1 + syscall + jr $ra + nop + +PrintStr: + addi $v0, $zero, 4 + syscall + jr $ra + nop
\ No newline at end of file |
