Question

I am looking for a program (Linux/FOSS preferred) or a website that can quickly and conveniently show me the hex equivalents of (Intel) assembly instructions

E.g. I enter:

test al, al

and it outputs

84 c0

Writing inline assembly in C and checking what it compiles to does not cout as quick and convenient.

Was it helpful?

Solution

I always use as from binutils for that. E.g:

$ echo -e "MOV DWORD PTR [RSP+4], 0x12345678" | as -o /dev/null -64 -al -msyntax=intel -mnaked-reg
GAS LISTING             page 1


   1 0000 C7442404  MOV DWORD PTR [RSP+4],0x12345678
   1      78563412 

$ echo -e "push eax" | as -o /dev/null -32 -al -msyntax=intel -mnaked-reg
GAS LISTING             page 1


   1 0000 50        push eax

OTHER TIPS

You could use NASM in conjunction with NDISASM, e.g.:

This is the assembly file (named, say, test.asm) with your instruction:

bits 32
test al, al

You assemble it:

nasm -f bin test.asm -o test.bin

And then you disassemble it:

ndisasm -b 32 test.bin

And this is what you get:

00000000  84C0              test al,al

Another way is to produce the listing file when assembling:

nasm -f bin test.asm -o test.bin -l test.lst

And this is what you get in test.lst:

 1                                  bits 32
 2 00000000 84C0                    test al, al
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top