Computers and Technology

Consider the following implementation of strlen, which returns the length of a zero-terminated string: strlen:
li $v0, 0
top:
lbu $t0, 0($a0)
beqz $t0, ret
addiu $v0, $v0, 1
addiu $a0, $a0, 1
b top
ret:
jr $ra
(a) If strlen is called on a 10-character string, how many dynamic instructions will be executed? Explain your answer.
(b) Below, rewrite the function to reduce the total number of instructions executed (e. g., for a 10-character string). The bigger the reduction, the better.
(c) How many instructions will your solution for (b) execute for a 10-character string? Explain your answer.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:00, danthehero56
Which of the following is true of operations within a spreadsheet program’s built-in functions? a. operations within parentheses, then multiplication and division, and then addition and subtraction are computed. b. operations within parentheses, then addition and subtraction, and then multiplication and division are computed. c. multiplication and division, then addition and subtraction, and then operations within parentheses are computed. d. addition and subtraction, then multiplication and division, and then operations within parentheses are computed
Answers: 2
image
Computers and Technology, 22.06.2019 11:30, jcazares3558
Awell-diversified portfolio needs about 20-25 stocks from different categories.
Answers: 2
image
Computers and Technology, 22.06.2019 13:30, AsiaDeas4078
Write lines of verse that rhyme to remember the following information: acid rain is a type of air pollution caused by chemicals in the air.
Answers: 1
image
Computers and Technology, 22.06.2019 14:30, SKYBLUE1015
What percentage of companies is projected to use social media to locate new employees in 2012
Answers: 2
Do you know the correct answer?
Consider the following implementation of strlen, which returns the length of a zero-terminated strin...

Questions in other subjects:

Konu
Mathematics, 07.07.2019 13:00