1. Machine Code in EU

What is not (yet) possible with Euphoria ?
        That is inline ASM, why not ?

                *  It is interpreterd
(It has to be compiled when executed ?? A bit weird with
                        ASM)
                * It is system-dependent

        The win32 version will run normal Euphoria progs, as long as they do
not call machine code routines...
        However, machine code in a interpreterd language can be the most
powerfull thing ever.

        The ASM will be compiled when ex.exe finds it in the program, it
can then compile it for the specified system it is on, with code
optimizations for that particular computer, video card, etc.
        It could also change dynamically... (if you press right in a
platform game it could change the code that moves the sprite
before it was called.
        How this preciously would be done, i dunno.
        Best would be if they language was as high-end (& system
independent) as possibe without executing unnessesary code.
        (So some inline language very low, but still system-independent)

        This would always create the fastest code possible for the system
it is running on.

        Anybody agrees/dissagrees ?

        This could also be done by an include file..
        Any volunteers ??
        Or any other people that know machine-code??

        Robert, i suggested this before to you, however i know you do not
think this is a good idea, why not??

Ralf

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
~~~~>> Ralf Nieuwenhuijsen <<~~~~
 ~~~>> nieuwen at xs4all.nl <<~~~~

new topic     » topic index » view message » categorize

2. Re: Machine Code in EU

Ralf Nieuwenhuijsen wrote:
<snip>
>         The ASM will be compiled when ex.exe finds it in the program, it
> can then compile it for the specified system it is on, with code
> optimizations for that particular computer, video card, etc.
>         It could also change dynamically... (if you press right in a
> platform game it could change the code that moves the sprite
> before it was called.
>         How this preciously would be done, i dunno.
>         Best would be if they language was as high-end (& system
> independent) as possibe without executing unnessesary code.
>         (So some inline language very low, but still system-independent)
>
>         This would always create the fastest code possible for the system
> it is running on.
>
>         Anybody agrees/dissagrees ?

>         Robert, i suggested this before to you, however i know you do not
> think this is a good idea, why not??
>
Ralf: I think I agree with Robert on this. I use several languages, including
Borland Pascal and C++, which have built-in assemblers. I have never had
any need to use this feature, because most speed problems can be solved
by thinking up a more efficient program strategy (how you do it, not with
what you do it).
Euphoria is fast, anyway, so I think only graphics would gain much
from machine coded routines. Maybe a graphics package could be developed
in assembler, compiled, and just called from Euphoria? You'd still need
 different
packages for different graphics cards/resolutions, etc., unfortunately.
And this would complicate Euphoria, eliminating one of Euphoria's best
features, simplicity.
Maybe we should just wait for Win95 Euphoria, since the graphics and game
routines are in Win DLL's anyway, I think.

Irv

new topic     » goto parent     » topic index » view message » categorize

3. Re: Machine Code in EU

Ralf Nieuwenhuijsen wrote:
>
>         What is not (yet) possible with Euphoria ?
>         That is inline ASM, why not ?
--snip--
>         This could also be done by an include file..
>         Any volunteers ??
>         Or any other people that know machine-code??

I don't claim to be an expert in machine code but the include file I'm
working on will convert a assembly language to machine codes right in
your program!  It's the closest thing to inline assembly language I've
seen.  Today I wrote the part that handles effective addresses, so now
it can do advanced memory operations.  The include file is available at
http://www.harborside.com/home/x/xseal/euphoria/asm.e .

The following code sample demonstrates how the functions work.  The
first argument is a string sequence of assembly language statements.
The second is a file handle.  If the file handle is nonzero, a commented
text representation of the sequence of machine code is output for you to
cut and paste in your program.  The function itself returns the same
sequence that you can poke into allocated memory.  The function get_asm
will also do this for you.  The assembly sample was taken from the
demo/callmach.ex file, with no modifications other than fudging the jump
instruction.  The sequence my function produced was identical to the
hard-coded instructions in callmach.ex!

---- sample code fragment begins ----
include asm.e
constant string_copy_code = asm_to_sequence(
    "push eax " &
    "push ebx " &
    "push edx " &
    "mov eax," & sprintf("%d", {string_space}) & " " &
    "mov edx," & sprintf("%d", {screen_location}) & " " &
    "mov bl, [eax] " &
    "inc eax " &
    "mov [edx],bl " &
    "add edx, 1 " &
    "cmp byte ptr [eax], 0 " &
    "jne -13 " &
    "pop edx " &
    "pop ebx " &
    "pop eax " &
    "ret",
    1) -- 1 for output to the screen
---- sample code fragment ends ----

Assembly language statements must be separated by a space, comma, or
semicolon, even when they are concatenated on separate lines.

I hate to say this but the code is still very buggy and has crashed on
me countless times.  I feel really bad promoting code that doesn't
always work. sad  And it still doesn't support code labels.

One other thing about calling machine code that I wish was possible
would be to pass parameters to the machine code procedure without having
to poke them into memory.  I suggest a call() procedure that accepts a
second argument, which would be a sequence of integers that would be
pushed on the stack before the the code is called.  Then the machine
code could simply pop the parameters off of the stack and do its thing.
Is this too much too ask, Robert Craig?

--
Pete Eberlein <xseal at harborside.com>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu