On 26 December 2013 21:27, Peter Maydell <peter.mayd...@linaro.org> wrote:

> Why is it OK to skip the addition of the base address for ES
> (in the movl_A0_EDI case) when the comment for addseg says
> it only applies to CS/DS/ES?

Scratch that, misread of the comment. addseg applies to DS/ES/SS.

> Why is it not OK to skip the addition
> of the base address for CS/DS/ES if it was specified by an
> override prefix rather than being the default for the insn?

This still applies though.

> It seems to me that we ought to try to get this code to a
> point where it looks more like:
>     if (ovr_seg < 0) {
>         ovr_seg = def_seg;
>     }
>     emit code to get address;
>     if (!segment_base_guaranteed_zero(s, ovr_seg)) {
>         emit code to add base to address;
>     }
>
> where segment_base_guaranteed_zero() is a helper
> function like:
> bool segment_base_guaranteed_zero(s, seg) {
>       /* Return true if we can guarantee at translate time that
>        * the base address of the specified segment is zero
>        * (and thus can skip emitting code to add it)
>        */
>       return (!s->addseg &&
>           (seg == R_CS || seg == R_DS || seg == R_SS));

s/R_CS/R_ES/;

> }

thanks
-- PMM

Reply via email to