Пример #1
0
/* for reusable object types */
int slapi_int_clear_object_extensions(int objecttype, void *object)
{
	int i;
	struct slapi_extension_block *eblock;
	void *parent;

	if ( get_extension_block( objecttype, object, &eblock, &parent ) != 0 ) {
		return -1;
	}

	if ( eblock->extensions == NULL ) {
		/* no extensions */
		return 0;
	}

	for ( i = registered_extensions.extensions[objecttype].count - 1; i >= 0; --i ) {
		free_extension( eblock, objecttype, object, parent, i );
	}

	for ( i = 0; i < registered_extensions.extensions[objecttype].count; i++ ) {
		new_extension( eblock, objecttype, object, parent, i );
	}

	return 0;
}
Пример #2
0
int slapi_int_create_object_extensions(int objecttype, void *object)
{
	int i;
	struct slapi_extension_block *eblock;
	void **peblock;
	void *parent;

	switch ((slapi_extension_t) objecttype) {
	case SLAPI_X_EXT_CONNECTION:
		peblock = &(((Connection *)object)->c_extensions);
		parent = NULL;
		break;	
	case SLAPI_X_EXT_OPERATION:
		peblock = &(((Operation *)object)->o_hdr->oh_extensions);
		parent = ((Operation *)object)->o_conn;
		break;
	default:
		return -1;
		break;
	}

	*peblock = NULL;

	ldap_pvt_thread_mutex_lock( &registered_extensions.mutex );
	if ( registered_extensions.extensions[objecttype].active == 0 ) {
		/*
		 * once we've created some extensions, no new extensions can
		 * be registered.
		 */
		registered_extensions.extensions[objecttype].active = 1;
	}
	ldap_pvt_thread_mutex_unlock( &registered_extensions.mutex );

	eblock = (struct slapi_extension_block *)slapi_ch_calloc( 1, sizeof(*eblock) );

	if ( registered_extensions.extensions[objecttype].count ) {
		eblock->extensions = (void **)slapi_ch_calloc( registered_extensions.extensions[objecttype].count, sizeof(void *) );
		for ( i = 0; i < registered_extensions.extensions[objecttype].count; i++ ) {
			new_extension( eblock, objecttype, object, parent, i );
		}
	} else {
		eblock->extensions = NULL;
	}

	*peblock = eblock;

	return 0;
}
Пример #3
0
/* 
  parse_args() 
  Parse the command line arguments
*/
void
parse_args(int argc, char **argv, twolame_options * encopts )
{
    int ch=0;

    // process args
    struct option longopts[] = {
    
        // Input
        { "raw-input",      no_argument,            NULL,       'r' },
        { "byte-swap",      no_argument,            NULL,       'x' },
        { "samplerate",     required_argument,      NULL,       's' },
        { "channels",       required_argument,      NULL,       'N' },
        { "swap-channels",  no_argument,            NULL,       'g' },
        { "scale",          required_argument,      NULL,       1000 },
        { "scale-l",        required_argument,      NULL,       1001 },
        { "scale-r",        required_argument,      NULL,       1002 },
        
        // Output
        { "mode",           required_argument,      NULL,       'm' },
        { "downmix",        no_argument,            NULL,       'a' },
        { "bitrate",        required_argument,      NULL,       'b' },
        { "psyc-mode",      required_argument,      NULL,       'P' },
        { "vbr",            no_argument,  		    NULL,       'v' },
        { "vbr-level",      required_argument,      NULL,       'V' },
        { "max-bitrate",    required_argument,      NULL,       'B' },
        { "ath",            required_argument,      NULL,       'l' },
        { "quick",          required_argument,      NULL,       'q' },
        { "single-frame",   no_argument,            NULL,       'S' },
        
        // Misc
        { "copyright",      no_argument,            NULL,       'c' },
        { "non-original",   no_argument,            NULL,       'o' },
        { "original",   	no_argument,            NULL,       1003 },
        { "protect", 		no_argument,            NULL,       'p' },
        { "padding",        no_argument,            NULL,       'd' },
        { "reserve-bits",   required_argument,      NULL,       'R' },
        { "deemphasis",     required_argument,      NULL,       'e' },
        { "energy",         no_argument,            NULL,       'E' },
        
        // Verbosity
        { "talkativity",    required_argument,      NULL,       't' },
        { "quiet",          no_argument,            NULL,       1004 },
        { "brief",          no_argument,            NULL,       1005 },
        { "verbose",        no_argument,            NULL,       1006 },
        { "help",           no_argument,            NULL,       'h' },
        
        { NULL,             0,                      NULL,       0 }
    };

    
    // Create a short options structure from the long one
    char* shortopts = build_shortopt_string( longopts );
    //printf("shortopts: %s\n", shortopts);
    
    
    while( (ch = getopt_long( argc, argv,  shortopts, longopts, NULL )) != -1) 
    {
        switch(ch) {
        
        // Input
            case 'r':
                sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16;
                break;

            case 'x':
                byteswap = TRUE;
                break;

            case 's':
                twolame_set_out_samplerate(encopts, atoi(optarg));
                sfinfo.samplerate = atoi(optarg);
                break;

            case 'N':
                sfinfo.channels = atoi(optarg);
                break;
                
            case 'g':
                channelswap = TRUE;
                break;
                
            case 1000:  // --scale
                twolame_set_scale( encopts, atof(optarg) );
                break;

            case 1001:  // --scale-l
                twolame_set_scale_left( encopts, atof(optarg) );
                break;

            case 1002:  // --scale-r
                twolame_set_scale_right( encopts, atof(optarg) );
                break;



        // Output
            case 'm':
                if (*optarg == 's') {
                    twolame_set_mode(encopts, TWOLAME_STEREO);
                } else if (*optarg == 'd') {
                    twolame_set_mode(encopts, TWOLAME_DUAL_CHANNEL);
                } else if (*optarg == 'j') {
                    twolame_set_mode(encopts, TWOLAME_JOINT_STEREO);
                } else if (*optarg == 'm') {
                    twolame_set_mode(encopts, TWOLAME_MONO);
                } else if (*optarg == 'a') {
                    twolame_set_mode(encopts, TWOLAME_AUTO_MODE);
                } else {
                    fprintf(stderr, "Error: mode must be a/s/d/j/m not '%s'\n\n", optarg);
                    usage_long();
                }
                break;

            case 'a':	// downmix
                twolame_set_mode(encopts, TWOLAME_MONO);
                 break;
                
            case 'b':
                twolame_set_bitrate(encopts, atoi(optarg));
                break;

            case 'P':
                twolame_set_psymodel(encopts, atoi(optarg));
                break;
                
            case 'v':
                twolame_set_VBR(encopts, TRUE);
                break;

            case 'V':
                twolame_set_VBR(encopts, TRUE);
                twolame_set_VBR_level(encopts, atof(optarg));
                break;

            case 'B':
                twolame_set_VBR_max_bitrate_kbps(encopts, atoi(optarg));
                break;

            case 'l':
                twolame_set_ATH_level(encopts, atof(optarg));
                break;
                
            case 'q':
                twolame_set_quick_mode(encopts, TRUE);
                twolame_set_quick_count(encopts, atoi(optarg));
                break;

            case 'S':
                single_frame_mode = TRUE;
                break;
                
                
    // Miscellaneous            
            case 'c':
                twolame_set_copyright(encopts, TRUE);
                break;
            case 'o':	// --non-original
                twolame_set_original(encopts, FALSE);
                break;
            case 1003:  // --original
                twolame_set_original(encopts, TRUE);
                break;
            case 'p':
                twolame_set_error_protection(encopts, TRUE);
                break;
            case 'd':
                twolame_set_padding(encopts, TWOLAME_PAD_ALL);
                break;
            case 'R':
                twolame_set_num_ancillary_bits(encopts, atoi(optarg));
                break;
            case 'e':
                if (*optarg == 'n')
                    twolame_set_emphasis(encopts, TWOLAME_EMPHASIS_N);
                else if (*optarg == '5')
                    twolame_set_emphasis(encopts, TWOLAME_EMPHASIS_5);
                else if (*optarg == 'c')
                    twolame_set_emphasis(encopts, TWOLAME_EMPHASIS_C);
                else {
                    fprintf(stderr, "Error: emphasis must be n/5/c not '%s'\n\n", optarg);
                    usage_long();
                }
                break;
            case 'E':
                twolame_set_energy_levels(encopts, TRUE);
                break;
        

    // Verbosity
            case 't':
                twolame_set_verbosity(encopts, atoi(optarg));
                break;

            case 1004:  // --quiet
                twolame_set_verbosity(encopts, 0);
                break;
                
            case 1005: // --brief
                twolame_set_verbosity(encopts, 1);
                break;
                
            case 1006: // --verbose
                twolame_set_verbosity(encopts, 4);
                break;
                
            case 'h':
                usage_long();
            break;
        
            default:
                usage_short();
            break;
        }
    }
    

    // Look for the input and output file names
    argc -= optind;
    argv += optind;
    while( argc ) {
        if (inputfilename[0] == '\0')
            strncpy(inputfilename, *argv, MAX_NAME_SIZE);
        else if (outputfilename[0] == '\0')
            strncpy(outputfilename, *argv, MAX_NAME_SIZE);
        else {
            fprintf(stderr, "excess argument: %s\n", *argv);
            usage_short();
        }
    
        argv++;
        argc--;
    }
    
    
    // Check that we now have input and output file names ok
    if ( inputfilename[0] == '\0') {
        fprintf(stderr, "Missing input filename.\n");
        usage_short();
    }
    if ( outputfilename[0] == '\0' && strcmp(inputfilename, "-")!=0 ) {
        // Create output filename from the inputfilename 
        // and change the suffix
        new_extension( inputfilename, OUTPUT_SUFFIX, outputfilename );
    }
    if ( outputfilename[0] == '\0') {
        fprintf(stderr, "Missing output filename.\n");
        usage_short();
    }
        
}
Пример #4
0
int main(int argc, char *argv[])
{
  FILE *out;
  FILE *dbg = NULL;
  //FILE *list = NULL;
  int i;
  int format = FORMAT_HEX;
  int create_list = 0;
  char *infile = NULL, *outfile = NULL;
  struct _asm_context asm_context;
  int error_flag=0;

  puts(credits);

  if (argc < 2)
  {
    printf("Usage: naken_asm [options] <infile>\n"
           "   -o <outfile>\n"
           "   -h             [output hex file]\n"
#ifndef DISABLE_ELF
           "   -e             [output elf file]\n"
#endif
           "   -b             [output binary file]\n"
           "   -s             [output srec file]\n"
           "   -l             [create .lst listing file]\n"
           "   -I             [add to include path]\n"
           "   -q             Quiet (only output errors)\n"
           "\n");
    exit(0);
  }

  memset(&asm_context, 0, sizeof(asm_context));

  for (i = 1; i < argc; i++)
  {
    if (strcmp(argv[i], "-o") == 0)
    {
      outfile = argv[++i];
    }
      else
    if (strcmp(argv[i], "-h") == 0)
    {
      format = FORMAT_HEX;
    }
      else
    if (strcmp(argv[i], "-b") == 0)
    {
      format = FORMAT_BIN;
    }
      else
    if (strcmp(argv[i], "-s") == 0)
    {
      format = FORMAT_SREC;
    }
#ifndef DISABLE_ELF
      else
    if (strcmp(argv[i], "-e") == 0)
    {
      format = FORMAT_ELF;
    }
#endif
#if 0
      else
    if (strcmp(argv[i], "-d") == 0)
    {
      asm_context.debug_file = 1;
    }
#endif
      else
    if (strcmp(argv[i], "-l") == 0)
    {
      create_list = 1;
    }
      else
    if (strncmp(argv[i], "-I", 2) == 0)
    {
      char *s = argv[i];
      if (s[2] == 0)
      {
        if (add_to_include_path(&asm_context, argv[++i]) != 0)
        {
          printf("Internal Error:  Too many include paths\n");
          exit(1);
        }
      }
        else
      {
        if (add_to_include_path(&asm_context, s+2) != 0)
        {
          printf("Internal Error:  Too many include paths\n");
          exit(1);
        }
      }
    }
      else
    if (strcmp(argv[i], "-q") == 0)
    {
      asm_context.quiet_output = 1;
    }
      else
    {
      if (infile != NULL)
      {
        printf("Error: Cannot use %s as input file since %s was already chosen.\n", argv[1], infile);
        exit(1);
      }
      infile = argv[i];
    }
  }

  if (infile == NULL)
  {
    printf("No input file specified.\n");
    exit(1);
  }

  if (outfile == NULL)
  {
    switch(format)
    {
      case FORMAT_HEX: outfile = "out.hex"; break;
      case FORMAT_BIN: outfile = "out.bin"; break;
      case FORMAT_ELF: outfile = "out.elf"; break;
      case FORMAT_SREC: outfile = "out.srec"; break;
      default: outfile = "out.err"; break;
    }
  }

#ifdef INCLUDE_PATH
  if (add_to_include_path(&asm_context, INCLUDE_PATH) != 0)
  {
    printf("Internal Error:  Too many include paths\n");
    exit(1);
  }
#endif

  if (tokens_open_file(&asm_context, infile) != 0)
  {
    printf("Couldn't open %s for reading.\n", infile);
    exit(1);
  }

  out = fopen(outfile, "wb");
  if (out == NULL)
  {
    printf("Couldn't open %s for writing.\n", outfile);
    exit(1);
  }

  if (asm_context.quiet_output == 0)
  {
    printf(" Input file: %s\n", infile);
    printf("Output file: %s\n", outfile);
  }

#if 0
  if (asm_context.debug_file == 1)
  {
    char filename[1024];
    strcpy(filename, outfile);

    new_extension(filename, "ndbg", 1024);

    dbg = fopen(filename,"wb");
    if (dbg == NULL)
    {
      printf("Couldn't open %s for writing.\n",filename);
      exit(1);
    }

    printf(" Debug file: %s\n",filename);

    fprintf(dbg, "%s\n", infile);
  }
#endif

  if (create_list == 1)
  {
    char filename[1024];
    strcpy(filename, outfile);

    new_extension(filename, "lst", 1024);

    asm_context.list = fopen(filename, "wb");
    if (asm_context.list == NULL)
    {
      printf("Couldn't open %s for writing.\n", filename);
      exit(1);
    }

    if (asm_context.quiet_output == 0)
    {
      printf("  List file: %s\n", filename);
    }
  }

  if (asm_context.quiet_output == 0)
  {
    printf("\nPass 1...\n");
  }

  symbols_init(&asm_context.symbols);
  macros_init(&asm_context.macros);

  asm_context.pass = 1;
  assemble_init(&asm_context);
  error_flag = assemble(&asm_context);
  if (error_flag != 0)
  {
    printf("** Errors... bailing out\n");
    unlink(outfile);
  }
    else
  {
    symbols_lock(&asm_context.symbols);
    // macros_lock(&asm_context.defines_heap);

    if (asm_context.quiet_output == 0) { printf("Pass 2...\n"); }
    asm_context.pass = 2;
    assemble_init(&asm_context);
    error_flag = assemble(&asm_context);

    if (format == FORMAT_HEX)
    {
      write_hex(&asm_context.memory, out);
    }
      else
    if (format == FORMAT_BIN)
    {
      write_bin(&asm_context.memory, out);
    }
      else
    if (format == FORMAT_SREC)
    {
      write_srec(&asm_context.memory, out);
    }
#ifndef DISABLE_ELF
      else
    if (format == FORMAT_ELF)
    {
      write_elf(&asm_context.memory, out, &asm_context.symbols, asm_context.filename, asm_context.cpu_type);
    }
#endif

    if (dbg != NULL)
    {
      for (i = 0; i < asm_context.memory.size; i++)
      {
        int debug_line = memory_debug_line(&asm_context, i);
        putc(debug_line >> 8, dbg);
        putc(debug_line & 0xff, dbg);
      }

      fclose(dbg);
    }

  }

  fclose(out);

  if (create_list == 1)
  {
    int ch = 0;
    char str[17];
    int ptr = 0;
    fprintf(asm_context.list, "data sections:");
    for (i = asm_context.memory.low_address; i <= asm_context.memory.high_address; i++)
    {
      if (memory_debug_line(&asm_context, i) == -2)
      {
        if (ch == 0)
        {
          if (ptr != 0)
          {
            output_hex_text(asm_context.list, str, ptr);
          }
          fprintf(asm_context.list, "\n%04x:", i/asm_context.bytes_per_address);
          ptr = 0;
        }

        unsigned char data = memory_read(&asm_context, i);
        fprintf(asm_context.list, " %02x", data);

        if (data >= ' ' && data <= 120)
        { str[ptr++] = data; }
          else
        { str[ptr++] = '.'; }

        ch++;
        if (ch == 16) { ch = 0; }
      }
        else
      {
        output_hex_text(asm_context.list, str, ptr);
        ch = 0;
        ptr = 0;
      }
    }
    output_hex_text(asm_context.list, str, ptr);
    fprintf(asm_context.list, "\n\n");

    assemble_print_info(&asm_context, asm_context.list);
  }

  assemble_print_info(&asm_context, stdout);

  //symbols_free(&asm_context.symbols);
  //macros_free(&asm_context.macros);

  if (asm_context.list != NULL) { fclose(asm_context.list); }
  fclose(asm_context.in);

  if (error_flag != 0)
  {
    printf("*** Failed ***\n\n");
    unlink(outfile);
  }

  //memory_free(&asm_context.memory);
  assemble_free(&asm_context);

  if (error_flag != 0) { return -1; }

  return 0;
}
Пример #5
0
int main(int argc, char *argv[])
{
FILE *out;
FILE *dbg=NULL;
FILE *list=NULL;
int i;
int format=FORMAT_HEX;
int create_list=0;
char *infile=NULL,*outfile=NULL;
struct _asm_context asm_context;
int error_flag=0;

  printf("\nnaken430asm - by Michael Kohn\n");
  printf("    Web: http://www.mikekohn.net/\n");
  printf("  Email: [email protected]\n\n");
  printf("Version: "VERSION"\n\n");

  if (argc<2)
  {
    printf("Usage: naken430asm [options] <infile>\n");
    printf("   -o <outfile>\n");
    printf("   -h             [output hex file]\n");
#ifndef DISABLE_ELF
    printf("   -e             [output elf file]\n");
#endif
    printf("   -b             [output binary file]\n");
    printf("   -d             [create .ndbg debug file]\n");
    printf("   -l             [create .lst listing file]\n");
    printf("   -I             [add to include path]\n");
    printf("\n");
    exit(0);
  }

  memset(&asm_context, 0, sizeof(asm_context));

  for (i=1; i<argc; i++)
  {
    if (strcmp(argv[i], "-o")==0)
    {
      outfile=argv[++i];
    }
      else
    if (strcmp(argv[i], "-h")==0)
    {
      format=FORMAT_HEX;
    }
      else
    if (strcmp(argv[i], "-b")==0)
    {
      format=FORMAT_BIN;
    }
#ifndef DISABLE_ELF
      else
    if (strcmp(argv[i], "-e")==0)
    {
      format=FORMAT_ELF;
    }
#endif
      else
    if (strcmp(argv[i], "-d")==0)
    {
      asm_context.debug_file=1;
    }
      else
    if (strcmp(argv[i], "-l")==0)
    {
      create_list=1;
    }
      else
    if (strncmp(argv[i], "-I", 2)==0)
    {
      char *s=argv[i];
      if (s[2]==0)
      {
        if (add_to_include_path(&asm_context, argv[++i])!=0)
        {
          printf("Internal Error:  Too many include paths\n");
          exit(1);
        }
      }
        else
      {
        if (add_to_include_path(&asm_context, s+2)!=0)
        {
          printf("Internal Error:  Too many include paths\n");
          exit(1);
        }
      }
    }
      else
    {
      infile=argv[i];
    }
  }

  if (infile==NULL)
  {
    printf("No input file specified.\n");
    exit(1);
  }

  if (outfile==NULL)
  {
    if (format==FORMAT_HEX)
    {
      outfile="out.hex";
    }
      else
    if (format==FORMAT_BIN)
    {
      outfile="out.bin";
    }
#ifndef DISABLE_ELF
      else
    if (format==FORMAT_ELF)
    {
      outfile="out.elf";
    }
#endif
  }

#ifdef INCLUDE_PATH
  if (add_to_include_path(&asm_context, INCLUDE_PATH)!=0)
  {
    printf("Internal Error:  Too many include paths\n");
    exit(1);
  }
#endif

  asm_context.in=fopen(infile,"rb");
  if (asm_context.in==NULL)
  {
    printf("Couldn't open %s for reading.\n",infile);
    exit(1);
  }

  asm_context.filename=infile;

  out=fopen(outfile,"wb");
  if (out==NULL)
  {
    printf("Couldn't open %s for writing.\n",outfile);
    exit(1);
  }

  printf(" Input file: %s\n",infile);
  printf("Output file: %s\n",outfile);

  if (asm_context.debug_file==1)
  {
    char filename[1024];
    strcpy(filename,outfile);

    new_extension(filename, "ndbg", 1024);

    dbg=fopen(filename,"wb");
    if (dbg==NULL)
    {
      printf("Couldn't open %s for writing.\n",filename);
      exit(1);
    }

    printf(" Debug file: %s\n",filename);

    fprintf(dbg,"%s\n",infile);
  }

  if (create_list==1)
  {
    char filename[1024];
    strcpy(filename,outfile);

    new_extension(filename, "lst", 1024);

    list=fopen(filename,"wb");
    if (list==NULL)
    {
      printf("Couldn't open %s for writing.\n",filename);
      exit(1);
    }

    printf("  List file: %s\n",filename);
  }

  printf("\n");

  address_heap_init(&asm_context.address_heap);
  defines_heap_init(&asm_context.defines_heap);

  printf("Pass 1...\n");
  asm_context.pass=1;
  assemble_init(&asm_context);
  error_flag=assemble(&asm_context);
  if (error_flag!=0)
  {
    printf("** Errors... bailing out\n");
    fclose(out);
    unlink(outfile);
    create_list=0;
  }
    else
  {
    address_heap_lock(&asm_context.address_heap);
    // defines_heap_lock(&asm_context.defines_heap);

    printf("Pass 2...\n");
    asm_context.pass=2;
    assemble_init(&asm_context);
    error_flag=assemble(&asm_context);

    if (format==FORMAT_HEX)
    {
      write_hex(&asm_context, out);
    }
      else
    if (format==FORMAT_BIN)
    {
      write_bin(&asm_context, out);
    }
#ifndef DISABLE_ELF
      else
    if (format==FORMAT_ELF)
    {
      write_elf(&asm_context, out);
    }
#endif

    if (dbg!=NULL)
    {
      for (i=0; i<65536; i++)
      {
        putc(asm_context.debug_line[i]>>8,dbg);
        putc(asm_context.debug_line[i]&0xff,dbg);
      }

      fclose(dbg);
    }

    fclose(out);
  }

#if 0
  for (i=asm_context.low_address; i<=asm_context.high_address; i++)
  {
    printf("%04x: %d\n", i, asm_context.debug_line[i]);
  }
#endif

  if (create_list==1)
  {
    int *lines=NULL;
    int line=1;
    int ch;
    fseek(asm_context.in, 0, SEEK_SET);

    /* Build a map of lines to offset in source file (really more
       of a map of lines to offset in debug_line which is an offset
       to input file */

    if (asm_context.line<65535)
    {
      lines=(int *)malloc((asm_context.line+1)*sizeof(int));
      memset(lines, -1, (asm_context.line+1)*sizeof(int));

      for (i=asm_context.high_address; i>=asm_context.low_address; i--)
      {
        if ((int)asm_context.debug_line[i]<0) continue;
        lines[asm_context.debug_line[i]]=i;
      }
    }

    /* Read input file again line by line and write back out to lst file.
       If line matches something in the index, then output the line and
       disassembled code */

    while(1)
    {
      ch=getc(asm_context.in);
      if (ch!=EOF) { putc(ch, list); }

      if (ch=='\n' || ch==EOF)
      {
        int i;
        int start;

        if (lines==NULL)
        { start=asm_context.low_address; }
          else
        {
          if (lines[line]>=0)
          {
            start=lines[line];
          }
            else
          {
            start=asm_context.high_address+1;
          }
        }

        //int loop_count=0;
        for (i=start; i<=asm_context.high_address; i++)
        {
          int num;

          if (asm_context.debug_line[i]==line)
          {
            fprintf(list, "\n");
            while(asm_context.debug_line[i]==line)
            {
              int cycles;
              char instruction[128];
              int count=msp430_disasm(asm_context.bin, i, instruction, &cycles);
              num=asm_context.bin[i]|(asm_context.bin[i+1]<<8);
              fprintf(list, "0x%04x: 0x%04x %-40s cycles: %d\n", i, num, instruction, cycles);
              count--;
              while (count>0)
              {
                i=i+2;
                num=asm_context.bin[i]|(asm_context.bin[i+1]<<8);
                fprintf(list, "0x%04x: 0x%04x\n", i, num);
                count--;
              }

              i=i+2;
            }

            fprintf(list, "\n");
            break;
          }
          //loop_count++;
        }

        //printf("loop_count=%d\n", loop_count);
        if (ch==EOF) { break; }
        line++;
      }
    }

    if (lines!=NULL) free(lines);

    assemble_print_info(&asm_context, list);

    fclose(list);
  }

  assemble_print_info(&asm_context, stdout);

  address_heap_free(&asm_context.address_heap);
  defines_heap_free(&asm_context.defines_heap);

  fclose(asm_context.in);

  if (error_flag!=0)
  {
    printf("*** Failed ***\n\n");
    unlink(outfile);
  }

  return 0;
}