gnupic: Thread: Local symbols


[<<] [<] Page 1 of 1 [>] [>>]
Subject: Local symbols
From: "George M. Gallant" ####@####.####
Date: 23 Nov 2003 03:56:20 -0000
Message-Id: <3FC0299C.5010207@comcast.net>

Does gpasm support the use of local symbols? I did not find any info in 
the manual.

Thanks,
    George

>
>  
>


Subject: Re: Local symbols
From: Craig Franklin ####@####.####
Date: 23 Nov 2003 04:37:41 -0000
Message-Id: <1069560650.31377.1.camel@R2D2>

If you mean using the LOCAL directive in macros, Yes.

Check the mpasm manual.  A copy is on the gputils website.

On Sat, 2003-11-22 at 21:29, George M. Gallant wrote:
> Does gpasm support the use of local symbols? I did not find any info in 
> the manual.
> 
> Thanks,
>     George
> 
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
> 

Subject: Re: Local symbols
From: "George M. Gallant" ####@####.####
Date: 23 Nov 2003 05:54:49 -0000
Message-Id: <3FC04560.8040609@comcast.net>

Craig,

No. I was looking for the ability to use local symbols as code. The gnu 
motorola 68K
assembler allow for the "f" and "b" to numeric symbols. The borland x86 
assembler uses
the "@@" notation, and the Dec assembler uses thee "n$" notation. Very 
handy for
those of us who are unable to think up creative names. The scope of the 
symbols is limited
to the code space between two regular symbols.

Thanks,
    George

Craig Franklin wrote:

>If you mean using the LOCAL directive in macros, Yes.
>
>Check the mpasm manual.  A copy is on the gputils website.
>
>On Sat, 2003-11-22 at 21:29, George M. Gallant wrote:
>  
>
>>Does gpasm support the use of local symbols? I did not find any info in 
>>the manual.
>>
>>Thanks,
>>    George
>>
>>    
>>
>>> 
>>>
>>>      
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ####@####.####
>>For additional commands, e-mail: ####@####.####
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ####@####.####
>For additional commands, e-mail: ####@####.####
>
>
>  
>


Subject: Re: Local symbols
From: Craig Franklin ####@####.####
Date: 24 Nov 2003 01:59:02 -0000
Message-Id: <1069637528.14701.2.camel@R2D2>

The only local symbols in absolute mode are in macros.  It is what I
referred to earlier.

If you use relocatable mode all symbols are local, unless you use the
GLOBAL directive.

On Sat, 2003-11-22 at 23:28, George M. Gallant wrote:
> Craig,
> 
> No. I was looking for the ability to use local symbols as code. The gnu 
> motorola 68K
> assembler allow for the "f" and "b" to numeric symbols. The borland x86 
> assembler uses
> the "@@" notation, and the Dec assembler uses thee "n$" notation. Very 
> handy for
> those of us who are unable to think up creative names. The scope of the 
> symbols is limited
> to the code space between two regular symbols.
> 
> Thanks,
>     George
> 
> Craig Franklin wrote:
> 
> >If you mean using the LOCAL directive in macros, Yes.
> >
> >Check the mpasm manual.  A copy is on the gputils website.
> >
> >On Sat, 2003-11-22 at 21:29, George M. Gallant wrote:
> >  
> >
> >>Does gpasm support the use of local symbols? I did not find any info in 
> >>the manual.
> >>
> >>Thanks,
> >>    George
> >>
> >>    
> >>
> >>> 
> >>>
> >>>      
> >>>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: ####@####.####
> >>For additional commands, e-mail: ####@####.####
> >>
> >>    
> >>
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: ####@####.####
> >For additional commands, e-mail: ####@####.####
> >
> >
> >  
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
> 

Subject: Local symbols
From: "George M. Gallant" ####@####.####
Date: 7 Nov 2004 01:43:27 +0000
Message-Id: <418D7DAD.6020401@comcast.net>

Craig,

Have you been able to look at the local symbols patch? I have a number of
math routines to check into the pc16 port of sdcc which use local symbols.
Vangelis Roakes just released a file that uses the "@xxx" notation but not
quite as I envision.

George

--- gputils-0.12.3/gplink/map.c	2004-07-24 22:06:06.000000000 -0400
+++ gputils-20040917/gplink/map.c	2004-09-19 15:39:10.000000000 -0400
@@ -222,7 +222,8 @@
         storage = "static";
       }
 
-      map_line("%25s   %#08x %10s %10s %s",
+      if (strstr(symbol->name, "_@") != NULL)
+        map_line("%25s   %#08x %10s %10s %s",
                symbol->name,
                symbol->value,
                location,
--- gputils-0.12.3/libgputils/gpsymbol.c	2004-01-07 01:35:54.000000000 -0500
+++ gputils-20040917/libgputils/gpsymbol.c	2004-09-19 15:30:57.000000000 -0400
@@ -21,6 +21,34 @@
 
 #include "stdhdr.h"
 #include "libgputils.h"
+/*
+ * Function to convert a local symbol name starting with a '@' into
+ * a unique name based on the previous regular name
+ *
+ * "last_perm_name"_"sym_name"
+ *
+ * gmg 09/19/04
+ */
+
+char *last_perm_sym = "";
+
+char *make_local_name(char *sym_name)
+{
+  static char tmp_name[256];
+
+  if (*sym_name == '@')
+  {
+    strcpy(tmp_name, last_perm_sym);
+    strcat(tmp_name, "_");
+    strcat(tmp_name, sym_name);
+  }
+  else
+  {
+    strcpy(tmp_name, sym_name);
+  }
+  return(tmp_name);
+}
+
 
 /* Base the hash func on the 1st, 2nd, 3rd and last characters of the
    string, and its length. */
@@ -78,15 +106,19 @@
 struct symbol *add_symbol(struct symbol_table *table, char *name)
 {
   struct symbol *r;
-  int index = hashfunc(table, name);
+  int index;
+  char *tmp_name;
+  
+  tmp_name = make_local_name(name);
+  index = hashfunc(table, tmp_name);
 
   r = table->hash_table[index];
-  while (r && ((*table->compare)(name, r->name) != 0))
+  while (r && ((*table->compare)(tmp_name, r->name) != 0))
     r = r->next;
 
   if (!r) {     /* No match */
     r = malloc(sizeof(*r));
-    r->name = strdup(name);
+    r->name = strdup(tmp_name);
     r->next = table->hash_table[index];
     r->annotation = NULL;
     table->hash_table[index] = r;
@@ -103,9 +135,12 @@
 {
   struct symbol *r = NULL; 
   struct symbol *last = NULL;
-  int index = hashfunc(table, name);
+  int index;
   int found_symbol = 0;
 
+  name = make_local_name(name);
+  index = hashfunc(table, name);
+
   /* Search for the symbol */
   if (table != NULL) {
     r = table->hash_table[index];
@@ -134,12 +169,15 @@
 struct symbol *get_symbol(struct symbol_table *table, char *name)
 {
   struct symbol *r = NULL;
+  char *tmp_name;
+
+  tmp_name = make_local_name(name);
 
   if (table != NULL) {
-    int index = hashfunc(table, name);
+    int index = hashfunc(table, tmp_name);
 
     r = table->hash_table[index];
-    while (r && ((*table->compare)(name, r->name) != 0))
+    while (r && ((*table->compare)(tmp_name, r->name) != 0))
       r = r->next;
 
     /* If r is still NULL, we didn't match.  Try the prev table on the stack */
@@ -157,7 +195,15 @@
 
 char *get_symbol_name(struct symbol *s)
 {
-  return s->name;
+  char
+    *cp;
+
+  cp = strstr(s->name, "_@");
+  if (cp == NULL)
+    cp = s->name;
+  else
+    cp++;				/* get past the '_' character */
+  return(cp);
 }
 
 void *get_symbol_annotation(struct symbol *s)
Subject: Re: Local symbols
From: Vangelis Rokas ####@####.####
Date: 7 Nov 2004 09:43:51 +0000
Message-Id: <Pine.LNX.4.61.0411071143160.3926@odyssey>

On Sat, 6 Nov 2004, George M. Gallant wrote:

> Have you been able to look at the local symbols patch? I have a number of
> math routines to check into the pc16 port of sdcc which use local symbols.
> Vangelis Roakes just released a file that uses the "@xxx" notation but not
> quite as I envision.


George, why did you implement things to reset the local scope at each
regular label encountered? I understand that there are conflicts with labels
between different functions in the same source, but this shouldn't be a
problem. OTOH, reseting the local scope, and forcing the sole use of '@'
labels in a function isn't the expected behaviour for an assembler nor for
the compiler.

Perhaps you should use the source line the '@' label is enouctered in order
to create unique label symbols.

regards,
Vangelis
Subject: Re: Local symbols
From: Craig Franklin ####@####.####
Date: 7 Nov 2004 14:15:17 +0000
Message-Id: <418DDA04.9050807@users.sourceforge.net>

George M. Gallant wrote:

> Craig,
>
> Have you been able to look at the local symbols patch?


I have been really busy lately.  There are several patches I need to 
look at.

> I have a number of
> math routines to check into the pc16 port of sdcc which use local 
> symbols.
> Vangelis Roakes just released a file that uses the "@xxx" notation but 
> not
> quite as I envision.
>

Why do you need this notation for a compiler?  It should be capable of 
generating unique labels.

> George
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ####@####.####
>For additional commands, e-mail: ####@####.####
>

Subject: Re: Local symbols
From: Craig Franklin ####@####.####
Date: 7 Nov 2004 21:40:32 +0000
Message-Id: <418E425F.8020104@users.sourceforge.net>

George M. Gallant wrote:

> Graig,
>
> I don't need for the compiler generated code.

<snip>

Your patch modifies the general purpose symbol table functions in the 
library.  This type of change should be limited to the assembler.

I haven't seen your code, so it is unclear to me why this feature is 
needed.  There is a LOCAL directive for macros and the #v() notation can 
be used too.  Maybe send me your code so I can understand what you are 
trying to do.

> George
>
> Craig Franklin wrote:
>
>> George M. Gallant wrote:
>>
>>> Craig,
>>>
>>> Have you been able to look at the local symbols patch?
>>
>>
>>
>>
>> I have been really busy lately.  There are several patches I need to 
>> look at.
>>
>>> I have a number of
>>> math routines to check into the pc16 port of sdcc which use local 
>>> symbols.
>>> Vangelis Roakes just released a file that uses the "@xxx" notation 
>>> but not
>>> quite as I envision.
>>>
>>
>> Why do you need this notation for a compiler?  It should be capable 
>> of generating unique labels.
>>
>>> George
>>>
>>> ------------------------------------------------------------------------ 
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ####@####.####
>>> For additional commands, e-mail: ####@####.####
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ####@####.####
>> For additional commands, e-mail: ####@####.####
>>
>>
>
>
>

Subject: Local symbols
From: "George M. Gallant" ####@####.####
Date: 18 Jan 2008 01:23:22 -0000
Message-Id: <478FFF61.3040907@comcast.net>

A few years ago I implemented local symbols into gpasm Upon posting a 
notice I received
significant negative replies to drop the idea from general use. Back on 
PICs and ready
to hack the current version for my use.

My previous scheme used the "@" as a starting character and mangled the 
name to include
the previous regular symbol. This doesnot work when the code had macros 
with their version
of local symbols.

I am thinking about using the gnu assembler notation this time. Perhaps 
even making a gnu
compatible psuedo directive set. Any interest?

George
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.