[hackers] [scc] [cc2-z80] Small format improvement || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 26 Jan 2016 14:22:11 +0100 (CET)

commit d87648e6d3b8b6d2f6f430a7ef1c4f378feeae09
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jan 26 14:19:12 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jan 26 14:19:12 2016 +0100

    [cc2-z80] Small format improvement

diff --git a/cc2/arch/z80/code.c b/cc2/arch/z80/code.c
index c453822..c35202b 100644
--- a/cc2/arch/z80/code.c
+++ b/cc2/arch/z80/code.c
_AT_@ -35,23 +35,20 @@ symname(Symbol *sym)
 {
         static char name[IDENTSIZ+1];
         static unsigned short id;
- int k = sym->kind;
 
         if (sym->name) {
                 switch (sym->kind) {
                 case GLOB:
                 case EXTRN:
                         snprintf(name, sizeof(name), "_%s", sym->name);
- return name;;
+ return name;
                 case PRIVAT:
                         return sym->name;
                 }
         }
 
- if (sym->numid == 0) {
- if ((sym->numid = ++id) == 0)
- error(EIDOVER);
- }
+ if (sym->numid == 0 && (sym->numid = ++id) == 0)
+ error(EIDOVER);
         sprintf(name, ".%d", sym->numid);
 
         return name;
_AT_@ -79,10 +76,10 @@ label(Symbol *sym)
 
         switch (sym->kind) {
         case EXTRN:
- printf("\tEXTRN %s\n", name);
+ printf("\tEXTRN\t%s\n", name);
                 return;
         case GLOB:
- printf("\tPUBLIC %s\n", name);
+ printf("\tPUBLIC\t%s\n", name);
                 break;
         }
 
_AT_@ -90,26 +87,17 @@ label(Symbol *sym)
 }
 
 static void
-emitstring(Node *np)
-{
- /*In z80 we can ignore the aligment */
- printf("\"%s\"", np->u.s);
- free(np->u.s);
- np->u.s = NULL;
-}
-
-static void
 emitconst(Node *np)
 {
         switch (np->type.size) {
         case 1:
- printf("%02X", (int) np->u.i & 0xFF);
+ printf("%d", (int) np->u.i & 0xFF);
                 break;
         case 2:
- printf("%04X", (int) np->u.i & 0xFFFF);
+ printf("%d", (int) np->u.i & 0xFFFF);
                 break;
         case 4:
- printf("%08X", (long) np->u.i & 0xFFFFFFFF);
+ printf("%ld", (long) np->u.i & 0xFFFFFFFF);
                 break;
         default:
                 abort();
_AT_@ -124,7 +112,9 @@ emittree(Node *np)
 
         switch (np->op) {
         case OSTRING:
- emitstring(np);
+ printf("\"%s\"", np->u.s);
+ free(np->u.s);
+ np->u.s = NULL;
                 break;
         case OCONST:
                 emitconst(np);
_AT_@ -143,7 +133,6 @@ emittree(Node *np)
         }
 }
 
-
 static void
 size2asm(Type *tp)
 {
Received on Tue Jan 26 2016 - 14:22:11 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 26 2016 - 14:24:41 CET