On Wed, Sep 19, 2001 at 10:22:27PM -0700, Dave Storrs wrote:
> I'm working on documenting the opcodes, and I want to make sure that I
> understand the 'RETURN' code properly.  I've poked around a little bit to
> see if I coudl figure it out, but I don't want to divert too much.  Would
> someone please explain to me what each of the following does?
> 
> RETURN 4
> RETURN 0
> RETURN -2     # Is this even legal?

First off, RETURN requires parenthesis at the moment, so none of the above
is legal.

RETURN(offset) returns from the executing op, and moves the program
counter by <offset> words.  RETURN(-2) is perfectly legal, and will
move the PC two words back, relative to the start of the currently
executing op.

For example, the jump_i op (which jumps to a new location, specified
as a relative offset) is written as follows:

  MANUAL_OP jump_i {
    RETURN(INT_REG(P1));
  }

This moves the PC by the amount specified in the integer register
identified by the op's first argument.

"RETURN(0);" (written exactly like that, no variation permitted)
is a special case, and terminates the runops loop.  The only op
which uses this is "end", and it doesn't actually ever execute.
Personally, I feel that this special case should be removed.

                        - Damien

Reply via email to