Пример #1
0
      public Operand(Value value)
      {
         if (value!=null)
         {
            if (value.Size == 1)
            {
               _addressingMode = AddressingModes.Immediate;
            }
            else if (value.Size == 2)
            {
               if (value is Pointer)
               {
                  _addressingMode = AddressingModes.Absolute;
               }
               else
               {
                  _addressingMode = AddressingModes.BigImmediate;
               }
            }
            else
            {
               throw new NotSupportedException("operands of size {" + value.Size + "} not supported");
            }

         }
         else
         {
            _addressingMode = AddressingModes.Implied;
         }

         _value = value;
     }
Пример #2
0
      public Operand(Value value, AddressingModes addressingMode)
      {
         if (value == null)
         {
            if (_addressingMode != AddressingModes.Implied)
            {
               throw new InvalidOperationException("invalid address mode for null value operand {" + Enum.GetName(typeof(AddressingModes), addressingMode) + "}");
            }
         }
         else
         {
            //Absolute = 4,
            //Indexed = 8,
            //Indirect = 16,
            //IndirectPreIndexed = 32,
            //IndirectPostIndexed = 64
            if (new[] { 4, 8, 16, 32, 64 }.ToList().Contains((int)addressingMode))
            {
               if (value.Size != 2)
               {
                  throw new InvalidOperationException("invalid address mode {" + Enum.GetName(typeof(AddressingModes), addressingMode) + "}");
               }
            }
         }

         _addressingMode = addressingMode;
         _value = value;

      }
Пример #3
0
  public Operand()
  {
     _addressingMode = AddressingModes.Implied;
     _value = null;
 }