aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i386-asm.c16
-rw-r--r--tests/asmtest.S1
2 files changed, 15 insertions, 2 deletions
diff --git a/i386-asm.c b/i386-asm.c
index 2623ef6..4d2f9b8 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 5bc8950..7f204cf 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)