From d4e77a8caf62e9d352c7faeebe5182f527e2f3fb Mon Sep 17 00:00:00 2001 From: Nicholas Pease Date: Mon, 30 Sep 2024 21:38:00 -0400 Subject: [PATCH] Final --- hw.s | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/hw.s b/hw.s index 57451cb..711e019 100644 --- a/hw.s +++ b/hw.s @@ -11,7 +11,44 @@ main: la a0, inputUInt ecall + mv s2, a0 + li a7, 1 # display input int ecall - \ No newline at end of file + li a7, 11 + li a0, 0x0a + ecall + + li s3, 2 + li s4, 0 + li s5, 3 + li s6, 1 + whileLoop: + ble s2, s6, endLoop # end loop if less than 1 + remu t3,s2,s3 # t3 = t4(int) % 2 remainder + + bne t3, s4, odd + + even: + srl s2, s2,s6 + #divu s2, s2, s3 + j end + + odd: + mul s2, s2, s5 + add s2, s2, s6 + + end: + li a7, 1 + mv a0, s2 + ecall + li a7, 11 + li a0, 0x0a + ecall + + j whileLoop + + endLoop: + li a7, 10 + ecall \ No newline at end of file