2007-02-25 12:49:04 +00:00
|
|
|
#!/bin/sh
|
2013-05-09 10:20:36 +00:00
|
|
|
set -e
|
2007-02-25 12:49:04 +00:00
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
ed=$1
|
|
|
|
em_table=$2
|
|
|
|
h=${3-.}
|
|
|
|
d=${4-.}
|
2007-02-25 12:49:04 +00:00
|
|
|
|
|
|
|
set `grep fpseu $em_table`
|
|
|
|
p=$2
|
|
|
|
set `grep fmnem $em_table`
|
|
|
|
m=$2
|
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - $em_table <<'A' > X
|
2007-02-25 12:49:04 +00:00
|
|
|
1,/^$/g/ /s// /gp
|
|
|
|
A
|
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - $em_table <<'A' | awk '{$2=$2+'$p'; print}' > Y
|
2007-02-25 12:49:04 +00:00
|
|
|
1,/^$/d
|
|
|
|
1,/^$/g/ /s// /gp
|
|
|
|
A
|
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - $em_table <<'A' | awk '{print $0,'$m'+i++}' > Z
|
2007-02-25 12:49:04 +00:00
|
|
|
1,/^$/d
|
|
|
|
1,/^$/d
|
|
|
|
1,/^$/g/ /s// /gp
|
|
|
|
A
|
2022-07-15 22:47:24 +00:00
|
|
|
$ed - $em_table <<'A' | awk '{print $0,'$m'+i++}'
|
2007-02-25 12:49:04 +00:00
|
|
|
|
|
|
|
i=`wc -l <Y`
|
|
|
|
echo 'lpseu' `expr $i + $p - 1` >>X
|
|
|
|
i=`wc -l <Z`
|
|
|
|
echo 'lmnem' `expr $i + $m - 1` >>X
|
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - X <<'A' > $h/em_spec.h
|
2007-02-25 12:49:04 +00:00
|
|
|
g/^/s//#define sp_/p
|
|
|
|
A
|
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - Y <<'A' > $h/em_pseu.h
|
2007-02-25 12:49:04 +00:00
|
|
|
g/ \(.*\) .*/s// \1/
|
|
|
|
g/\(.*\) \(.*\)/s//#define ps_\1 \2/p
|
|
|
|
A
|
|
|
|
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - Z <<'A' > $h/em_mnem.h
|
2007-02-25 12:49:04 +00:00
|
|
|
g/ .* /s// /
|
|
|
|
g/\(.*\) \(.*\)/s//#define op_\1 \2/p
|
|
|
|
A
|
|
|
|
|
|
|
|
(
|
|
|
|
echo 'char em_pseu[][4] = {'
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - Y <<'A'
|
2007-02-25 12:49:04 +00:00
|
|
|
g/\(...\).*/s// "\1",/p
|
|
|
|
A
|
|
|
|
echo '};'
|
|
|
|
) > $d/em_pseu.c
|
|
|
|
|
|
|
|
(
|
|
|
|
echo 'char em_mnem[][4] = {'
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - Z <<'A'
|
2007-02-25 12:49:04 +00:00
|
|
|
g/\(...\).*/s// "\1",/p
|
|
|
|
A
|
|
|
|
echo '};'
|
|
|
|
) > $d/em_mnem.c
|
|
|
|
|
|
|
|
(
|
|
|
|
echo '#include <em_flag.h>
|
|
|
|
char em_flag[] = {'
|
2018-06-02 16:02:51 +00:00
|
|
|
$ed - Z <<'A' | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
|
2007-02-25 12:49:04 +00:00
|
|
|
g/^... /s///
|
|
|
|
g/ .*/s///
|
|
|
|
g/\(.\)\(.\)/s//PAR_\1 | FLO_\2/
|
|
|
|
g/-/s//NO/g
|
|
|
|
g/.*/s// &,/p
|
|
|
|
A
|
|
|
|
echo '};'
|
|
|
|
) > $d/em_flag.c
|
|
|
|
|
|
|
|
rm X Y Z
|