diff --git a/i386-asm.c b/i386-asm.c index 2623ef64..4d2f9b8a 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -376,8 +376,20 @@ static void parse_operand(TCCState *s1, Operand *op) op->e.v = e.v; op->e.sym = e.sym; } else { - op->e.v = 0; - op->e.sym = NULL; + next(); + if (tok == '%') { + unget_tok('('); + op->e.v = 0; + 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 == '(') { next(); diff --git a/tests/asmtest.S b/tests/asmtest.S index 5bc89501..7f204cf5 100644 --- a/tests/asmtest.S +++ b/tests/asmtest.S @@ -122,6 +122,7 @@ addl $0x123, 0x100 addl $0x123, 0x100(%ebx) addl $0x123, 0x100(%ebx,%edx,2) addl $0x123, 0x100(%esp) +addl $0x123, (3*8)(%esp) addl $0x123, (%ebp) addl $0x123, (%esp) cmpl $0x123, (%esp)