Ejemplo n.º 1
0
        protected (FSRIndexedMode indMode, Expression memPtr) GetDataAbsAddress(MachineOperand opernd)
        {
            switch (opernd)
            {
            case PICOperandDataMemoryAddress absmem:
                if (absmem.DataTarget == PICDataAddress.Invalid)
                {
                    throw new InvalidOperationException($"Invalid data absolute address operand.");
                }

                if (PICRegisters.TryGetRegister(absmem.DataTarget, out var sfrReg))
                {
                    if (sfrReg != PICRegisterStorage.None)
                    {
                        var imode = PICRegisters.IndirectOpMode(sfrReg, out PICRegisterStorage fsr);
                        if (imode != FSRIndexedMode.None)
                        {
                            return(imode, binder.EnsureRegister(fsr));
                        }
                        return(imode, binder.EnsureRegister(sfrReg));
                    }
                }
                return(FSRIndexedMode.None, DataMem8(PICDataAddress.Ptr(absmem.DataTarget)));

            default:
                throw new InvalidOperationException($"Invalid data absolute address operand.");
            }
        }
Ejemplo n.º 2
0
 public PICRegisterUniqueAddress(string nmmrID)
 {
     if (string.IsNullOrEmpty(nmmrID))
     {
         throw new ArgumentNullException(nameof(nmmrID));
     }
     Addr   = null;
     NMMRID = nmmrID;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Construct the PIC register's traits based on the given <see cref="IJoinedRegister"/> descriptor
        /// and its children PIC registers' traits.
        /// </summary>
        /// <remarks>
        /// The construction of the joined register's traits assumes that the enumeration of attached registers/traits
        /// is enuerable in increasing registers' order (LSB, MSB, little-endian).
        /// </remarks>
        /// <param name="joinedSFR">The joined PIC register descriptor.</param>
        /// <param name="attachedRegsTraits">The joined registers' traits.</param>
        /// <exception cref="ArgumentNullException">Thrown when one or more required arguments are null.</exception>
        public PICRegisterTraits(IJoinedRegister joinedSFR, IEnumerable <PICRegisterTraits> attachedRegsTraits)
        {
            if (joinedSFR is null)
            {
                throw new ArgumentNullException(nameof(joinedSFR));
            }
            if (attachedRegsTraits is null)
            {
                throw new ArgumentNullException(nameof(attachedRegsTraits));
            }
            Name       = joinedSFR.Name;
            Desc       = joinedSFR.Description;
            RegAddress = new PICRegisterSizedUniqueAddress(PICDataAddress.Ptr(joinedSFR.Addr), (int)joinedSFR.BitWidth);
            var rev = attachedRegsTraits.Reverse();

            Access     = AdjustString(String.Join("", rev.Select(e => e.Access)), '-');
            MCLR       = AdjustString(String.Join("", rev.Select(e => e.MCLR)), 'u');
            POR        = AdjustString(String.Join("", rev.Select(e => e.POR)), '0');
            Impl       = rev.Aggregate(0UL, (total, reg) => total = (total << 8) + reg.Impl);
            IsVolatile = attachedRegsTraits.Any(e => e.IsVolatile == true);
            IsIndirect = attachedRegsTraits.Any(e => e.IsIndirect == true);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Construct the PIC register's traits based on the given <see cref="SFRDef"/> descriptor.
 /// </summary>
 /// <param name="sfr">The PIC register descriptor.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="sfr"/> is null.</exception>
 public PICRegisterTraits(ISFRRegister sfr)
 {
     if (sfr is null)
     {
         throw new ArgumentNullException(nameof(sfr));
     }
     if (string.IsNullOrEmpty(sfr.NMMRID))
     {
         RegAddress = new PICRegisterSizedUniqueAddress(PICDataAddress.Ptr(sfr.Addr), (int)sfr.BitWidth);
     }
     else
     {
         RegAddress = new PICRegisterSizedUniqueAddress(sfr.NMMRID, (int)sfr.BitWidth);
     }
     Name       = sfr.Name;
     Desc       = sfr.Description;
     Impl       = sfr.ImplMask;
     Access     = AdjustString(sfr.AccessBits, '-');
     MCLR       = AdjustString(sfr.MCLR, 'u');
     POR        = AdjustString(sfr.POR, '0');
     IsVolatile = sfr.IsVolatile;
     IsIndirect = sfr.IsIndirect;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Instantiates a new bit-field address with given holding register address and bit-field position.
 /// </summary>
 /// <param name="regAddr">The register PIC data memory address.</param>
 /// <param name="bitPos">The bit position of the bit-field.</param>
 public BitFieldPosAndAddrKey(PICDataAddress regAddr, ulong bitPos)
 {
     RegAddr = regAddr;
     BitPos  = bitPos;
 }
Ejemplo n.º 6
0
 public PICRegisterSizedUniqueAddress(ushort addr, int bitWidth = 0) : this(PICDataAddress.Ptr(addr), bitWidth)
 {
 }
Ejemplo n.º 7
0
 public PICRegisterSizedUniqueAddress(PICDataAddress addr, int bitWidth = 0) : base(addr)
 {
     BitWidth = bitWidth;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Instantiates a Absolute Data Address operand. Used by MOVFF instructions.
 /// </summary>
 /// <param name="absAddr">The data byte address.</param>
 public PICOperandDataMemoryAddress(PICDataAddress absAddr) : base((PrimitiveType)absAddr.DataType)
 {
     DataTarget = absAddr;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Instantiates a Absolute Data Address operand. Used by MOVFF instructions.
 /// </summary>
 /// <param name="absAddr">The data byte address.</param>
 public PICOperandDataMemoryAddress(uint absAddr) : base(PrimitiveType.Ptr32)
 {
     DataTarget = PICDataAddress.Ptr(absAddr);
 }
Ejemplo n.º 10
0
 public PICRegisterUniqueAddress(ushort addr) : this(PICDataAddress.Ptr(addr))
 {
 }
Ejemplo n.º 11
0
 public PICRegisterUniqueAddress(PICDataAddress addr)
 {
     Addr   = addr ?? throw new ArgumentNullException(nameof(addr));
     NMMRID = string.Empty;
 }