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 34 35 36 37 38 39 40 41 42 43 44
|
#!/bin/sh
# Translate the assembler syntax of RISC-V assembler programs
# Usage: asm-riscv.sh < riscvlinux-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,//.*$,,'
# Copyright (C) 2017-2022 Bruno Haible <bruno@clisp.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
tmpscript1=sed$$tmp1
tmpscript2=sed$$tmp2
tmpremove='rm -f $tmpscript1 $tmpscript2'
trap "$tmpremove" HUP INT TERM
cat > $tmpscript1 << \EOF
# ----------- Remove gcc self-identification
/gcc2_compiled/d
/gnu_compiled_c/d
/\.ident/d
EOF
cat > $tmpscript2 << \EOF
# ----------- Introduce macro syntax for assembler pseudo-ops
/\.section\([ ]\+\).*GNU-stack/d
EOF
sed -f $tmpscript1 | \
sed -f $tmpscript2
eval "$tmpremove"
|