At 11:04 PM 9/17/2001 +0100, Simon Cozens wrote:
>On Mon, Sep 17, 2001 at 05:52:19PM -0400, Dan Sugalski wrote:
> > >Which is really going to screw up backpatching. :(
> >
> > Maybe. I don't think it's as big a deal as you might think it is, since we
> > vector through a register, and you can just patch the register load.
>
>The reason I started looking at this was because the test suite contains
>this:
>
> skip( "label constants unimplemented in assembler", 1 );
> set I4, 42
> set I5, HERE
> jump I5
> set I4, 1234
>HERE:
> print I4
> end
Ah. That's wrong. Or, rather, the "set I5, HERE" bit should be fetching the
address of HERE from the fixup section, assuming we do that. (We might not,
I'm not sure whether it's worth it yet)
>Since HERE isn't known when it's first encountered, we leave a space
>for backpatching. But when we backpatch, to get it right, we need to
>be aware that we're doing a set, and produce an absolute rather than
>a relative address.
Now that I know what you're looking for, I can say with some certainty:
"Don't *do* that!" :-)
Since jump jumps to a constant address, and the bytecode is relocatable,
it's not possible to resolve the address that jump is going to at assembly
time. Either the address needs to be fetched from the fixup section or the
code should do a branch rather than a jump.
>This isn't easy. Especially since to make that
>work, we need to know that the register will be used to do a jump and
>not a branch. Consider:
>
>set I5, WHEREVER
>
> if I1, HERE, THERE
>HERE: jump I5
>THERE: branch I5
>
>When we do the set, should WHEREVER be a relative or an absolute
>address?
Generally neither. That code's broken. :)
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk