cc_emit.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* Copyright (C) 2025 Gtker
  2. * This file is part of M2-Planet.
  3. *
  4. * M2-Planet is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * M2-Planet is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "cc.h"
  18. struct token_list* emit(char *s, struct token_list* head);
  19. void emit_out(char* s);
  20. void emit_label(char* prefix, char* name);
  21. extern char* emit_string;
  22. void emit_to_string(char* s);
  23. void reset_emit_string(void);
  24. char* register_from_string(int reg);
  25. char* integer_to_raw_byte_string(int value);
  26. void emit_unconditional_jump(char* prefix, char* name, char* note);
  27. void emit_jump_if_zero(int reg, char* prefix, char* name, char* note);
  28. void emit_jump_if_not_zero(int reg, char* prefix, char* name, char* note);
  29. void emit_jump_if_equal(int reg1, int reg2, char* prefix, char* name, char* note);
  30. void emit_load_named_immediate(int reg, char* prefix, char* name, char* note);
  31. void write_load_immediate(int reg, int value, char* note);
  32. void emit_load_immediate(int reg, int value, char* note);
  33. /* Adds destination and source and places result in destination */
  34. void write_add(int destination_reg, int source_reg, char* note);
  35. void emit_add(int destination_reg, int source_reg, char* note);
  36. void write_add_immediate(int reg, int value, char* note);
  37. void emit_add_immediate(int reg, int value, char* note);
  38. /* Subtracts destination and source and places result in destination */
  39. void write_sub(int destination_reg, int source_reg, char* note);
  40. void emit_sub(int destination_reg, int source_reg, char* note);
  41. void write_sub_immediate(int reg, int value, char* note);
  42. void emit_sub_immediate(int reg, int value, char* note);
  43. void emit_mul_into_register_zero(int reg, char* note);
  44. void emit_mul_register_zero_with_immediate(int value, char* note);
  45. void write_move(int destination_reg, int source_reg, char* note);
  46. void emit_move(int destination_reg, int source_reg, char* note);
  47. void emit_load_relative_to_register(int destination, int offset_register, int value, char* note);
  48. void emit_dereference(int reg, char* note);
  49. void emit_push(int reg, char* note);
  50. void emit_pop(int reg, char* note);