Collins Chen wrote: > I encounter a problem about instruction > "jmp" and "call". I expect the "jmp" and > "call" with a 16-bit offset, but every > time the GCC compile them with 32-bit offset. > This cause the vga bios can't run. I don't > know how to fix it, can you help me? Thanks! > Example: > e8 a1 00 : call 00a1 > b0 50 : movb $0x50, %al > e6 80 : outb %al, $0x80 > This three instructions will > be compiled to two instructions as follow: > e8 a1 00 b0 50 : call 50b000a1 > e6 80 : outb %al, $0x80
It seems your disassembler thinks the code runs in 32bit mode. Don't worry. As you see, GCC get's it right: the bytes are the same! The point is that E8 (call) has a 'word' as an argument. Now, in 16-bit mode, a word is 16bits. In 32-bit a 'word' is 32bits. So in 16bit mode E8 is followed by 2 bytes, in 32bit it is followed by 4. In other words: most instructions in x86 when using a word DON'T specify exactly the size. They use the default size (unless you prepend a prefix byte). The processor knows what mode he is in, and acts accordingly. But the decompiler must be told, since it seems it assumes 32 bit mode. Stefanos Papanicolopulos