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?