http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53354
Bug #: 53354 Summary: %z# asm specifier could be extended to support immediate constraints Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: svfue...@gmail.com It would be nice if %z# would work with immediate asm constraints: void foo(void) { #if 1 int x = 1; asm("mov%z0 %0, bar":: "r" (x)); #else asm("mov%z0 %0, bar":: "i" (1)); #endif } The first option isn't optimal as an extra register is needed. If the second is tried, gcc exits with "error: invalid 'asm': invalid operand type used with operand code 'z'" Typically, to work around this, people use a switch statement based on the size of the immediate, and manually copy the code for sizes of 1, 2, 4, 8 byte registers. It would be simpler if the bulky switch statements weren't necessary.