-
Notifications
You must be signed in to change notification settings - Fork 11
/
mips-7.asm
99 lines (68 loc) · 1.09 KB
/
mips-7.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
.data
string1: .asciiz "Enter a number : "
endLine: .asciiz "\n"
string2: .asciiz "Addition result is : "
string3: .asciiz "Substraction result is : "
string4: .asciiz "Your second number is greater than your first number and then you can not sub these two numbers : "
.text
main:
j EnteraNumber
EnteraNumber:
li $v0,4
la $a0,string1
syscall
li $v0,5
syscall
move $t0,$v0
li $v0,4
la $a0,string1 #cout<<Enter a number
syscall
li $v0,5
syscall
move $t1,$v0
beq $t0,$t1, Addition
j Substraction
Addition:
add $t2,$t1,$t0
li $v0,4
la $a0,string2 #cout<<Addition result is
syscall
li $v0,1
move $a0,$t2
syscall
j end_label
Substraction:
bgt $t1,$t0, EnteraNumber2
j SUB2
SUB2:
sub $t2,$t0,$t1
li $v0,4
la $a0,string3 #cout<<Addition result is
syscall
li $v0,1
move $a0,$t2
syscall
j end_label
EnteraNumber2:
li $v0,4
la $a0,string4
syscall
li $v0,4
la $a0,endLine
syscall
li $v0,4
la $a0,string1
syscall
li $v0,5
syscall
move $t0,$v0
li $v0,4
la $a0,string1 #cout<<Enter a number
syscall
li $v0,5
syscall
move $t1,$v0
j Substraction
end_label:
li $v0, 10 #exit
syscall