Question: Help with MIPS assembly language (MARS 4.5) hallow square base on N input This is what I have so far, can someone help me please

Help with MIPS assembly language (MARS 4.5) hallow square base on N input

Help with MIPS assembly language (MARS 4.5) hallow square base on N

This is what I have so far, can someone help me please What I need help with is with the if statement so that I will print the character a user inputs The expected output for the program is the following:

3

XXX

X X

XXX

MY CODE: so far

.data

prompt:

.asciiz "Enter an N value: "

prompt1:

.asciiz "Enter a character: "

newline:

.asciiz " "

n: .word 0

answer: .word 0

errormsg:

.asciiz "N should be greater or equal to 3"

userInput: .space 2

space: .asciiz " "

.text

.globl main

main:

#prompt1 and read character

li $v0, 4

la $a0, prompt1

syscall

#Getting user's input as text

li $v0, 8

la $a0, userInput

li $a1, 2

syscall

#prompt newline

li $v0, 4

la $a0, newline

syscall

#prompt and read int

li $v0, 4

la $a0, prompt

syscall

#read int and store in $t0

li $v0, 5

syscall

move $t0, $v0 #store n in $t0

bge $v0, 3, proceed #if input is 0 or more, goto proceed otherwise display error message and goto exit

li $v0, 4

la $a0, errormsg

syscall

b exit

proceed:

#print n

li $v0, 1

move $a0, $t0

syscall

#prompt newline

li $v0, 4

la $a0, newline

syscall

for1:

beq $t3, $t0, end_for1

addi $t3, $t3, 1 # Increment counter

li $t4, 0 #reseting j to 0 after each iteration of the for loop

######################## Inner loop

for2:

beq $t4, $t0, end_for2

addi $t4, $t4, 1 # Increment counter

beqz $t4, if

b for2

if:

#print Character

li $v0, 4

la $a0, userInput

syscall

end_if:

end_for2:

######################## Inner loop

b for1

end_for1:

exit:

li $v0, 10

syscall

.end main

*C program to print hollow square star pattern #include int main( int i, j, N; Input number of rows from user/ printf("Enter number of rows: "); scanf("%d", &N); Iterate over each row /*Iterate over each column/ for (j-1; j

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!