Page 358 - Embedded Microprocessor Systems Real World Design
P. 358

Indirect Addressing
                 Indirect addressing uses a register to point to the data. Continuing with  our example, the
                 processor executes the instruction at location 0002. This is an indirect instruction that says,
                 “Put the value addressed (pointed to) by IAR into register RO.” Since IAR contains 0010 and
                 location 0010 contains 12M, we  end up with the value  12AF3 in register RO.


                 Direct Branching
                 Direct branching, like direct addressing, includes the destination address (new PC value) as
                 part of the instruction. Our example system continues, executing the instruction at location
                 0003. This is a direct branch instruction that says, “Start executing at the location pointed
                 to by  the data value following the opcode.” Because this data value is 0008, the processor
                 loads the PC with 0008 and continues on.


                 Indirect Branching
                 Again, like  indirect  addressing, indirect branching  takes the  destination address from  a
                 register. In our example, the processor executes the instruction at location 0008, which loads
                 the IAR with a new value (0015). The instruction at location OOOA  says, “Start executing at
                 the location addressed by IAR.” Because IAR contains 0015, the next instruction is fetched
                 from there.


                 Indexed Addressing

                 Indexed addressing uses two values to access a location. In the example, register RO  is loaded
                 with 0004 by the instruction at address 0012/0013. IAR already contains 0012 from the indi-
                 rect branch instruction just executed. The instruction at 0014 is an indexed instruction that
                 says, “Load RO  with  the value addressed by  [IAR + RO] .” Since IAR + RO  = 0012 + 0004 =
                 0016, the value from 0016 (2AC7) is loaded into RO. Note that we loaded the value into one
                 of the registers used to calculate the address; we  could have loaded it into another register
                 in the processor. Some microprocessors support an indexeddirect instruction where one of
                 the two index parameters is immediate data in the instruction.


                 Indexed Branching
                 Although not  shown in  the  example, indexed branching works  the  same way  as  indexed
                 addressing, where a pair of registers are added to generate the destination address. A special
                 case of indexed direct branching commonly is used in microprocessors where a direct data
                 value is used as an index from the program counter. The direct data value usually is a signed
                 8 or  16bit number, allowing  branching  of  +127  (%bit) or +32K  (l6bit) locations. For
                 example, if the program counter is 12BC, a branch instruction that contains an %bit value
                 of 06 would cause a branch to 12C2 (12BC + 06). On some microprocessors, this is the only
                 kind of conditional branch  available, and only unconditional branches have  the ability to
                 reach the entire address range of  the CPU.


                 Appendix D                                                           339
   353   354   355   356   357   358   359   360   361   362   363