set I0, I7 # number of items on the stack
set I1, 0 # no integer return values
The current example is listed below. I am very much a novice at reading PASM
so hopefully I didn't interpret the program wrong.
Paul Seamons
PS - By the way the new examples (I think they are new - they are new to me)
are very nice and descriptive of PASM.
--------------------------------------------------------------
set I0, 1 # prototyped
set I1, 0 # no items on the stack
set I5, 42
set I6, 56
bsr SPAN
ne I0, 0, RETURNERROR # item on stack
# we don't know the number of integers values returned
ne I2, 0, RETURNERROR # string return values
ne I3, 0, RETURNERROR # PMC return values
ne I4, 0, RETURNERROR # numeric return values
MORE: restore I2
print I2
print " "
dec I1
if I1, MORE
print "\n"
end
RETURNERROR:
print "Error with return values from SPAN!\n"
end
SPAN: ne I0, 1, CALLERROR # not prototyped
ne I1, 0, CALLERROR # items on stack
set I7, 0 # count of integers
REDO: save I6
dec I6
inc I7
le I5, I6, REDO
set I0, 0 # no items on the stack
set I1, I7 # one integer return value
set I2, 0 # no string return values
set I3, 0 # no PMC return values
set I4, 0 # no numeric return values
ret
CALLERROR:
print "Error calling SPAN!\n"
end
--------------------------------------------------------------
Paul Seamons wrote:
> Their is an example at http://www.parrotcode.org/examples/ that returns a list
> of integers that span two integers. The return types appear to be set wrong
> in the SPAN bsr. It seems the return values should be
>
> set I0, I7 # number of items on the stack
> set I1, 0 # no integer return values
>
> The current example is listed below. I am very much a novice at reading PASM
> so hopefully I didn't interpret the program wrong.
Hurm. The code as written works, though you're right, it doesn't follow the coding conventions.
It works only because we cheat, and use the I7 return value (returned via I1) explicitly to count
how many items to print from the stack. Attached, find a more proper example. Website has a patch in the queue.
Good eye. When I checked these before, I /only/ checked to make sure they generated the output they were supposed to.
> Paul Seamons
>
> PS - By the way the new examples (I think they are new - they are new to me)
> are very nice and descriptive of PASM.
The examples have been around for a while, though the page just got an overhaul a few weeks ago. We need to get PIR examples up there.
Thanks again.