m_C_mnem 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. EM_TABLE=$1
  3. echo "switch(p->em_opcode) {"
  4. for i in - cdflnorswz p b
  5. do
  6. list=`./argtype $i $EM_TABLE`
  7. case $i in
  8. -) args='()'
  9. echo " /* no arguments */"
  10. ;;
  11. cdflnorswz)
  12. args='(p->em_cst)'
  13. echo " /* one integer constant argument */"
  14. ;;
  15. p)
  16. args='(p->em_pnam)'
  17. echo " /* a procedure name argument */"
  18. ;;
  19. b)
  20. : Grumbl, an instruction label as argument is encoded in a sp_cst2
  21. args='((label) (p->em_cst))'
  22. echo " /* An instruction label argument */"
  23. ;;
  24. esac
  25. for i in $list
  26. do
  27. cat << EOF
  28. case op_$i:
  29. C_$i$args;
  30. break;
  31. EOF
  32. done
  33. done
  34. list=`./argtype g $EM_TABLE`
  35. cat << 'EOF'
  36. default:
  37. /* a "g" argument */
  38. if (p->em_argtype == nof_ptyp) {
  39. switch(p->em_opcode) {
  40. default:
  41. EM_error = "Illegal mnemonic";
  42. break;
  43. EOF
  44. for i in $list
  45. do
  46. cat << EOF
  47. case op_$i:
  48. C_${i}_dlb(p->em_dlb, p->em_off);
  49. break;
  50. EOF
  51. done
  52. cat << 'EOF'
  53. }
  54. }
  55. else if (p->em_argtype == sof_ptyp) {
  56. switch(p->em_opcode) {
  57. default:
  58. EM_error = "Illegal mnemonic";
  59. break;
  60. EOF
  61. for i in $list
  62. do
  63. cat << EOF
  64. case op_$i:
  65. C_${i}_dnam(p->em_dnam, p->em_off);
  66. break;
  67. EOF
  68. done
  69. cat << 'EOF'
  70. }
  71. }
  72. else /*argtype == cst_ptyp */ {
  73. switch(p->em_opcode) {
  74. default:
  75. EM_error = "Illegal mnemonic";
  76. break;
  77. EOF
  78. for i in $list
  79. do
  80. cat << EOF
  81. case op_$i:
  82. C_$i(p->em_cst);
  83. break;
  84. EOF
  85. done
  86. cat << 'EOF'
  87. }
  88. }
  89. }
  90. EOF