Skip to content

Commit 95d184c

Browse files
author
Stefan
committed
i386-asm.c: Optional % for variables in specific registers
Handle 'register long r10 __asm__("%r10")' without %, too. Using GCC the % is optional. The musl source code does not use the % prefix. The GCC source code uses both variants.
1 parent 5aebf10 commit 95d184c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

i386-asm.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,22 +1233,23 @@ static const char *skip_constraint_modifiers(const char *p)
12331233
return p;
12341234
}
12351235

1236-
/* If T (a token) is of the form "%reg" returns the register
1237-
number and type, otherwise return -1. */
1236+
/* If t (a token) is of the form "%reg" or "reg" return the register number and
1237+
type, otherwise return -1. With GCC the % is optional, too. */
12381238
ST_FUNC int asm_parse_regvar (int t)
12391239
{
12401240
const char *s;
12411241
Operand op;
12421242
if (t < TOK_IDENT || (t & SYM_FIELD))
12431243
return -1;
12441244
s = table_ident[t - TOK_IDENT]->str;
1245-
if (s[0] != '%')
1246-
return -1;
1247-
t = tok_alloc_const(s + 1);
1245+
if (s[0] == '%')
1246+
++s;
1247+
t = tok_alloc_const(s);
12481248
unget_tok(t);
1249+
/* Internally the % prefix is required. */
12491250
unget_tok('%');
12501251
parse_operand(tcc_state, &op);
1251-
/* Accept only integer regs for now. */
1252+
/* Accept only integer regs for now. */
12521253
if (op.type & OP_REG)
12531254
return op.reg;
12541255
else

0 commit comments

Comments
 (0)