-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpyramid-reverse.asm
More file actions
56 lines (52 loc) · 938 Bytes
/
pyramid-reverse.asm
File metadata and controls
56 lines (52 loc) · 938 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
#pyramid-reverse.asm
# Written by: Gopal Chitaure (gochit01@wsc.edu)
# Nested loop concept
#Printing pyramid pattern
###########
#########
#######
#####
###
#
.data
star: .asciiz "*"
new_line: .asciiz "\n"
dot: .asciiz " "
.text
main:
li $s0, 1
li $s2, 0
li $s3, 10
jal loop_outer
loop_outer:
li $s1, 0
bgt $s0, 6, exit_outer
loop_inner:
bgt $s1, 10, exit_inner
bgt $s1, $s3, print_space
blt $s1, $s2, print_space
#print space
li $v0, 4
la $a0, star
syscall
addi $s1, $s1, 1 #increament counter
j loop_inner
print_space:
li $v0, 4
#move $a0, $s1
la $a0, dot
syscall
addi $s1, $s1, 1 #increament counter
j loop_inner
exit_inner:
addi $s0, $s0, 1 #increament counter
addi $s2, $s2, 1
subi $s3, $s3, 1
#print stars
li $v0, 4
la $a0, new_line
syscall
j loop_outer
exit_outer:
li $v0, 10
syscall