private void SetRegister(PICRegisterStorage preg, uint ival) { if (preg.HasAttachedRegs) { preg.AttachedRegs !.ForEach((sreg) => SetRegister(sreg, (uint)((ival >> (int)sreg.BitAddress) & sreg.BitMask))); return; } ValidRegs.Add(preg); ValidRegsValues[preg] = new PICRegisterContent(preg.Traits) { ActualValue = ival }; }
/// <summary> /// Loads the PIC registers, as found in the PIC definition, into the registers symbol table. /// </summary> /// <param name="registersSymTable">The registers symbol table interface.</param> /// <param name="pic">the PIC definition.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="registersSymTable"/> is /// null.</exception> protected void LoadRegistersInTable(IPICRegisterSymTable registersSymTable, IPICDescriptor pic) { if (pic == null) { throw new ArgumentNullException(nameof(pic)); } symTable = registersSymTable ?? throw new ArgumentNullException(nameof(registersSymTable)); regNumber = 0; foreach (var sfr in pic.SFRs) { var reg = AddSFRRegister(sfr, regNumber); regNumber++; symTable.AddRegister(reg); } foreach (var jsfr in pic.JoinedRegisters) { var subregs = new List <PICRegisterStorage>(); bitRegAddr = 0; foreach (var sfr in jsfr.ChildSFRs) { if (!PICRegisters.TryGetRegister(sfr.Name, out var creg)) { creg = AddSFRRegister(sfr, regNumber++); } creg.BitAddress = bitRegAddr; subregs.Add(creg); bitRegAddr += 8; } if (subregs.Count > 0) { var sfr = new PICRegisterStorage(jsfr, regNumber, subregs); if (symTable.AddRegister(sfr)) { regNumber++; } } } }
private PICRegisterStorage AddSFRRegister(ISFRRegister sfr, int regnum) { var reg = new PICRegisterStorage(sfr, regNumber) { BitAddress = 0UL }; foreach (var sfld in sfr.BitFields) { if ((sfld.Name != sfr.Name) && (sfld.BitWidth != sfr.BitWidth)) { var fld = new PICRegisterBitFieldStorage(reg, sfld); if (!reg.BitFields.ContainsKey(fld.BitFieldSortKey)) { if (symTable.AddRegisterBitField(fld)) { reg.BitFields.Add(fld.BitFieldSortKey, fld); continue; } } } } return(reg); }
/// <summary> /// Instantiates a new PIC register's bit-field. /// </summary> /// <param name="reg">The PIC register containing the bit field.</param> /// <param name="sfrfielddef">The bit field definition per PIC XML definition.</param> public PICRegisterBitFieldStorage(PICRegisterStorage reg, ISFRBitField sfrfielddef) : base(reg, (uint)(sfrfielddef.BitMask << sfrfielddef.BitPos), sfrfielddef.Name, CreateBitFieldType(sfrfielddef.BitWidth)) { SFRField = sfrfielddef; BitFieldSortKey = new PICRegisterBitFieldSortKey(sfrfielddef.BitPos, (byte)sfrfielddef.BitWidth); }
public PICOperandRegister(PICRegisterStorage reg) : base(reg.DataType) { Register = reg; }