Sprawdzanie opcodułów Intel z łatwością w Linuksie

Szukałem praktycznego narzędzia, które drukowałoby kody operacyjne dowolnej 64-bitowej lub 32-bitowej instrukcji Intela w Linuksie, np. coś jakHiew's asembler w DOS. Jedną z opcji jest usługa internetowa.

Ponieważ nie mogłem znaleźć żadnego, zrobiłem własnebash skrypt, który tworzy plik źródłowy zespołu z parametrów wiersza poleceń (instrukcja [s] i <32/64>), kompiluje, łączy i dezasembluje go oraz pokazuje prawidłowe wiersze demontażu. Ale czy jest już jakiś program, który by się pokazałwszystko możliwe kodowanie dla dowolnej instrukcji, np. dlamov eax,ebx? Moje podejście za pomocąnasm, ld indisasm oczywiście daje tylko jedno możliwe kodowanie dla każdej instrukcji.

Za pomocą tego skryptu mogę uzyskać kodowanie używane przeznasm dla 64 i 32-bitowego kodu, np .:

/home/user/code/asm$ showop 'nop;add eax,ebx;cpuid' 64

00000000  90                nop
00000001  01D8              add eax,ebx
00000003  0FA2              cpuid

Ale jak mogę łatwo uzyskać wszystkie możliwe kodowania kodu? Czy jest już dostępny jakiś program?

Oto kod:

#!/bin/bash

# usage: showop instructions bits

asminstr=$1
bits=$2

# asminstr="nop;nop;nop;nop;add eax,ebx;nop;nop;nop"
# bits=64

numberofinstr=`echo $asminstr | grep -o ";" | wc -l`
((numberofinstr++))

if [ -f tempasmfile.asm ]
    then
    rm tempasmfile.asm
fi
if [ -f tempobjfile.o ]
    then
    rm tempobjfile.o
fi
if [ -f tempexefile ]
    then
    rm tempexefile
fi

printf "[bits $bits]\nsection .text\nglobal _start\n\n_start:\n`echo $asminstr | sed 's/;/\\n/g'`\n" >tempasmfile.asm

nasm -f elf$bits tempasmfile.asm -o tempobjfile.o
ld tempobjfile.o -o tempexefile

if [ $bits -eq 32 ]
then
    ndisasm -b $bits -e 0x60 tempexefile | head -n $numberofinstr
elif [ $bits -eq 64 ]
then
    ndisasm -b $bits -e 0x80 tempexefile | head -n $numberofinstr
fi
rm tempasmfile.asm
rm tempobjfile.o
rm tempexefile

questionAnswers(1)

yourAnswerToTheQuestion