home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / CROSSASM / 68ASMSIM.ZIP / asmsrc / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-14  |  4.0 KB  |  76 lines

  1. /***********************************************************************
  2.  *
  3.  *        ERROR.C
  4.  *        Error message printer for 68000 Assembler
  5.  *
  6.  *    Function: printError()
  7.  *        Prints an appropriate message to the specified output
  8.  *        file according to the error code supplied. If the
  9.  *        errorCode is OK, no message is printed; otherwise an
  10.  *        WARNING or ERROR message is produced. The line number
  11.  *        will be included in the message unless lineNum = -1.
  12.  *
  13.  *     Usage:    printError(outFile, errorCode, lineNum)
  14.  *        FILE *outFile;
  15.  *        int errorCode, lineNum;
  16.  *
  17.  *      Author: Paul McKee
  18.  *        ECE492    North Carolina State University
  19.  *
  20.  *        Date:    12/12/86
  21.  *
  22.  ************************************************************************/
  23.  
  24.  
  25. #include <stdio.h>
  26. #include "asm.h"
  27.  
  28. int    printError(outFile, errorCode, lineNum)
  29. FILE *outFile;
  30. int errorCode, lineNum;
  31. {
  32. char numBuf[20];
  33.  
  34.     if (lineNum >= 0)
  35.         sprintf(numBuf, " in line %d", lineNum);
  36.     else
  37.         numBuf[0] = '\0';
  38.  
  39.     switch (errorCode) {
  40.         case SYNTAX         : fprintf(outFile, "ERROR%s: Invalid syntax\n", numBuf); break;
  41.         case UNDEFINED         : fprintf(outFile, "ERROR%s: Undefined symbol\n", numBuf); break;
  42.         case DIV_BY_ZERO     : fprintf(outFile, "ERROR%s: Division by zero attempted\n", numBuf); break;
  43.         case NUMBER_TOO_BIG  : fprintf(outFile, "WARNING%s: Numeric constant exceeds 32 bits\n", numBuf); break;
  44.         case ASCII_TOO_BIG   : fprintf(outFile, "WARNING%s: ASCII constant exceeds 4 characters\n", numBuf); break;
  45.         case INV_OPCODE      : fprintf(outFile, "ERROR%s: Invalid opcode\n", numBuf); break;
  46.         case INV_SIZE_CODE   : fprintf(outFile, "WARNING%s: Invalid size code\n", numBuf); break;
  47.         case INV_ADDR_MODE   : fprintf(outFile, "ERROR%s: Invalid addressing mode\n", numBuf); break;
  48.         case MULTIPLE_DEFS   : fprintf(outFile, "ERROR%s: Symbol multiply defined\n", numBuf); break;
  49.         case PHASE_ERROR     : fprintf(outFile, "ERROR%s: Symbol value differs between first and second pass\n", numBuf); break;
  50.         case INV_QUICK_CONST : fprintf(outFile, "ERROR%s: MOVEQ instruction constant out of range\n", numBuf); break;
  51.         case INV_VECTOR_NUM  : fprintf(outFile, "ERROR%s: Invalid vector number\n", numBuf); break;
  52.         case INV_BRANCH_DISP : fprintf(outFile, "ERROR%s: Branch instruction displacement is out of range or invalid\n", numBuf); break;
  53.         case LABEL_REQUIRED  : fprintf(outFile, "ERROR%s: Label required with this directive\n", numBuf); break;
  54.         case INV_DISP           : fprintf(outFile, "ERROR%s: Displacement out of range\n", numBuf); break;
  55.         case INV_ABS_ADDRESS : fprintf(outFile, "ERROR%s: Absolute address exceeds 16 bits\n", numBuf); break;
  56.         case INV_8_BIT_DATA  : fprintf(outFile, "ERROR%s: Immediate data exceeds 8 bits\n", numBuf); break;
  57.         case INV_16_BIT_DATA : fprintf(outFile, "ERROR%s: Immediate data exceeds 16 bits\n", numBuf); break;
  58.         case INCOMPLETE      : fprintf(outFile, "WARNING%s: Evaluation of expression could not be completed\n", numBuf); break;
  59.         case NOT_REG_LIST    : fprintf(outFile, "ERROR%s: The symbol specified is not a register list symbol\n", numBuf); break;
  60.         case REG_LIST_SPEC   : fprintf(outFile, "ERROR%s: Register list symbol used in an expression\n", numBuf); break;
  61.         case REG_LIST_UNDEF  : fprintf(outFile, "ERROR%s: Register list symbol not previously defined\n", numBuf); break;
  62.         case INV_SHIFT_COUNT : fprintf(outFile, "ERROR%s: Invalid constant shift count\n", numBuf); break;
  63.         case INV_FORWARD_REF : fprintf(outFile, "ERROR%s: Forward references not allowed with this directive\n", numBuf); break;
  64.         case INV_LENGTH      : fprintf(outFile, "ERROR%s: Block length is less that zero\n", numBuf); break;
  65.         case ODD_ADDRESS     : fprintf(outFile, "ERROR%s: Origin value is odd (Location counter set to next highest address)\n", numBuf); break;
  66.         default : if (errorCode > ERROR)
  67.                 fprintf(outFile, "ERROR%s: No message defined\n", numBuf);
  68.               else if (errorCode > WARNING)
  69.                 fprintf(outFile, "WARNING%s: No message defined\n", numBuf);
  70.         }
  71.  
  72.     return NORMAL;
  73.  
  74. }
  75.  
  76.