-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb.asm
55 lines (49 loc) · 1.16 KB
/
b.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
#---------------------------#---------------------------#---------------------------START
.data
str1: .asciiz "Enter the first number:\n"
str2: .asciiz "Enter the second number:\n"
str3: .asciiz "The product is:\n"
#---------------------------variables declaration
.text
.globl main
#---------------------------main function
main:
#---------------------------print str1
la $a0,str1
li $v0,4
syscall
li $v0,5
syscall
move $s0,$v0
#---------------------------read 1st integer
#---------------------------print str2
la $a0,str2
li $v0,4
syscall
li $v0,5
syscall
move $s1,$v0
#---------------------------read 2nd integer
#---------------------------v1 stores output
li $v1,0
#---------------------------Loop started
Loop:
add $v1,$v1,$s0
#---------------------------addition
subi $s1,$s1,1
#---------------------------loop increment
bnez $s1,Loop
#---------------------------loop check
#---------------------------Loop ended
exit:
la $a0,str3
li $v0,4
syscall
#---------------------------print str3
move $a0,$v1
li $v0,1
syscall
#---------------------------print product
addi $a1,$a2,4
li $a2,10
#---------------------------#---------------------------#---------------------------END