This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[z80][committed] fix some issues with equ directives


Hi,
It was brought to my attention that z80-as rejects some valid uses 
of equ as 
infix operator. I have fixed this problem as well as an off-by-one 
error in the line 
numbers in the symbol listing of symbols that are defined with equ.
I have also added a test case for the parsing of equ directives

Arnold Metselaar

src/gas/Changelog:
2009-10-25  Arnold Metselaar  <arnold.metselaar@planet.nl>

	* config/tc-z80.c (z80_start_line_hook): Fix parsing of 'equ' or
	 'defl' in cases where the space between the keyword and the
	 expression has been scrubbed away. 
	 Do not check whether a symbol is redefined with 'equ' here;
	 the function equals takes an argument indicating whether
	 redefinitions are allowed. 
	Only call LISTING_NEWLINE if needed, and then after the call to
	bump_line_counters. 

src/gas/testsuite/ChangeLog:
2009-10-25  Arnold Metselaar  <arnold.metselaar@planet.nl>

	* gas/z80/equ.d, gas/z80/equ.s: Added test of parsing equ 
directives.
	* gas/z80/z80.exp: Run it.

	* gas/z80/redef.d: Expect little endian output only.	

Index: config/tc-z80.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-z80.c,v
retrieving revision 1.10
diff -u -p -r1.10 tc-z80.c
--- config/tc-z80.c     2 Sep 2009 07:24:21 -0000       1.10
+++ config/tc-z80.c     25 Oct 2009 15:53:33 -0000
@@ -253,10 +253,8 @@ z80_start_line_hook (void)
     {
       char c, *rest, *line_start;
       int len;
-      symbolS * symbolP;

       line_start = input_line_pointer;
-      LISTING_NEWLINE ();
       if (ignore_input ())
        return 0;

@@ -275,20 +273,17 @@ z80_start_line_hook (void)
        len = 4;
       else
        len = 0;
-      if (len && (rest[len] == ' ' || rest[len] == '\t'))
+      if (len && (!ISALPHA(rest[len]) ) )
        {
          /* Handle assignment here.  */
-         input_line_pointer = rest + len;
          if (line_start[-1] == '\n')
-           bump_line_counters ();
-         /* Most Z80 assemblers require the first definition of a
-             label to use "EQU" and redefinitions to have "DEFL".  
*/
-         if (len == 3 && (symbolP = symbol_find (line_start)) != 
NULL)
            {
-             if (S_IS_DEFINED (symbolP) || symbol_equated_p 
(symbolP))
-               as_bad (_("symbol `%s' is already defined"), 
line_start);
+             bump_line_counters ();
+             LISTING_NEWLINE ();
            }
-         equals (line_start, 1);
+         input_line_pointer = rest + len - 1;
+         /* Allow redefining with "DEFL" (len == 4), but not 
with "EQU".  */
+         equals (line_start, len == 4);
          return 1;
        }
       else


Index: gas/z80/redef.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/z80/redef.d,v
retrieving revision 1.1
diff -u -r1.1 redef.d
--- gas/z80/redef.d     25 Oct 2005 17:40:18 -0000      1.1
+++ gas/z80/redef.d     25 Oct 2009 14:03:38 -0000
@@ -4,5 +4,5 @@
 .*: .*

 Contents of section .data:
- 0000 00000000 0[04]00000[04] 0[08]00000[08] 0[0c]00000[0c]
[   ]+................[     ]*
+ 0000 00000000 04000000 08000000 0c000000[     ]+................
[     ]*
 #pass
Index: gas/z80/z80.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/z80/z80.exp,v
retrieving revision 1.6
diff -u -r1.6 z80.exp
--- gas/z80/z80.exp     14 Sep 2008 14:04:00 -0000      1.6
+++ gas/z80/z80.exp     25 Oct 2009 14:03:38 -0000
@@ -3,6 +3,8 @@
 if [istarget z80-*-*] then {
 # test redefinitions
     run_dump_test "redef"
+# test parsing of equ definitions
+    run_dump_test "equ"
 # test parsing of " and '
     run_dump_test "quotes"
 # test suffixes


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]