bugZ80 assembler - Bugs: bug #65208, Label syntax is inconsistent

 
 

bug #65208: Label syntax is inconsistent

Submitter:  None
Submitted:  Wed 24 Jan 2024 07:32:13 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 24 Jan 2024 07:32:13 PM UTC, original submission:  

The code:

                 call p_foo
         p_foo:

fails

         foo.asm:1: error: `,' expected. Remainder of line: _foo
         foo.asm:3: error: unable to resolve reference: _foo
         * 2 errors found *


"p_foo" is considered a valid label by check_label()

    for (c = *p; isalnum (*c) || *c == '_' || *c == '.'; ++c)
    {
    }


In assemble():

            case CALL:
              if (!(r = rd_cc (&ptr)))
                {
                  wrtb (0xCD);
                }


            rd_cc (const char **p)
            {              
              const char *list[] = { "nz", "z", "nc", "c", "po", "pe", "p", "m", NULL };
              return indx (p, list, 0, NULL);
            }

rd_cc() is called to check for condition codes; e.g.:

          call p,bar


But indx() does not consider "_" to be part of a label:

      if (*check || (isalnum (check[-1]) && isalnum (input[0])))
        continue;

and so incorrectly parses the leading "p", leaving "_foo" unscanned.

Changing indx to:

      if (*check || (isalnum (check[-1]) && (isalnum (input[0]) || input[0] == '_' || input == '.')))
        continue;

allows indx to properly parse labels.







$ git diff
diff --git a/src/z80asm.c b/src/z80asm.c
index bfa46e4..256f291 100644
--- a/src/z80asm.c
+++ b/src/z80asm.c
@@ -190,7 +190,7 @@ indx (const char *ptr, const char *list, int error, const char **expr)
 
          ++check;
        }
-      if (*check || (isalnum (check[-1]) && isalnum (input[0])))
+      if (*check || (isalnum (check[-1]) && (isalnum (input[0]) || input[0] == '_' || input == '.')))
        continue;
       if (had_expr)
        {

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #55608:  z80asm.patch added by None (427B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

Only logged-in users can vote.

 

Follows 1 latest change.

Date Changed by Updated Field Previous Value => Replaced by
2024-01-24 None Attached File- Added z80asm.patch, #55608

Back to the top

Powered by Savane 3.14-f13d.
Corresponding source code