Dan Sugalski <[EMAIL PROTECTED]> writes: > Ah, this is incorrect. goto ADDRESS should go to an absolute address, > period. It's for use in those times when you *have* an absolute > address--for example when you've just fetched the address of a > subroutine from a symbol table.
but what do i put in the symbol table? every address i have in the symbol is, unless my understanding is severly flawed, determined at compile time by the assembler and is relative to the start of the byte code. if i have code like (perl5 syntax to avoid confusion) my $f = sub { print "hello" }; $f->(); i imagine that will become more or less: (in pseudo pasm) closure_000: print "hello" ret main: set_sym P0, '$f', [closure_000] fetch_sym I0, P0, '$f' jsr I0 > Jumping from the start of the > bytecode segment is an interesting idea, but since it's only valid > when used to transfer control from within the current segment, you > might as well just use goto OFFSET instead. sorry, but i don't understand. > -- all i want to be able to do is: set I0, [whatever] .... jsr I0 or set I0, [wherever] .... jump I0 and as far as i know i can't currently do this. and i can't use goto OFFSET() because the pc at the time of the jump isn't known when the register is set, although jsr [I0 - @] might sort of work, but it can't. although the ever so contorted set I0, [wherever] .... add I0, I0, [-@ - 4] bsr I0 works, i find jsr I0 slightly cleaner. i really shouldn't be modifying goto ADDRESS(), but i should just modify jump and jsr, hence the following patch to core.ops. This patch has the happy side effect of giving Piers Cawley what he wants, i say this as proof that i'm not the only lunatic who thinks this may be a good idea :) -- -Marco Ring the bells that still can ring. Forget the perfect offering. There's a crack in everything. It's how the light gets in. -Isonard Cohen post scriptum - did my patch to lib/Parrot/Assembler get lost in the haze or was there something wrong with it? post post scriptum - i noticed a mention of #parrot in some email, which network is that on? Index: core.ops =================================================================== RCS file: /cvs/public/parrot/core.ops,v retrieving revision 1.124 diff -u -r1.124 core.ops --- core.ops 19 Apr 2002 01:32:40 -0000 1.124 +++ core.ops 19 Apr 2002 17:05:03 -0000 @@ -2601,8 +2601,8 @@ =item B<bsr>(in INT) -Branch to the location specified by $1. Push the current location onto the call -stack for later returning. +Branch forward or backward by the amount in $1. Push the current +location onto the call stack for later returning. =cut @@ -2614,26 +2614,33 @@ ######################################## +=item B<jsr>(in INT) + =item B<jsr>() -Jump to the location specified by register X. Push the current -location onto the call stack for later returning. +Jump to the address held in register $1. Push the current location +onto the call stack for later returning. TODO: Implement this, or delete the entry. +inline op jsr (in INT) { + stack_push(interpreter, interpreter->control_stack, expr NEXT(), +STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL); + goto ADDRESS(interpreter->code->byte_code + $1); +} + =cut ######################################## -=item B<jump>(out INT) +=item B<jump>(in INT) Jump to the address held in register $1. =cut inline op jump(in INT) { - goto OFFSET($1); + goto ADDRESS(interpreter->code->byte_code + $1); } =back