src/gccode.c
/************************************************************************/
/*									*/
/*		    c o d e _ b l o c k _ s i z e			*/
/*									*/
/*	Given a native pointer to a code block, return its size.	*/
/*									*/
/************************************************************************/
c o d e _ b l o c k _ s i z e

Given a native pointer to a code block, return its size.
c o d e _ b l o c k _ s i z e Given a native pointer to a code block return its size .
int code_block_size(long unsigned int codeblock68k) {
  InstPtr codeptr, initcodeptr;
  register unsigned int opnum;
  register unsigned int len;
  struct fnhead *fnbase;
  fnbase = (struct fnhead *)codeblock68k;
  initcodeptr = codeptr = ((InstPtr)fnbase) + fnbase->startpc;
  while (T) {
    switch (opnum = Get_BYTE(codeptr)) {
      case ENDOFX:  return (codeptr - initcodeptr);
    };
    if ((len = oplength[opnum]) >
        LONGEST_OPCODE) { 
      char errtext[200];
      sprintf(errtext,
              "Unrecognized bytecode (0%o) at offset 0%to in code block x%x,x%x; continue to use "
              "UFN length",
              opnum, codeptr - (InstPtr)fnbase, (int)((codeblock68k >> 16) & 0xFF), (int)(codeblock68k & 0xFFFF));
      error(errtext);
      oplength[opnum] = len = (((UFN *)UFNTable) + (opnum))->byte_num;
    }
    codeptr += len + 1;
  };
}
int code_block_size ( long unsigned int codeblock68k ) { InstPtr codeptr , initcodeptr ; register unsigned int opnum ; register unsigned int len ; struct fnhead * fnbase ; fnbase = ( struct fnhead * ) codeblock68k ; initcodeptr = codeptr = ( ( InstPtr ) fnbase ) + fnbase -> startpc ; while ( T ) { switch ( opnum = Get_BYTE ( codeptr ) ) { case ENDOFX : return ( codeptr - initcodeptr ) ; } ; if ( ( len = oplength [ opnum ] ) > LONGEST_OPCODE ) { char errtext [ 200 ] ; sprintf ( errtext , " " " " , opnum , codeptr - ( InstPtr ) fnbase , ( int ) ( ( codeblock68k >> 16 ) & 0xFF ) , ( int ) ( codeblock68k & 0xFFFF ) ) ; error ( errtext ) ; oplength [ opnum ] = len = ( ( ( UFN * ) UFNTable ) + ( opnum ) ) -> byte_num ; } codeptr += len + 1 ; } ; }
c o d e _ b l o c k _ s i z e
c o d e _ b l o c k _ s i z e
/* -X- */ /* len > biggest possible marks an unknown opcode */