Pristine Ack-5.5
[Ack-5.5.git] / util / ceg / defaults / m_C_mnem
1 EM_TABLE=$1
2 argtype=$2
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
21 : Grumbl, an instruction label as argument is encoded in a sp_cst2
22
23                 args='((label) (p->em_cst))'
24                 echo "  /* An instruction label argument */"
25                 ;;
26         esac
27         for i in $list
28         do
29                 cat << EOF
30         case op_$i:
31                 C_$i$args;
32                 break;
33 EOF
34         done
35 done
36 list=`$argtype g $EM_TABLE`
37 cat << 'EOF'
38         default:
39 /* a "g" argument */
40                 if (p->em_argtype == nof_ptyp) {
41                         switch(p->em_opcode) {
42                                 default:
43                                         C_error = "Illegal mnemonic";
44                                         break;
45 EOF
46 for i in $list
47 do
48         cat << EOF
49                                 case op_$i:
50                                         C_${i}_dlb(p->em_dlb, p->em_off);
51                                         break;
52 EOF
53 done
54 cat << 'EOF'
55                         }
56                 }
57                 else if (p->em_argtype == sof_ptyp) {
58                         switch(p->em_opcode) {
59                                 default:
60                                         C_error = "Illegal mnemonic";
61                                         break;
62 EOF
63 for i in $list
64 do
65         cat << EOF
66                                 case op_$i:
67                                         C_${i}_dnam(p->em_dnam, p->em_off);
68                                         break;
69 EOF
70 done
71 cat << 'EOF'
72                         }
73                 }
74                 else /*argtype == cst_ptyp */ {
75                         switch(p->em_opcode) {
76                                 default:
77                                         C_error = "Illegal mnemonic";
78                                         break;
79 EOF
80 for i in $list
81 do
82         cat << EOF
83                                 case op_$i:
84                                         C_$i(p->em_cst);
85                                         break;
86 EOF
87 done
88 cat << 'EOF'
89                         }
90                 }
91 }
92 EOF