10.07.2015 Views

Instruction Sets

Instruction Sets

Instruction Sets

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

66 CHAPTER 2 <strong>Instruction</strong> <strong>Sets</strong>AddressData0 3 100r1031000 3 50 3 5r0CPUMemory<strong>Instruction</strong>: LDR r0,[r1]FIGURE 2.13Register-indirect addressing in the ARM.0 3 201 r150 3 201SUB r1, r15, #&101Distance 5 0 3 1010 3 100 FOO0 3 5MemoryFIGURE 2.14Computing an absolute address using the PC.loads r0 from the address given by r1 r2, whileLDR r0,[r1, #4]loads r0 from the address r1 4.This begs the question of how we get an address into a register—we need to beable to set a register to an arbitrary 32-bit value. In the ARM,the standard way to seta register to an address is by performing arithmetic on the program counter, whichis stored in r15. By adding or subtracting to the PC a constant equal to the distancebetween the current instruction (i.e.,the instruction that is computing the address)and the desired location,we can generate the desired address without performing aload. The ARM programming system provides an ADR pseudo-operation to simplify

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!