Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. f.genInstr("",          "cdq",         "",               "");
  2.             f.genInstr("",          "idivl",         "%ecx",               "");
  3.             f.genInstr("",          "movl",         "%edx,%eax",               "  mod");
  4. @Override
  5.     void genCode(CodeFile f) {//Common for all operators
  6.         f.genInstr("",          "pushl",         "%eax",               "");
  7.         right.genCode(f);
  8.         f.genInstr("",          "movl",         "%eax,%ecx",               "");
  9.         f.genInstr("",          "popl",         "%eax",               "");//Special code for each operator
  10.         if (token.equals("*")) {f.genInstr("",          "imull",         "%ecx,%eax",               "  *");} else if (token.equals("div")) {f.genInstr("",          "cdq",         "",               "");
  11.             f.genInstr("",          "idivl",         "%ecx",               "  /");} else if (token.equals("mod")) {f.genInstr("",          "cdq",         "",               "");
  12.             f.genInstr("",          "idivl",         "%ecx",               "");
  13.             f.genInstr("",          "movl",         "%edx,%eax",               "  mod");} else if (token.equals("and")) {f.genInstr("",          "andl",         "%ecx,%eax",               "  and");} else {
  14.             Main.panic("Factor opr - genCode()");
  15.         }
  16.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement