From 0d9376da70d984c2a6d60838ec07075a3e6504e3 Mon Sep 17 00:00:00 2001 From: Joe Soroka Date: Tue, 1 Feb 2011 15:53:48 -0800 Subject: [PATCH] tccasm: accept bracketed offset expressions --- i386-asm.c | 16 ++++++++++++++-- tests/asmtest.S | 1 + 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)