コード例 #1
0
ファイル: AssemblerX86_64.cs プロジェクト: bartwe/plukc
        /// <summary>
        /// Inserts an unconditional jump to the location described by the jump token.
        /// This may be a forward or backward jump, but should be local to the Assembler.
        /// </summary>
        public override void Jump(Compiler.JumpToken token)
        {
            JumpToken t = (JumpToken)token;

            t.SetKind(JumpTokenKind.Relative);
            region.WriteByte(0xe9); // relative offset next instruction
            t.SetJumpSite(region.InsertIntToken());
        }
コード例 #2
0
ファイル: AssemblerX86_64.cs プロジェクト: bartwe/plukc
 /// <summary>
 /// Conditional version of Jump().
 /// Takes the jump if the type part of the accumulator is empty
 /// </summary>
 public override void JumpIfUnassigned(JumpToken token)
 {
     token.SetKind(JumpTokenKind.Relative);
     region.Write(new byte[] {
         0x48, 0x21, 0xd2, // and rdx, rdx
         0x0f, 0x84        // jz
     });
     token.SetJumpSite(region.InsertIntToken());
 }
コード例 #3
0
ファイル: AssemblerX86_64.cs プロジェクト: bartwe/plukc
 /// <summary>
 /// Conditional version of Jump().
 /// Reads a boolean value from the accumulator
 /// </summary>
 public override void JumpIfFalse(JumpToken token)
 {
     token.SetKind(JumpTokenKind.Relative);
     region.Write(new byte[] {
         0x48, 0x21, 0xc0, // and rax, rax
         0x0f, 0x84        // jz
     });
     token.SetJumpSite(region.InsertIntToken());
 }
コード例 #4
0
        public override void JumpIfUnassigned(Compiler.JumpToken token)
        {
            JumpToken t = (JumpToken)token;

            t.SetKind(JumpTokenKind.Relative);
            region.Write(new byte[] {
                0x21, 0xd2, // and edx, edx
                0x0f, 0x84  // jz
            });
            t.SetJumpSite(region.InsertIntToken());
        }
コード例 #5
0
        public override void JumpIfTrue(Compiler.JumpToken token)
        {
            JumpToken t = (JumpToken)token;

            t.SetKind(JumpTokenKind.Relative);
            region.Write(new byte[] {
                0x21, 0xc0, // and eax, eax
                0x0f, 0x85  // jnz
            });
            t.SetJumpSite(region.InsertIntToken());
        }
コード例 #6
0
ファイル: AssemblerX86_64.cs プロジェクト: bartwe/plukc
        public override void JumpIfNotMarked(Compiler.JumpToken token)
        {
            region.Write(new byte[] {
                0x48, 0xF7, 0xC2, 0x01, 0x00, 0x00, 0x00 // test rdx, 1
            });
            JumpToken t = (JumpToken)token;

            t.SetKind(JumpTokenKind.Relative);
            region.Write(new byte[] {
                0x0f, 0x84  // jz
            });
            t.SetJumpSite(region.InsertIntToken());
        }
コード例 #7
0
ファイル: AssemblerX86_64.cs プロジェクト: bartwe/plukc
        /// <summary>
        /// Tests the content of the accumulator for nullness and puts the result as a boolean in the accumulator.
        /// Note: the type part of the boolean is missing.
        /// </summary>
        public override void IsNotNull()
        {
            JumpToken zeroJump = new JumpToken();

            zeroJump.SetKind(JumpTokenKind.Relative);
            region.Write(new byte[] {
                0x48, 0x31, 0xC0, // xor rax, rax
                0x48, 0x21, 0xd2, // and rdx, rdx
                0x0f, 0x84        // jz
            });
            zeroJump.SetJumpSite(region.InsertIntToken());
            region.Write(new byte[] {
                0x48, 0x83, 0xf0, 0x01 // xor rax, 1
            });
            zeroJump.SetDestination(region.CurrentLocation);
        }