[cc65] externzp decls

Date view Thread view Subject view

From: Tim Vanderhoek (vanderh_at_ecf.utoronto.ca)
Date: 2000-01-29 21:20:37


I couldn't find any way to tell the cc65 compiler that an extern
variable belonged on the zpage.

I added an "externzp" extension to do this.  This is probably not the
best way to do it --- there should be something more general.  Say
"extern __zeropage__ v;" or even "__zeropage__ v;" to _request_ that
a new variable be put into some zeropage segment.

I haven't tested this extensively.  One can, of course, argue that
it's even silly since if one cares enough to have something on the
zpage, they should also care enough to write the whole thing in asm...  :)

I don't know if Uz (aka "You") want to add this or not, given the
preceeding two paras.  However, if there is something subtly broken by
this, at least, I'd prefer to know now rather than get strange errors
someday later...  :)

Relative to 2.4.0.  I see I also screwed-up some tabs vs. spaces and
the numbering in scanner.h needs to be redone.  These are easy to
fix...  I'm a little too lazy at the moment.  :)

diff -ru4 cc65-2.4.0-orig/cc65/declare.c cc65-2.4.0/cc65/declare.c
--- cc65-2.4.0-orig/cc65/declare.c	Sat Jan  8 11:46:22 2000
+++ cc65-2.4.0/cc65/declare.c	Sat Jan 29 15:02:51 2000
@@ -291,8 +291,13 @@
     	    gettok ();
     	    return (SC_EXTERN | SC_STATIC);
     	    break;
 
+	case EXTERNZP:
+	    gettok ();
+	    return (SC_EXTERN | SC_STATIC | SC_ZEROPAGE);
+	    break;
+
     	case STATIC:
     	    gettok ();
     	    return SC_STATIC;
 
diff -ru4 cc65-2.4.0-orig/cc65/scanner.c cc65-2.4.0/cc65/scanner.c
--- cc65-2.4.0-orig/cc65/scanner.c	Sun Jan  9 14:50:22 2000
+++ cc65-2.4.0/cc65/scanner.c	Sat Jan 29 14:46:24 2000
@@ -71,8 +71,9 @@
     { "double",        	DOUBLE,	       	TT_C   	},
     { "else",  	       	ELSE,  	       	TT_C  	},
     { "enum",  	       	ENUM,  	       	TT_C  	},
     { "extern",        	EXTERN,	       	TT_C   	},
+    { "externzp",       EXTERNZP,       TT_EXT  },
     { "fastcall",      	FASTCALL,	TT_EXT 	},
     { "float", 	       	FLOAT, 	       	TT_C  	},
     { "for",   	       	FOR,   	       	TT_C  	},
     { "goto",  	       	GOTO,  	       	TT_C  	},
diff -ru4 cc65-2.4.0-orig/cc65/scanner.h cc65-2.4.0/cc65/scanner.h
--- cc65-2.4.0-orig/cc65/scanner.h	Sun Jan  9 14:50:22 2000
+++ cc65-2.4.0/cc65/scanner.h	Sat Jan 29 14:30:43 2000
@@ -24,8 +24,9 @@
 #define CEOF 		0
 
 #define AUTO	     	10
 #define EXTERN	     	11
+#define EXTERNZP	103
 #define REGISTER     	12
 #define STATIC	     	13
 #define TYPEDEF	     	14
 #define ENUM		15


-- 
Signature withheld by request of author.
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:35 CET