This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ia32 suffix inconsistency


On Wed, Dec 15, 2010 at 8:00 AM, Etienne Lorrain
<etienne_lorrain@yahoo.fr> wrote:
> Mer 15.12.10, H.J. Lu <hjl.tools@gmail.com> wrote:
>> > $ echo 'and $1,(%ebx)' | as
>> > $ echo 'cmp $1,(%ebx)' | as
>> > $ echo 'xor $1,(%ebx)' | as
>> > $ echo 'or $1,(%ebx)' | as
>>
>> Those insns extend immX to 32bit first.
>
> I am just saying that this default make it easy to make an error.
> For me, I was thinking I was accessing a byte - or more exactly
> that AS would optimise it to a byte access because of the smaller
> hexadecimal encoding of $1.

You should read IA32 SDM very carefully if you want to write in assembly.

>> > Note that optimising 'orl $0,(%ebx)' to 'orb $0,(%ebx)'
>> > is incorrect
>>
>> I don't quite follow you.
>>
>> or $1,(%ebx)
>>
>> has the same result as
>>
>> or $0x00000001,(%ebx)
>>
>> Both apply to 32bit memory.
>
> But
> orb $0,(%ebx)
> does the or (no change of the value) and set the
> zero flag if the *byte* is zero, and:
> orl $0x00000000,(%ebx)
> does the or (no change of the value) and set the
> zero flag if the *dword* is zero, isn't it?
>

Please read IA32 SDM:

http://www.intel.com/products/processor/manuals/index.htm



-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]