// Copyright (C) 1999-2003 Core Technologies. // // This file is part of tpasm. // // tpasm is free software; you can redistribute it and/or modify // it under the terms of the tpasm LICENSE AGREEMENT. // // tpasm is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // tpasm LICENSE AGREEMENT for more details. // // You should have received a copy of the tpasm LICENSE AGREEMENT // along with tpasm; see the file "LICENSE.TXT". #include "include.h" static int CompareLabels(const void *i,const void *j) // compare the labels given by the entries i and j // This is called by qsort { LABEL_RECORD **recordA, **recordB; recordA=(LABEL_RECORD **)i; recordB=(LABEL_RECORD **)j; return(strcmp(&(*recordA)->theSymbol->name[0],&(*recordB)->theSymbol->name[0])); } static bool OutputSymbols(FILE *theFile) // Dump symbol information in sunplus style { int i; LABEL_RECORD *theLabel; int numLabels; LABEL_RECORD **sortArray; unsigned int moduleLength; numLabels=NumLabels(); if((sortArray=(LABEL_RECORD **)NewPtr(sizeof(LABEL_RECORD *)*numLabels))) { theLabel=labelsHead; for(i=0;inext; } qsort(sortArray,numLabels,sizeof(LABEL_RECORD *),CompareLabels); // sort the array (not that it matters here) fputc(0xfe,theFile); // start of Microtek symbol file (0xfe) fputc(strlen(sourceFileName),theFile); // length of source file name fprintf(theFile,"%s",sourceFileName); // source file name moduleLength=2; // figure out how big the module is (+2 for some reason) for(i=0;iresolved) { moduleLength += 1 + strlen(theLabel->theSymbol->name) + 2; // add length of this entry } } fputc((moduleLength>>16)&0xff,theFile); fputc((moduleLength>>8)&0xff,theFile); fputc(moduleLength&0xff,theFile); // three-byte module length (big-endian byte order) fputc(0x02,theFile); // size of symbol address (2 = 16 bit) for(i=0;iresolved) { fputc(strlen(theLabel->theSymbol->name),theFile); // length of the symbol name fprintf(theFile,"%s",theLabel->theSymbol->name); // symbol name itself fputc(theLabel->theValue&0xff,theFile); // symbol value (2 bytes) fputc((theLabel->theValue>>8)&0xff,theFile); } } fputc(0xfe,theFile); fputc(0xff,theFile); // end of Microtek symbol file (0xff) DisposePtr(sortArray); } return(true); } // output file types handled here (the constuctors for these variables link them to the global // list of output file types that the assembler knows how to handle) static OUTPUTFILE_TYPE outputFileType("sunplus","Sunplus format symbol listing",true,OutputSymbols);