EasyManua.ls Logo

Intel 8253 - Page 408

Intel 8253
773 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
XA User Guide 6-8 4/17/98
6.3 Relative Branching and Jumps
Program memory addresses as referenced by Jumps, Calls, and Branch instructions must be word
aligned in XA. For instance, a branch instruction may occur at any code address, but it may only
branch to an even address. This forced alignment to even address provides three benefits:
Branch ranges are doubled without providing an extra bit in the instruction and
Faster execution as XA always fetches first two byte of an instruction simultaneously.
Allows translated 8051 code to have branches extended over intervening code that will tend to
grow when translated and generally increase the chances of a branch target being in that
range.
The rel8 displacement is a 9-bit two’s complement integer which is encoded as 8-bits that
represents the relative distance in words from the current PC to the destination PC. Similarly, the
rel16 displacement is a 17-bit twos complement integer which is encoded as 16-bits. The value of
the PC used in the target address calculation is the address of the instruction following the Branch,
Jump or Call instruction.
The 8-bit signed displacement is between -128 to +127. The branch range for rel8 is (sample
calculation shown below) is really +254 bytes to -256 bytes for instructions located at an even
address, and +253 to -257 for the same located at an odd address, with the limitation that the target
address is word aligned in code memory.
The 16-bit signed displacement is -32,768 to +32,767. The branch range is therefore +65,534 bytes
to -65,536 bytes for instructions located at an even address, and +65,533 to -65,537 for the same
located at an odd address, with the limitation that the target address is word aligned in code
memory.
Sample calculation for rel8 range:
Assuming word aligned branch target, forward range as measured from current PC is:
Branch Target Address - Current PC
Now, maximum positive signed 8-bit displacement = +127; So, rel8 << 1 is +254
If Current PC = ODD, then
Range = 254 - 1 = +253 as PC is forced to an even location, else
If current PC = EVEN, then
Range = +254
Similarly, reverse range as measured from current PC is:
Branch Target Address - Current PC
Now, maximum positive signed 8-bit displacement = -128; So, rel8 << 1 is -256
If Current PC = ODD, then
Range = -257
Else if current PC = EVEN, then
Range = -256

Table of Contents