On Mon, Mar 20, 2023 at 6:03 AM Ni, Ray <ray...@intel.com> wrote:
>
> >  ASM_PFX(FspInfoHeaderRelativeOff):
> >
> >     DD    0x12345678               ; This value must be patched by the 
> > build script
> >
> > -   and   rax, 0xffffffff
> >
> > +   mov   eax, eax                 ; equal to and rax, 0xFFFFFFFF
>
> Based on the discussion, we know "mov eax, eax" clears upper 32bits of RAX.
> But this code looks very confusing. Is there any other instruction that can 
> do the same thing?

Hi Ray,

Any instruction that writes to the lower 32-bits should zero the upper bits.
(Pardon my AT&T syntax, just reverse the operands for Intel syntax)

and $0xffffffff,%eax gets you a 3 byte opcode (since imm8 is signed,
you only need 0xff as the immediate)
and %eax, %eax gets you 2 bytes
mov %eax, %eax gets you 2 bytes

even something silly like adding 0 to EAX should work. But in a pure
efficiency+size POV, the last 2 instructions should be optimal.

-- 
Pedro


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101400): https://edk2.groups.io/g/devel/message/101400
Mute This Topic: https://groups.io/mt/97678369/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to