Title: Problems with Prefixes
1Problems with Prefixes
Suppose there is an instruction using a prefix.
Without interrupts, it executes in sequence as
follows
1
Prefix
2
Instruction
If an interrupt is allowed to occur after the
prefix is fetched, but before the instruction is
fetched, then the immediate value used for the
instruction wont be correct once normal program
flow is restored after the interrupt.
1
Prefix
Interrupt Occurs
Instruction
These instructions executing in the interrupt
routine will cause the value of the prefix to be
lost.
Instruction
Instruction
Interrupt return point
2
Instruction
2Prefix Fix
How to fix ? Disallow an interrupt from
occurring between the prefix and the prefixed
instruction. OR Rather than returning to the
instruction that was about to be executed, return
to the preceding instruction prefix. This can be
done via address inheritance.
Interrupt return point
1
Prefix
Interrupt Occurs
Instruction
These instructions executing in the interrupt
routine will cause the value of the prefix to be
lost.
Instruction
Instruction
2
Instruction
3Address Inheritance
The cache outputs both the instruction fetched
and its address. Both of these values are
captured in the instruction fetch stage. In each
processor stage, both the instruction and its
address are tracked.
Cache
Instruction
Instruction Address
When a instruction is loaded in the fetch stage,
the decode stage is checked to see if the
instruction in the decode stage is a constant
prefix. If the decode stage instruction is a
constant prefix instruction, then the following
instruction inherits the address from the
constant prefix instruction.
Decode stage
Constant Prefix Instruction
Instruction Address
Fetch stage
Next Instruction
Instruction Address
When a return address is determined in the
execution stage, the address of the constant
prefix instruction ends up being used rather than
the address of the displaced instruction due to
the address inheritance,