]> Shamusworld >> Repos - rmac/blobdiff - debug.c
ELF support for RMAC.
[rmac] / debug.c
diff --git a/debug.c b/debug.c
index 7d498c77eaa36d6fce4650d995222d449bd482ce..6359cfbc2bddf5909807c3d65d20262d876fa9fe 100644 (file)
--- a/debug.c
+++ b/debug.c
@@ -1,9 +1,9 @@
 //
 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
 // DEBUG.C - Debugging Messages
-// Copyright (C) 199x Landon Dyer, 2011-2012 Reboot and Friends
+// Copyright (C) 199x Landon Dyer, 2011-2017 Reboot and Friends
 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
-// Source Utilised with the Kind Permission of Landon Dyer
+// Source utilised with the kind permission of Landon Dyer
 //
 
 #include "debug.h"
@@ -18,7 +18,7 @@ static int siztab[4] = { 3, 5, 9, 9 };
 
 
 //
-// Print 'c' Visibly
+// Print 'c' visibly
 //
 int visprt(char c)
 {
@@ -43,8 +43,7 @@ TOKEN * printexpr(TOKEN * tp)
                        switch ((int)*tp++)
                        {
                        case SYMBOL:
-//                             printf("`%s' ", ((SYM *)*tp)->sname);
-                               printf("`%s' ", symbolPtr[*tp]->sname);
+                               printf("'%s' ", symbolPtr[*tp]->sname);
                                tp++;
                                break;
                        case CONST:
@@ -61,7 +60,6 @@ TOKEN * printexpr(TOKEN * tp)
                }
        }
 
-//     printf(";\n");
        return tp + 1;
 }
 
@@ -88,34 +86,29 @@ int chdump(CHUNK * ch, int format)
 int fudump(CHUNK * ch)
 {
        PTR p;
-       char * ep;
-       WORD attr, esiz;
-       WORD line, file;
-       LONG loc;
 
        for(; ch!=NULL;)
        {
                p.cp = ch->chptr;
-               ep = ch->chptr + ch->ch_size;
+               uint8_t * ep = ch->chptr + ch->ch_size;
 
                while (p.cp < ep)
                {
-                       attr = *p.wp++;
-                       loc = *p.lp++;
-                       file = *p.wp++;
-                       line = *p.wp++;
+                       uint16_t attr = *p.wp++;
+                       uint32_t loc = *p.lp++;
+                       uint16_t file = *p.wp++;
+                       uint16_t line = *p.wp++;
 
                        printf("$%04X $%08X %d.%d: ", (int)attr, loc, (int)file, (int)line);
 
                        if (attr & FU_EXPR)
                        {
-                               esiz = *p.wp++;
+                               uint16_t esiz = *p.wp++;
                                printf("(%d long) ", (int)esiz);
                                p.tk = printexpr(p.tk);
                        }
                        else
                        {
-//                             printf("`%s' ;\n", (*p.sy)->sname);
                                printf("`%s' ;", (*p.sy)->sname);
                                p.sy++;
                        }
@@ -152,14 +145,11 @@ int mudump(void)
 
        for(mch=firstmch; mch!=NULL; mch=mch->mcnext)
        {
-               printf("mch=$%08X mcptr=$%08X mcalloc=$%X mcused=$%X\n",
-                       (uint32_t)mch,
-                       (mch->mcptr.lw),
-                       mch->mcalloc,
-                       (mch->mcused));
+               printf("mch=$%p mcptr=$%08X mcalloc=$%X mcused=$%X\n",
+                       mch, (mch->mcptr.lw), mch->mcalloc, (mch->mcused));
 
                p = mch->mcptr;
-               
+
                for(;;)
                {
                        w = *p.wp++;
@@ -191,12 +181,14 @@ int mudump(void)
 
 
 //
-// Dump memory from 'start' for 'count' bytes; `flg' is the following ORed together:
+// Dump memory from 'start' for 'count' bytes; `flg' is the following ORed
+// together:
 // 0 - bytes
 // 1 - words
 // 2 - longwords
-// 
-// if `base' is not -1, then print it at the start of each line, incremented accordingly.
+//
+// if `base' is not -1, then print it at the start of each line, incremented
+// accordingly.
 //
 int mdump(char * start, LONG count, int flg, LONG base)
 {
@@ -211,7 +203,7 @@ int mdump(char * start, LONG count, int flg, LONG base)
                        {
                                printf("  ");
 
-                               while(j < i)
+                               while (j < i)
                                visprt(start[j++]);
 
                                putchar('\n');
@@ -227,7 +219,7 @@ int mdump(char * start, LONG count, int flg, LONG base)
                {
                case 0:
                        printf("%02X ", start[i] & 0xff);
-                       ++i;
+                       i++;
                        break;
                case 1:
                        printf("%02X%02X ", start[i] & 0xff, start[i+1] & 0xff);
@@ -246,18 +238,18 @@ int mdump(char * start, LONG count, int flg, LONG base)
                        base += 1 << (flg & 3);
        }
 
-       // Print remaining bit of ascii; the hairy expression computes the number of
-       // spaces to print to make the ascii line up nicely.
+       // Print remaining bit of ASCII; the hairy expression computes the number
+       // of spaces to print to make the ASCII line up nicely.
        if (j != i)
        {
                k = ((16 - (i - j)) / (1 << (flg & 3))) * siztab[flg & 3];
 
-               while(k--)
+               while (k--)
                        putchar(' ');
 
                printf("  ");
 
-               while(j < i)
+               while (j < i)
                        visprt(start[j++]);
 
                putchar('\n');
@@ -293,34 +285,34 @@ int dumptok(TOKEN * tk)
                case STRING:                                       // STRING <address>
                        printf("STRING='%s'", string[*tk++]);
                        break;
-               case SYMBOL:                                       // SYMBOL <address> 
+               case SYMBOL:                                       // SYMBOL <address>
                        printf("SYMBOL='%s'", string[*tk++]);
                        break;
-               case EOL:                                          // End of line 
+               case EOL:                                          // End of line
                        printf("EOL");
                        break;
                case TKEOF:                                        // End of file (or macro)
                        printf("TKEOF");
                        break;
-               case DEQUALS:                                      // == 
+               case DEQUALS:                                      // ==
                        printf("DEQUALS");
                        break;
-               case DCOLON:                                       // :: 
+               case DCOLON:                                       // ::
                        printf("DCOLON");
                        break;
-               case GE:                                           // >= 
+               case GE:                                           // >=
                        printf("GE");
                        break;
-               case LE:                                           // <= 
+               case LE:                                           // <=
                        printf("LE");
                        break;
-               case NE:                                           // <> or != 
+               case NE:                                           // <> or !=
                        printf("NE");
                        break;
-               case SHR:                                          // >> 
+               case SHR:                                          // >>
                        printf("SHR");
                        break;
-               case SHL:                                          // << 
+               case SHL:                                          // <<
                        printf("SHL");
                        break;
                default:
@@ -336,13 +328,11 @@ int dumptok(TOKEN * tk)
 
 
 //
-// Dump Everything
+// Dump everything
 //
 int dump_everything(void)
 {
-       int i;
-
-       for(i=1; i<NSECTS; i++)
+       for(int i=1; i<NSECTS; i++)
        {
                if (sect[i].scattr & SUSED)
                {
@@ -359,7 +349,7 @@ int dump_everything(void)
 
        printf("\nMarks:\n");
        mudump();                                                               // Dump marks
-       printf("Total memory allocated=$%X\n", amemtot);
 
        return 0;
 }
+