Relative Addressing Relative addressing is used only with certain jump instructions.

The system executes a jump by changing the contents of the PC to the address of the next instruction to be executed. For example, if we wished to jump to the instruction stored at location 4EH in code memory, the PC would be loaded with 4EH. Then, during the next execution cycle the contents of the PC (4EH) are placed on the address bus and the instruction at 4EH is retrieved. A relative address (or offset) is an 8-bit signed value, which is added to the PC to form the address of the next instruction to be executed. With 8-bit signed numbers, the MSB is used to determine whether the number is positive or negative. If the MSB is 0 then the number is positive, while if the MSB is 1 the number is negative. The instruction below shows how to jump six locations ahead. SJMP 06H SJUMP is an unconditional jump and is a 2-byte instruction

The S in SJMP stands for short. The range of signed 8-bit numbers is -127 to 128.

Absolute Addressing Absolute addressing is only used with the ACALL and AJMP instructions. ACALL - subroutine call (2 byte instruction) AJMP - unconditional jump (2 byte instruction) These instructions allow you to move to any instruction within the same 2K of memory. We will look at the AJMP instruction only (at a later date, when we begin dealing with subroutines we will deal with the ACALL instruction). The operation of the AJMP instruction is detailed below: AJMP address (PC) <- (PC) + 2 (PC10-PC0) <- address10 - address0

Sign up to vote on this title
UsefulNot useful