On Wed, 24 Apr 2002, Steve Fink wrote:
> On Wed, Apr 24, 2002 at 03:22:57PM -0400, Simon Glover wrote: > > > > --- core.ops.old Wed Apr 24 15:07:05 2002 > > +++ core.ops Wed Apr 24 15:22:03 2002 > > @@ -470,7 +470,7 @@ > > Sets register $1 to the current address plus the offset $2 > > > > inline op set_addr(out INT, in INT) { > > - $1 = cur_opcode + $2; > > + $1 = (INTVAL) CUR_OPCODE + $2; > > goto NEXT(); > > } > > That doesn't look right. If cur_opcode is an opcode_t*, then > precedence says that this is > > $1 = ( (INTVAL) CUR_OPCODE ) + $2 > > which means you're adding bytes instead of opcodes, and the offset > will be too small. You're quite right - corrected patch below, plus a simple test case. Simon --- core.ops.old Wed Apr 24 15:07:05 2002 +++ core.ops Wed Apr 24 16:03:31 2002 @@ -470,7 +470,7 @@ Sets register $1 to the current address plus the offset $2 inline op set_addr(out INT, in INT) { - $1 = cur_opcode + $2; + $1 = (INTVAL) (CUR_OPCODE + $2); goto NEXT(); } --- t/op/basic.t.old Wed Apr 24 16:06:26 2002 +++ t/op/basic.t Wed Apr 24 16:07:50 2002 @@ -1,6 +1,6 @@ #! perl -w -use Parrot::Test tests => 7; +use Parrot::Test tests => 8; # It would be very embarrassing if these didn't work... output_is(<<'CODE', '', "noop, end"); @@ -54,4 +54,16 @@ done OUTPUT +output_is(<<'CODE', <<'OUTPUT', "set_addr"); + set_addr I1, FOO + jump I1 + print "Jump failed\n" + end + +FOO: print "Jump succeeded\n" + end +CODE +Jump succeeded +OUTPUT + 1; # HONK