www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/07/08:47:41

Xref: news2.mv.net comp.os.msdos.djgpp:6800
From: mud AT merlin DOT sedona DOT net (Justin Frankel)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem compiler large header file
Date: 31 Jul 1996 00:09:53 GMT
Organization: Nullsoft
Lines: 59
Message-ID: <4tm88h$gfn@news2.texas.net>
References: <4stkat$e09 AT ari DOT ari DOT net>
NNTP-Posting-Host: merlin.sedona.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Nathaniel Meo (flyboy AT ari DOT net) wrote:
: I have this program that has a large datafile which I put into a
: header file with BIN2H and it created a 700K header file. Problem is
: when I compile the program with it theres the message "Exit with
: SIGSEGV" and some other data. Am I doing something wrong here or does
: DJGPP just have a problem compiling large header files?

I too had that problem awhile back, but I found a workaround...

I made a program called 'bin2s' which converts binary files into as files
which can be assembled. djgpp has no problem assembling very large .s files...

Here is the source:

-- cut here --

#include <stdio.h>

void main(int argc, char *argv[]) {
  FILE *in, *out;
  char *outfilename;
  char *token;
  int length;
  if (argc != 4) { 
    printf("Usage: bin2s file.dat outfile.s \"token_name\"\n");
    return;
  }
  in = fopen(argv[1],"rb");
  out = fopen(argv[2],"wb");
  if (!in || !out) {
    printf("Error: file not found\n");
    return;
  }
  outfilename = argv[2];
  token = argv[3];
  fseek(in,0,SEEK_END);
  length = ftell(in);
  fseek(in,0,SEEK_SET);
  fprintf(out,".file \"%s\"\n",outfilename);
  fprintf(out,".text\n");
  fprintf(out,".global %s\n%s:\n",token,token);
  fprintf(out,".byte ");
  while (length--) {
    static int firsttime;
    static int linecount;
    if (++linecount > 14) {
      linecount = 0;
      fprintf(out,"\n.byte ");
    }
    else if (firsttime) fprintf(out,", ");
    firsttime = 1;
    fprintf(out,"%i",fgetc(in) & 0x000000FF);
  }
  fprintf(out,"\n\n\n");
  fclose(in);
  fclose(out);
}

-- cut here --

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019