-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.asm
More file actions
33 lines (28 loc) · 849 Bytes
/
example.asm
File metadata and controls
33 lines (28 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
# Do not use label "main" in your functions, it should be used only in the calling function
.globl average
average:
addi sp, sp , -4 # allocate space for stack frame by adujusting the stack pointer (sp register)
sw ra, 0(sp) # save the return address (ra register)
# save other registers to stack if needed
# body of the function, write your code here
mv t1, a0
beqz t1, exit
mv t2, a1
beqz t2, exit
li t3, 2
add t1, t1, t2
div t1, t1, t3
mv a0, t1
exit:
# restore registers from stack if needed
lw ra, 0(sp) # Restore return address register
addi sp, sp, 4 # deallocate space for stack frame
ret # return to calling point