https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124504
Bug ID: 124504
Summary: -m16 -masm=intel emits wrong JMP and CALL instructions
Product: gcc
Version: 15.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: paul.emmerich at icloud dot com
Target Milestone: ---
Reproducer:
void example(void (*func)()) {
func();
}
-O1 compiles this as a CALL:
> gcc-15 -m16 -masm=intel -c -O1 example.c
67 FF 5C 24 10 lcall [esp + 0x10]
> gcc-15 -m16 -c -O1 example.c
67 66 FF 54 24 10 call dword ptr [esp + 0x10]
-O2 compiles this as a JMP:
> gcc-15 -m16 -masm=intel -c -O2 example.c
67 FF 6C 24 04 ljmp [esp + 4]
> gcc-15 -m16 -c -O2 example.c
67 FF 64 24 04 jmp word ptr [esp + 4]
But with -masm=intel it outputs a far call/jmp which is wrong.
Also in the CALL case the 0x66 prefix disappears with the -masm=intel syntax,
but I think the 0x66 prefix being applied inconsistently is a different bug.