Simon -- > On Mon, Sep 17, 2001 at 10:33:35AM -0400, Gregor N. Purdy wrote: > > as *word* counts not *byte* counts -- D'Oh!) > > Isn't assembly programming fun? :) Woo-hoo! > > */ > > > > static int > > -check_magic(void** program_code) { > > +check_magic(void** program_code, long* program_size) { > > + program_size -= sizeof(IV); > > return (GRAB_IV(program_code) == PARROT_MAGIC); > > } > > And to think, just above that "*/" is a load of lovely documentation > you haven't touched... It would be my pleasure to update the docs if this doesn't die an early death. I wanted to get initial reactions to the idea and implementation before investing the extra time. > > +#ifdef TRACE_OPS > > + fprintf(stderr, "PC=%ld; OP=%ld (%s)\n", code - code_start, *code, >op_names[*code]); > > +#endif /* TRACE_OPS */ > > That's neat. Thanks. > > +#ifdef TRACE_OPS > > + if (code >= code_start && code < (code_start + code_size)) { > > + fprintf(stderr, "PC=%ld; OP=%ld (%s)", code - code_start, *code, >op_names[*code]); > > + if (op_args[*code]) { > > + fprintf(stderr, "; ARGS=("); > > + for(i = 0; i < op_args[*code]; i++) { > > + if (i) { fprintf(stderr, ", "); } > > + fprintf(stderr, "%ld", *(code + i + 1)); > > + } > > + fprintf(stderr, ")"); > > + } > > + fprintf(stderr, "\n"); > > + } else { > > + fprintf(stderr, "PC=%ld; OP=<err>\n", code - code_start); > > + } > > +#endif /* TRACE_OPS */ > > That's less than neat, but I can't think of a better way to do it. I'm thinking of just putting it in a function to sweep the mess under the rug... > > + if (code < code_start || code >= (code_start + code_size)) { > > + fprintf(stderr, "Error: Control left bounds of byte-code block (now at >location %d)!\n", code - code_start); > > + exit(1); > > I don't like this check in every iteration. Nor do I. Note that the checks themselves are about as cheap as they *can* be, though. And I think that not checking is dangerous. I *did* get some segfaults when I was working on the jump_i example. Just try running blamo.pasm (attached) on your stock interpreter... 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 \_____________________________________________________________________/
# # blamo.pasm # # A simple program to blow up the interpreter. # # 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: $ # set I0 -4 jump I0