Page 126 - Understanding Automotive Electronics
P. 126

2735 | CH 4  Page 113  Tuesday, March 10, 1998  11:06 AM



                                         MICROCOMPUTER INSTRUMENTATION AND CONTROL                         4





                    Figure 4.8
                    Instruction Byte
                    Arrangement




                                                         FPO











                                         in the present example, the largest forward branch is 127 memory locations and
                                         the largest backward branch is 128 memory locations.

                                         Offset Example
                                              Suppose the program counter is at address 5,122 and the instruction at
                                         this location is a branch instruction. The instruction to which the branch is to
                                         be made is located at memory address 5,218. Since the second byte of the
                                         branch instruction is only 8 bits wide, the actual address 5,218 cannot be
                                         contained therein. Therefore, the difference or offset (96) between the current
                                         program counter value (5,122) and the desired new address (5,218) is
                                         contained in the second byte of the branch instruction. The offset value (96) is
                                         added to the address in the program counter (5,122) to obtain the new address
                                         (5,218), which is then placed on the address bus. The binary computation of
                                         the final address from the program counter value and second byte of the branch
                                         instruction is shown in Figure 4.9
                                         Jump Instruction

                    8-bit branch operations   Branch instructions have a range of +127 or –128 (in the present 8-bit
                    are limited to an offset   example). If the branch needs to go beyond this range, a jump instruction must
                    range of +127 or –128   be used. The jump instruction is a 3-byte instruction. The first byte is the jump
                    memory locations. Thus,   op code, and the next two bytes are the actual jump address. The CPU loads
                    program branches to   the jump address directly into the program counter, and the program counter
                    locations farther away   effectively gets restarted at the new jump location. The CPU continues to fetch
                    must use jump instruc-  and execute instructions in exactly the same way it did before the jump was
                    tions. These 3-byte   made.
                    instructions contain the   The jump instruction causes the CPU to jump out of one section of the
                    entire memory address.  program into another. The CPU cannot automatically return to the first section
                                         because no record was kept of the previous location. However, another
                                         instruction, the jump-to-subroutine, does leave a record of the previous
                                         instruction address.


                                         UNDERSTANDING AUTOMOTIVE ELECTRONICS                            113
   121   122   123   124   125   126   127   128   129   130   131