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

Write a leaf procedure with the following prototype: It should return the number

ID: 3878608 • Letter: W

Question

Write a leaf procedure with the following prototype:

It should return the number of characters in the character array buffer (by starting at index zero and looking at the characters in the array. The "sentinel" character at the end is '' which is also the number zero and this should not be counted).

A good first step with this is to write the Java code that will do this calculation.

D Question 3 24 pts Write a leaf procedure with the following prototype: long long int strlenCchar buffer) It should return the number of characters in the character array buffer (by starting at index zero and looking at the characters in the array. The "sentinel" character at the end is'' which is also the number zero and this should not be counted) A good first step with this is to write the Java code that will do this calculation Description Initialize counter register X9 to zero Compute the absolute address of Label Instruction STRLEN STRLEN LOOP buffer_i storing in X10. Load buffer_i into X10. Branch to STRLEN _RETURN label if buffer_i is zero. Increment counter register by 1.

Explanation / Answer

STRLEN:

ADD X9,XZR,XZR

STRLEN_LOOP:

ADDI X11,X9,X10 ; Assuming characters take 1byte, absolute address would be base address stored in X10 plus index(counter) in X9

LOAD X12, [X11]

BEQ STRLEN_RETURN

ADDI X9,X9,#1

B STRLEN_LOOP

STRLEN_RETURN:

ADD X0, X9, XZR

return

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote