-
Notifications
You must be signed in to change notification settings - Fork 0
/
8_to_2.s
91 lines (71 loc) · 1.13 KB
/
8_to_2.s
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
.text
.globl __start
__start:
loop:
la $a0, gives
jal printstr
la $a0, buffer
li $a1, 5
li $v0, 8
syscall
li $v0, 4
syscall
la $a0, endl
li $v0,4
syscall
la $a0, conv
jal printstr
li $t0,0
li $t9,0
li $t8,5
cases: beq $t0,$t8,loop
lb $t1, buffer($t0)
beqz $t1, loop
beq $t1,'1', p1
beq $t1,'2', p2
beq $t1,'3', p3
beq $t1,'4', p4
beq $t1,'5', p5
beq $t1,'6', p6
beq $t1,'7', p6
j exit
inc: addi $t0,$t0,1
j cases
p1: la $a0,one
jal printstr
j inc
p2: la $a0,two
jal printstr
j inc
p3: la $a0,three
jal printstr
j inc
p4: la $a0,four
jal printstr
j inc
p5: la $a0,five
jal printstr
j inc
p6: la $a0,six
jal printstr
j inc
p7: la $a0,seven
jal printstr
j inc
exit: li $v0, 10
syscall
printstr: li $v0, 4
syscall
jr $ra
.data
buffer: .space 10
gives: .asciiz "Give a string: "
conv: .asciiz "Converted: "
endl: .asciiz "\n"
one: .asciiz "001"
two: .asciiz "010"
three: .asciiz "011"
four: .asciiz "100"
five: .asciiz "101"
six: .asciiz "110"
seven: .asciiz "111"