m_C_mnem 1.4 KB

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