-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmips1.asm
159 lines (92 loc) · 2.36 KB
/
mips1.asm
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#print hello world
#.data
# hello: .asciiz "hello world"
#.text
# li $v0,4
# la $a0, hello
# syscall
##############################################################################
#substarction
#.data
# number1: .word 20
# number2: .word 8
#.text
# lw $t1,number1
# lw $t2,number2
# sub $t0, $t1,$t2
#####################################################################
#multipilication
# this only multiplies at maximum only 16 bits long integers
# uses a mul argument
#.data
# number1: .word 12
# number2: .word 10
#.text
# lw $s0,number1
# lw $s1,number2
# mul $s2, $s0, $s1
# li $v0,1
# add $a0,$zero, $s2
# syscall
#multiplication without an input data
#only multiplies only 16 bit long integers at maximum
# used a mul argument here
#.data
#.text
# addi $s0, $zero, 10
# addi $s1, $zero, 20
# mul $t2, $s0, $s1
# li $v0,1
# move $a0, $t2
# syscall
#multiplication
#to multiply long integers that are more than 16bits long
#used a mult arguument
#.data
#.text
# addi $s0, $zero, 10000000
# addi $s1 , $zero, 30
# mult $s0,$s1
# li $v0, 1
# mflo $a0
#vsyscall
#multipilication
#used a ss1 arguument
#.data
#.text
# addi $s1, $zero , 10
# li $v0,1
# sll $a0, $s1 , 3
# syscall
##############################################################################################
#division
#using div argument with three registers - this divied the numbers with an over-flow
# .data
# .text
# addi $t0, $zero, 10
# addi $t1, $zero, 5
# div $t2, $t0, $t1
# li $v0, 1
# add $a0, $zero, $t2
# syscall
##division
## using div argument with only teo register values - this divides and stores the quoitent to li and the remainder to hi
#.data
.#text
# addi $t1, $zero , 10
# addi $t2 , $zero, 3
# div $t1, $t2
# li $v0, 1
# mflo $a0
# syscall
# li $v0, 1
# mfhi $a0
# syscall
# li $v0,10
# syscall
##############################################################################
.data
.text
addi $t0, $zero, 10
add $t1, $zero, 58
rem $s1,$t1,$t0