Browse Source

+ also support local labels in the Z80 inline assembler reader

git-svn-id: branches/z80@44884 -
nickysn 5 years ago
parent
commit
e5f4419694
1 changed files with 32 additions and 24 deletions
  1. 32 24
      compiler/z80/raz80asm.pas

+ 32 - 24
compiler/z80/raz80asm.pas

@@ -174,7 +174,7 @@ Unit raz80asm;
           begin
           begin
             firsttoken:=FALSE;
             firsttoken:=FALSE;
             len:=0;
             len:=0;
-            { directive or local label }
+            { directive }
             if c = '.' then
             if c = '.' then
               begin
               begin
                 inc(len);
                 inc(len);
@@ -188,30 +188,18 @@ Unit raz80asm;
                     c:=current_scanner.asmgetchar;
                     c:=current_scanner.asmgetchar;
                   end;
                   end;
                 actasmpattern[0]:=chr(len);
                 actasmpattern[0]:=chr(len);
-                { this is a local label... }
-                if (c=':') and is_locallabel(actasmpattern) then
-                  begin
-                    { local variables are case sensitive }
-                    actasmtoken:=AS_LLABEL;
-                    c:=current_scanner.asmgetchar;
-                    firsttoken:=true;
-                    exit;
-                  end
                 { must be a directive }
                 { must be a directive }
-                else
+                if is_asmdirective(actasmpattern) then
+                 exit;
+                if is_targetdirective(actasmpattern) then
                   begin
                   begin
-                    if is_asmdirective(actasmpattern) then
-                     exit;
-                    if is_targetdirective(actasmpattern) then
-                      begin
-                        actasmtoken:=AS_TARGET_DIRECTIVE;
-                        exit;
-                      end;
-                    Message1(asmr_e_not_directive_or_local_symbol,actasmpattern);
+                    actasmtoken:=AS_TARGET_DIRECTIVE;
+                    exit;
                   end;
                   end;
+                Message1(asmr_e_not_directive_or_local_symbol,actasmpattern);
               end;
               end;
-            { only opcodes and global labels are allowed now. }
-            while c in ['A'..'Z','a'..'z','0'..'9','_'] do
+            { only opcodes, global and local labels are allowed now. }
+            while c in ['A'..'Z','a'..'z','0'..'9','_','@'] do
               begin
               begin
                 inc(len);
                 inc(len);
                 actasmpattern[len]:=c;
                 actasmpattern[len]:=c;
@@ -222,7 +210,11 @@ Unit raz80asm;
             { Label ? }
             { Label ? }
             if c = ':' then
             if c = ':' then
               begin
               begin
-                actasmtoken:=AS_LABEL;
+                { Local label ? }
+                if is_locallabel(actasmpattern) then
+                  actasmtoken:=AS_LLABEL
+                else
+                  actasmtoken:=AS_LABEL;
                 { let us point to the next character }
                 { let us point to the next character }
                 c:=current_scanner.asmgetchar;
                 c:=current_scanner.asmgetchar;
                 firsttoken:=true;
                 firsttoken:=true;
@@ -700,10 +692,19 @@ Unit raz80asm;
                   exit;
                   exit;
                 end;
                 end;
 
 
-              '@' :
+              '@' : { possiblities : - local label reference , such as in jmp @local1 }
+                    {                - @Result, @Code or @Data special variables.     }
                 begin
                 begin
-                  actasmtoken:=AS_AT;
+                  actasmpattern:=c;
                   c:=current_scanner.asmgetchar;
                   c:=current_scanner.asmgetchar;
+                  while c in  ['A'..'Z','a'..'z','0'..'9','_','@','$','&','?'] do
+                   begin
+                     actasmpattern:=actasmpattern + c;
+                     c:=current_scanner.asmgetchar;
+                   end;
+                  actasmpattern_origcase:=actasmpattern;
+                  uppervar(actasmpattern);
+                  actasmtoken:=AS_ID;
                   exit;
                   exit;
                 end;
                 end;
 
 
@@ -2274,6 +2275,13 @@ Unit raz80asm;
         { main loop }
         { main loop }
         repeat
         repeat
           case actasmtoken of
           case actasmtoken of
+            AS_LLABEL:
+              Begin
+                if CreateLocalLabel(actasmpattern,hl,true) then
+                  ConcatLabel(curlist,hl);
+                Consume(AS_LLABEL);
+              end;
+
             AS_LABEL:
             AS_LABEL:
               Begin
               Begin
                 if SearchLabel(upper(actasmpattern),hl,true) then
                 if SearchLabel(upper(actasmpattern),hl,true) then