コード例 #1
0
        public static IReadable Invoke(string scopeName, IReference storage, IntExpression lhs, IntExpression rhs,
                                       ActionOnThreeLowRegisters registerAction, ActionOnTwoLowRegistersAndAByte byteAction)
        {
            var f = FuncBuilder.Instance;

            using (f.OpenScope(scopeName)) {
                var sm        = new StorageManager(storage);
                var lhsResult = lhs.EvaluateTo(sm.ForLhs(rhs));
                var rhsResult = rhs.EvaluateTo(sm.ForRhs(lhsResult));

                var storageReg   = storage.ProposeRegisterOrScratch0();
                var lhsReg       = lhsResult.ToRegister(f.Scratch0);
                var rhsRegOrByte = rhsResult.ToRegisterOrByte(f.Scratch1);
                if (rhsRegOrByte.IsRegister)
                {
                    registerAction(storageReg, lhsReg, rhsRegOrByte.Register);
                }
                else
                {
                    byteAction(storageReg, lhsReg, rhsRegOrByte.Byte);
                }
                storage.FromRegister(storageReg);
                return(storage);
            }
        }
コード例 #2
0
        protected override IReadable EvaluateToHelper(IReference storage)
        {
            var f=FuncBuilder.Instance;
              using(f.OpenScope(opCode.ToHumanReadable())) {
            var emitter=CodeGenerator.Emitter;

            var sm=new StorageManager(storage);
            var lhsResult=lhs.EvaluateTo(sm.ForLhs(rhs));
            var rhsResult=rhs.EvaluateTo(sm.ForRhs(lhsResult));

            var storageReg=f.Scratch0;
            var lhsReg=lhsResult.ToRegister(f.Scratch0);
            var rhsReg=rhsResult.ToRegister(f.Scratch1);
            emitter.EmitRegisterMoveIfDifferent(storageReg, lhsReg);
            emitter.Emit(opCode, storageReg, rhsReg);
            storage.FromRegister(storageReg);
            return storage;
              }
        }
コード例 #3
0
        protected override IReadable EvaluateToHelper(IReference storage)
        {
            Format4OpCode registerOpCode;
            Format1OpCode immediateOpCode;

            if (shiftLeft)
            {
                registerOpCode  = Format4OpCode.LSL;
                immediateOpCode = Format1OpCode.LSL;
            }
            else
            {
                registerOpCode  = Format4OpCode.ASR;
                immediateOpCode = Format1OpCode.ASR;
            }

            var f       = FuncBuilder.Instance;
            var emitter = CodeGenerator.Emitter;

            using (f.OpenScope(registerOpCode.ToHumanReadable())) {
                var sm        = new StorageManager(storage);
                var lhsResult = lhs.EvaluateTo(sm.ForLhs(rhs));
                var rhsResult = rhs.EvaluateTo(sm.ForRhs(lhsResult));

                var scratch0 = f.Scratch0;
                var scratch1 = f.Scratch1;

                var storageReg     = scratch0;
                var lhsReg         = lhsResult.ToRegister(scratch0);
                var rhsRegOrOffset = rhsResult.ToRegisterOrUint5(scratch1);
                if (rhsRegOrOffset.IsRegister)
                {
                    emitter.EmitRegisterMoveIfDifferent(storageReg, lhsReg);
                    emitter.Emit(registerOpCode, storageReg, rhsRegOrOffset.Register);
                }
                else
                {
                    emitter.Emit(immediateOpCode, storageReg, lhsReg, rhsRegOrOffset.Byte);
                }
                storage.FromRegister(storageReg);
                return(storage);
            }
        }
コード例 #4
0
        protected override IReadable EvaluateToHelper(IReference storage)
        {
            var f = FuncBuilder.Instance;

            using (f.OpenScope(opCode.ToHumanReadable())) {
                var emitter = CodeGenerator.Emitter;

                var sm        = new StorageManager(storage);
                var lhsResult = lhs.EvaluateTo(sm.ForLhs(rhs));
                var rhsResult = rhs.EvaluateTo(sm.ForRhs(lhsResult));

                var storageReg = f.Scratch0;
                var lhsReg     = lhsResult.ToRegister(f.Scratch0);
                var rhsReg     = rhsResult.ToRegister(f.Scratch1);
                emitter.EmitRegisterMoveIfDifferent(storageReg, lhsReg);
                emitter.Emit(opCode, storageReg, rhsReg);
                storage.FromRegister(storageReg);
                return(storage);
            }
        }
コード例 #5
0
        public static IReadable Invoke(string scopeName, IReference storage, IntExpression lhs, IntExpression rhs,
      ActionOnThreeLowRegisters registerAction, ActionOnTwoLowRegistersAndAByte byteAction)
        {
            var f=FuncBuilder.Instance;

              using(f.OpenScope(scopeName)) {
            var sm=new StorageManager(storage);
            var lhsResult=lhs.EvaluateTo(sm.ForLhs(rhs));
            var rhsResult=rhs.EvaluateTo(sm.ForRhs(lhsResult));

            var storageReg=storage.ProposeRegisterOrScratch0();
            var lhsReg=lhsResult.ToRegister(f.Scratch0);
            var rhsRegOrByte=rhsResult.ToRegisterOrByte(f.Scratch1);
            if(rhsRegOrByte.IsRegister) {
              registerAction(storageReg, lhsReg, rhsRegOrByte.Register);
            } else {
              byteAction(storageReg, lhsReg, rhsRegOrByte.Byte);
            }
            storage.FromRegister(storageReg);
            return storage;
              }
        }
コード例 #6
0
ファイル: Shift.cs プロジェクト: meikeric/DotCopter
        protected override IReadable EvaluateToHelper(IReference storage)
        {
            Format4OpCode registerOpCode;
              Format1OpCode immediateOpCode;
              if(shiftLeft) {
            registerOpCode=Format4OpCode.LSL;
            immediateOpCode=Format1OpCode.LSL;
              } else {
            registerOpCode=Format4OpCode.ASR;
            immediateOpCode=Format1OpCode.ASR;
              }

              var f=FuncBuilder.Instance;
              var emitter=CodeGenerator.Emitter;

              using(f.OpenScope(registerOpCode.ToHumanReadable())) {
            var sm=new StorageManager(storage);
            var lhsResult=lhs.EvaluateTo(sm.ForLhs(rhs));
            var rhsResult=rhs.EvaluateTo(sm.ForRhs(lhsResult));

            var scratch0=f.Scratch0;
            var scratch1=f.Scratch1;

            var storageReg=scratch0;
            var lhsReg=lhsResult.ToRegister(scratch0);
            var rhsRegOrOffset=rhsResult.ToRegisterOrUint5(scratch1);
            if(rhsRegOrOffset.IsRegister) {
              emitter.EmitRegisterMoveIfDifferent(storageReg, lhsReg);
              emitter.Emit(registerOpCode, storageReg, rhsRegOrOffset.Register);
            } else {
              emitter.Emit(immediateOpCode, storageReg, lhsReg, rhsRegOrOffset.Byte);
            }
            storage.FromRegister(storageReg);
            return storage;
              }
        }