Re: An Object-Oriented Syntax for x86 Assembly



On 23 Apr 2005 14:41:52 -0700
randyhyde@xxxxxxxxxxxxx wrote:

>
> Johannes Kroll remove-this]@gmx.de> wrote:
> >
> > Nice to have would be something like
> >
> > eax.add(5).mul(ebx).div(12)
> >
> > i. e. you use the result of the previous instruction as an operand
> for
> > the next one, without writing it twice. The above could be
> > translated
> to
> >
> > add eax, 5
> > mul ebx
> > ; and here's the first problem...
> > mov ecx, 12
> > div ecx
>
> In HLA, when you do something like "div( 12, edx:eax);" you get code
> like the following:
>
> twelve:dword := 12;
> .
> .
> .
> div twelve

Ok, this is probably better, or easier, then thrashing a register. It
would be best to use a register if one is "free", and a memory variable
if not. But then you would have to have some register allocation code,
which makes it all more HLL-like.

But it would be a nice way to write long calculations in an asm-like
way. Maybe. :-) I'd probably be more interested in writing it than in
using it...


> No reason you couldn't do something similar with the object-oriented
> syntax. Of course, there is the issue of EDX (or DX, or AH) being
> involved in the calculation and how do you note that in this syntax.
> In the HLA system, for example, you have to explicitly provide a
> second operand that specifies the size. I suppose in the
> object-oriented approach you could assume that the size is twice the
> object's and write
>
> eax.div( xxx ) --- means edx:eax/xxx

I'd expect that one to read from EAX only, not from EDX:EAX.


> or make it explicit
>
> edx:eax.div( xxx )
>
> You could also write
>
> edx:eax.mod( xxx )
>
> which would be exactly the same instruction as above, except it
> returns EDX as its operand rather than EAX, i.e.,
>
> edx:eax.mod( xxx ).add(3)
>
> would compute
>
> edx = (edx:eax % xxx) + 3

Yes, that's good. But then

ebx.mod(10)

or maybe even

ebx:ecx.mod(esi)

should work, too.


> Just a thought.
> Randy Hyde
>
.



Relevant Pages

  • VMI Interface Proposal Documentation for I386, Part 5
    ... to three register arguments. ... of the native instruction set. ... Most of these calls behave as standard C functions, and as such, may ... clobber registers EAX, EDX, ECX, flags. ...
    (Linux-Kernel)
  • Re: Bit extraction
    ... The register EAX has its low 16 bits being AX, ... I think the NOP goes in place to allow it to pair with the instruction ... V pipeline on the superscalar Pentium Pro+, ...
    (comp.lang.asm.x86)
  • Re: To Frank
    ... describes the instruction as if it were working on *two* qwords. ... Copies a quadword from the source operand to the ... register and a 64-bit memory location, or to move data between two XMM ...
    (alt.lang.asm)
  • Re: Nibz processor @ <570 MAXII LEs (16 bit generic specified), 20MHz
    ... register to hold the address of the second operand. ... The size of the needed memory depends mostly on the application ... The jump instruction is one word, ...
    (comp.arch.fpga)
  • Re: Intel 8086 opcodes
    ... The ADD instruction performs a byte or word ... and stores the result back in the destination operand. ... the operands can be in a register or in memory (MOD and R/M ... add immediate with register/memory to register/memory ...
    (comp.os.cpm)