asm_engine.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Andrea Di Biagio
  3. * Politecnico di Milano, 2007
  4. *
  5. * asm_engine.h
  6. * Formal Languages & Compilers Machine, 2007/2008
  7. *
  8. */
  9. #ifndef _ASM_TRANSLATION
  10. #define _ASM_TRANSLATION
  11. #include "collections.h"
  12. #include "asm_struct.h"
  13. typedef struct
  14. {
  15. t_list *code; /* the instruction+data segment */
  16. t_list *labels; /* a set of asm_labels */
  17. int codesize; /* the size of the instruction segment */
  18. }t_translation_infos;
  19. /* create an instance of `t_translation_info' initializing the internal data
  20. * of every field of the structure */
  21. extern t_translation_infos * initStructures(int *errorcode);
  22. /* Insert an instruction inside the `code' list of `infos' */
  23. extern int addInstruction(t_translation_infos *infos
  24. , t_asm_instruction *instruction);
  25. /* Insert a new label. The label must be initialized externally */
  26. extern int insertLabel(t_translation_infos *infos, t_asm_label *label);
  27. /* find a label with a given `ID' */
  28. extern t_asm_label * findLabel(t_translation_infos *infos, char *ID, int *asm_errorcode);
  29. /* remove a label */
  30. extern int removeLabel(t_translation_infos *infos, char *ID);
  31. /* add a block of data into the data segment */
  32. extern int addData(t_translation_infos *infos, t_asm_data *data);
  33. /* finalization of the `infos' structure */
  34. extern int finalizeStructures(t_translation_infos *infos);
  35. /* begin the translation process */
  36. extern int asm_writeObjectFile(t_translation_infos *infos, char *output_file);
  37. #endif