/* PutTargetFile: close and store waveform or parm file */ void PutTargetFile(char *s) { if(tgtPK == WAVEFORM) { if(CloseWaveOutput(wv,tgtFF,s)<SUCCESS) HError(1014,"PutTargetFile: Could not save waveform file %s", s); } else { if(SaveBuffer(pb,s,tgtFF)<SUCCESS) HError(1014,"PutTargetFile: Could not save parm file %s", s ); CloseBuffer(pb); } if (trace & T_TOP){ AppendTrace("->"); AppendTrace(s); PrintTrace(); ResetHeap(&tStack); trList.str = NULL; } if(trans != NULL) SaveLabs(s,trans); }
//------------------------------------------------------------------------- // Returns non-zero on unrecoverable error. int ParseEBANKEquals(ParseInput_t *InRecord, ParseOutput_t *OutRecord) { ParseOutput_t Dummy; Address_t Address; int Value, i; OutRecord->Extend = InRecord->Extend; OutRecord->IndexValid = InRecord->IndexValid; OutRecord->EBank = InRecord->EBank; OutRecord->SBank = InRecord->SBank; OutRecord->NumWords = 0; OutRecord->ProgramCounter = InRecord->ProgramCounter; if (*InRecord->Mod1) { strcpy(OutRecord->ErrorMessage, "Extra fields."); OutRecord->Warning = 1; } i = GetOctOrDec(InRecord->Operand, &Value); if (!i) { PseudoToSegmented(Value, &Dummy); Address = Dummy.ProgramCounter; DoIt: if (Address.Invalid) { strcpy(OutRecord->ErrorMessage, "Destination address not resolved."); OutRecord->Fatal = 1; return (0); } if (!Address.Erasable) { strcpy(OutRecord->ErrorMessage, "Destination not erasable."); OutRecord->Fatal = 1; return (0); } if (Address.SReg < 0 || Address.SReg > 01777) { strcpy(OutRecord->ErrorMessage, "Destination address out of range."); OutRecord->Fatal = 1; return (0); } OutRecord->EBank.last = OutRecord->EBank.current; OutRecord->EBank.current = Address; OutRecord->EBank.oneshotPending = 1; OutRecord->LabelValue = Address; OutRecord->LabelValueValid = 1; } else { // The operand is NOT a number. Presumably, it's a symbol. i = FetchSymbolPlusOffset(&InRecord->ProgramCounter, InRecord->Operand, "", &Address); if (!i) { IncPc(&Address, OpcodeOffset, &Address); goto DoIt; } sprintf(OutRecord->ErrorMessage, "Symbol \"%s\" undefined or offset bad", InRecord->Operand); OutRecord->Fatal = 1; } #ifdef YAYUL_TRACE PrintTrace(InRecord, OutRecord); #endif return (0); }
int ParseBANK(ParseInput_t *InRecord, ParseOutput_t *OutRecord) { int Value, i; // Pass EXTEND through. OutRecord->Extend = InRecord->Extend; if (InRecord->IndexValid) { strcpy(OutRecord->ErrorMessage, "Illegally preceded by INDEX."); OutRecord->Fatal = 1; OutRecord->Index = 0; } // The case of no Operand has a special meaning. It means simply to // advance the program counter by however many words have already // been used in the current bank. It would be used after a SETLOC. if (!*InRecord->Operand) { OutRecord->ProgramCounter = InRecord->ProgramCounter; if (OutRecord->ProgramCounter.Invalid) return (0); if (!OutRecord->ProgramCounter.Address || !OutRecord->ProgramCounter.Fixed) { strcpy(OutRecord->ErrorMessage, "Works only for fixed-memory."); OutRecord->Fatal = 1; return (0); } if (OutRecord->ProgramCounter.Banked) { i = OutRecord->ProgramCounter.FB + 010 * OutRecord->ProgramCounter.Super; OutRecord->ProgramCounter.SReg = 02000 + UsedInBank[i]; OutRecord->ProgramCounter.Value = 010000 + i * 02000 + UsedInBank[i]; } else if (OutRecord->ProgramCounter.Value >= 04000 && OutRecord->ProgramCounter.Value <= 05777) { OutRecord->ProgramCounter.SReg = 04000 + UsedInBank[2]; OutRecord->ProgramCounter.Value = OutRecord->ProgramCounter.SReg; } else if (OutRecord->ProgramCounter.Value >= 06000 && OutRecord->ProgramCounter.Value <= 07777) { OutRecord->ProgramCounter.SReg = 06000 + UsedInBank[3]; OutRecord->ProgramCounter.Value = OutRecord->ProgramCounter.SReg; } #ifdef YAYUL_TRACE PrintTrace(InRecord, OutRecord); #endif return (0); } // Here's where we assume that an Operand field exists. i = GetOctOrDec(InRecord->Operand, &Value); if (!i) { if (Value >= 0 && Value <= 043) { OutRecord->ProgramCounter = (const Address_t) { 0 }; OutRecord->ProgramCounter.Address = 1; OutRecord->ProgramCounter.SReg = 02000; OutRecord->ProgramCounter.Fixed = 1; OutRecord->ProgramCounter.Banked = 1; if (Value >= 040) { OutRecord->ProgramCounter.Super = 1; OutRecord->ProgramCounter.FB = Value - 010; } else { OutRecord->ProgramCounter.Super = 0; OutRecord->ProgramCounter.FB = Value; } if (Block1 && Value >= 0 && Value <= 2) { OutRecord->ProgramCounter.Value = 02000 * Value; OutRecord->ProgramCounter.SReg = 02000 * Value; OutRecord->ProgramCounter.Banked = 0; OutRecord->ProgramCounter.Unbanked = 1; } else if (Block1) { OutRecord->ProgramCounter.Value = 06000; OutRecord->ProgramCounter.SReg = 06000; } else if (Value == 2 || Value == 3) OutRecord->ProgramCounter.Value = Value * 02000; else OutRecord->ProgramCounter.Value = 010000 + Value * 02000; OutRecord->ProgramCounter.Value += UsedInBank[Value]; OutRecord->ProgramCounter.SReg += UsedInBank[Value]; } else { strcpy(OutRecord->ErrorMessage, "BANK operand range is 00 to 43."); OutRecord->Fatal = 1; OutRecord->ProgramCounter = (const Address_t) { 0 }; OutRecord->ProgramCounter.Invalid = 1; } } else {