Re: Linux, X, ld, gcc, linking, shared libraries and stuff

From: Herbert Kleebauer (klee_at_unibwm.de)
Date: 03/28/05


Date: Mon, 28 Mar 2005 22:19:52 +0200

Betov wrote:
> Herbert Kleebauer <klee@unibwm.de> écrivait news:4248167F.5263BD35
 
> > What code does RosAsm generate for a "mov eax,eax"
> > instruction:
> >
> > 89 c0 move.l r0,r0
> > 90 exg.l r0,r0
>
> It generates, of course the first form. You are
> confusing _Optimization_ and choice of the most
> appropriated encoding form.

??? To choose the most appropriate encoding for a given
task is optimization. I think, you mean that RosAsm does
optimization only within a single instruction (choose the
most appropriate encoding for a single instruction) but
does not optimize a sequence of instructions.

Therefore if you want to push a 10 onto the stack, RosAsm
uses:

  6a 0a moveq.l #10,-(sp)

and not:

  68 0000000a move.l #10,-(sp)

But that's illogical. In the example above (move the content
of register eax into eax) there is also just one instruction
with two different encoding

  89 c0 move.l r0,r0
  90 exg.l r0,r0

and RosAsm doesn't automatically choose the "most appropriated
encoding form".

Another example would be, if you want to sign extend the
content of ax to eax. There are also two encoding forms:

  98 ext.l r0
  0f bf c0 movs.wl r0,r0

Does RosAsm here automatically choose the "most appropriated
encoding form"? If not, why then in the "push" example?

I think, the real problem again is Intel. There are two different
move instructions, MOV moves a 32 bit source operand to 32 bit
destination whereas MOVSX takes a 8 bit source operand, sign
extends it to 32 bit and moves it to a 32 bit destination.
Exactly the same is true for push. There is a PUSH instruction
which takes a 32 immediate operand and pushes it onto the stack
and there is a PUSHSX instruction (a completely different
instruction as MOVSX is different from MOV) which takes a 8 bit
immediate operand, sign extends it to 32 bit an push it onto
the stack. The God Intel has chosen to use the same name PUSH
for this two different instructions. And as a religious man you
do exactly as your God tell you and also use the same name for
this different instructions (without wasting a single second
whether this makes any sense). But now you have a big problem:
With "PUSH 10" you are not able to decide which of the two
PUSH instruction should be used. NASM at least gives a workaround
by adding a "byte" before the immediate operand, but RosAsm
completely ignores the problem.

If Intel had chosen to use two different names for the
different instructions (PUSH and PUSHSX similar to MOV
and MOVSX), would RosAsm then also automatically convert a
"PUSH 10" to a "PUSHSX 10"?

- If not, then your PUSH solution has nothing to do with

    2) RosAsm chooses the shortest of the available forms
       when there are several equivalent one.

  but only shows, that RosAsm (in opposite to NASM) isn't able
  to solve the problem with the two different push instructions.

- If yes, then RosAsm also has to use the shortest of the
  available forms for

    89 c0 move.l r0,r0
    90 exg.l r0,r0

  or

    98 ext.l r0
    0f bf c0 movs.wl r0,r0



Relevant Pages

  • Re: Some confusion on Stack operation
    ... By integrating 16-bit and 32-bit segments into a single protected-mode task. ... assembler to differentiate between 'push ax' and 'push eax'. ... instruction coding is the same. ...
    (alt.lang.asm)
  • Re: To Richard Heathfield: enoughs enough
    ... > A single CISC instruction that searches for a NUL byte takes Otime. ... language" in a typical machine with a typical stack. ... push intIndex1 ...
    (comp.programming)
  • Re: Some confusion on Stack operation
    ... Using A 16-Bit TSS with 32-Bit Constructs ... assembler to differentiate between 'push ax' and 'push eax'. ... instruction coding is the same. ... ELSE (* OperandSize = 16*) ...
    (alt.lang.asm)
  • Re: C++ Object Pointers
    ... I shoud add that on a RISC machine, a call is a control transfer, so the RISC equivalent ... because the call instruction will transfer control but the instruction following it will ... >push the return ...
    (microsoft.public.vc.mfc)
  • Re: Question about Instruction Format (ModR/M)
    ... I haven't them in any of my AMD lists. ... it's in Intel and AMD's current manuals ... Intel's VMX instruction list includes: ... encoding instruction a.k.a. ...
    (alt.lang.asm)

Loading