"Clinton Pierce" <[EMAIL PROTECTED]> writes: > Given that, there's a possible bug in Jürgen's patch (or IMCC?). Given: > > .sub _main > call _INIT > .arg 0 > call _READLINE > .result $S0 > print $S0 > end > .end > .sub _INIT > $P0=new PerlArray # Array of BASIC FD's > getstdin $P1 # traditional #0 > defined $I0, $P1 > unless $I0, err > $P0[0]=$P1 > getstdout $P1 # traditional #1, etc... > $P0[1]=$P1 > defined $I0, $P1 > unless $I0, err > store_global "FDS", $P0 > ret > err: print "Cannot get handle for STDIN" > end > .end > .sub _READLINE # string readline(int fd) > saveall > .param int fd > find_global $P0, "FDS" > $P1=$P0[fd] > set $S0, "" > read $S0, $P1, 255 # <-- Crunch > .return $S0 > restoreall > ret > .end
What is that supposed to do? As I understand it it reads a line from stdin and writes it to standard out. A short test of this code simply worked. If it does not work for you, can you send me a parrot -t of this code? > This produces the PASM: > > _main: > bsr _INIT > save 0 > bsr _READLINE > restore S0 > print S0 > end > _INIT: > new P1, 19 # .PerlArray > getstdin P0 > defined I0, P0 > unless I0, err > set P1[0], P0 > getstdout P0 # <-- bug is here? Overwrote my P0. Overwriting P0 is not a problem here. You don't use it any more. Overwriting P1[0] would be a problem, but this should not be the case because getstd* create always a new PMC. > set P1[1], P0 > store_global "FDS", P1 > ret > err: > print "Cannot get handle for STDIN" > end > _READLINE: > saveall > restore I0 > find_global P0, "FDS" > set P0, P0[I0] > set S0, "" > read S0, P0, 255 > save S0 > restoreall > ret > Either behavior is fine, so long as we're consistant and/or documented. getstd* Px don't change the value of the old Px, but changing the pointer to a new PMC. Its like set P0, P1 and not like assign P0, P1 bye boe -- Juergen Boemmels [EMAIL PROTECTED] Fachbereich Physik Tel: ++49-(0)631-205-2817 Universitaet Kaiserslautern Fax: ++49-(0)631-205-3906 PGP Key fingerprint = 9F 56 54 3D 45 C1 32 6F 23 F6 C7 2F 85 93 DD 47