-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyramid.s
61 lines (46 loc) · 846 Bytes
/
pyramid.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
.text
.globl __start
__start:
la $s0, string
li $s1,0
add $t0, $s0,$s1
lbu $t1,0($t0)
loop: beq $t1,$zero,step2
addi $s1,$s1,1
add $t6, $s0,$s1
lbu $t1,0($t6)
j loop
step2: li $t0,0
move $t1, $s1
addi $t1, $t1,-1
li $t2,0
loop2: bgt $t0,$s1, exit
blt $t1,$zero,exit
add $t4, $t2,$s0
lb $t5, 0($t4)
beq $t5,$zero, ch
beq $t0,$t2,print
beq $t1, $t2, print
printsp: li $v0,4
la $a0, space
syscall
addi $t2,$t2,1
j loop2
print: move $a0,$t5
li $v0,11
syscall
addi $t2,$t2,1
j loop2
ch: li $v0,4
la $a0, endl
syscall
li $t2,0
addi $t0,$t0,1
addi $t1,$t1,-1
j loop2
exit: li $v0,10
syscall
.data
string: .asciiz "abcdefghij"
endl: .asciiz "\n"
space: .asciiz " "