0

I have the script which (as intended) allows me to see the difference in the opcodes generated for the different architectures (especially intrested in x87 instructions on x86 vs x86_64).

#!/usr/bin/env bash

cat - <<__EOF> a.cpp
int main()
{
    double const x(1.0);
    asm volatile ("fldl (%0)" : : "a" (&x));
    return 0;
}
__EOF
EXEC_STR='g++ a.cpp -c -O0 -o /dev/null -m${BITNESS} -mfpmath=387 -Wa,-adhlns="${BITNESS}.lst"'
FILTER_STR='awk "/\/APP/, /\/NO_APP/" ${BITNESS}.lst | cut -f 2- > ${BITNESS}_.lst'
BITNESS=32 bash -c "${EXEC_STR} && ${FILTER_STR}"
BITNESS=64 bash -c "${EXEC_STR} && ${FILTER_STR}"
diff -w -B 32_.lst 64_.lst

Output:

3c3
<   fldl (%eax)
---
>   fldl (%rax)

But cut -f 2- cut out the column with opcode too (this is udesirable), in addition to cutting out the first column.

Are there other ways to get the desired result? And how to filter out the text?

Tomilov Anatoliy
  • 15,657
  • 10
  • 64
  • 169
  • why not just use the encoding tables in the intel manuals? (I do concede they are a bit annoying to understand sometimes...) – Necrolis Jan 07 '13 at 08:11
  • I want to see the code, generated by **gcc**, too (in slighty modified version of above script it possible). – Tomilov Anatoliy Jan 07 '13 at 08:15

0 Answers0