Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with this MIPS assembly language question! Consider the program belo

ID: 3791738 • Letter: P

Question

Please help with this MIPS assembly language question!

Consider the program below: .data str: .asciiz "Computer Organization and Assembly Language" char: .asciiz "a" .text la $s0, char lb $s0, 0 ($s0) la $s1, str add $a0, $zero, $zero loop: lb $s2, 0 ($s1) beq $s2, $zero, done bne $s2, $s0, noInc addi $a0, $a0, 1 nolnc: addi $s1, $s1, 1 j loop done: addi $v0, $zero, 1 syscall addi $v0, $zero, 10 syscall Syscall number 1 is used to display an integer in $a0 on the console screen. The above program will display one number on the console screen. What is the number?

Explanation / Answer

The number displayed on console is 4. Find the explanation below:

Declarations:

.asciiz adds a null terminator at the end of the string and character. Hence the variables are:

loop:

The program executes till $s2 == "" at the end of the string. Now the done function is called and syscall number 1 is executed which has to print the integer stored in $a0.

This number is 4, as explained above.

With syscall number 2, the program exits.