浏览代码

fixed an opcode generation

Andrea Gussoni 8 年之前
父节点
当前提交
18f5132433
共有 3 个文件被更改,包括 12 次插入11 次删除
  1. 10 9
      acse/Acse.y
  2. 1 1
      acse/axe_engine.c
  3. 1 1
      acse/axe_struct.h

+ 10 - 9
acse/Acse.y

@@ -311,11 +311,12 @@ assign_statement : IDENTIFIER LSQUARE exp RSQUARE ASSIGN exp
                   gen_move_immediate(program, location, $3.value);
                   gen_addi_instruction(program, infty, REG_0, $3.infty);
                 }
-               else
+               else {
                   instr = gen_add_instruction
                         (program, location, REG_0, $3.value, CG_DIRECT_ALL);
                   gen_add_instruction(program, infty, REG_0, $3.infty, 
                                       CG_DIRECT_ALL);
+                }
 
                /* free the memory associated with the IDENTIFIER */
                free($1);
@@ -433,7 +434,7 @@ return_statement : RETURN
 
 read_statement : READ LPAR IDENTIFIER RPAR 
             {
-               int locationi, infty;
+               int location, infty;
                
                /* read from standard input an integer value and assign
                 * it to a variable associated with the given identifier */
@@ -446,7 +447,7 @@ read_statement : READ LPAR IDENTIFIER RPAR
 
                /* insert a read instruction */
                gen_read_instruction (program, location);
-               gen_addi_instruction(program, infty, REG_0, 1)
+               gen_addi_instruction(program, infty, REG_0, 1);
 
                /* free the memory associated with the IDENTIFIER */
                free($3);
@@ -476,10 +477,10 @@ write_statement : WRITE LPAR exp RPAR
             }
 ;
 
-exp: NUMBER      { $$ = create_expression ($1, 1, IMMEDIATE); }
-   | UNDEF       { $$ = create_expression (0, 0, IMMEDIATE);  }
-   | PLUSINFTY   { $$ = create_expression (1, -1, IMMEDIATE); }
-   | MINUSINFTY  { $$ = create_expression (2, -1, IMMEDIATE); }
+exp: NUMBER      { $$ = create_expression_inf ($1, 1, IMMEDIATE); }
+   | UNDEF       { $$ = create_expression_inf (0, 0, IMMEDIATE);  }
+   | PLUSINFTY   { $$ = create_expression_inf (1, -1, IMMEDIATE); }
+   | MINUSINFTY  { $$ = create_expression_inf (2, -1, IMMEDIATE); }
    | IDENTIFIER  {
                      int location, infty;
    
@@ -489,7 +490,7 @@ exp: NUMBER      { $$ = create_expression ($1, 1, IMMEDIATE); }
                      
                      /* return the register location of IDENTIFIER as
                       * a value for `exp' */
-                     $$ = create_expression (location, infty, REGISTER);
+                     $$ = create_expression_inf (location, infty, REGISTER);
 
                      /* free the memory associated with the IDENTIFIER */
                      free($1);
@@ -559,7 +560,7 @@ exp: NUMBER      { $$ = create_expression ($1, 1, IMMEDIATE); }
                         $$ = handle_binary_comparison (program, $1, $3, _GT_);
    }
    | exp EQ exp      {
-`       if (($1.expression_type == IMMEDIATE) && 
+       if (($1.expression_type == IMMEDIATE) && 
             ($3.expression_type == IMMEDIATE)) {
             int undef = ($1.infty * $3.infty != 0);
             int value = (($1.infty + $3.infty) * ($1.value == $3.value)) != 0;

+ 1 - 1
acse/axe_engine.c

@@ -740,7 +740,7 @@ void printOpcode(int opcode, FILE *fp)
       case SUB : opcode_to_string = "SUB"; break;
       case ANDL : opcode_to_string = "ANDL"; break;
       case ORL : opcode_to_string = "ORL"; break;
-      case EORL : opcode_to_string = "EORL"; break;
+      case EORL : opcode_to_string = "XORL"; break;
       case ANDB : opcode_to_string = "ANDB"; break;
       case ORB : opcode_to_string = "ORB"; break;
       case EORB : opcode_to_string = "EORB"; break;

+ 1 - 1
acse/axe_struct.h

@@ -121,7 +121,7 @@ extern t_axe_label * alloc_label(int value);
 /* create an expression */
 extern t_axe_expression create_expression (int value, int type);
 
-extern t_axe_expression create_expression (int value, int infty, int type);
+extern t_axe_expression create_expression_inf (int value, int infty, int type);
 
 /* create an instance that will mantain infos about a while statement */
 extern t_while_statement create_while_statement();