pointers to variables

new topic     » topic index » view thread      » older message » newer message

Hi, all. I have returned to Euphoria after seven years of being distracted. Got to say I am thrilled by what has progressed in my absence! v2.1 was the big one back then.

Here's something I always wanted: direct access to the contents of Euphoria variables from within my assembly routines. Peeks and pokes are fine for shuffling small quantities of data back and forth but dent assembly performance with large data sets as they are (relative to assembler) quite slow, even with sequence operations. I think the good way to do this would be with a function to return the memory address of a Euphoria object that the assembly code could read or write directly. (who remembers the varptr() function from good ol` Basic?)

IIRC there is a suggestion that a function such as var_id() may be introduced. A further refinement to this may be along the lines of pointer = get_var_address(var_id(myvar)).

That's all I would need or want - just the pointer.

Now I believe that the memory representation of Euphoria objects would be quite complicated and any assembler code that deals with such may be difficult but this is something I think I can deal with.

I think it would be the responsibility of the assembler writer to untangle/reentangle sequences. Perhaps only the very ambitious would construct deeply nested sequences from within asm to return to Euphoria. In fact, it may well not be possible to create new or enlarge existing sequences from within assembly given just a pointer but this would not make it any less useful.

What exactly do I want to do? Okay, here's an example. Say I have generated a floating point fractal bitmap image in memory using an assembly language routine (which I intend to do). I now want to bring this structure into Euphoria to determine it's Lyapunov exponent. The traditional method would appear to involve many, many thousands of individual peek() and float64_to_atom() statements, not a fast operation. (in early code I tried this and found the data transfer took longer than generating the fractal in the first place!) The pointer method would require the asm routine to write values directly into a preallocated one-dimensional sequence which would be immediately ready for use.

Would anyone else find a use for this? Is there a better way I am overlooking? I have many questions, Mr Sparkle.

Nick Metcalfe

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu