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

7.11 Write an assembly program with the following specifications. a. In the main

ID: 3850268 • Letter: 7

Question

7.11 Write an assembly program with the following specifications.


a. In the main block, you should have two registers R4 and R5. They should be checked in an infinite loop. If R4 is greater than R5, then the greater subroutine will be called. If R4 is less than R5, then the less subroutine will be called. If R4 equals R5, then no operations will be done.


b. In the greater subroutine, your code will fill the decimal numbers 1, 2, 3, 4, 5 in hexadecimal form to five successive memory locations. After this operation, the value in R4 will be decreased by one.


c. In the less subroutine, your code will fill the decimal numbers 10, 9, 8, 7, 6 in hexadecimal form to five successive memory locations. After this operation, the value in R4 will be decreased by one.


This is an assembly code written as (mov.w #00, R4, and add.w) please!!!

Explanation / Answer

a)

MOV R0, #5 ; R0 is current number
MOV R1, #0 ; R1 is count of number of iterations
again ADD R1, R1, #1 ; increment number of iterations
ANDS R0, R0, #1 ; test whether R0 is odd
BEQ even
ADD R0, R0, R0, LSL #1 ; if odd, set R0 = R0 + (R0 << 1) + 1
ADD R0, R0, #1 ; and repeat (guaranteed R0 > 1)
B again
even MOV R0, R0, ASR #1 ; if even, set R0 = R0 >> 1
SUBS R7, R0, #1 ; and repeat if R0 != 1
BNE again
halt B halt ; infinite loop to stop computation

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