public void EmitsData()
        {
            var instr = new DeclareData<ushort>(0xABCD, 0xEF01);
            Assert.AreEqual(new ushort[]{0xABCD, 0xEF01}, instr.Data);

            var emittable = instr.Construct(Context).First() as RawEmittable;
            Assert.AreEqual(new byte[]{0xCD, 0xAB, 0x01, 0xEF}, emittable.Content);
        }
        public void EmitsData()
        {
            Func<Context, SimpleExpression> expression = (context) => new SimpleExpression(context.Address);
            var size = DataSize.Bit32;
            var instr = new DeclareData(expression, size);
            Assert.AreEqual(expression, instr.Expression);
            Assert.AreEqual(size, instr.Size);

            Int128 value = 0xDEADBEEF;
            Context.Address = value;

            var emittable = instr.Construct(Context).First() as ExpressionEmittable;
            Assert.AreEqual(value, emittable.Expression.Constant);
            Assert.IsNull(emittable.Expression.Reference);
            Assert.AreEqual(size, emittable.Size);
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public override void VisitDeclareData(DeclareData declaration)
        {
            int linelength = 0;
            linelength = WriteIndent(indentationlevel);

            switch (declaration.Size)
            {
                case DataSize.Bit8:
                    Writer.Write("db ");
                    linelength += 3;
                    break;
                case DataSize.Bit16:
                    Writer.Write("dw ");
                    linelength += 3;
                    break;
                case DataSize.Bit32:
                    Writer.Write("dd ");
                    linelength += 3;
                    break;
                case DataSize.Bit64:
                    Writer.Write("dq ");
                    linelength += 3;
                    break;
                case DataSize.Bit128:
                case DataSize.Bit256:
                default:
                    throw new LanguageException("Declared data's size is not supported.");
            }

            // TODO: Write the expression
            throw new NotImplementedException();
            //linelength += WriteExpression(declaration.Expression);

            WriteCommentOf(declaration, linelength);
        }