File: asmsparc.sh

package info (click to toggle)
ffcall 1.8-4.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,752 kB
  • ctags: 3,102
  • sloc: asm: 19,563; ansic: 11,737; sh: 5,402; makefile: 885
file content (33 lines) | stat: -rwxr-xr-x 887 bytes parent folder | download | duplicates (50)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# Translate the assembler syntax of sparc assembler programs
# Usage: asmsparc < sunos4-asm-file > portable-asm-file
# The portable-asm-file has to be
#   1. preprocessed,
#   2. grep -v '^ *#line' | grep -v '^#'
#   3. sed -e 's,% ,%,g' -e 's,//.*$,,' -e 's,\$,#,g'

tmpscript1=sed$$tmp1
tmpscript2=sed$$tmp2
tmpremove='rm -f $tmpscript1 $tmpscript2'
trap "$tmpremove" 1 2 15

cat > $tmpscript1 << \EOF
# ----------- Remove gcc self-identification
/gcc2_compiled/d
/gnu_compiled_c/d
EOF

cat > $tmpscript2 << \EOF
# ----------- Turn # into $, to avoid trouble in preprocessing
s,#,\$,g
# ----------- Declare global symbols as functions (we have no variables)
s/\.global _\([A-Za-z0-9_]*\)$/.global _\1\
	DECLARE_FUNCTION(\1)/
# ----------- Global symbols depends on ASM_UNDERSCORE
s/_\([A-Za-z0-9_:]*\)/C(\1)/
EOF

sed -f $tmpscript1 | \
sed -f $tmpscript2

eval "$tmpremove"