Without using move or li, write MIPS assembly language using MARS simulator to print a half pyramid depending on a value n of a user input. Such that if n = 5 were entered the following would be printed:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
Code:
;Assume SI holds the number n (>=1) of rows of the pyramid
.286
.model small
.stack 1024h
.data
.code
mov cx, 1 ;Outer counter (i)
_rows_loop:
mov bx, 1 ;Inner counter (j)
__cols_loop:
;Print number bx
inc bx ;Increment inner counter
cmp bx, cx ;If (j<i) keep looping
jb _cols_loop
;Print new-line
inc cx ;Increment outer counter
cmp cx, si ;If (i<n) keep looping
jb _rows_loop
end
Get Answers For Free
Most questions answered within 1 hours.