Re: order of operands in HLA

From: The_Sage (theeSage_at_azrmci.net)
Date: 08/26/04


Date: Wed, 25 Aug 2004 19:00:22 -0700


>Reply to article by: "wolfgang kern" <nowhere@nevernet.at>
>Date written: Wed, 25 Aug 2004 13:08:31 +0200
>MsgID:<cghtsi$rh4$3@newsreader1.utanet.at>

>|>|>Actually there are (useless doubles) for many instructions in the
>|>|>IA code-set:
>|>|> Intel/AMD ;my syntax
>|>|>8b c1 MOV EAX,ECX ;LD EAX,ECX
>|>|>89 c8 MOV EAX,ECX ;ST ECX,EAX ,but I use only for ST reg,[mem]
>|>|>... same for the whole 'ADD/../CMP' reg,reg group a.o.

>|>| What this have to do with order of operands for Intel processors?

>|>Now, there is actually a direction-bit (b1) within the binary
>|>opcode for a large range of instructions.

>|>It is part of the hardware architecture and vital for all
>|> READ/MODIFY/WRITE actions like
>|>XOR al,[mem] in opposition to XOR [mem],al

>|>and even the order is unimportant for MOV's, I always recommend
>|>all assembler writers to use the 88/89 for reg,reg/mem
>|>and 8a/8b for mem/reg only.

>|>I would have expected a 'sage' to know about ;) :)

>|Again, that has absolutely nothing to do with the order of the operands for
>|Intel processors. Obviously you don't know what the direction bit is for.

>Are you sure you know to whom you talking right now?
>I try to keep my politeness:
>Over and Out.

You are such a nice guy, I will try to be just as polite in return...

Using the link that Ed gave...

   ftp://download.intel.com/design/Pentium4/manuals/25366714.pdf

Table B-9 lists the encoding for the operation direction bit and table B-11
lists all the general purpose instruction formats and encodings. Only eight out
of about over 350 instructions use the direction bit. And of those eight, none
of them will reverse operands for anything other than the registers or memory -
which means no reversing of anything with an immediate value in it, ie -- there
is a reverse bit for CMP AX, BX but no reverse bit for CMP 7, AX or CMP 7, [AX].

In other words, the direction bit is useless as it doesn't actually reverse all
the operands of the processor, it only reverses the operands for an extremely
limited number of very select instructions, ie -- the reverse bit is for
exceptions to the rule only. It would be extremely confusing to partially
reverse the operands on only a very small handful of instructions so it isn't
any wonder that any assembler with any common sense wouldn't bother providing a
way to reverse the operands for those few exceptions. The only reason I can see
for doing so is for reverse engineering protection, not for programmers to
actually use.

The manual does state that bit 2 of the floating point operations sets the
operand direction but that is for the *co-processor* and not the processor.

>For all other readers:
>the confusion of direction-flag vs. direction-bit seems to be widely
>distributed. It's explained within this thread already.

I didn't see it, but then again, I don't need to.

The Sage

=============================================================
My Home Page : http://members.cox.net/the.sage

"My friend plans to make a fortune with his invention. It's a
big metal box with a slot on one side and a sign that says
'How gullible are you? To find out, insert $50.'" -- COMEDY
COMES CLEAN, by Bill Jones
=============================================================



Relevant Pages

  • Re: XP Home SP2 Install will not boot now!?!
    ... Same problem as above, only I seem to be in reverse, I was attempting to ... remove SP2. ... I got the above error code. ... I followed the instructions in the ...
    (microsoft.public.windowsupdate)
  • Re: Problem with FPU code...
    ... > Have you ever used a Hewlett-Packard calculator with reverse ... The x87 stack is very much modelled after it. ... things a bit and use the instructions that 'pop' after the instruction ...
    (comp.lang.asm.x86)
  • Re: shutdown -p now
    ... Kjell wrote: ... >and the above instructions should work. ... >If you are using r5.0 you will get the above error message. ... My experience has been just the reverse. ...
    (freebsd-questions)
  • Re: Table for x86 arithmetic instructions
    ... I'd look for 'integer instructions' description in the CPU-manuals. ... on GP-register or memory with immediate operands. ... DIV and IDIV exist only in this two forms: ...
    (comp.lang.asm.x86)
  • How to add simplified mnemonics for ppc branch instructions
    ... It is possible to add Alternative Form instructions to dis.of. ... show that Alt Forms with all-zero operands can only be utilized by "dis" ... merging Basic Form branch instruction opcodes with their BI and BO ...
    (comp.sys.powerpc.tech)