~poptart/riscv-business

57136bec69f7abbc775d419068227611fa7024d3 — terrorbyte 2 years ago 34c518c
Added attrocious inline single instruction generator for quickly checking instruction format in CPU order
1 files changed, 37 insertions(+), 0 deletions(-)

A util/trashdis.sh
A util/trashdis.sh => util/trashdis.sh +37 -0
@@ 0,0 1,37 @@
#!/bin/sh
export ARCH="rv64g"
export CARCH="rv64gc"

while :; do
	case $1 in
		-h|-\?|--help)
			printf "echo 'li a7,0xfff' | trashdis.sh\\ntrashdis.sh 'li a7,0xfff'\\n-c - use compressed instructions\\n-h - print this help\\n"
			exit
			;;
		-c|--compressed)
			ARCH="${CARCH}"
			;;
		-?*)
			printf 'Unknown option: %s\n' "$1" >&2
			;;
		*)
			break
	esac
	shift
done

if [ -p /dev/stdin ]; then
	while IFS= read i; do
		printf "%s\n" "${i}"| \
			gcc -x assembler -march=${ARCH} -c -o /tmp/semiinline.o - \
			&& objdump -D /tmp/semiinline.o | \
			tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f3-| \
			sed '/^$/d' | grep -v -e "section \.text:" -e "format elf"
	done
else 
	printf "%s\n" "$*" |  \
		gcc -x assembler -march=${ARCH} -c -o /tmp/semiinline.o - \
		&& objdump -D /tmp/semiinline.o | \
		tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f3-| \
		sed '/^$/d' | grep -v -e "section \.text:" -e "format elf"
fi