예제 #1
0
파일: cfg.c 프로젝트: arnew/yaboot
void cfg_print_images (void)
{
     struct IMAGES *p;
     char *label, *alias;

     char *ret = cfg_get_strg_i (cf_options, "default");
     int defflag=0;

     printl_count = 0;
     for (p = images; p; p = p->next) {
	  if (p->obsolete)
		  continue;

	  label = cfg_get_strg_i (p->table, "label");
	  if (!label) {
	       label = cfg_get_strg_i (p->table, "image");
	       alias = strrchr (label, '/');
	       if (alias)
		    label = alias + 1;
	  }
	  if(!strcmp(bootoncelabel,label))
	       defflag=2;
	  else if(!strcmp(ret,label))
	       defflag=1;
	  else
	       defflag=0;
	  alias = cfg_get_strg_i (p->table, "alias");
	  printlabel (label, defflag);
	  if (alias)
	       printlabel (alias, 0);
     }
     prom_printf("\n");
}
예제 #2
0
ostream& ppsig::printui (ostream& fout, const string& funame, Tree label, Tree lo, Tree hi, Tree step) const
{
    fout << funame << '(';
    printlabel(fout, label);
    return fout
           << ',' << ppsig(lo,fEnv)
           << ',' << ppsig(hi,fEnv)
           << ',' << ppsig(step,fEnv)
           << ')';
}
예제 #3
0
파일: c80.c 프로젝트: adamsch1/scc
dumplits()
  {int j,k;
  if (litptr==0) return;  /* if nothing there, exit...*/
  printlabel(litlab);col(); /* print literal label */
  k=0;      /* init an index... */
  while (k < litptr)  /*   to loop with */
    {defbyte();  /* pseudo-op to define byte */
    j=10;    /* max bytes per line */
    while(j--)
      {outdec((litq[k++]&127));
      if ((j==0) | (k>=litptr))
        {nl();    /* need <cr> */
        break;
        }
      outbyte(',');  /* separate bytes */
      }
    }
  }
예제 #4
0
ostream& ppsig::printui (ostream& fout, const string& funame, Tree label) const
{
    fout << funame << '(';
    printlabel(fout, label);
    return fout << ')';
}
예제 #5
0
파일: function.c 프로젝트: blakewford/BPM
newfunc ()
{
        char    n[NAMESIZE], *ptr;
        fexitlab = getlabel();

        if (!symname (n) ) {
                error ("illegal function or declaration");
                kill ();
                return;
        }
        if (ptr = findglb (n)) {
                if (ptr[IDENT] != FUNCTION)
                        multidef (n);
                else if (ptr[OFFSET] == FUNCTION)
                        multidef (n);
                else
                        ptr[OFFSET] = FUNCTION;
        } else
                addglb (n, FUNCTION, CINT, FUNCTION, PUBLIC);
        prologue ();
        if (!match ("("))
                error ("missing open paren");
        prefix ();
        outstr (n);
        col ();
        nl ();
        locptr = STARTLOC;
        argstk = 0;
        while (!match (")")) {
                if (symname (n)) {
                        if (findloc (n))
                                multidef (n);
                        else {
                                addloc (n, 0, 0, argstk, AUTO);
                                argstk = argstk + intsize();
                        }
                } else {
                        error ("illegal argument name");
                        junk ();
                }
                blanks ();
                if (!streq (line + lptr, ")")) {
                        if (!match (","))
                                error ("expected comma");
                }
                if (endst ())
                        break;
        }
        stkp = 0;
        argtop = argstk;
        while (argstk) {
                if (amatch ("register", 8)) {
                        if (amatch("char", 4))
                                getarg(CCHAR);
                        else if (amatch ("int", 3))
                                getarg(CINT);
                        else
                                getarg(CINT);
                        ns();
                } else if (amatch ("char", 4)) {
                        getarg (CCHAR);
                        ns ();
                } else if (amatch ("int", 3)) {
                        getarg (CINT);
                        ns ();
                } else {
                        error ("wrong number args");
                        break;
                }
        }
        statement(YES);
        printlabel(fexitlab);
        col();
        nl();
        modstk (0);
        gret ();
        stkp = 0;
        locptr = STARTLOC;

}
예제 #6
0
int Crecompilateur::re(const char *outname, Cprogramlisting *plisting,
		       Copcodes *popcode_list, Crom_file *prom)
{
  FILE *fp;
  Instruction6502 *pinstr;
  bool            irqbrkvector = false;
  bool            nmivector = false;

  try
    {
      fp = fopen(outname, "w");
      if (fp == NULL)
	{
	  snprintf(m_error_str, sizeof(m_error_str),
		   "opening file %s failed", outname);
	  throw int(1);
	}
      //      fp = stdout;
      create_label_list(plisting, popcode_list);
      writeheader(fp);
      pinstr = plisting->get_next(true);
      while (pinstr != NULL)
	{
	  switch (pinstr->isvectorstart)
	    {
	    case resetstart:
	      // Label of the first instruction executed on start/reset
	      fprintf(fp, "NESReset:\n");
	      break;
	    case nmistart:
	      // Label of the non maskable interrupt routine
	      fprintf(fp, "NESNonMaskableInterrupt:\n");
	      nmivector = true;
	      break;
	    case irqbrkstart:
	      //
	      fprintf(fp, "NESIRQBRK:\n");
	      irqbrkvector = true;
	      break;
	    default:
	      break;
	    }
	  printlabel(fp, pinstr);
	  switch (isreplaced(pinstr, popcode_list))
	    {
	    case noreplace:
	      outinstr(fp, pinstr, popcode_list);
	      break;
	    case replaceIOPort:
	      outReplaceIOport(fp, pinstr, popcode_list);
	      break;
	    case replaceBackupRam:
	      //outReplaceBackupRam(fp, pinstr, popcode_list);
	      break;
	    case replaceJumpIndirect:
	      outReplaceJumpIndirect(fp, pinstr, popcode_list);
	      break;
	    default:
	      break;
	    };
	  pinstr = plisting->get_next(false);
	}
      fprintf(fp, "\n");
      if (!nmivector)
	{
	  fprintf(fp, "NESNonMaskableInterrupt:\n");
	  fprintf(fp, "\tjmp DebugHandler\n");
	}
      if (!irqbrkvector)
	{
	  fprintf(fp, "NESIRQBRK:\n");
	  fprintf(fp, "\tjmp DebugHandler\n");
	}
      fprintf(fp, "\n");
      // io port accesses are replaced by a jsr to a routine,
      // the routines are written here.
      writeiop_routines(fp, plisting, popcode_list);
      fprintf(fp, "\n.ENDS\n");
      fclose(fp);
    }
  catch (int e)
    {
      return 1;
    }
  return 0;
}
예제 #7
0
/*
|| Standard main
*/
int
main( int argc, char *argv[] )
{
    char buf[ HETMAX_BLOCKSIZE ];
    HETB *hetb;
    int rc;
    int fileno;
    U32  blocks;
    U32  uminsz;
    U32  umaxsz;
    U32  ubytes;
    U32  cminsz;
    U32  cmaxsz;
    U32  cbytes;
    U32  totblocks;
    U32  totubytes;
    U32  totcbytes;
    U32  opts = 0;
    char pgmpath[MAX_PATH];
    char *pgm;

#define O_ALL           0xC0
#define O_FILES         0X80
#define O_LABELS        0X40
#define O_DATASETS      0X20
#define O_TAPEMAP_OUTPUT  0x10
#define O_TAPEMAP_INVOKED 0x08

    /* Figure out processing based on the program name */
    hostpath(pgmpath, argv[0], sizeof(pgmpath));
    pgm = strrchr(pgmpath, '/');
    if (pgm)
    {
        pgm++;
    }
    else
    {
        pgm = argv[0];
    }
    strtok (pgm, ".");
    if  ((strcmp(pgm, "tapemap") == 0) || (strcmp(pgm, "TAPEMAP") == 0))
    {
        opts = O_TAPEMAP_OUTPUT+O_TAPEMAP_INVOKED;
    }

    INITIALIZE_UTILITY(pgm);

    /* Display the program identification message */
    display_version (stderr, "Hercules HET and AWS tape map program ", FALSE);

    if (! (opts & O_TAPEMAP_INVOKED) )
    {

        opts = O_ALL;

        while( TRUE )
        {
            rc = getopt( argc, argv, "adfhlt" );
            if( rc == -1 )
            {
                break;
            }

            switch( rc )
            {
                case 'a':
                    opts = O_ALL;
                break;

                case 'd':
                    opts = O_DATASETS;
                break;

                case 'f':
                    opts = O_FILES;
                break;

                case 'h':
                    usage( pgm );
                    exit( 1 );
                break;

                case 'l':
                    opts = O_LABELS;
                break;

                case 't':
                    opts = O_TAPEMAP_OUTPUT;
                break;

                default:
                    usage( pgm );
                    exit( 1 );
                break;
            }
        }

    }  // end if (! (opts & O_TAPEMAP_INVOKED) )

    argc -= optind;
    if( argc != 1 )
    {
        usage( pgm );
        exit( 1 );
    }

    if( opts & O_ALL )
    {
        printf( sep );
        printf( "%-20.20s: %s\n", "Filename", argv[ optind ] );
    }

    rc = het_open( &hetb, argv[ optind ], 0 );
    if( rc < 0 )
    {
        printf( "het_open() returned %d\n", rc );
        het_close( &hetb );
        exit( 1 );
    }

    fileno = 0;
    blocks = 0;

    uminsz = 0;
    umaxsz = 0;
    ubytes = 0;
    cminsz = 0;
    cmaxsz = 0;
    cbytes = 0;

    totblocks = 0;
    totubytes = 0;
    totcbytes = 0;

    while( TRUE )
    {
#ifdef EXTERNALGUI
        if( extgui )
        {
            /* Report progress every nnnK */
            off_t curpos = ftell( hetb->fd );
            if( ( curpos & PROGRESS_MASK ) != ( prevpos & PROGRESS_MASK ) )
            {
                prevpos = curpos;
                fprintf( stderr, "IPOS=%" I64_FMT "d\n", (U64)curpos );
            }
        }
#endif /*EXTERNALGUI*/

        rc = het_read( hetb, buf );
        if( rc == HETE_EOT )
        {
            if( opts & O_TAPEMAP_OUTPUT )
            {
                printf ("End of tape.\n");
            }
            break;
        }

        if( rc == HETE_TAPEMARK )
        {
            fileno += 1;

            if( opts & O_TAPEMAP_OUTPUT )
            {
                printf ("File %u: Blocks=%u, block size min=%u, max=%u\n",
                        fileno, blocks, uminsz, umaxsz      );
            }

            if( opts & O_FILES )
            {
                printf( sep );
                printf( "%-20.20s: %d\n", "File #", fileno );
                printf( "%-20.20s: %d\n", "Blocks", blocks );
                printf( "%-20.20s: %d\n", "Min Blocksize", uminsz );
                printf( "%-20.20s: %d\n", "Max Blocksize", umaxsz );
                printf( "%-20.20s: %d\n", "Uncompressed bytes", ubytes );
                printf( "%-20.20s: %d\n", "Min Blocksize-Comp", cminsz );
                printf( "%-20.20s: %d\n", "Max Blocksize-Comp", cmaxsz );
                printf( "%-20.20s: %d\n", "Compressed bytes", cbytes );
            }

            totblocks += blocks;
            totubytes += ubytes;
            totcbytes += cbytes;

            blocks = 0;

            uminsz = 0;
            umaxsz = 0;
            ubytes = 0;
            cminsz = 0;
            cmaxsz = 0;
            cbytes = 0;

            continue;
        }

        if( rc < 0 )
        {
            printf( "het_read() returned %d\n", rc );
            break;
        }

        blocks += 1;
        ubytes += hetb->ublksize;
        cbytes += hetb->cblksize;

        if( uminsz == 0 || hetb->ublksize < uminsz ) uminsz = hetb->ublksize;
        if( hetb->ublksize > umaxsz ) umaxsz = hetb->ublksize;
        if( cminsz == 0 || hetb->cblksize < cminsz ) cminsz = hetb->cblksize;
        if( hetb->cblksize > cmaxsz ) cmaxsz = hetb->cblksize;

        if( opts & O_LABELS )
        {
            printlabel( buf, rc );
        }

        if( opts & O_TAPEMAP_OUTPUT )
        {
            printlabeltapemap( buf, rc );
        }

        if( opts & O_DATASETS )
        {
            printdataset( buf, rc, fileno );
        }
    }

    if( opts & O_FILES )
    {
        printf( sep );
        printf( "%-20.20s:\n", "Summary" );
        printf( "%-20.20s: %d\n", "Files", fileno );
        printf( "%-20.20s: %d\n", "Blocks", totblocks );
        printf( "%-20.20s: %d\n", "Uncompressed bytes", totubytes );
        printf( "%-20.20s: %d\n", "Compressed bytes", totcbytes );
        printf( "%-20.20s: %d\n", "Reduction", totubytes - totcbytes );
    }

    het_close( &hetb );

    return 0;
}
예제 #8
0
/*
 * evaluate one initialiser
 *
 * if dump is TRUE, dump literal immediately
 * save character string in litq to dump later
 * this is used for structures and arrays of pointers to char, so that the
 * struct or array is built immediately and the char strings are dumped later
 */
void init(int size, int ident, int *dim, int more, int dump, int is_struct)
{
    int32_t value;
    int     sz;			/* number of chars in queue */
/*
 * djm 14/3/99 We have to rewrite this bit (ugh!) so that we store
 * our literal in a temporary queue, then if needed, we then dump
 * it out..
 */

    if ((sz = qstr(&value)) != -1 ) {
        sz++;
#if 0
        if (ident == VARIABLE || (size != 1 && more != CCHAR))
            error(E_ASSIGN);
#endif
#ifdef INIT_TEST
        outstr("ident=");
        outdec(ident);
        outstr("size=");
        outdec(size);
        outstr("more=");
        outdec(more);
        outstr("dim=");
        outdec(*dim);
        outstr("sz=");
        outdec(sz);
        nl();
#endif
        if (ident == ARRAY && more == 0) {
/*
 * Dump the literals where they are, padding out as appropriate
 */
            if (*dim != -1 && sz > *dim) {
/*
 * Ooops, initialised to long a string!
 */
                warning(W_INIT2LONG);
                sz = *dim;
                gltptr = sz;
                *(glbq + sz - 1) = '\0';	/* Terminate string */
            }
            dumplits(((size == 1) ? 0 : size), NO, gltptr, glblab, glbq);
            *dim -= sz;
            gltptr = 0;
            dumpzero(size, *dim);
            return;
        } else {
/*
 * Store the literals in the queue!
 */
            storeq(sz, glbq, &value);
            gltptr = 0;
            defword();
            printlabel(litlab);
            outbyte('+');
            outdec(value);
            nl();
            --*dim;
            return;
        }
    }
/*
 * djm, catch label names in structures (for (*name)() initialisation
 */
    else {
        char sname[NAMEMAX + 1];
        SYMBOL *ptr;
        if (symname(sname)  && strcmp(sname,"sizeof") ) {	/* We have got something.. */
            if ((ptr = findglb(sname))) {
                /* Actually found sommat..very good! */
                if (ident == POINTER || (ident == ARRAY && more)) {
                    defword();
                    outname(ptr->name, dopref(ptr));
                    nl();
                    --*dim;
                } else if (ptr->type == ENUM) {
                    value = ptr->size;
                    goto constdecl;
                } else {
                    error(E_DDECL);
                }
            } else
                error(E_UNSYMB, sname);
        } else if (rcmatch('}')) {
#if 0
            dumpzero(size,*dim);
#endif
        } else if (constexpr(&value, 1)) {
        constdecl:
            if (ident == POINTER) {
                /* 24/1/03 dom - We want to be able to assign values to
                   pointers or they're a bit useless..
                */
#if 0
                /* the only constant which can be assigned to a pointer is 0 */
                if (value != 0)
                    warning(W_ASSPTR);
#endif
                size = 2;
                dump = YES;
            }
            if (dump) {
                /* struct member or array of pointer to char */
                if (size == 4) {
/* there appears to be a bug in z80asm regarding defl */
                    defbyte();
                    outdec((value % 65536UL) % 256);
                    outbyte(',');
                    outdec((value % 65536UL) / 256);
                    outbyte(',');
                    outdec((value / 65536UL) % 256);
                    outbyte(',');
                    outdec((value / 65536UL) / 256);
                } else {
                    if (size == 1)
                        defbyte();
                    else
                        defword();
                    outdec(value);
                }
                nl();
                /* Dump out a train of zeros as appropriate */
                if (ident == ARRAY && more == 0) {		 
                    dumpzero(size,(*dim)-1);
                }

            } else
                stowlit(value, size);
            --*dim;
        }
    }
}