Merge pull request #2280 from pm100/seglist
Add segment ID to assembler listing for reloc code
This commit is contained in:
@@ -102,6 +102,7 @@ Short options:
|
|||||||
-mm model Set the memory model
|
-mm model Set the memory model
|
||||||
-o name Name the output file
|
-o name Name the output file
|
||||||
-s Enable smart mode
|
-s Enable smart mode
|
||||||
|
-S Generate segment offsets in listing
|
||||||
-t sys Set the target system
|
-t sys Set the target system
|
||||||
-v Increase verbosity
|
-v Increase verbosity
|
||||||
|
|
||||||
@@ -127,6 +128,7 @@ Long options:
|
|||||||
--no-utf8 Disable use of UTF-8 in diagnostics
|
--no-utf8 Disable use of UTF-8 in diagnostics
|
||||||
--pagelength n Set the page length for the listing
|
--pagelength n Set the page length for the listing
|
||||||
--relax-checks Relax some checks (see docs)
|
--relax-checks Relax some checks (see docs)
|
||||||
|
--segment-list Generate segment offsets in listing
|
||||||
--smart Enable smart mode
|
--smart Enable smart mode
|
||||||
--target sys Set the target system
|
--target sys Set the target system
|
||||||
--verbose Increase verbosity
|
--verbose Increase verbosity
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ unsigned char RelaxChecks = 0; /* Relax a few assembler checks */
|
|||||||
unsigned char StringEscapes = 0; /* Allow C-style escapes in strings */
|
unsigned char StringEscapes = 0; /* Allow C-style escapes in strings */
|
||||||
unsigned char LongJsrJmpRts = 0; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
|
unsigned char LongJsrJmpRts = 0; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
|
||||||
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
|
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
|
||||||
|
unsigned char SegList = 0; /* Show segments in listing */
|
||||||
unsigned char ExpandMacros = 0; /* Expand macros in listing */
|
unsigned char ExpandMacros = 0; /* Expand macros in listing */
|
||||||
|
|
||||||
/* Emulation features */
|
/* Emulation features */
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ extern unsigned char RelaxChecks; /* Relax a few assembler checks */
|
|||||||
extern unsigned char StringEscapes; /* Allow C-style escapes in strings */
|
extern unsigned char StringEscapes; /* Allow C-style escapes in strings */
|
||||||
extern unsigned char LongJsrJmpRts; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
|
extern unsigned char LongJsrJmpRts; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
|
||||||
extern unsigned char WarningsAsErrors; /* Error if any warnings */
|
extern unsigned char WarningsAsErrors; /* Error if any warnings */
|
||||||
|
extern unsigned char SegList; /* Show segments in listing */
|
||||||
extern unsigned char ExpandMacros; /* Expand macros in listing */
|
extern unsigned char ExpandMacros; /* Expand macros in listing */
|
||||||
|
|
||||||
/* Emulation features */
|
/* Emulation features */
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ static unsigned ListBytes = 12; /* Number of bytes to list for one line
|
|||||||
static int ListingEnabled = 1; /* Enabled if > 0 */
|
static int ListingEnabled = 1; /* Enabled if > 0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Code */
|
/* Code */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -105,6 +104,7 @@ void NewListingLine (const StrBuf* Line, unsigned char File, unsigned char Depth
|
|||||||
L->Next = 0;
|
L->Next = 0;
|
||||||
L->FragList = 0;
|
L->FragList = 0;
|
||||||
L->FragLast = 0;
|
L->FragLast = 0;
|
||||||
|
L->Seg = ActiveSeg->Num;
|
||||||
L->PC = GetPC ();
|
L->PC = GetPC ();
|
||||||
L->Reloc = GetRelocMode ();
|
L->Reloc = GetRelocMode ();
|
||||||
L->File = File;
|
L->File = File;
|
||||||
@@ -181,6 +181,7 @@ void InitListingLine (void)
|
|||||||
L = L->Next;
|
L = L->Next;
|
||||||
/* Set the values for this line */
|
/* Set the values for this line */
|
||||||
CHECK (L != 0);
|
CHECK (L != 0);
|
||||||
|
L->Seg = ActiveSeg->Num;
|
||||||
L->PC = GetPC ();
|
L->PC = GetPC ();
|
||||||
L->Reloc = GetRelocMode ();
|
L->Reloc = GetRelocMode ();
|
||||||
L->Output = (ListingEnabled > 0);
|
L->Output = (ListingEnabled > 0);
|
||||||
@@ -191,6 +192,7 @@ void InitListingLine (void)
|
|||||||
|
|
||||||
/* Set the values for this line */
|
/* Set the values for this line */
|
||||||
CHECK (LineCur != 0);
|
CHECK (LineCur != 0);
|
||||||
|
LineCur->Seg = ActiveSeg->Num;
|
||||||
LineCur->PC = GetPC ();
|
LineCur->PC = GetPC ();
|
||||||
LineCur->Reloc = GetRelocMode ();
|
LineCur->Reloc = GetRelocMode ();
|
||||||
LineCur->Output = (ListingEnabled > 0);
|
LineCur->Output = (ListingEnabled > 0);
|
||||||
@@ -276,7 +278,7 @@ static char* MakeLineHeader (char* H, const ListLine* L)
|
|||||||
{
|
{
|
||||||
char Mode;
|
char Mode;
|
||||||
char Depth;
|
char Depth;
|
||||||
|
unsigned Offset = 0;
|
||||||
/* Setup the PC mode */
|
/* Setup the PC mode */
|
||||||
Mode = (L->Reloc)? 'r' : ' ';
|
Mode = (L->Reloc)? 'r' : ' ';
|
||||||
|
|
||||||
@@ -284,8 +286,17 @@ static char* MakeLineHeader (char* H, const ListLine* L)
|
|||||||
Depth = (L->Depth < 10)? L->Depth + '0' : '+';
|
Depth = (L->Depth < 10)? L->Depth + '0' : '+';
|
||||||
|
|
||||||
/* Format the line */
|
/* Format the line */
|
||||||
sprintf (H, "%06lX%c %c", L->PC, Mode, Depth);
|
if (!SegList) {
|
||||||
memset (H+9, ' ', LINE_HEADER_LEN-9);
|
Offset = 9;
|
||||||
|
sprintf (H, "%06lX%c %c", L->PC, Mode, Depth);
|
||||||
|
} else if (L->Reloc) {
|
||||||
|
Offset = 12;
|
||||||
|
sprintf (H, "%02X.%06lX%c %c",L->Seg, L->PC, Mode, Depth);
|
||||||
|
} else {
|
||||||
|
Offset = 12;
|
||||||
|
sprintf (H, " %06lX%c %c", L->PC, Mode, Depth);
|
||||||
|
}
|
||||||
|
memset (H + Offset, ' ', LINE_HEADER_LEN - Offset - (SegList?0:3));
|
||||||
|
|
||||||
/* Return the buffer */
|
/* Return the buffer */
|
||||||
return H;
|
return H;
|
||||||
@@ -313,8 +324,11 @@ void CreateListing (void)
|
|||||||
PageNumber = 0;
|
PageNumber = 0;
|
||||||
PrintPageHeader (F, LineList);
|
PrintPageHeader (F, LineList);
|
||||||
|
|
||||||
/* Terminate the header buffer. The last byte will never get overwritten */
|
/* Terminate the header buffer. The last byte will never get overwritten
|
||||||
HeaderBuf [LINE_HEADER_LEN] = '\0';
|
** the - 3 adjust is for when the segnum gets prepended to the header.
|
||||||
|
*/
|
||||||
|
|
||||||
|
HeaderBuf [(SegList ? LINE_HEADER_LEN : LINE_HEADER_LEN - 3)] = '\0';
|
||||||
|
|
||||||
/* Walk through all listing lines */
|
/* Walk through all listing lines */
|
||||||
L = LineList;
|
L = LineList;
|
||||||
@@ -426,7 +440,7 @@ void CreateListing (void)
|
|||||||
L->PC += Chunk;
|
L->PC += Chunk;
|
||||||
|
|
||||||
/* Copy the bytes into the line */
|
/* Copy the bytes into the line */
|
||||||
P = HeaderBuf + 11;
|
P = HeaderBuf + (SegList?14: 11);
|
||||||
for (I = 0; I < Chunk; ++I) {
|
for (I = 0; I < Chunk; ++I) {
|
||||||
*P++ = *B++;
|
*P++ = *B++;
|
||||||
*P++ = *B++;
|
*P++ = *B++;
|
||||||
@@ -448,7 +462,9 @@ void CreateListing (void)
|
|||||||
L = L->Next;
|
L = L->Next;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (SegList) {
|
||||||
|
ListSegments (F);
|
||||||
|
}
|
||||||
/* Close the listing file */
|
/* Close the listing file */
|
||||||
(void) fclose (F);
|
(void) fclose (F);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ struct StrBuf;
|
|||||||
|
|
||||||
|
|
||||||
/* Length of the header of a listing line */
|
/* Length of the header of a listing line */
|
||||||
#define LINE_HEADER_LEN 24
|
#define LINE_HEADER_LEN 27
|
||||||
|
|
||||||
/* One listing line as it is stored in memory */
|
/* One listing line as it is stored in memory */
|
||||||
typedef struct ListLine ListLine;
|
typedef struct ListLine ListLine;
|
||||||
@@ -68,6 +68,7 @@ struct ListLine {
|
|||||||
ListLine* Next; /* Pointer to next line */
|
ListLine* Next; /* Pointer to next line */
|
||||||
Fragment* FragList; /* List of fragments for this line */
|
Fragment* FragList; /* List of fragments for this line */
|
||||||
Fragment* FragLast; /* Last entry in fragment list */
|
Fragment* FragLast; /* Last entry in fragment list */
|
||||||
|
unsigned Seg; /* Which segment this line targets */
|
||||||
unsigned long PC; /* Program counter for this line */
|
unsigned long PC; /* Program counter for this line */
|
||||||
unsigned char Reloc; /* Relocatable mode? */
|
unsigned char Reloc; /* Relocatable mode? */
|
||||||
unsigned char File; /* From which file is the line? */
|
unsigned char File; /* From which file is the line? */
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ static void Usage (void)
|
|||||||
" -mm model\t\t\tSet the memory model\n"
|
" -mm model\t\t\tSet the memory model\n"
|
||||||
" -o name\t\t\tName the output file\n"
|
" -o name\t\t\tName the output file\n"
|
||||||
" -s\t\t\t\tEnable smart mode\n"
|
" -s\t\t\t\tEnable smart mode\n"
|
||||||
|
" -S\t\t\t\tEnable segment offset listing\n"
|
||||||
" -t sys\t\t\tSet the target system\n"
|
" -t sys\t\t\tSet the target system\n"
|
||||||
" -v\t\t\t\tIncrease verbosity\n"
|
" -v\t\t\t\tIncrease verbosity\n"
|
||||||
" -x\t\t\t\tExpand macros\n"
|
" -x\t\t\t\tExpand macros\n"
|
||||||
@@ -132,6 +133,7 @@ static void Usage (void)
|
|||||||
" --no-utf8\t\t\tDisable use of UTF-8 in diagnostics\n"
|
" --no-utf8\t\t\tDisable use of UTF-8 in diagnostics\n"
|
||||||
" --pagelength n\t\tSet the page length for the listing\n"
|
" --pagelength n\t\tSet the page length for the listing\n"
|
||||||
" --relax-checks\t\tRelax some checks (see docs)\n"
|
" --relax-checks\t\tRelax some checks (see docs)\n"
|
||||||
|
" --segment-list\t\tEnable segment offset listing\n"
|
||||||
" --smart\t\t\tEnable smart mode\n"
|
" --smart\t\t\tEnable smart mode\n"
|
||||||
" --target sys\t\t\tSet the target system\n"
|
" --target sys\t\t\tSet the target system\n"
|
||||||
" --verbose\t\t\tIncrease verbosity\n"
|
" --verbose\t\t\tIncrease verbosity\n"
|
||||||
@@ -743,7 +745,12 @@ static void OptVersion (const char* Opt attribute ((unused)),
|
|||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void OptSeglist (const char* Opt attribute ((unused)),
|
||||||
|
const char* Arg attribute ((unused)))
|
||||||
|
/* Enable segment listing */
|
||||||
|
{
|
||||||
|
SegList = 1;
|
||||||
|
}
|
||||||
|
|
||||||
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
|
static void OptWarningsAsErrors (const char* Opt attribute ((unused)),
|
||||||
const char* Arg attribute ((unused)))
|
const char* Arg attribute ((unused)))
|
||||||
@@ -1074,6 +1081,7 @@ int main (int argc, char* argv [])
|
|||||||
{ "--no-utf8", 0, OptNoUtf8 },
|
{ "--no-utf8", 0, OptNoUtf8 },
|
||||||
{ "--pagelength", 1, OptPageLength },
|
{ "--pagelength", 1, OptPageLength },
|
||||||
{ "--relax-checks", 0, OptRelaxChecks },
|
{ "--relax-checks", 0, OptRelaxChecks },
|
||||||
|
{ "--segment-list", 0, OptSeglist },
|
||||||
{ "--smart", 0, OptSmart },
|
{ "--smart", 0, OptSmart },
|
||||||
{ "--target", 1, OptTarget },
|
{ "--target", 1, OptTarget },
|
||||||
{ "--verbose", 0, OptVerbose },
|
{ "--verbose", 0, OptVerbose },
|
||||||
@@ -1162,6 +1170,10 @@ int main (int argc, char* argv [])
|
|||||||
OptSmart (Arg, 0);
|
OptSmart (Arg, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'S':
|
||||||
|
OptSeglist (Arg, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
OptTarget (Arg, GetArg (&I, 2));
|
OptTarget (Arg, GetArg (&I, 2));
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -476,7 +476,18 @@ void SegDump (void)
|
|||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListSegments (FILE* destination)
|
||||||
|
{
|
||||||
|
/* summary of segments when seglist requested */
|
||||||
|
unsigned I;
|
||||||
|
fprintf (destination, "\nSegment summary\n\n");
|
||||||
|
for (I = 0; I < CollCount (&SegmentList); ++I) {
|
||||||
|
Segment* S = CollAtUnchecked (&SegmentList, I);
|
||||||
|
if(S->FragCount) {
|
||||||
|
fprintf (destination, "Segment: %02X = %s\n", S->Num, S->Def->Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SegInit (void)
|
void SegInit (void)
|
||||||
/* Initialize segments */
|
/* Initialize segments */
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#ifndef SEGMENT_H
|
#ifndef SEGMENT_H
|
||||||
#define SEGMENT_H
|
#define SEGMENT_H
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
/* common */
|
/* common */
|
||||||
#include "coll.h"
|
#include "coll.h"
|
||||||
@@ -95,6 +95,9 @@ extern Segment* ActiveSeg;
|
|||||||
Fragment* GenFragment (unsigned char Type, unsigned short Len);
|
Fragment* GenFragment (unsigned char Type, unsigned short Len);
|
||||||
/* Generate a new fragment, add it to the current segment and return it. */
|
/* Generate a new fragment, add it to the current segment and return it. */
|
||||||
|
|
||||||
|
void ListSegments (FILE* destination);
|
||||||
|
/* List the segments to the given file when seglist set */
|
||||||
|
|
||||||
void UseSeg (const SegDef* D);
|
void UseSeg (const SegDef* D);
|
||||||
/* Use the given segment */
|
/* Use the given segment */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user