History

tccasm: accept bracketed offset expressions

Joe Soroka committed 15 years ago

Commit 0d9376d1 parent 47b4cf22 files · +15 −2Browse files

Unified · Split

2 files
  1. i386-asm.c +14 −2
  2. tests/asmtest.S +1 −0
i386-asm.c+14−2
@@ -376,8 +376,20 @@ static void parse_operand(TCCState *s1, Operand *op) · 375 unmodified lines
376376 op->e.v = e.v;
377377 op->e.sym = e.sym;
378378 } else {
379− op->e.v = 0;
380− op->e.sym = NULL;
379+ next();
380+ if (tok == '%') {
381+ unget_tok('(');
382+ op->e.v = 0;
383+ op->e.sym = NULL;
384+ } else {
385+ /* bracketed offset expression */
386+ asm_expr(s1, &e);
387+ if (tok != ')')
388+ expect(")");
389+ next();
390+ op->e.v = e.v;
391+ op->e.sym = e.sym;
392+ }
381393 }
382394 if (tok == '(') {
383395 next();
tests/asmtest.S+1−0
@@ -122,6 +122,7 @@ addl $0x123, 0x100 · 121 unmodified lines
122122 addl $0x123, 0x100(%ebx)
123123 addl $0x123, 0x100(%ebx,%edx,2)
124124 addl $0x123, 0x100(%esp)
125+addl $0x123, (3*8)(%esp)
125126 addl $0x123, (%ebp)
126127 addl $0x123, (%esp)
127128 cmpl $0x123, (%esp)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t