示例#1
0
        public void EmitsSpecifiedBytes()
        {
            var instr = new Align(8, 0xAB);
            Assert.AreEqual(0xAB, instr.PaddingByte);
            Assert.AreEqual(8, instr.Boundary);

            Context.Address = 5;
            var emittable = instr.Construct(Context).First() as RawEmittable;
            Assert.AreEqual(new byte[] { 0xAB, 0xAB, 0xAB }, emittable.Content);

            #if OPERAND_SET
            instr.PaddingByte = 0xCD;
            emittable = instr.Construct(Context) as RawEmittable;
            Assert.AreEqual(new byte[] { 0xCD, 0xCD, 0xCD }, emittable.Content);
            #endif
        }
示例#2
0
        public void EmitsNullBytes()
        {
            var instr = new Align(4);
            Assert.AreEqual(0x00, instr.PaddingByte);
            Assert.AreEqual(4, instr.Boundary);

            Context.Address = 1;

            var emittable = instr.Construct(Context).First() as RawEmittable;
            Assert.AreEqual(new byte[]{0x00, 0x00, 0x00}, emittable.Content);

            #if OPERAND_SET
            instr.Boundary = 8;
            emittable = instr.Construct(Context) as RawEmittable;
            Assert.AreEqual(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, emittable.Content);
            #endif
        }
        /// <inheritdoc />
        public override void VisitAlign(Align align)
        {
            int linelength = 0;
            linelength = WriteIndent(indentationlevel);

            string s;
            if (align.PaddingByte != 0x90)
                s = String.Format("align {0}, db {1}", align.Boundary, align.PaddingByte);
            else
                s = String.Format("align {0}", align.Boundary);
            Writer.Write(s);
            linelength += s.Length;

            WriteCommentOf(align, linelength);
        }