private void RewriteJump(bool link, bool absolute)
        {
            Identifier regIdx;

            if (link)
            {
                Debug.Assert(instrCur.Operands.Length == 2, "Expected a link register");
                m.Assign(Reg(0), instrCur.Address);
                regIdx = Reg(1);
            }
            else
            {
                regIdx = Reg(0);
            }
            Expression dst;

            if (absolute)
            {
                dst = regIdx;
            }
            else
            {
                dst = m.IAdd(instrCur.Address, regIdx);
            }
            if (link)
            {
                m.Call(dst, 0, instrCur.InstructionClass);
            }
            else
            {
                m.Goto(dst, instrCur.InstructionClass);
            }
        }
Beispiel #2
0
 private void Brk()
 {
     emitter.Call(
         new ProcedureConstant(
             new Pointer(new CodeType(), 2),
             host.EnsurePseudoProcedure("__brk", VoidType.Instance, 0)),
         2);
 }
Beispiel #3
0
 private void RewriteCall(Z80Instruction instr)
 {
     if (instr.Operands[0] is ConditionOperand cOp)
     {
         m.BranchInMiddleOfInstruction(
             GenerateTestExpression(cOp, true),
             instr.Address + instr.Length,
             InstrClass.ConditionalTransfer);
         m.Call(((AddressOperand)instr.Operands[1]).Address, 2);
     }
     else
     {
         m.Call(((AddressOperand)instr.Operands[0]).Address, 2);
     }
 }
Beispiel #4
0
        private void Jsr()
        {
            rtlc = RtlClass.Transfer | RtlClass.Call;
            var mem = (MemoryAccess)RewriteOperand(instrCur.Operand);

            m.Call(mem.EffectiveAddress, 2);
        }
Beispiel #5
0
        private void RewriteB(bool link)
        {
            Address addr = ((AddressOperand)instr.Dst).Address;

            if (link)
            {
                if (instr.Cond == Condition.al)
                {
                    emitter.Call(addr, 0);
                }
                else
                {
                    emitter.If(TestCond(instr.Cond), new RtlCall(addr, 0, RtlClass.Transfer));
                }
            }
            else
            {
                if (instr.Cond == Condition.al)
                {
                    emitter.Goto(addr);
                }
                else
                {
                    emitter.Branch(TestCond(instr.Cond), addr, RtlClass.ConditionalTransfer);
                }
            }
        }
Beispiel #6
0
        private void RewriteB(bool link)
        {
            Address addr = Address.Ptr32((uint)Dst.ImmediateValue.Value);

            if (link)
            {
                ric.Class = RtlClass.Transfer;
                if (instr.ArchitectureDetail.CodeCondition == ArmCodeCondition.AL)
                {
                    emitter.Call(addr, 0);
                }
                else
                {
                    emitter.If(TestCond(instr.ArchitectureDetail.CodeCondition), new RtlCall(addr, 0, RtlClass.Transfer));
                }
            }
            else
            {
                if (instr.ArchitectureDetail.CodeCondition == ArmCodeCondition.AL)
                {
                    ric.Class = RtlClass.Transfer;
                    emitter.Goto(addr);
                }
                else
                {
                    ric.Class = RtlClass.ConditionalTransfer;
                    emitter.Branch(TestCond(instr.ArchitectureDetail.CodeCondition), addr, RtlClass.ConditionalTransfer);
                }
            }
        }
Beispiel #7
0
 private void RewriteCall(Z80Instruction instr)
 {
     rtlc = RtlClass.Transfer | RtlClass.Call;
     if (instr.Op1 is ConditionOperand cOp)
     {
         m.BranchInMiddleOfInstruction(
             GenerateTestExpression(cOp, true),
             instr.Address + instr.Length,
             RtlClass.ConditionalTransfer);
         m.Call(((AddressOperand)instr.Op2).Address, 2);
     }
     else
     {
         m.Call(((AddressOperand)instr.Op1).Address, 2);
     }
 }
Beispiel #8
0
 private void RewriteCall()
 {
     iclass = InstrClass.Transfer | InstrClass.Call;
     var dst = OpSrc(instr.Operands[0]);
     dst.DataType = PrimitiveType.Ptr16;
     m.Call(dst, 2);
 }
Beispiel #9
0
        private void RewriteCall()
        {
            rtlc = RtlClass.Transfer | RtlClass.Call;
            var dst = OpSrc(instr.Operand1);

            dst.DataType = PrimitiveType.Ptr16;
            m.Call(dst, 2);
        }
Beispiel #10
0
        private void RewriteCall()
        {
            iclass = InstrClass.Transfer | InstrClass.Call;
            var dst = Operand(instr.Operands[0]);
            var ea  = ((MemoryAccess)dst).EffectiveAddress;

            m.Call(ea, 2);
        }
Beispiel #11
0
        private void RewriteCall(Z80Instruction instr)
        {
            var cOp = instr.Op1 as ConditionOperand;

            if (cOp != null)
            {
                emitter.BranchInMiddleOfInstruction(
                    GenerateTestExpression(cOp, true),
                    instr.Address + instr.Length,
                    RtlClass.ConditionalTransfer);
                emitter.Call(((ImmediateOperand)instr.Op2).Value, 2);
            }
            else
            {
                emitter.Call(((ImmediateOperand)instr.Op1).Value, 2);
            }
        }
Beispiel #12
0
        private void RewriteCall()
        {
            rtlc = RtlClass.Transfer | RtlClass.Call;
            var dst = Operand(instr.op1);
            var ea  = ((MemoryAccess)dst).EffectiveAddress;

            m.Call(ea, 2);
        }
Beispiel #13
0
 private void RewriteCall(HexagonInstruction instr)
 {
     if (instr.ConditionPredicate != null)
     {
         var pred = RewritePredicateExpression(instr.ConditionPredicate, !instr.ConditionInverted);
         m.BranchInMiddleOfInstruction(pred, instr.Address + 4, InstrClass.ConditionalTransfer);
     }
     m.Call(OperandSrc(instr.Operands[0]), 0);
 }
Beispiel #14
0
        private void RewriteGosub()
        {
            int lineNumber = 0;

            if (!EatSpaces() ||
                !GetInteger(out lineNumber))
            {
                SyntaxError();
            }
            emitter.Call(Address.Ptr16((ushort)lineNumber), 2);
        }
Beispiel #15
0
        private void RewriteGosub()
        {
            int lineNumber = 0;

            if (!EatSpaces() ||
                !GetInteger(out lineNumber))
            {
                SyntaxError();
            }
            rtlc = RtlClass.Transfer | RtlClass.Call;
            m.Call(Address.Ptr16((ushort)lineNumber), 2);
        }
Beispiel #16
0
        private void RewriteCalla()
        {
            var cc   = ((ConditionalOperand)instr.Operands[0]).CondCode;
            var addr = ((AddressOperand)instr.Operands[1]).Address;

            if (cc == CondCode.cc_UC)
            {
                m.Call(addr, 2);
                return;
            }
            throw new NotImplementedException();
        }
Beispiel #17
0
        private void RewriteB(bool link)
        {
            Expression dst;

            if (Dst.Type == ArmInstructionOperandType.Immediate)
            {
                dst = Address.Ptr32((uint)Dst.ImmediateValue.Value);
            }
            else
            {
                dst = Operand(Dst);
            }
            if (link)
            {
                rtlc = RtlClass.Transfer | RtlClass.Call;
                if (instr.ArchitectureDetail.CodeCondition != ArmCodeCondition.AL)
                {
                    m.BranchInMiddleOfInstruction(
                        TestCond(instr.ArchitectureDetail.CodeCondition).Invert(),
                        Address.Ptr32((uint)(instr.Address + instr.Bytes.Length)),
                        RtlClass.ConditionalTransfer);
                }
                m.Call(dst, 0);
            }
            else
            {
                if (instr.ArchitectureDetail.CodeCondition == ArmCodeCondition.AL)
                {
                    rtlc = RtlClass.Transfer;
                    m.Goto(dst);
                }
                else
                {
                    rtlc = RtlClass.ConditionalTransfer;
                    var addr = dst as Address;
                    if (addr != null)
                    {
                        m.Branch(TestCond(instr.ArchitectureDetail.CodeCondition), addr, RtlClass.ConditionalTransfer);
                    }
                    else
                    {
                        m.BranchInMiddleOfInstruction(
                            TestCond(instr.ArchitectureDetail.CodeCondition).Invert(),
                            Address.Ptr32((uint)(instr.Address + instr.Bytes.Length)),
                            RtlClass.ConditionalTransfer);
                        m.Goto(dst, RtlClass.Transfer);
                    }
                }
            }
        }
Beispiel #18
0
        public void AOS_LookupA6Call()
        {
            Given_Func("#1 512 0x200 Allocate( heap/a1, size/d0)\n");

            When_Create_Platform();
            m.Call(m.IAdd(binder.EnsureRegister(Registers.a6), -512), 4);
            var state = arch.CreateProcessorState();
            var svc   = platform.FindService(rtls.Last(), state);

            Assert.AreEqual("Allocate", svc.Name);
            Assert.AreEqual(2, svc.Signature.Parameters.Length);
            Assert.AreEqual("a1", svc.Signature.Parameters[0].Storage.ToString());
            Assert.AreEqual("d0", svc.Signature.Parameters[1].Storage.ToString());
        }
Beispiel #19
0
        private void RewriteGosub()
        {
            int lineNumber = 0;

            if (!EatSpaces() ||
                !GetInteger(out lineNumber))
            {
                SyntaxError();
            }
            iclass = InstrClass.Transfer | InstrClass.Call;
            var addr = Lines[(ushort)lineNumber].Address;

            m.Call(addr, 2);
        }
Beispiel #20
0
        private void RewriteB(bool link)
        {
            Expression dst;

            if (Dst.Type == ArmInstructionOperandType.Immediate)
            {
                dst = Address.Ptr32((uint)Dst.ImmediateValue.Value);
            }
            else
            {
                dst = Operand(Dst);
            }
            if (link)
            {
                ric.Class = RtlClass.Transfer;
                if (instr.ArchitectureDetail.CodeCondition == ArmCodeCondition.AL)
                {
                    m.Call(dst, 0);
                }
                else
                {
                    m.If(TestCond(instr.ArchitectureDetail.CodeCondition), new RtlCall(dst, 0, RtlClass.Transfer));
                }
            }
            else
            {
                if (instr.ArchitectureDetail.CodeCondition == ArmCodeCondition.AL)
                {
                    ric.Class = RtlClass.Transfer;
                    m.Goto(dst);
                }
                else
                {
                    ric.Class = RtlClass.ConditionalTransfer;
                    var addr = dst as Address;
                    if (addr != null)
                    {
                        m.Branch(TestCond(instr.ArchitectureDetail.CodeCondition), addr, RtlClass.ConditionalTransfer);
                    }
                    else
                    {
                        m.If(TestCond(instr.ArchitectureDetail.CodeCondition), new RtlGoto(dst, RtlClass.ConditionalTransfer));
                    }
                }
            }
        }
Beispiel #21
0
        private void RewriteJsr(H8Instruction instr)
        {
            var target = ((MemoryAccess)OpSrc(instr.Operands[0])).EffectiveAddress;

            m.Call(target, 2);      //$REVIEW: what about 'advanced mode'?
        }
Beispiel #22
0
 private void RewriteCall()
 {
     rtlc = InstrClass.Transfer | InstrClass.Call;
     m.Call(RewriteOp(0), 2);    //$TODO: 3-byte mode in architecture.
 }
Beispiel #23
0
        private void RewriteAcall()
        {
            var acba = binder.EnsureRegister(Registers.acba);

            m.Call(m.Mem32(m.IAdd(acba, RewriteOp(0))), 0);
        }
Beispiel #24
0
        private void RewriteBsr()
        {
            var dst = ((AddressOperand)instr.Operands[0]).Address;

            m.Call(dst, 2);
        }
Beispiel #25
0
 private void RewriteCall()
 {
     iclass = InstrClass.Transfer | InstrClass.Call;
     m.Call(RewriteOp(instr.Operands[0]), 2);
 }
Beispiel #26
0
 public void Call(HExpr dst, int bytesOnStack)
 {
     m.Call(GetExpression(dst), (byte)bytesOnStack);
 }
Beispiel #27
0
 private void RewriteBsr()
 {
     m.Call(((AddressOperand)instr.Operands[0]).Address, 2);
 }
Beispiel #28
0
        private void RewriteCall()
        {
            var target = RewriteSrc(instr.Operands[0]);

            m.Call(target, 4);
        }
Beispiel #29
0
        private void Jsr()
        {
            var mem = (MemoryAccess)RewriteOperand(instrCur.Operands[0]);

            m.Call(mem.EffectiveAddress, 2);
        }
Beispiel #30
0
        private void RewriteBla()
        {
            var dst = Operand(instr.Operands[0]);

            m.Call(dst, 0);
        }