Brian -- > > I also did 'vi t/jump.list'. With these hard-coded relative offsets, I > > think the program should be producing the desired output, but it > > doesn't. If it did, I could do some tricks in jakoc and/or assemble.pl > > to create a pseudo-op for jumping to any label, and another for > > setting up the return-offset based on the end-label of the destination > > block and the label we want it to return to. It sure would be nice, > > though, to have a real 'absjump_i' opcode (really start-of-bytecode- > > relative rather than current-program-counter relative). > > This won't be needed once jsr/ret become available. ret is (really) the > absjump_i you're looking for since its only purpose is to return to a > previous place. Everything else can be setup as relative to the PC. I agree that jsr/ret are what I really want, but I'm dying to play with baby subroutines in jako, and I think I could play enough games with a properly understood jump_i and some assembler magic to make them work. I now have jump.pasm working right (the key was to think in terms of word offsets, not byte offsets). > > It would also be helpful to have jump_ic and absjump_ic, rather than > > having to load these things into registers. > > You can use branch_ic for this. absjump is probably a bad idea since it > appears the return value of the opcode function is really a memory > address of the host machine. If an absolute value (relative to the > beginning of the opcode stream) was used, then it would have to be > relocated at load-time and wouldn't be able to remain read-only. My mental model for this thing is "Parrot is a CPU architecture" and a lot of what I'm trying to make it do is behave as much as possible in that way. So, if we are talking about a CPU architecture (ISA), lacking the full complement of relative and absolute jumps, register and constant comparisons, etc. is a bummer. Mucking with things like memory addresses of host machines, etc. is important, but only at the interpreter level, not at the ISA design level (IMHO). I don't see a relocation issue anyway, since the way I look at the interpreter code is: PC === (code - start_code) So if an instruction says "absjump 43", then I know that I need to do: code = (start_code + 43) and if an instruction says "(rel)jump 43" then I know that I need to do: code += 43 neither of these is a problem in my eyes. > Overall, I think you're barking up the wrong tree. jsr/ret are for > subroutines. Your subroutine isn't going to work for more than one > caller, since the return offset is hardcoded, you might as well write > jump.pasm as: Not quite. First, recall jump.pasm (attached). It does work now that I've got the offsets correct. Now, there is nothing to stop us from moving the setting of I2 to earlier (jump2.pasm, attached). With appropriate labels and address arithmetic (jump3.pasm, attached) it is even almost readable. Now, if we also have good macros and '* == PC' and calculated labels, we can have some real fun (jump4.pasm, attached). Of course, this doesn't allow us to do recursion, wastes registers, etc. But, it would allow me to play with the syntax of the language with a simple implementation until cooler ops are available. > We're going to have to wait for Dan (or, you could manually apply the > patch I posted earlier which adds a simple jsr/ret implementation) Probably it would be best to wait. But my Impatience is showing... Regards, -- Gregor _____________________________________________________________________ / perl -e 'srand(-2091643526); print chr rand 90 for (0..4)' \ Gregor N. Purdy [EMAIL PROTECTED] Focus Research, Inc. http://www.focusresearch.com/ 8080 Beckett Center Drive #203 513-860-3570 vox West Chester, OH 45069 513-860-3579 fax \_____________________________________________________________________/
# # jump.pasm # # A program to test the 'jump_i' opcode. # # Copyright (C) 2001 Gregor N. Purdy. All rights reserved. # This program is free software. It is subject to the same # license as Perl itself. # # $Id: jump.pasm,v 1.1 2001/09/17 14:05:08 gregor Exp $ # MAIN: print "Jump test.\n" print "Jumping to subroutine...\n" set I1, 5 jump I1 RET: print "Returned from subroutine!\n" end SUB: print "Entered subroutine...\n" set I2, -8 jump I2
# # jump2.pasm # # A program to test the 'jump_i' opcode. # # Copyright (C) 2001 Gregor N. Purdy. All rights reserved. # This program is free software. It is subject to the same # license as Perl itself. # # $Id: $ # MAIN: print "Jump test.\n" print "Jumping to subroutine...\n" set I1, 5 set I2, -8 jump I1 RET: print "Returned from subroutine!\n" end SUB: print "Entered subroutine...\n" jump I2
# # jump3.pasm # # A program to test the 'jump_i' opcode. # # Copyright (C) 2001 Gregor N. Purdy. All rights reserved. # This program is free software. It is subject to the same # license as Perl itself. # # $Id: $ # MAIN: print "Jump test.\n" print "Jumping to subroutine...\n" set I1, &SUB_ENTER - &CALL set I2, &CALL - &SUB_LEAVE CALL: jump I1 print "Returned from subroutine!\n" end SUB_ENTER: print "Entered subroutine...\n" jump I2 SUB_LEAVE:
# # jump4.pasm # # A program to test the 'jump_i' opcode. # # Copyright (C) 2001 Gregor N. Purdy. All rights reserved. # This program is free software. It is subject to the same # license as Perl itself. # # $Id: $ # .def call(sub, r1, r2) set $r1, &"${sub}_ENTER" - * + 6 set $r2, * - &"${sub}_LEAVE" - 3 jump $r1 .enddef MAIN: print "Jump test.\n" print "Jumping to subroutine...\n" call S1 print "Returned from subroutine!\n" end S1_ENTER: print "Entered subroutine...\n" jump I2 S1_LEAVE: