At 10:45 AM 09-06-2001 -0400, Ken Fox wrote:
>Dave Mitchell wrote:
> > So how does that all work then? What does the parrot assembler for
> >
> >       foo($x+1, $x+2, ...., $x+65)
>
>The arg list will be on the stack. Parrot just allocates new PMCs and
>pushes the PMC on the stack.
>
>I assume it will look something like
>
>   new_pmc pmc_register[0]
>   add pmc_register[0], $x, 1
>   push pmc_register[0]
>
>   new_pmc pmc_register[0]
>   add pmc_register[0], $x, 2
>   push pmc_register[0]
>
>   ...
>
>   call foo, 65

Hmmm, I assumed it would be something like:

load $x, P0             ;; load $x into PMC register 0
new P2          ;; Create a new PMC in register 2
push p0,p2              ;; Make P2 be ($x)
add p0,#1,p1            ;; Add 1 to $x, store in PMC register 1
push p1,p2              ;; Make P2 be ($x,$x+1)
add p0,#2,p1            ;; Add 2 to $x, store in PMC register 1
push p1,p2              ;; Make P2 be ($x,$x+1,$x+2)
...
call foo,p2             ;; Call foo($x,$x+1,...,$x+65)

Although this would be premature optimization, since I see this idiom being 
used a lot, it may be useful to have some special-purpose ops to handle 
creating arg-lists, like a "new_array size,register" op, that would create 
a new PMC containing a pre-sized array (thus eliminating repeatedly growing 
the array with the push ops), or a "push5 destreg, reg1, reg2, reg3, reg4, 
reg5" op (and corresponding pushN ops for N=2 to 31) that push the 
specified registers (in order) onto the destreg.



>Hmm. It didn't occur to me that raw values might go on the call
>stack. Is the call stack going to store PMCs only? That would
>simplify things a lot.

If ops and functions should be able to be used interchangeably, I wouldn't 
expect any function arguments to be stored on the stack, but passed via 
registers (or lists referenced in registers).


>- Ken

Reply via email to