Allow inline %assert inside of complex immediates.
authorMichael Buesch <mb@bu3sch.de>
Mon, 9 Jun 2008 16:16:39 +0000 (18:16 +0200)
committerMichael Buesch <mb@bu3sch.de>
Mon, 9 Jun 2008 16:16:39 +0000 (18:16 +0200)
Signed-off-by: Michael Buesch <mb@bu3sch.de>
assembler/parser.y
assembler/scanner.l
assembler/test.asm

index e75d9f4d371873ae1d0ab2e7d3f3c757e313ad5f..50065bab65e6b7f514c800052aaea51d0c393cf4 100644 (file)
@@ -516,7 +516,12 @@ asmdir             : ASM_ARCH hexnum_decnum {
                        ad->u.start = label;
                        $$ = ad;
                  }
-               | ASM_ASSERT assertion {
+               | asm_assert {
+                       $$ = NULL;
+                 }
+               ;
+
+asm_assert     : ASM_ASSERT assertion {
                        unsigned int ok = (unsigned int)(unsigned long)$2;
                        if (!ok)
                                assembler_assertion_failed();
@@ -1201,6 +1206,10 @@ complex_imm      : PAREN_OPEN complex_imm_arg complex_imm_oper complex_imm_arg PAREN_
                | PAREN_OPEN complex_imm PAREN_CLOSE {
                        $$ = $2;
                  }
+               | PAREN_OPEN asm_assert PAREN_CLOSE {
+                       /* Inline assertion. Always return zero */
+                       $$ = (void *)(unsigned long)(unsigned int)0;
+                 }
                | PAREN_OPEN BITW_NOT complex_imm PAREN_CLOSE {
                        unsigned long n = (unsigned long)$3;
                        n = ~n;
index 6fb3599c0ac16586568ed71cceee80990d8d79ec..5013d0e94e4e0a430fcab9f357624686cd2a7888 100644 (file)
@@ -51,7 +51,7 @@ NEWLINE               ((\r)|(\n)|(\r\n))
 
 ^{WS}*"%"{WS}*arch     { update_lineinfo(); return ASM_ARCH; }
 ^{WS}*"%"{WS}*start    { update_lineinfo(); return ASM_START; }
-^{WS}*"%"{WS}*assert   { update_lineinfo(); return ASM_ASSERT; }
+"%"{WS}*assert         { update_lineinfo(); return ASM_ASSERT; }
 
 ^{WS}*\.text{WS}*$                     { update_lineinfo(); return SECTION_TEXT; }
 ^{WS}*\.initvals/\({IDENTIFIER}\)      { update_lineinfo(); return SECTION_IVALS; }
index ecbc2732179a202efa7e275bf3924d038d261333..cb0d3bdf95a42ab85ac3b4d136667ddd59e5d2e4 100644 (file)
 
 .text
 
+       /* Inline assertion inside of a complex immediate.
+        * The %assert() expression will always return zero. */
+       mov     (1 + (%assert(1 == ((1 + 2) - 2)))), r0
+
 label:
        /* ADD instructions */
        add     r0,r1,r2        /* add */