コード例 #1
0
 public static Tile LogNot_Reg()
 {
     return(makeUnopTile <LogNotOperatorNode, RegisterNode> (
                (regNode, root, left) => new [] {
         InstructionFactory.Cmp(left, new ConstantNode <long> (0L)),                              // cmp(l, 0)
         InstructionFactory.Sete(regNode)                                                         // if l = 0 then reg = 1 else reg = 0
     }
                ));
 }
コード例 #2
0
 static Tile conditionalWithCmpRegReg <T>(string cond_type)
     where T : BinaryOperatorNode
 {
     return(conditionalWithCmp <T, RegisterNode, RegisterNode> (
                (root, reg1, reg2, lbl) => new[] {
         InstructionFactory.Cmp(reg1, reg2),
         InstructionFactory.Jump(cond_type, lbl)
     }
                ));
 }
コード例 #3
0
 static Tile conditionalWithCmpConstReg <T, C>(string cond_type)
     where T : BinaryOperatorNode
 {
     return(conditionalWithCmp <T, ConstantNode <C>, RegisterNode> (
                (root, reg1, con, lbl) => new[] {
         InstructionFactory.Cmp(reg1, con),
         InstructionFactory.Jump(cond_type, lbl)
     }
                ));
 }
コード例 #4
0
 static Tile compareRegConst <T, C>(string cond_type)
     where T : BinaryOperatorNode
 {
     return(compare <T, RegisterNode, ConstantNode <C> > (
                (regNode, root, left, right) => new[] {
         InstructionFactory.Cmp(left, right),
         InstructionFactory.Set(cond_type, regNode)
     }
                ));
 }
コード例 #5
0
 public static Tile RegReg()
 {
     // l = 0            ->  first instruction sets reg to 0
     // r = 0 but l > 0  ->  fourth instruction sets reg to 0
     // l > 0 and r > 0  ->  first instruction sets reg = l > 0 and nothing changes
     return(makeBinopTile <LogAndOperatorNode, RegisterNode, RegisterNode> (
                (regNode, left, right) => new[] {
         InstructionFactory.Move(regNode, left),                                // reg = left
         InstructionFactory.Xor(left, left),                                    // left = 0
         InstructionFactory.Cmp(right, left),                                   // if right == 0
         InstructionFactory.Cmove(regNode, left)                                // then reg = 0
     }
                ));
 }