-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.s
86 lines (63 loc) · 1019 Bytes
/
convert.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
.text
.globl main
main:
la $t0,A
la $t1,a
lb $t0,0($t0)
lb $t1,0($t1)
li $t3,0
sub $s7, $t1,$t0
li $v0,12
la $a0, letter_given
li $a0,2
syscall
move $s2,$v0
la $s0, str
beq $s2,$t0,upper
beq $s2,$t1,lower
j exit
upper:
add $t2, $t3,$s0
lbu $s4, 0($t2)
beq $s4,$zero,end
li $s5,'a'
li $s6,'z'
slt $t5,$s4,$s5
bne $t5,$zero,skip
slt $t5,$s6,$s4
bne $t5,$zero,skip
sub $s4,$s4,$s7
sb $s4,0($t2)
skip:
li $v0,11
move $a0,$s4
syscall
addi $t3, $t3,1
j upper
lower:
add $t2, $t3,$s0
lbu $s4, 0($t2)
beq $s4,$zero,end
li $s5,'A'
li $s6,'Z'
slt $t5,$s4,$s5
bne $t5,$zero,skip2
slt $t5,$s6,$s4
bne $t5,$zero,skip2
add $s4,$s4,$s7
sb $s4,0($t2)
skip2:
li $v0,11
move $a0,$s4
syscall
addi $t3, $t3,1
j lower
end:
exit: li $v0,10
syscall
.data
A: .asciiz "A"
a: .asciiz "a"
str: .asciiz "AaBbCcDd"
space: .asciiz "\n"
letter_given: .space 2