asm_debug.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * Andrea Di Biagio
  3. * Politecnico di Milano, 2007
  4. *
  5. * asm_debug.c
  6. * Formal Languages & Compilers Machine, 2007/2008
  7. *
  8. */
  9. #include "asm_debug.h"
  10. /* convert the integer code of `dataType' into a string */
  11. char * dataType_toString(int dataType)
  12. {
  13. if (dataType == ASM_WORD)
  14. return ".WORD";
  15. if (dataType == ASM_SPACE)
  16. return ".SPACE";
  17. return "<UNKNOWN>";
  18. }
  19. char * dataFormat_toString(int dataFormat)
  20. {
  21. if (dataFormat == ASM_FORMAT_TER)
  22. return "TERNARY";
  23. if (dataFormat == ASM_FORMAT_BIN)
  24. return "BINARY";
  25. if (dataFormat == ASM_FORMAT_UNR)
  26. return "UNARY";
  27. if (dataFormat == ASM_FORMAT_JMP)
  28. return "JUMP";
  29. if (dataFormat == ASM_FORMAT_NULL)
  30. return "NULL";
  31. return "<UNKNOWN_FORMAT>";
  32. }
  33. char * opcode_toString(int opcode)
  34. {
  35. switch(opcode)
  36. {
  37. case ADD_OP : return "ADD";
  38. case SUB_OP : return "SUB";
  39. case ANDL_OP : return "ANDL";
  40. case ORL_OP : return "ORL";
  41. case XORL_OP : return "XORL";
  42. case ANDB_OP : return "ANDB";
  43. case ORB_OP : return "ORB";
  44. case XORB_OP : return "XORB";
  45. case MUL_OP : return "MUL";
  46. case DIV_OP : return "DIV";
  47. case SHL_OP : return "SHL";
  48. case SHR_OP : return "SHR";
  49. case ROTL_OP : return "ROTL";
  50. case ROTR_OP : return "ROTR";
  51. case NEG_OP : return "NEG";
  52. case SPCL_OP : return "SPCL";
  53. case ADDI_OP : return "ADDI";
  54. case SUBI_OP : return "SUBI";
  55. case ANDLI_OP : return "ANDLI";
  56. case ORLI_OP : return "ORLI";
  57. case XORLI_OP : return "XORLI";
  58. case ANDBI_OP : return "ANDBI";
  59. case ORBI_OP : return "ORBI";
  60. case XORBI_OP : return "XORBI";
  61. case MULI_OP : return "MULI";
  62. case DIVI_OP : return "DIVI";
  63. case SHLI_OP : return "SHLI";
  64. case SHRI_OP : return "SHRI";
  65. case ROTLI_OP : return "ROTLI";
  66. case ROTRI_OP : return "ROTRI";
  67. case NOTL_OP : return "NOTL";
  68. case NOTB_OP : return "NOTB";
  69. case NOP_OP : return "NOP";
  70. case MOVA_OP : return "MOVA";
  71. case JSR_OP : return "JSR";
  72. case RET_OP : return "RET";
  73. case HALT_OP : return "HALT";
  74. case BT_OP : return "BT";
  75. case BF_OP : return "BF";
  76. case BHI_OP : return "BHI";
  77. case BLS_OP : return "BLS";
  78. case BCC_OP : return "BCC";
  79. case BCS_OP : return "BCS";
  80. case BNE_OP : return "BNE";
  81. case BEQ_OP : return "BEQ";
  82. case BVC_OP : return "BVC";
  83. case BVS_OP : return "BVS";
  84. case BPL_OP : return "BPL";
  85. case BMI_OP : return "BMI";
  86. case BGE_OP : return "BGE";
  87. case BLT_OP : return "BLT";
  88. case BGT_OP : return "BGT";
  89. case BLE_OP : return "BLE";
  90. case SEQ_OP : return "SEQ";
  91. case SGE_OP : return "SGE";
  92. case SGT_OP : return "SGT";
  93. case SLE_OP : return "SLE";
  94. case SLT_OP : return "SLT";
  95. case SNE_OP : return "SNE";
  96. case LOAD_OP : return "LOAD";
  97. case STORE_OP : return "STORE";
  98. case READ_OP : return "READ";
  99. case WRITE_OP : return "WRITE";
  100. default : return "<INVALID_OPCODE>";
  101. }
  102. }