{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 24-Example - Example Suppose that R0 contains the base...

This preview shows pages 1–6. Sign up to view the full content.

Example Suppose that R0 contains the base address of an array of an array of n bytes Translate this code into assembly int sum = 0; for (int i = 0; i < n; i++) sum += A[i]; 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example int R3 = 0; for (R5 = 0; R5 < n; R5++) R3 += A[R5]; 2 int sum = 0; for (int i = 0; i < n; i++) sum += A[i];
Example int R3 = 0; for (R5 = 0; R5 < n; R5++) R3 += A[R5]; 3 LD R3, #0 LD R5, #0 LD R6, #n loop: SUB R7, R6, R5 BZ R7, end ADD R1, R0, R5 LD R2, (R1) ADD R3, R3, R2 ADD R5, R5, #1 JMP loop end: HALT int sum = 0; for (int i = 0; i < n; i++) sum += A[i];

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Example int R3 = 0; for (R5 = 0; R5 < n; R5++) R3 += A[R5]; 4 LD R3, #0 LD R5, #0 LD R6, #n loop: SUB R7, R6, R5 BZ R7, end ADD R1, R0, R5 LD R2, (R1) ADD R3, R3, R2 ADD R5, R5, #1 JMP loop end: HALT int R3 = 0; for (R5 = 0; R5 < n; R5++) { if (A[R5] > 0) R3 += A[R5]; }
Example int R3 = 0; for (R5 = 0; R5 < n; R5++) R3 += A[R5]; 5 LD R3, #0 LD R5, #0 LD R6, #n loop: SUB R7, R6, R5 BZ R7, end ADD R1, R0, R5 LD R2, (R1) ADD R3, R3, R2 ADD R5, R5, #1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 12

24-Example - Example Suppose that R0 contains the base...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online