-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.s
More file actions
76 lines (57 loc) · 997 Bytes
/
mod.s
File metadata and controls
76 lines (57 loc) · 997 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
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
.align 2
.data
msg1: .asciiz "this function returns int1 % int2, enter int1: "
msg2: .asciiz "enter int2: "
msg3: .asciiz "result: "
nln: .asciiz "\n"
.text
.globl main
main:
# print msg1
la $a0, msg1
li $v0, 4
syscall
# take in int1
li $v0, 5
syscall
move $t0, $v0
# print new line
la $a0, nln
li $v0, 4
syscall
# print msg2
la $a0, msg2
li $v0, 4
syscall
# take in int2
li $v0, 5
syscall
move $t1, $v0
# print new line
la $a0, nln
li $v0, 4
syscall
# FOR DIVISION
# li $t2, 0
loop:
# exit and print the result if int1 < int2
blt $t0, $t1, exit
# subtract int2 from int1
sub $t0, $t0, $t1
# FOR DIVISION
# increment the counter
#addi $t2, $t2, 1
# loop again
j loop
exit:
# print msg3
la $a0, msg3
li $v0, 4
syscall
# print remainder
move $a0, $t0
li $v0, 1
syscall
# exit
li $v0, 10
syscall