]> git.sur5r.net Git - cc65/blobdiff - src/cc65/asmstmt.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / cc65 / asmstmt.c
index 3f858c679f7a8501a6cde6f8b61c700a40db3fbd..ce2660e546dd82d1fc07ddb7f9c154b566aff099 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                asmstmt.c                                 */
+/*                                 asmstmt.c                                 */
 /*                                                                           */
-/*           Inline assembler statements for the cc65 C compiler            */
+/*            Inline assembler statements for the cc65 C compiler            */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
@@ -54,7 +54,7 @@
 
 
 /*****************************************************************************/
-/*                                  Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -90,9 +90,9 @@ static SymEntry* AsmGetSym (unsigned Arg, unsigned Type)
 
     /* Argument must be an identifier */
     if (CurTok.Tok != TOK_IDENT) {
-               Error ("Identifier expected for argument %u", Arg);
-       AsmErrorSkip ();
-               return 0;
+        Error ("Identifier expected for argument %u", Arg);
+        AsmErrorSkip ();
+        return 0;
     }
 
     /* Get a pointer to the symbol table entry */
@@ -100,9 +100,9 @@ static SymEntry* AsmGetSym (unsigned Arg, unsigned Type)
 
     /* Did we find a symbol with this name? */
     if (Sym == 0) {
-       Error ("Undefined symbol `%s' for argument %u", CurTok.Ident, Arg);
-       AsmErrorSkip ();
-       return 0;
+        Error ("Undefined symbol `%s' for argument %u", CurTok.Ident, Arg);
+        AsmErrorSkip ();
+        return 0;
     }
 
     /* We found the symbol - skip the name token */
@@ -110,9 +110,9 @@ static SymEntry* AsmGetSym (unsigned Arg, unsigned Type)
 
     /* Check if we have a global symbol */
     if ((Sym->Flags & Type) != Type) {
-               Error ("Type of argument %u differs from format specifier", Arg);
-       AsmErrorSkip ();
-       return 0;
+        Error ("Type of argument %u differs from format specifier", Arg);
+        AsmErrorSkip ();
+        return 0;
     }
 
     /* Mark the symbol as referenced */
@@ -138,15 +138,15 @@ static void ParseByteArg (StrBuf* T, unsigned Arg)
 
     /* Check the range but allow negative values if the type is signed */
     if (IsSignUnsigned (Expr.Type)) {
-       if (Expr.IVal < 0 || Expr.IVal > 0xFF) {
-           AsmRangeError (Arg);
-           Expr.IVal = 0;
-       }
+        if (Expr.IVal < 0 || Expr.IVal > 0xFF) {
+            AsmRangeError (Arg);
+            Expr.IVal = 0;
+        }
     } else {
-       if (Expr.IVal < -128 || Expr.IVal > 127) {
-           AsmRangeError (Arg);
-           Expr.IVal = 0;
-       }
+        if (Expr.IVal < -128 || Expr.IVal > 127) {
+            AsmRangeError (Arg);
+            Expr.IVal = 0;
+        }
     }
 
     /* Convert into a hex number */
@@ -172,15 +172,15 @@ static void ParseWordArg (StrBuf* T, unsigned Arg)
 
     /* Check the range but allow negative values if the type is signed */
     if (IsSignUnsigned (Expr.Type)) {
-       if (Expr.IVal < 0 || Expr.IVal > 0xFFFF) {
-           AsmRangeError (Arg);
-           Expr.IVal = 0;
-       }
+        if (Expr.IVal < 0 || Expr.IVal > 0xFFFF) {
+            AsmRangeError (Arg);
+            Expr.IVal = 0;
+        }
     } else {
-       if (Expr.IVal < -32768 || Expr.IVal > 32767) {
-           AsmRangeError (Arg);
-           Expr.IVal = 0;
-       }
+        if (Expr.IVal < -32768 || Expr.IVal > 32767) {
+            AsmRangeError (Arg);
+            Expr.IVal = 0;
+        }
     }
 
     /* Convert into a hex number */
@@ -219,25 +219,25 @@ static void ParseGVarArg (StrBuf* T, unsigned Arg)
     /* Parse the symbol name parameter and check the type */
     SymEntry* Sym = AsmGetSym (Arg, SC_STATIC);
     if (Sym == 0) {
-       /* Some sort of error */
-       return;
+        /* Some sort of error */
+        return;
     }
 
     /* Check for external linkage */
     if (Sym->Flags & (SC_EXTERN | SC_STORAGE | SC_FUNC)) {
-       /* External linkage or a function */
-       /* ### FIXME: Asm name should be generated by codegen */
-       SB_AppendChar (T, '_');
-       SB_AppendStr (T, Sym->Name);
+        /* External linkage or a function */
+        /* ### FIXME: Asm name should be generated by codegen */
+        SB_AppendChar (T, '_');
+        SB_AppendStr (T, Sym->Name);
     } else if (Sym->Flags & SC_REGISTER) {
         char Buf[32];
         xsprintf (Buf, sizeof (Buf), "regbank+%d", Sym->V.R.RegOffs);
         SB_AppendStr (T, Buf);
     } else {
-       /* Static variable */
-       char Buf [16];
-       xsprintf (Buf, sizeof (Buf), "L%04X", Sym->V.Label);
-       SB_AppendStr (T, Buf);
+        /* Static variable */
+        char Buf [16];
+        xsprintf (Buf, sizeof (Buf), "L%04X", Sym->V.Label);
+        SB_AppendStr (T, Buf);
     }
 }
 
@@ -252,8 +252,8 @@ static void ParseLVarArg (StrBuf* T, unsigned Arg)
     /* Parse the symbol name parameter and check the type */
     SymEntry* Sym = AsmGetSym (Arg, SC_AUTO);
     if (Sym == 0) {
-       /* Some sort of error */
-       return;
+        /* Some sort of error */
+        return;
     }
 
     /* The symbol may be a parameter to a variadic function. In this case, we
@@ -261,9 +261,9 @@ static void ParseLVarArg (StrBuf* T, unsigned Arg)
      * if this is the case.
      */
     if ((Sym->Flags & SC_PARAM) == SC_PARAM && F_IsVariadic (CurrentFunc)) {
-       Error ("Argument %u has no fixed stack offset", Arg);
-       AsmErrorSkip ();
-       return;
+        Error ("Argument %u has no fixed stack offset", Arg);
+        AsmErrorSkip ();
+        return;
     }
 
     /* Calculate the current offset from SP */
@@ -287,11 +287,11 @@ static void ParseLabelArg (StrBuf* T, unsigned Arg attribute ((unused)))
 
     } else {
 
-       /* Add a new label symbol if we don't have one until now */
-               SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF);
+        /* Add a new label symbol if we don't have one until now */
+        SymEntry* Entry = AddLabelSym (CurTok.Ident, SC_REF);
 
-       /* Append the label name to the buffer */
-       SB_AppendStr (T, LocalLabelName (Entry->V.Label));
+        /* Append the label name to the buffer */
+        SB_AppendStr (T, LocalLabelName (Entry->V.Label));
 
         /* Eat the label name */
         NextToken ();
@@ -353,34 +353,34 @@ static void ParseAsm (void)
 
     /* Parse the statement. It may contain several lines and one or more
      * of the following place holders:
-     *   %b    - Numerical 8 bit value
-     *   %w    - Numerical 16 bit value
-     *   %l    - Numerical 32 bit value
-     *   %v    - Assembler name of a (global) variable
-     *   %o    - Stack offset of a (local) variable
-     *   %g    - Assembler name of a C label
+     *   %b     - Numerical 8 bit value
+     *   %w     - Numerical 16 bit value
+     *   %l     - Numerical 32 bit value
+     *   %v     - Assembler name of a (global) variable
+     *   %o     - Stack offset of a (local) variable
+     *   %g     - Assembler name of a C label
      *   %s     - Any argument converted to a string (almost)
-     *   %%    - The % sign
+     *   %%     - The % sign
      */
     Arg = 0;
     while ((C = SB_Get (&S)) != '\0') {
 
-               /* If it is a newline, the current line is ready to go */
-               if (C == '\n') {
+        /* If it is a newline, the current line is ready to go */
+        if (C == '\n') {
 
-                   /* Pass it to the backend and start over */
-                   g_asmcode (&T);
-                   SB_Clear (&T);
+            /* Pass it to the backend and start over */
+            g_asmcode (&T);
+            SB_Clear (&T);
 
-               } else if (C == '%') {
+        } else if (C == '%') {
 
-                   /* Format specifier */
-                   ++Arg;
+            /* Format specifier */
+            ++Arg;
             C = SB_Get (&S);
             switch (C) {
                 case '%':   SB_AppendChar (&T, '%');    break;
                 case 'b':   ParseByteArg (&T, Arg);     break;
-               case 'g':   ParseLabelArg (&T, Arg);    break;
+                case 'g':   ParseLabelArg (&T, Arg);    break;
                 case 'l':   ParseLongArg (&T, Arg);     break;
                 case 'o':   ParseLVarArg (&T, Arg);     break;
                 case 's':   ParseStrArg (&T, Arg);      break;
@@ -392,17 +392,17 @@ static void ParseAsm (void)
                     goto Done;
             }
 
-       } else {
+        } else {
 
-           /* A normal character, just copy it */
-           SB_AppendChar (&T, C);
+            /* A normal character, just copy it */
+            SB_AppendChar (&T, C);
 
-       }
+        }
     }
 
     /* If the target buffer is not empty, we have a last line in there */
     if (!SB_IsEmpty (&T)) {
-       g_asmcode (&T);
+        g_asmcode (&T);
     }
 
 Done:
@@ -430,18 +430,18 @@ void AsmStatement (void)
     /* String literal */
     if (CurTok.Tok != TOK_SCONST) {
 
-       /* Print a diagnostic */
-       Error ("String literal expected");
+        /* Print a diagnostic */
+        Error ("String literal expected");
 
-       /* Try some smart error recovery: Skip tokens until we reach the
-        * enclosing paren, or a semicolon.
-        */
-       AsmErrorSkip ();
+        /* Try some smart error recovery: Skip tokens until we reach the
+         * enclosing paren, or a semicolon.
+         */
+        AsmErrorSkip ();
 
     } else {
 
-       /* Parse the ASM statement */
-       ParseAsm ();
+        /* Parse the ASM statement */
+        ParseAsm ();
     }
 
     /* Closing paren needed */