On Sun, 2001-09-16 at 11:51, Gregor N. Purdy wrote:
> All --
> 
> > Anyone care to post a subcall.pasm example file that shows the
> > implementation of a subroutine and a call to it? I was thinking
> > of starting from euclid.pasm (since it has two args), but I'm
> > not sure I understand what the calling convention is really
> > supposed to look like...
> 
> Here are a couple of attempts using just jump_i. I've played a bit
> with the assembler locally to try to make it allow 'set I0, LABEL',
> followed by 'jump I0', but I think it always calculates relatative
> offsets for labels as needec by branch, et al. Do we need an
> assembler syntax for 'absolute location of this label'?
> 
> I think jump.pasm should work (I've hardcoded the jump-to locations
> as hex numbers), but it doesn't.
> 
> The jumpsub.pasm example is closer to what I'd really like to do...
>  
> Any thoughts?
> 
> 

Its not going to work, if I understand it correctly.  I tried doing it
(even set up the symbol '*' to mean the current PC) and do it, but it
seems the ops take a relative offset.  Take jump_i, for example:

/* JUMP Ix */
MANUAL_OP jump_i {
  RETURN(INT_REG(P1));
}

becomes

/* JUMP Ix */
IV *jump_i(IV cur_opcode[], struct Parrot_Interp *interpreter) {
  IV return_offset = 1;
  return cur_opcode + INT_REG(cur_opcode[1]);
  return cur_opcode + return_offset;
}

So everything has to be done as a relative offset to the current PC.  I
had a patch early on which implemented jsr_ic and ret, but they were
rejected pending Dan's work...and rightly so, because I cheated and
returned the PC I wanted, bypassing the RETURN() macro :)

Brian



> Regards,
> 
> -- Gregor
>  _____________________________________________________________________ 
> /     perl -e 'srand(-2091643526); print chr rand 90 for (0..4)'      \
> 
>    Gregor N. Purdy                          [EMAIL PROTECTED]
>    Focus Research, Inc.                http://www.focusresearch.com/
>    8080 Beckett Center Drive #203                   513-860-3570 vox
>    West Chester, OH 45069                           513-860-3579 fax
> \_____________________________________________________________________/


Reply via email to