While using objdump to disassemble a piece of 16-bit i386 code I noticed that using Intel asm syntax leads to erroneous results for some opcodes. The command lines I used were as follows: objdump -d -mi386 -Maddr16,data16 mbr.o (gas syntax) objdump -d -mi386:intel -Maddr16,data16 mbr.o (Intel syntax) The only little problem with gas syntax was that objdump showed a sign-expanded immediate as a 32-bit value in its output: 5a: 83 f9 ff cmp $0xffffffff,%cx In Intel syntax there were more errors. I'll show them along with corresponding gas-syntax output so the problems are clearly visible. The most of the trouble seems related to indexing with registers. Thanks! === start Intel syntax === 00000048 <main.4>: 48: 8a 14 89 mov dl,BYTE PTR [ecx+ecx*4] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0000004a <main.5>: 4a: 89 e7 mov di,sp 4c: 8a 74 01 8b mov dh,BYTE PTR [ecx+eax-117] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 50: 4c 02 bb 00 7c 80 fe rex64X add r15b,BYTE PTR [ebx-25134080] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 57: ff 75 32 push DWORD PTR [ebp+50] 5a: 83 f9 ff cmp cx,0xffffffffffffffff ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5d: 75 2d jne 8c <main.7> 5f: 51 push rcx 60: 53 push rbx ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 61: bb aa 55 mov bx,0x55aa 64: b4 41 mov ah,0x41 66: cd 13 int 0x13 68: 72 20 jb 8a <main.6> 6a: 81 fb 55 aa cmp bx,0xaa55 6e: 75 1a jne 8a <main.6> 70: f6 c1 01 test cl,0x1 73: 74 15 je 8a <main.6> 75: 5b pop rbx 76: 66 data32 77: 6a 00 push 0x0 79: 66 data32 7a: ff 74 08 06 push DWORD PTR [eax+ecx+6] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 7e: 53 push rbx 7f: 6a 01 push 0x1 81: 6a 10 push 0x10 83: 89 e6 mov si,sp 85: b8 00 42 mov ax,0x4200 88: eb 05 jmp 8f <main.8> 0000008a <main.6>: 8a: 5b pop rbx 8b: 59 pop rcx ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0000008c <main.7>: 8c: b8 01 02 mov ax,0x201 0000008f <main.8>: 8f: cd 13 int 0x13 91: 89 fc mov sp,di 93: 72 0f jb a4 <err_rd> 95: 81 bf fe 01 55 aa 75 cmp DWORD PTR [edi-1437269506],0xc75 9c: 0c ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 9d: ff e3 jmp bx === end Intel syntax === === start gas syntax === 00000048 <main.4>: 48: 8a 14 mov (%si),%dl 0000004a <main.5>: 4a: 89 e7 mov %sp,%di 4c: 8a 74 01 mov 1(%si),%dh 4f: 8b 4c 02 mov 2(%si),%cx 52: bb 00 7c mov $0x7c00,%bx 55: 80 fe ff cmp $0xff,%dh 58: 75 32 jne 8c <main.7> 5a: 83 f9 ff cmp $0xffffffff,%cx 5d: 75 2d jne 8c <main.7> 5f: 51 push %cx 60: 53 push %bx 61: bb aa 55 mov $0x55aa,%bx 64: b4 41 mov $0x41,%ah 66: cd 13 int $0x13 68: 72 20 jb 8a <main.6> 6a: 81 fb 55 aa cmp $0xaa55,%bx 6e: 75 1a jne 8a <main.6> 70: f6 c1 01 test $0x1,%cl 73: 74 15 je 8a <main.6> 75: 5b pop %bx 76: 66 6a 00 pushl $0x0 79: 66 ff 74 08 pushl 8(%si) 7d: 06 push %es 7e: 53 push %bx 7f: 6a 01 push $0x1 81: 6a 10 push $0x10 83: 89 e6 mov %sp,%si 85: b8 00 42 mov $0x4200,%ax 88: eb 05 jmp 8f <main.8> 0000008a <main.6>: 8a: 5b pop %bx 8b: 59 pop %cx 0000008c <main.7>: 8c: b8 01 02 mov $0x201,%ax 0000008f <main.8>: 8f: cd 13 int $0x13 91: 89 fc mov %di,%sp 93: 72 0f jb a4 <err_rd> 95: 81 bf fe 01 55 aa cmpw $0xaa55,510(%bx) 9b: 75 0c jne a9 <err_os> 9d: ff e3 jmp *%bx === end gas syntax ===
*** Bug 442 has been marked as a duplicate of this bug. ***
http://sources.redhat.com/ml/binutils-cvs/2004-10/msg00092.html
Subject: Re: objdump -d gets some i386 16-bit opcodes wrong Thanks for fixing this!