{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


load-store-examples-1 - Address Contents 0x00008218 0x92...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 379 Load/Store Examples Example #1 The following program should return the number of occurrences of the ASCII character passed into the routine in r0. The number of occurrences should be returned in r0. Does the program work? If not, why not? What must be done to fix the program? example STMFD SP!,{lr} ; Store lr ldr r1, =string ; Pointer to string mov r2, r0 mov r0, #0 search ldrb r3, [r1],#1 cmp r3, r2 bne check_for_null add r0, r0, #1 check_for_null cmp r3, #0 bne search LDMFD SP!, {lr} ; Restore lr MOV pc, lr Example #2 Step through the following program Determine the contents of r1, r2, and r3 after the program has executed. What changes are made to memory by the program? Initial Conditions ldr r1, =data ; Pointer to data ldrb r2,[r1] add r1, r1, #3 ldrb r3, [r1] strb r2, [r1] sub r1, r1, #3 strb r3, [r1] How can the program be made to run faster yet still produce the same results?
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Address Contents 0x00008218 0x92 0x00008219 0x01 0x0000821A 0x85 0x0000802B 0x0000802C 0x00008217 0x0A 0xC5 0x4F Example #3 Consider the following example which operates on the NULL terminated string pointed to by the label string Which of the following best describes what the program does? Sorts the characters in the string Converts all lowercase characters to upper case and vice versa Eliminates all occurrences of the character held in r0 in the string Terminates the string at the first occurrence of the character held in r0 Counts the number of occurrences of the character held in r0 ldr r1, =string ; r1 = orig strng ldr r2, =string ; r2 = new strng next ldrb r3, [r1], #1 ; r3 = character cmp r3, #0 ; End of string? beq done cmp r0, r3 beq next strb r3, [r2], #1 b next done strb r3, [r2], #1 ; Save NULL...
View Full Document

{[ snackBarMessage ]}