H-4
DINK32 PowerPC ISA Debugger User’s Manual
For More Information On This Product,
Go to: www.freescale.com
MOTOROLA
Explanation
H.3.2.1
Little Endian Swap Instruction Sequence
The peripheral logic is switched to little endian first (before the processor) in reset1.s (i.e.,
the specific programming of the bridge chip to be in little endian mode). There is a period
of time when the processor and the peripheral logic will not be in the same endian mode.
This period should be minimized. It is interesting to note that this period is of interest
because the addresses, that you think you are executing from, may not actually be intuitive.
In the the V7.0 code this is not a problem (and is not dealt with) because the instructions
that are being accessed, when the peripheral logic has been switched to LE and the
processor is still in BE, are already in local memory in BE format and the processor hasn’t
switched yet. If, however, you were running from code out in PCI then there would be an
issue because the ‘unmunge’ logic in the peripheral chip has just been turned ‘on’ but the
processor is not munging addresses just yet.
There is an elegant way of handling this. Place a sequence (approximately 30) of ‘ORI
R0,R0,0x60’ opcodes in the code stream after switching the peripheral logic to LE and then
after these ‘ori’ instructions begin, LE code modules which have DUPLICATE opcodes can
run until the processor can be put into LE mode (i.e., until the RFI executes).
NOTE
The ori r0,r0,0x60 opcode is used because it is an opcode that
doesn't matter if the bytes are read as BE or LE (i.e., they are
the same opcode; a relatively innocuous no-op). 0x60000060 is
still 0x60000060 in big or little endian mode.
After this assembly code (which has duplicate instructions), ‘regular’ compiler generated
LE modules may be located.
NOTE
The duplicated instructions handle the fact that the address is
temporarily ‘unmunged’ so it is coming out as 0x04, 0x00,
0x0C, 0x08, etc. Instead of duplicating instructions you could
alternate a no-op with the real instruction or reverse the opcode
in memory (not recommended for clarity).
H.3.3
DINKLE V7.0 10/8/97 makefile
This makefile will only work with V7.0, it is included here only
for illustrative purposes.
DEBUG =
OPTIM =
CC = /risc/tools/pkgs/metaware/bin/hcppc -HL -Hnocopyr -c -Hsds -fsoft #-Hlist
CCobj = $(CC) $(DEBUG) $(OPTIM)
PREP = $(CC) -P
F
Freescale Semiconductor, Inc.
n
.