Hello all,

1) First question is how to tell if variadic function recieved 11 or
   12 or more params (for simplicity let's suppose that we use only
   pmc parameters).

According calling conventions (pdd03) first 11 params end up in P5-P15
registers and leftover goes into array in P3. The problem is that
there is no indication (unless I'm missing something) if function was
called with more than 11 params other than register P3 being
initialized with some array PMC. But it may be as well that function
was called with just 11 params and P3 contains some array by accident
(it could be for example some array from previous sub call).

2) Second question if there is an op to access registers by their
   number (it is quite troublesome to write code to retrieve
   parameters in variadic function from P5-P15 registeres without such
   op).

ops/set.ops has setp_ind op which allows to write to register by its
number but it seems there is no op to read register by its number.

3) Not really a question but a feature request for IMCC to provide
   some support for variadic functions to avoid writing same code
   again and again to read parameters of variadic function from either
   P5-P15 registers or from array in P3 register as necessary. Not
   sure about syntax though. It could look for example like this:

# calculates sum of all parameters
.sub _sum
        new $P1, .PerlInt
        $P1 = 0
        # generates code which sets $I1 to a number of parameters 
        $I1 = .param_num
loop:
        if $I1 == 0 goto return
        # retrieves a parameter by its number
        $P2 = .param($I1)
        add $P1, $P2
        dec $I1
        goto loop
return:
        .pcc_begin_return
        .return $P1
        .pcc_end_return
.end


-- 
Ilya Martynov,  [EMAIL PROTECTED]
CTO IPonWEB (UK) Ltd
Quality Perl Programming and Unix Support
UK managed @ offshore prices - http://www.iponweb.net
Personal website - http://martynov.org

Reply via email to