iw6-mod/deps/udis86/scripts/asmtest.sh
2024-02-27 01:34:37 -05:00

39 lines
749 B
Bash

#!/usr/bin/env bash
objdump="otool -tV"
yasm=yasm
asmfile="ud_yasmtest.asm"
binfile="ud_yasmtest.bin"
Sfile="ud_yasmtest.S"
objfile="ud_yasmtest.o"
echo "[bits $1]" > $asmfile
echo $2 >> $asmfile
$yasm -f bin -o $binfile $asmfile
if [ ! $? -eq 0 ]; then
echo "error: failed to assemble"
exit 1
fi
echo "-- hexdump --------------------------------------"
hexdump $binfile
echo
echo "-- objdump --------------------------------------"
hexdump -e '1/1 ".byte 0x%02x\n"' $binfile > $Sfile
gcc -c $Sfile -o $objfile
$objdump -d $objfile
echo
echo "-- udcli (intel) ---------------------------------"
../udcli/udcli -$1 $binfile
echo
echo "-- udcli (at&t) ----------------------------------"
../udcli/udcli -$1 -att $binfile
echo
exit 0