Example #1
0
void GeneratLst()
{
unsigned int j;
unsigned long startip;
unsigned int offs2,line;
unsigned char flag;
	hout=CreateOutPut("lst","wt");
	if(lstend[pdbg-1]==0)lstend[pdbg-1]=endinptr;
	startip=(comfile!=file_w32&&comfile!=file_bin?0:ImageBase);
	fprintf(hout,"SPHINX/SHEKER C-- One Pass Disassembler. Version %d.%02d%s %s\n",ver1,ver2,betta,__DATE__);
	for(j=0;j<pdbg;j++){
//printf("line %d loc %X\n",dbgnum[j],dbgloc[j]);
		if((int)lstflag[j]!=-1){
			flag=lstflag[j];
			offs2=lstend[j];
			outptr=dbgloc[j];
			instruction_offset=outptr+startip;
			seg_size=(unsigned char)(16+16*(flag&1));
			line=dbgnum[j];
			if(offs2!=outptr){
/*
				if(line!=0)printf("%s %u:",(startfileinfo+dbgmod[j])->filename,line);
				if(lststring[j]!=NULL)printf(" %s\n",lststring[j]);
				else if(line!=0)printf("\n");
	*/
				fprintf(hout,"\n");
				if(line!=0)fprintf(hout,"%s %u:",(startfileinfo+dbgmod[j])->filename,line);
				if(lststring[j]!=NULL)fprintf(hout," %s\n",lststring[j]);
				else if(line!=0)fprintf(hout,"\n");
  			while(outptr<offs2){
					if(flag&0x1e)undata(instruction_offset,offs2-dbgloc[j],(flag>>1)&15);
	  		  else unassemble(instruction_offset);
				}
			}
Example #2
0
int main(int argc, char* argv)
{
	unsigned long address = (unsigned long)main;
	long i;
	long instr_len;
	for (i = 0; i < 20; i++)
	{
		instr_len = unassemble(address);
		if (!instr_len)
			break;
		address += instr_len;
		printf("%s\n", gDisassemblyOutputBuf);
	}

	return 0;
}
Example #3
0
void main(int argc, char *argv[])
{
  word16 instr_len;
  word16 offset;
  char infilename[80];
  char c;

  *infilename = 0;
  while (--argc) {
    argv++;
    if (**argv=='?') {
hlp:  fprintf(stderr,
      "2ASM  Version 1.01  (C) Copyright 1992, Robin Hilliard\n"
      "Converts binary files to 80*86 assembly\n"
      "Usage:\n"
      "\t2asm <file> [-e] [-x] [-s] [-d]\n"
      "Switches:\n"
      "\t-e :\tDisassemble (unoverridden) emulated 80*87 instructions\n"
      "\t-x :\tOutput numbers in pure hex (default is reassemblable)\n"
      "\t-s :\tDon't specify operand size, even where necessary\n"
      "\t-d :\tDon't specify distance short/near/far jmps and calls"
      );
      exit(1);
    }
    if (isoption(**argv)) {
      while (isoption(**argv)) {
nextflag:
        switch (c = *(++*argv)) {
        case 'e':
             do_emul87 = 1;
             break;
        case 'x':
             do_hex = 1;
             break;
        case 's':
             do_size = 0;
             break;
        case 'd':
             do_distance = 0;
             break;
        case '?':
        case 'H':
             goto hlp;
        case '#': /* hidden flag in the Loft's programs! */
             fprintf(stderr,"Last compiled on " __TIME__ ", " __DATE__) ;
             exit(1);
        default:
             fprintf(stderr, "Unknown option: `-%c'", c);
             exit(1);
        }
        ++*argv;
      }
    } else { /* assume that its a file name */
      if (*infilename) {
        fprintf(stderr,"Unknown file argument: \"%s\"", *argv);
        exit(1);
      }
      strcpy(infilename,*argv);
    }
  }
  if ((infile=fopen(infilename,"rb"))==NULL) {
    printf("Unable to open %s",infilename);
    exit(2);
  }
  offset = 0;
  strlwr(infilename);
  if (strstr(infilename, ".com")) /* not perfect, fix later */
    instruction_offset = offset = 0x100;
  if (!setjmp(reached_eof)) {
    do {
      instr_len = unassemble(offset);
      offset += instr_len;
    } while (instr_len); /* whoops, no files > 64k */
  }
}