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

This is what I have so far, but it is not working. ADD X5, XZR, XZR // adding 21

ID: 3904742 • Letter: T

Question

This is what I have so far, but it is not working.

ADD X5, XZR, XZR // adding 21 to X5 to represent a 9 digit UIN

ADD X5, X5, #21

ADD X0, XZR, XZR // ADDING 10 from 0 to get 10

ADD X0, X0, #10

loop: CBZ X0, L2 // If X0 is not 0 keep looping

SUB X0, X0, #1 // SUBTRACTING 1 FROM X0 so it will loop 10 times

SUB X5, X5, #1 // subtract 1 from the sum of the UIN (21)

B loop // loop back to CBZ

L2:

STUR X5, [SP, #0] // Store final UIN answer

BR X30

.section .data

Add a new assembly file to your Lab03 project called lab03b.S (use the procedure you used in Lab02 to add this file and make sure it gets called from main.c) In this file, write an ARMv8 program with the following specifications: Reserve space in memory for a variable called UIN of size double word. The initial value of UIN will be the sum of the digits in your UIN .The program should implement the following piece of C-code: for i -0 i

Explanation / Answer

LDR X5,=UIN //address of UIN variable is stored in X5

LDR X4,[X5] // value of UIN variable is stored in X4

LDR X0,=0x0 // i= 0

LDR X1,=0x0A // i<10 maximum point

LOOP:

CBE X0,X1,END_OF_LOOP // condition for loop to continue for 10 times

SUB X4,X4,#1 # UIN = UIN - 1

ADD X0,X0,#1 # i++

B LOOP

END_OF_LOOP:

STUR X4,[X5]

BR X30

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