-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
102 lines (83 loc) · 1.61 KB
/
main.asm
File metadata and controls
102 lines (83 loc) · 1.61 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
.data
.text
# macro to terminate the simualtion
.macro exit ()
.text
li a7,10
ecall
.end_macro
# macro to print a integer value
.macro print_int (%reg)
.text
li a7,1
add x10, %reg, x0
ecall
.end_macro
# marco to print a hexadecimal value
.macro print_hex (%reg)
.text
li a7,34
add x10, %reg, x0
ecall
.end_macro
# macro to print a string
.macro print_str (%str)
.data
str_label: .string %str
.text
li a7, 4
la x10, str_label
ecall
.end_macro
.globl main
main:
# to test example function
print_str("Output of example function\n")
li x10, 250 # pass inputs
li x11, -2
call average
mv t0, a0
print_str("Value stored in x10:")
print_int(t0)
# Use the following labels for functions
# problem 1: lpyear
# problem 2: gcd
# problem 3: npnum
# problem 4: palin
# to test lpyear function
print_str("\nOutput of lpyear function\n")
li x10, 2001 # pass inputs
call lpyear
mv t0, a0
print_str("Value stored in x10:")
print_int(t0)
print_str("\nOutput of gcd function\n")
li x10, 250 # pass inputs
li x11, 100
call gcd
mv t0, a0
print_str("Value stored in x10:")
print_int(t0)
# to test npnum function
print_str("\nOutput of npnum function\n")
li x10, 5
call npnum
mv t0, a0
print_str("Value stored in x10:")
print_int(t0)
# to test palin function
print_str("\nOutput of palin function\n")
li x10, 0x121 # pass inputs
call palin
mv t0, a0
print_str("Value stored in x10: ")
print_int(t0)
exit()