Package label

Examples of label.Label


      this.out.println("    lds    r24, Button_Down");
    else if (str.equals("Meggy.Button.Left"))
      this.out.println("    lds    r24, Button_Left");
    else if (str.equals("Meggy.Button.Right"))
      this.out.println("    lds    r24, Button_Right");
    Label l1 = new Label();
    Label l2 = new Label();
    Label l3 = new Label();

    this.out.println("    # if button value is zero, push 0 else push 1");
    this.out.println("    tst    r24");
    this.out.println("    breq   " + l1.toString());
    this.out.println(l2.toString() + ":");
    this.out.println("    ldi    r24, 1");
    this.out.println("    jmp    " + l3.toString());
    this.out.println(l1.toString() + ":");
    this.out.println(l3.toString() + ":");
    genExpStore(node, new Reg16("r24", null));
  }
View Full Code Here


    genExpStore(node, new Reg16("r24", null));
  }

  public void visitIfStatement(IfStatement node)
  {
    Label l1 = new Label();
    Label l2 = new Label();
    Label l3 = new Label();

    this.out.println("");
    this.out.println("    #### if statement");

    if(node.getExp() != null)
      node.getExp().accept(this);

    this.out.println("");
    this.out.println("    # load condition and branch if false");
    Reg16 reg = genExpLoad(node.getExp(), 24);
    this.out.println("    #load zero into reg");
    this.out.println("    ldi    r25, 0");
    this.out.println("");
    this.out.println("    #use cp to set SREG");
    this.out.println("    cp     " + reg.lo8 + ", r25");
    this.out.println("    #WANT breq " + l1.toString());
    this.out.println("    brne   " + l2.toString());
    this.out.println("    jmp    " + l1.toString());

    this.out.println("");
    this.out.println("    # then label for if");
    this.out.println(l2.toString() + ":");
    if(node.getThenStatement() != null)
      node.getThenStatement().accept(this);

    this.out.println("    jmp    " + l3.toString());

    this.out.println("");
    this.out.println("    # else label for if");
    this.out.println(l1.toString() + ":");
    if(node.getElseStatement() != null)
      node.getElseStatement().accept(this);

    this.out.println("");
    this.out.println("    # done label for if");           
    this.out.println(l3.toString() + ":");
  }
View Full Code Here

  }

  public void visitWhileStatement(WhileStatement node)
  {
    Label l1 = new Label();
    Label l2 = new Label();
    Label l3 = new Label();

    this.out.println("");
    this.out.println("    #### while statement");
    this.out.println(l1.toString() + ":");

    if(node.getExp() != null)
      node.getExp().accept(this);

    this.out.println("");
    this.out.println("    # if not(condition)");
    Reg16 reg = genExpLoad(node.getExp(), 24);
    this.out.println("    ldi    r25,0");
    this.out.println("    cp     " + reg.lo8 + ", r25");
    this.out.println("    # WANT breq " + l3.toString());
    this.out.println("    brne   " + l2.toString());
    this.out.println("    jmp    " + l3.toString());

    this.out.println("");
    this.out.println("    # while loop body");
    this.out.println(l2.toString() + ":");

    if(node.getStatement() != null)
      node.getStatement().accept(this);

    this.out.println("");
    this.out.println("    # jump to while test");
    this.out.println("    jmp   " + l1.toString());
    this.out.println("");
    this.out.println("    # end of while");
    this.out.println(l3.toString() + ":");

  }
View Full Code Here

       into account, by promoting a byte (1 register) to an int (register pair),
       making sure the int value correctly preserves the sign.

       Outequalexp can generate code like the following:
       */
    Label l1 = new Label();
    Label l2 = new Label();
    Label l3 = new Label();
    this.out.println("");
    this.out.println("    # equality check expression");
   
    Reg16 reg1 = genExpLoad(node.getRExp(), 18);
    Reg16 reg2 = genExpLoad(node.getLExp(), 24);
View Full Code Here

    this.out.println("    # &&: left operand");

    if(node.getLExp() != null)
      node.getLExp().accept(this);

    Label l1 = new Label();
    Label l2 = new Label();
    this.out.println("");
    this.out.println("    # &&: if left operand is false do not eval right");

    Reg16 reg1 = genExpLoad(node.getLExp(), 24);

    genExpStore(node, reg1);

    this.out.println("    # compare left exp with zero");
    this.out.println("    ldi     r25, 0");

    this.out.println("    cp      " + reg1.lo8 + ", r25");
    this.out.println("    # Want this, breq" + l1.toString());
    this.out.println("    brne    " + l2.toString());
    this.out.println("    jmp     " + l1.toString());   

    this.out.println("");
    this.out.println(l2.toString() + ":");
    this.out.println("    # right operand");

    genExpLoad(node.getLExp(), 24);

    if(node.getRExp() != null)
View Full Code Here

    Reg16 reg = new Reg16("r24", "r25");
    genExpStore(node, reg);
    //this.out.flush();
  }
  public void outLtExp(LtExp node) {
    Label l1 = new Label();
    Label l2 = new Label();
    Label l3 = new Label();

    this.out.println();
    this.out.println("    # less than expression");
    Reg16 reg1 = genExpLoad(node.getRExp(), 18);
    Reg16 reg2 = genExpLoad(node.getLExp(), 24);
View Full Code Here

      }
    }
    return output;
  }
  public void promoteVal(Reg16 regPair) {
    Label l1 = new Label();
    Label l2 = new Label();

    this.out.println("    # promoting a byte to an int");
    this.out.println("    tst     " + regPair.lo8);
    this.out.println("    brlt     " + l1.toString());
    this.out.println("    ldi    r25, 0");
    this.out.println("    jmp    " + l2.toString());
    this.out.println(l1.toString() + ":");
    this.out.println("    ldi    r25, hi8(-1)");
    this.out.println(l2.toString() + ":");
    genMoveReg(regPair, new Reg16(regPair.lo8, "r25"));

  }
View Full Code Here

TOP

Related Classes of label.Label

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.