1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

initial commit

This commit is contained in:
paul moore 2023-12-02 09:16:49 -08:00
parent 5537b61e6a
commit d21616ea71
5 changed files with 35 additions and 8 deletions

View File

@ -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 LongJsrJmpRts = 0; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
unsigned char WarningsAsErrors = 0; /* Error if any warnings */
unsigned char SegList = 0;
/* Emulation features */
unsigned char DollarIsPC = 0; /* Allow the $ symbol as current PC */

View File

@ -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 LongJsrJmpRts; /* Allow JSR/JMP/RTS as alias for JSL/JML/RTL */
extern unsigned char WarningsAsErrors; /* Error if any warnings */
extern unsigned char SegList;
/* Emulation features */
extern unsigned char DollarIsPC; /* Allow the $ symbol as current PC */

View File

@ -73,7 +73,7 @@ static unsigned ListBytes = 12; /* Number of bytes to list for one line
/* Switch the listing on/off */
static int ListingEnabled = 1; /* Enabled if > 0 */
static int EverReloc = 0;
/*****************************************************************************/
@ -105,6 +105,7 @@ void NewListingLine (const StrBuf* Line, unsigned char File, unsigned char Depth
L->Next = 0;
L->FragList = 0;
L->FragLast = 0;
L->Seg = ActiveSeg->Num;
L->PC = GetPC ();
L->Reloc = GetRelocMode ();
L->File = File;
@ -121,6 +122,7 @@ void NewListingLine (const StrBuf* Line, unsigned char File, unsigned char Depth
LineLast->Next = L;
}
LineLast = L;
EverReloc = EverReloc || L->Reloc;
}
}
@ -181,6 +183,7 @@ void InitListingLine (void)
L = L->Next;
/* Set the values for this line */
CHECK (L != 0);
L->Seg = ActiveSeg->Num;
L->PC = GetPC ();
L->Reloc = GetRelocMode ();
L->Output = (ListingEnabled > 0);
@ -191,6 +194,7 @@ void InitListingLine (void)
/* Set the values for this line */
CHECK (LineCur != 0);
LineCur->Seg = ActiveSeg->Num;
LineCur->PC = GetPC ();
LineCur->Reloc = GetRelocMode ();
LineCur->Output = (ListingEnabled > 0);
@ -276,7 +280,7 @@ static char* MakeLineHeader (char* H, const ListLine* L)
{
char Mode;
char Depth;
unsigned Offset = 0;
/* Setup the PC mode */
Mode = (L->Reloc)? 'r' : ' ';
@ -284,8 +288,18 @@ static char* MakeLineHeader (char* H, const ListLine* L)
Depth = (L->Depth < 10)? L->Depth + '0' : '+';
/* Format the line */
sprintf (H, "%06lX%c %c", L->PC, Mode, Depth);
memset (H+9, ' ', LINE_HEADER_LEN-9);
if (!SegList) {
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 H;
@ -314,7 +328,8 @@ void CreateListing (void)
PrintPageHeader (F, LineList);
/* Terminate the header buffer. The last byte will never get overwritten */
HeaderBuf [LINE_HEADER_LEN] = '\0';
HeaderBuf [(SegList ? LINE_HEADER_LEN : LINE_HEADER_LEN -3)] = '\0';
/* Walk through all listing lines */
L = LineList;
@ -426,7 +441,7 @@ void CreateListing (void)
L->PC += Chunk;
/* Copy the bytes into the line */
P = HeaderBuf + 11;
P = HeaderBuf + (SegList?14: 11);
for (I = 0; I < Chunk; ++I) {
*P++ = *B++;
*P++ = *B++;

View File

@ -60,7 +60,8 @@ struct StrBuf;
/* Length of the header of a listing line */
#define LINE_HEADER_LEN 24
#define LINE_HEADER_LEN 27
static unsigned LineHeaderLen = 24;
/* One listing line as it is stored in memory */
typedef struct ListLine ListLine;
@ -68,6 +69,7 @@ struct ListLine {
ListLine* Next; /* Pointer to next line */
Fragment* FragList; /* List of fragments for this line */
Fragment* FragLast; /* Last entry in fragment list */
unsigned Seg; /* Which segment this line targets */
unsigned long PC; /* Program counter for this line */
unsigned char Reloc; /* Relocatable mode? */
unsigned char File; /* From which file is the line? */

View File

@ -661,7 +661,12 @@ static void OptVersion (const char* Opt attribute ((unused)),
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)),
const char* Arg attribute ((unused)))
@ -1069,6 +1074,9 @@ int main (int argc, char* argv [])
case 'W':
WarnLevel = atoi (GetArg (&I, 2));
break;
case 'S':
OptSeglist (Arg, 0);
break;
default:
UnknownOption (Arg);