shithub: scc

Download patch

ref: 55210afb602705a30acb416bc224664ed56dfb67
parent: d2b15f1ea22699cecc79a9cf2a10c236b807a191
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 24 17:32:01 EST 2016

[cc2-z80] Export/Import symbols

EXTRN is used to declared variables that are defined in another
module (or maybe in the same module), while PUBLIC it is used
to declare that a variable defined in the module must be
exported and being public for the other modules.

--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
@@ -38,7 +38,9 @@
 label(Symbol *sym)
 {
 	int seg, flags = sym->type.flags;
+	char *name = symname(sym);
 
+	putchar('\n');
 	if (flags & FUNF)
 		seg = CODESEG;
 	else if (flags & INITF)
@@ -47,7 +49,16 @@
 		seg = BSSSEG;
 	segment(seg);
 
-	printf("%s:\n", symname(sym));
+	switch (sym->kind) {
+	case EXTRN:
+		printf("\tEXTRN %s\n", name);
+		return;
+	case GLOB:
+		printf("\tPUBLIC %s\n", name);
+		break;
+	}
+
+	printf("%s:\n", name);
 }
 
 static void