Esempio n. 1
0
//-------------------------------------------------------------------------
// JMS: Assign a symbol a new value. Returns 0 on success. This is used for
// backward compatability to avoid changing lots of existing code. Sets the
// new debugging parameters to their default values.
int
EditSymbol(const char *Name, Address_t *Value)
{
  return EditSymbolNew(Name, Value, SYMBOL_REGISTER, "", 0);
}
Esempio n. 2
0
int
ParseEQUALS (ParseInput_t *InRecord, ParseOutput_t *OutRecord)
{
    Address_t LabelValue = { 1 };
    int Value, i;
    OutRecord->ProgramCounter = InRecord->ProgramCounter;
    OutRecord->Bank = InRecord->Bank;
    OutRecord->LabelValue.Invalid = 1;
    OutRecord->NumWords = 0;
    OutRecord->Equals = 1;
    // As a special case, it sometimes happens that the label is empty.
    // I *believe* that this is done only for documentation purposes, and
    // has no other effect.
    if (*InRecord->Label == 0)
    {
        OutRecord->LabelValueValid = 0;
        return (0);
    }
    // As another special case, there is sometimes no operand.  *That* means
    // that the current program counter is the value.
    if (*InRecord->Operand == 0 && *InRecord->Mod1 == 0)
    {
        // JMS: Even though it is assigned the program counter as the current
        // value, it is still just a constant
        //EditSymbol (InRecord->Label, &InRecord->ProgramCounter);
        EditSymbolNew (InRecord->Label, &InRecord->ProgramCounter, SYMBOL_CONSTANT,
                       CurrentFilename, CurrentLineInFile);
        OutRecord->LabelValue = InRecord->ProgramCounter;
        return (0);
    }
    // Next, it may be that the operand is simply a number.  If so, then
    // we're talking about a simple constant.
    i = GetOctOrDec (InRecord->Operand, &Value);
    if (i)
    {
        // The operand is NOT a number.  Presumably, it's a symbol.
        i = FetchSymbolPlusOffset (&InRecord->ProgramCounter,
                                   InRecord->Operand,
                                   InRecord->Mod1, &LabelValue);
        if (i)
        {
            sprintf(OutRecord->ErrorMessage, "Symbol \"%s\" undefined or offset bad", InRecord->Operand);
            OutRecord->Fatal = 1;
            return (0);
        }
#if 0
        if (!i)
        {
            LabelValue = CONSTANT (0);
            LabelValue.Value = Value;
            EditSymbol (InRecord->Label, &LabelValue);
        }
#endif
        if (OpcodeOffset)
        {
            if (LabelValue.Constant)
            {
                LabelValue.Value += OpcodeOffset;
            }
            else
                IncPc (&LabelValue, OpcodeOffset, &LabelValue);
        }

        // JMS: This is just a constant to add to the symbol table
        //EditSymbol (InRecord->Label, &LabelValue);
        EditSymbolNew (InRecord->Label, &LabelValue, SYMBOL_CONSTANT,
                       CurrentFilename, CurrentLineInFile);
        OutRecord->LabelValueValid = 1;
    }
    else
    {
        ParseOutput_t TempOutput;
        if (*InRecord->Operand == '+' || *InRecord->Operand == '-')
        {
            IncPc (&InRecord->ProgramCounter, Value, &LabelValue);
        }
        else
        {
            if (Value < -16383 || Value > 32767)
            {
                strcpy (OutRecord->ErrorMessage, "Value out of range---truncating");
                OutRecord->Warning = 1;
                if (Value < -16383)
                    Value = -16383;
                else if (Value > 32767)
                    Value = 32767;
            }
            LabelValue.Invalid = 0;
            LabelValue.Constant = 1;
            LabelValue.Value = Value;
            PseudoToSegmented (Value, &TempOutput);
        }

        // JMS: This is just a constant to add to the symbol table
        //EditSymbol (InRecord->Label, &LabelValue /*&TempOutput.ProgramCounter*/);
        EditSymbolNew (InRecord->Label, &LabelValue, SYMBOL_CONSTANT,
                       CurrentFilename, CurrentLineInFile);
    }
    OutRecord->LabelValue = LabelValue;
    return (0);
}
Esempio n. 3
0
int ParseEQUALS(ParseInput_t *InRecord, ParseOutput_t *OutRecord)
{
  Address_t LabelValue = { 1 };
  int Value, i;

  OutRecord->ProgramCounter = InRecord->ProgramCounter;
  OutRecord->EBank = InRecord->EBank;
  OutRecord->SBank = InRecord->SBank;
  OutRecord->LabelValue.Invalid = 1;
  OutRecord->NumWords = 0;
  OutRecord->Equals = 1;

  // As a special case, it sometimes happens that the label is empty.
  // I *believe* that this is done only for documentation purposes, and
  // has no other effect.
  if (*InRecord->Label == 0)
    {
      OutRecord->LabelValueValid = 0;
      return (0);
    }

  // As another special case, there is sometimes no operand.  *That* means
  // that the current program counter is the value.  
  if (*InRecord->Operand == 0 && *InRecord->Mod1 == 0)
    {
      EditSymbolNew(InRecord->Label, &InRecord->ProgramCounter, SYMBOL_CONSTANT,
                    CurrentFilename, CurrentLineInFile);
      OutRecord->LabelValue = InRecord->ProgramCounter;
      return (0);
    }

  i = GetOctOrDec(InRecord->Operand, &Value);
  if (i)
    {
      // The operand is NOT a number.  Presumably, it's a symbol.
      if (!strcmp(InRecord->Mod1, "+") || !strcmp(InRecord->Mod1, "-"))
      {
          // Handle the case of whitespace between +/- and the actual offset. 
          if (*InRecord->Mod2 != 0)
          {
              char mod[1 + MAX_LINE_LENGTH];

              strcpy(mod, InRecord->Mod1);
              strcat(mod, InRecord->Mod2);
              i = FetchSymbolPlusOffset(&InRecord->ProgramCounter, 
                                        InRecord->Operand, 
                                        mod, 
                                        &LabelValue);
          }
          else
          {
              sprintf(OutRecord->ErrorMessage, "Syntax error, invalid offset specified");
              OutRecord->Fatal = 1;
              return(0);
          }
      }
      else
      {
          i = FetchSymbolPlusOffset(&InRecord->ProgramCounter, 
                                    InRecord->Operand, 
                                    InRecord->Mod1, 
                                    &LabelValue);
      }

      if (i)
      {
          sprintf(OutRecord->ErrorMessage, "Symbol \"%s\" undefined or offset bad", InRecord->Operand);
          OutRecord->Fatal = 1;
          return(0);
      }

      if (OpcodeOffset)
        {
          if (LabelValue.Constant)
            {
              LabelValue.Value += OpcodeOffset;
            }
          else
            IncPc(&LabelValue, OpcodeOffset, &LabelValue);
        }

      EditSymbolNew(InRecord->Label, &LabelValue, SYMBOL_CONSTANT, CurrentFilename, CurrentLineInFile);
      OutRecord->LabelValueValid = 1;
    }
  else
    {
      // Next, it may be that the operand is simply a number.  If so, then
      // we're talking about a simple constant.  

      ParseOutput_t TempOutput;

      if (*InRecord->Operand == '+' || *InRecord->Operand == '-')
        {
          IncPc(&InRecord->ProgramCounter, Value, &LabelValue);
        }
      else
        {
          if (Value < -16383 || Value > 32767)
            {
              strcpy(OutRecord->ErrorMessage, "Value out of range---truncating");
              OutRecord->Warning = 1;
              if (Value < -16383)
                Value = -16383;
              else if (Value > 32767)
                Value = 32767;  
            }

          LabelValue.Invalid = 0;
          LabelValue.Constant = 1;
          LabelValue.Value = Value;

          PseudoToSegmented(Value, &TempOutput);

          if (!TempOutput.ProgramCounter.Invalid)
            {
              LabelValue = TempOutput.ProgramCounter;
              if (!strcmp(InRecord->Operator, "ERASE"))
                {
                  // Special case. This is to handle "ERASE start - end" constructs, 
                  // which should not be tagged as constants.
                  LabelValue.Constant = 0;
                }
              else
                {
                  // Otherwise mark it as a constant as well.
                  LabelValue.Constant = 1;
                }
            }
        }

      EditSymbolNew(InRecord->Label, &LabelValue, SYMBOL_CONSTANT, CurrentFilename, CurrentLineInFile);
    }

  OutRecord->LabelValue = LabelValue;

  return (0);  
}