diff --git a/Codes_en_COREC/tests/test5.corec b/Codes_en_COREC/tests/test5.corec index 053feb414d1e408b549a6db6c2bd8061607c643f..f2932258667e425dff75b8847d7f3158dd4a48dc 100644 --- a/Codes_en_COREC/tests/test5.corec +++ b/Codes_en_COREC/tests/test5.corec @@ -14,6 +14,7 @@ prog Test6 { f2 = f2*2; printstr("Expected : 1.3 * 2 = 2.6\nObtained : "); print(f2); + f1 /= f2+f2*4; printstr("Expected : 3.8 / (2.6 + 2.6 * 4) = 0.29230767\nObtained : "); print(f1) diff --git a/Codes_en_COREC/tests/test6.corec b/Codes_en_COREC/tests/test6.corec index afa9e3475772cec4ff7d189a88dcb56dd3d45570..e82b0fe722ffe7d41d901d05030de30ef3b44ed3 100644 --- a/Codes_en_COREC/tests/test6.corec +++ b/Codes_en_COREC/tests/test6.corec @@ -10,7 +10,7 @@ prog Test6 { array2D[1,0] = 3.0; array2D[1,1] = 4.5; array2D[1,2] = 5; - + printstr("Expected : 0.0 1.0 2.0 3.0 4.5 5.0 \nObtained : "); print(array2D); array3D[0,0,0] = 0; @@ -22,6 +22,7 @@ prog Test6 { array3D[1,1,0] = 6; array3D[1,1,1] = 7; + printstr("Expected : 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 \nObtained : "); print(array3D); printstr("Fini") } diff --git a/lib.c b/lib.c index 2d17350b1fd97f0ecd47146552906b8d6042e075..4a5a17a5aab92d1a9f4a0d56efdbac7a4b91bceb 100644 --- a/lib.c +++ b/lib.c @@ -852,7 +852,13 @@ void print_aff_array(struct symtable * t, struct code * c, FILE* fout,int i) // V alternative, effectue directement le*4 en calcul vu qu'on devrait passer par un load immediate dans tout les cas // fprintf(fout,"%sla $t0, %s\n",tabulation,c->quads[i].sym1->u.name); load_tab_addr_macro("$t0", "$t1", "$t2", c->quads[i].sym1,c->quads[i].sym2,t,fout); - load_symbol_macro("$f0","$t2",c->quads[i].sym3,t,fout);// sym3 is a float so the tmp register will be + + if(!ISFLOAT(c->quads[i].sym3)) + { // TODO make this temporary fix cleaner + convert_int_to_float("$f0","$t2",c->quads[i].sym3,t,fout); + fprintf(fout,"%smfc1 $t2, $f0\n",tabulation); + } else + load_symbol_macro("$f0","$t1",c->quads[i].sym3,t,fout); // sym3 is a float so the tmp register will be fprintf(fout,"%sswc1 $f0, ($t0)\n",tabulation); #ifdef LIBDEBUG fprintf(fout,"%s# end of aff_array section\n",tabulation); @@ -919,13 +925,6 @@ void load_symbol_macro(char * dest, char * tmp_used, struct symbol * sym, struct if(sym->kind == CONSTANT_INT) // var = 3 // in this case the value is a constant int we can do a load immediate in $a0 with value*4 fprintf(fout,"%sli %s, %ld\n",tabulation,dest,(sym->u.value_int)); - else if(sym->kind == NAME_LOC){ - fprintf(fout,"%slw %s, %s\n",tabulation,dest,(sym->u.name)); - fprintf(fout,"%smtc1 %s, $f0\n",tabulation,dest); - fprintf(fout,"%scvt.s.w $f2, $f0\n",tabulation); - fprintf(fout,"%sswc1 $f2, temp_float\n",tabulation); - fprintf(fout,"%slw %s, temp_float\n",tabulation,dest); - } // in other cases we need to load the value from the label of the corresponding symbol else if( sym->kind == NAME || sym->kind == NAME_LOC || sym->kind == ARRAY) { // var = 4*3 fprintf(fout,"%slw %s, %s\n",tabulation,dest,(sym->u.name));