Esempio n. 1
0
        public List <Instruction> PutFromField(FieldSRef src)
        {
            var code = new List <Instruction>();

            if (varref.AsReg() == null)
            {
                code.AddRange(varref.FetchToReg(RegVRef.rScratchTab));
                code.Add(new Instruction
                {
                    opcode = Opcode.Sub,
                    op1    = src,
                    op2    = this.InRegister(RegVRef.rScratchTab),
                    dest   = this.InRegister(RegVRef.rScratchTab),
                    acc    = true,
                });
                code.AddRange(varref.PutFromReg(RegVRef.rScratchTab));
            }
            else
            {
                code.Add(new Instruction
                {
                    opcode = Opcode.Sub,
                    op1    = src,
                    op2    = this,
                    dest   = this,
                    acc    = true,
                });
            }

            return(code);
        }
Esempio n. 2
0
        public List <Instruction> CodeGen()
        {
            var code = new List <Instruction>();

            var srcreg = source.AsReg();
            var tgtreg = target.AsReg();

            if (srcreg == null || (srcreg != null && tgtreg != null))
            {
                code.AddRange(source.FetchToReg(tgtreg ?? RegVRef.rScratchTab));
            }
            if (tgtreg == null)
            {
                code.AddRange(target.PutFromReg(srcreg ?? RegVRef.rScratchTab));
            }

            return(code);
        }