crtc-demos / gcc-ia16

GNU General Public License v2.0
14 stars 2 forks source link

Inline assembly constraint "=@cc<cond>" is broken. #5

Closed iucoen closed 2 years ago

iucoen commented 2 years ago

gcc for i386 and x86_64 support setting output of inline assembly block based on condition flags.

For example

int is_zero;
asm("test %1, %1" : "=@ccz"(is_zero) : "=r"(0));

would set is_zero to 1. On i386 that assembly block would be equivalent to:

asm("test %1, %1\n ""setz %0\n" : "=r"(is_zero) : "=r"(0));

With gcc-ia16, "=@cc" would get parsed as just "c", and the compiler emits a "mov %cx, %0" instead, which is wrong. If "=@cc" is not supported, the compiler should at least fail with an error, not interpret the constraint to mean %cx.

iucoen commented 2 years ago

wrong repo