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

Preview File Edit View Go Tools Window Help Dygsl Design and Comguter Achesture

ID: 3745201 • Letter: P

Question

Preview File Edit View Go Tools Window Help Dygsl Design and Comguter Achesture At xtion ty Sara arh (rago 30 of 12- Exercise 6.20 Consider the following high-level code snippet. Assume that the base addresses of array1 and array2 are held in R1 and R2 and that array2 s initialized before it is used. inti: int array11100] int array20100]: for (i0: 1100: i-i+1) (a) Write the code snippet in ARM assembly without using pre- or post-indexing (b) Write the code snippet in ARM assembly with pre- or post-indexing and a (c) Compare the difference in code density (i.e., number of instructions) between array1[i] = array2[i]; or a scaled register. Use as few instructions as possible (given the constraints), scaled register available. Use as few instructions as possible. (a) and (b). Discuss any advantages or disadvantages. 20 4

Explanation / Answer

@R1 contains initial address of array1

@R2 contains initial address of array2, Array 2 is already initialized with values

@For count and offset value in Solution with pre or post indexing--> R3

@For Count in Solution without pre or post indexing--> R3

@Q.1.

@Without pre or post indexing

MOV R3, #0;

.loop

ADD R2, R2, #4

LDR R4, [R2];

ADD R1, R1, #4

STR R4, [R1];

ADD R3, R3, #4;

CMP R3, #400;

BL loop;

@Q.2.

@With pre or post indexing

MOV R3, #0;

.loop

LDR R4, [R2, R3];

STR R4, [R1, R3];

ADD R3, R3, #4;

CMP R3, #400;

BL loop;

Total number of lines in Q.1. -> 8

Total number of lines in Q.2 -> 6

Difference of lines: 2 (Lesser in solution with pre or post indexing)

Advantages of pre or post indexing: Number of lines of code reduces

Disadvantages of pre or post indexing: Internally the process becomes more complicated. Moreover assembler has to convert pre or post indexing into normal internally which takes some more computational cycles of CPU.

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