Zadatak 1 fprintf(output, "\n%s:\n\t\t\tWORD\t1", $2); ili code("\n%s:\n\t\t\tWORD\t1", $2); Zadatak 2 function : type _ID { function_index = try_to_insert_id($2,FUNCTION,$1); var_num = 0; code("\n%s:", $2); code("\n\t\t\tPUSH\t%%14"); code("\n\t\t\tMOV \t%%15,%%14"); } _LPAREN _RPAREN body { if (get_last_element() > function_index) clear_symbols(function_index + 1); gen_str_lab($2,"_exit"); code("\n\t\t\tMOV \t%%14,%%15"); code("\n\t\t\tPOP \t%%14"); code("\n\t\t\tRET"); } ; body : _LBRACKET variable_list { code("\n\t\t\tSUBU\t%%15,$%d,%%15", 4*var_num); gen_str_lab(get_name(function_index), "_body"); } statement_list _RBRACKET | _LBRACKET { gen_str_lab(get_name(function_index), "_body"); } statement_list _RBRACKET ; Zadatak 3 return_statement : _RETURN num_exp _SEMICOLON { if(!check_types(function_index, $2)) printerror("incompatible types in return"); // vrednost return izraza se prebaci u registar %13 gen_mov($2, FUNCTION_REG); code("\n\t\t\tJMP\t@%s_exit",get_name(function_index)); } ;