tccasm: accept bracketed offset expressions

This commit is contained in:
Joe Soroka 2011-02-01 15:53:48 -08:00
parent 47b4cf22cd
commit 0d9376da70
2 changed files with 15 additions and 2 deletions

View File

@ -376,8 +376,20 @@ static void parse_operand(TCCState *s1, Operand *op)
op->e.v = e.v; op->e.v = e.v;
op->e.sym = e.sym; op->e.sym = e.sym;
} else { } else {
next();
if (tok == '%') {
unget_tok('(');
op->e.v = 0; op->e.v = 0;
op->e.sym = NULL; op->e.sym = NULL;
} else {
/* bracketed offset expression */
asm_expr(s1, &e);
if (tok != ')')
expect(")");
next();
op->e.v = e.v;
op->e.sym = e.sym;
}
} }
if (tok == '(') { if (tok == '(') {
next(); next();

View File

@ -122,6 +122,7 @@ addl $0x123, 0x100
addl $0x123, 0x100(%ebx) addl $0x123, 0x100(%ebx)
addl $0x123, 0x100(%ebx,%edx,2) addl $0x123, 0x100(%ebx,%edx,2)
addl $0x123, 0x100(%esp) addl $0x123, 0x100(%esp)
addl $0x123, (3*8)(%esp)
addl $0x123, (%ebp) addl $0x123, (%ebp)
addl $0x123, (%esp) addl $0x123, (%esp)
cmpl $0x123, (%esp) cmpl $0x123, (%esp)