If the base register was word aligned before the

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: egister to be used to access a number of memory locations which are in the same area of memory. Sometimes it is useful to modify the base register to point to the transfer address. This can be achieved by using pre-indexed addressing with auto-indexing, and allows the program to walk through a table of values: LDR r0, [r1,#4]! ; + + r0 := mem32[r1 4] ; r1 := r1 4 The exclamation mark indicates that the instruction should update the base register after initiating the data transfer. On the ARM this auto-indexing costs no extra time since it is performed on the processor's datapath while the data is being fetched from memory. It is exactly equivalent to preceding a simple register-indirect load with a data processing instruction that adds the offset (4 bytes in this example) to the base register, but the time and code space cost of the extra instruction are avoided. Data transfer instructions 59 Another useful form of the instruction, called post-indexed addressing, allows the base to be used without an offset as the transfer address, after which it is auto-indexed: LDR r0, [r1], #4 r0 := mem32 [r1] r1 := r1 + 4 Here the exclamation mark is not needed, since the only use of the immediate offset is as a base register modifier. Again, this form of the instruction is exactly equivalent to a simple register-indirect load followed by a data processing instruction, but it is faster and occupies less code space. Using the last of these forms we can now improve on the table copying program example introduced earlier: The load and store instructions are repeated until the required number of values has been copied into TABLE2, then the loop is exited. Control flow instructions are required to determine the loop exit; they will be introduced shortly. In the above examples the address offset from the base register was always an immediate value. It can equally be another register, optionally subject to a shift operation before being added to the base, but such forms of the instruction are less useful than the immedi...
View Full Document

This document was uploaded on 10/30/2011 for the course CSE 378 380 at SUNY Buffalo.

Ask a homework question - tutors are online