Beispiel #1
0
        public byte[] Add(byte[] a, byte[] b, out bool overflow)
        {
            uint64_t _a = new uint64_t(a);
            uint64_t _b = new uint64_t(b);

            uint64_t result = _a + _b;

            byte[] r = result.ToBinary();
            byte[] values;

            overflow = false;

            if (a.Length >= b.Length)
            {
                values = new byte[a.Length];
            }
            else
            {
                values = new byte[b.Length];
            }

            Array.Copy(r, values, values.Length);
            if (values.Length < 8)
            {
                overflow = (r[values.Length + 1] > 0);
            }
            else
            {
                try
                {
                    UInt64 temp = checked (_a + _b);
                }
                catch (OverflowException)
                {
                    overflow = true;
                    flags    = flags | ALUFlags.Overflow;
                }
            }

            flags = ALUFlags.None;
            if (overflow)
            {
                flags = flags | ALUFlags.Overflow;
            }
            return(values);
        }
Beispiel #2
0
 public Opcode(uint64_t value, uint16_t address)
     : this()
 {
     this.Address = address;
     FromBinary(value.ToBinary());
 }