commit 55210afb602705a30acb416bc224664ed56dfb67
Author:     Roberto E. Vargas Caballero <k...@shike2.com>
AuthorDate: Sun Jan 24 22:32:01 2016 +0100
Commit:     Roberto E. Vargas Caballero <k...@shike2.com>
CommitDate: Sun Jan 24 22:32:01 2016 +0100

    [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.

diff --git a/cc2/arch/z80/code.c b/cc2/arch/z80/code.c
index 448b988..cfe2228 100644
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
@@ -38,7 +38,9 @@ void
 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 @@ label(Symbol *sym)
                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

Reply via email to