1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-02 15:29:33 +00:00

Don't print a zero offset in labels

git-svn-id: svn://svn.cc65.org/cc65/trunk@1197 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2002-03-17 14:32:19 +00:00
parent 05753557ce
commit cf23f0937c

View File

@ -96,31 +96,39 @@ static void CheckLocalOffs (unsigned Offs)
static char* GetLabelName (unsigned flags, unsigned long label, long offs) static const char* GetLabelName (unsigned Flags, unsigned long Label, long Offs)
{ {
static char lbuf [256]; /* Label name */ static char Buf [256]; /* Label name */
/* Create the correct label name */ /* Create the correct label name */
switch (flags & CF_ADDRMASK) { switch (Flags & CF_ADDRMASK) {
case CF_STATIC: case CF_STATIC:
/* Static memory cell */ /* Static memory cell */
xsprintf (lbuf, sizeof (lbuf), "%s%+ld", LocalLabelName (label), offs); if (Offs) {
xsprintf (Buf, sizeof (Buf), "%s%+ld", LocalLabelName (Label), Offs);
} else {
xsprintf (Buf, sizeof (Buf), "%s", LocalLabelName (Label));
}
break; break;
case CF_EXTERNAL: case CF_EXTERNAL:
/* External label */ /* External label */
xsprintf (lbuf, sizeof (lbuf), "_%s%+ld", (char*) label, offs); if (Offs) {
xsprintf (Buf, sizeof (Buf), "_%s%+ld", (char*) Label, Offs);
} else {
xsprintf (Buf, sizeof (Buf), "_%s", (char*) Label);
}
break; break;
case CF_ABSOLUTE: case CF_ABSOLUTE:
/* Absolute address */ /* Absolute address */
xsprintf (lbuf, sizeof (lbuf), "$%04X", (unsigned)((label+offs) & 0xFFFF)); xsprintf (Buf, sizeof (Buf), "$%04X", (int)((Label+Offs) & 0xFFFF));
break; break;
case CF_REGVAR: case CF_REGVAR:
/* Variable in register bank */ /* Variable in register bank */
xsprintf (lbuf, sizeof (lbuf), "regbank+%u", (unsigned)((label+offs) & 0xFFFF)); xsprintf (Buf, sizeof (Buf), "regbank+%u", (unsigned)((Label+Offs) & 0xFFFF));
break; break;
default: default:
@ -128,13 +136,13 @@ static char* GetLabelName (unsigned flags, unsigned long label, long offs)
} }
/* Return a pointer to the static buffer */ /* Return a pointer to the static buffer */
return lbuf; return Buf;
} }
/*****************************************************************************/ /*****************************************************************************/
/* Pre- and postamble */ /* Pre- and postamble */
/*****************************************************************************/ /*****************************************************************************/
@ -656,7 +664,7 @@ void g_getstatic (unsigned flags, unsigned long label, long offs)
/* Fetch an static memory cell into the primary register */ /* Fetch an static memory cell into the primary register */
{ {
/* Create the correct label name */ /* Create the correct label name */
char* lbuf = GetLabelName (flags, label, offs); const char* lbuf = GetLabelName (flags, label, offs);
/* Check the size and generate the correct load operation */ /* Check the size and generate the correct load operation */
switch (flags & CF_TYPE) { switch (flags & CF_TYPE) {
@ -905,7 +913,7 @@ void g_putstatic (unsigned flags, unsigned long label, long offs)
/* Store the primary register into the specified static memory cell */ /* Store the primary register into the specified static memory cell */
{ {
/* Create the correct label name */ /* Create the correct label name */
char* lbuf = GetLabelName (flags, label, offs); const char* lbuf = GetLabelName (flags, label, offs);
/* Check the size and generate the correct store operation */ /* Check the size and generate the correct store operation */
switch (flags & CF_TYPE) { switch (flags & CF_TYPE) {
@ -1438,7 +1446,7 @@ void g_addstatic (unsigned flags, unsigned long label, long offs)
unsigned L; unsigned L;
/* Create the correct label name */ /* Create the correct label name */
char* lbuf = GetLabelName (flags, label, offs); const char* lbuf = GetLabelName (flags, label, offs);
switch (flags & CF_TYPE) { switch (flags & CF_TYPE) {
@ -1487,7 +1495,7 @@ void g_addeqstatic (unsigned flags, unsigned long label, long offs,
/* Emit += for a static variable */ /* Emit += for a static variable */
{ {
/* Create the correct label name */ /* Create the correct label name */
char* lbuf = GetLabelName (flags, label, offs); const char* lbuf = GetLabelName (flags, label, offs);
/* Check the size and determine operation */ /* Check the size and determine operation */
switch (flags & CF_TYPE) { switch (flags & CF_TYPE) {
@ -1730,7 +1738,7 @@ void g_subeqstatic (unsigned flags, unsigned long label, long offs,
/* Emit -= for a static variable */ /* Emit -= for a static variable */
{ {
/* Create the correct label name */ /* Create the correct label name */
char* lbuf = GetLabelName (flags, label, offs); const char* lbuf = GetLabelName (flags, label, offs);
/* Check the size and determine operation */ /* Check the size and determine operation */
switch (flags & CF_TYPE) { switch (flags & CF_TYPE) {
@ -1983,7 +1991,7 @@ void g_addaddr_static (unsigned flags, unsigned long label, long offs)
/* Add the address of a static variable to ax */ /* Add the address of a static variable to ax */
{ {
/* Create the correct label name */ /* Create the correct label name */
char* lbuf = GetLabelName (flags, label, offs); const char* lbuf = GetLabelName (flags, label, offs);
/* Add the address to the current ax value */ /* Add the address to the current ax value */
AddCodeLine ("clc"); AddCodeLine ("clc");
@ -4013,7 +4021,7 @@ void g_strlen (unsigned flags, unsigned long val, long offs)
if (flags & CF_CONST) { if (flags & CF_CONST) {
/* The address of the string is constant. Create the correct label name */ /* The address of the string is constant. Create the correct label name */
char* lbuf = GetLabelName (flags, val, offs); const char* lbuf = GetLabelName (flags, val, offs);
/* Generate the strlen code */ /* Generate the strlen code */
AddCodeLine ("ldy #$FF"); AddCodeLine ("ldy #$FF");