mirror of
https://github.com/cc65/cc65.git
synced 2025-01-04 23:33:05 +00:00
Added INPUTOFFS and INPUTSIZE
git-svn-id: svn://svn.cc65.org/cc65/trunk@2411 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
e3d3a43c3c
commit
fd2fa25f28
@ -261,6 +261,20 @@ following attributes are recognized:
|
|||||||
input file name on the command line.
|
input file name on the command line.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>INPUTOFFS</tt></tag>
|
||||||
|
|
||||||
|
The attribute is followed by a numerical value that gives an offset into
|
||||||
|
the input file which is skipped before reading data. The attribute may be
|
||||||
|
used to skip headers or unwanted code sections in the input file.
|
||||||
|
|
||||||
|
|
||||||
|
<tag><tt>INPUTSIZE</tt></tag>
|
||||||
|
|
||||||
|
INPUTSIZE is followed by a numerical value that gives the amount of data
|
||||||
|
to read from the input file. Data beyond <tt/INPUTOFFS+INPUTSIZE/ is
|
||||||
|
ignored.
|
||||||
|
|
||||||
|
|
||||||
<tag><tt>OUTPUTNAME</tt></tag>
|
<tag><tt>OUTPUTNAME</tt></tag>
|
||||||
|
|
||||||
The attribute is followed by string value, which gives the name of the
|
The attribute is followed by string value, which gives the name of the
|
||||||
|
@ -86,18 +86,43 @@ void LoadCode (void)
|
|||||||
Error ("Cannot seek on file `%s': %s", InFile, strerror (errno));
|
Error ("Cannot seek on file `%s': %s", InFile, strerror (errno));
|
||||||
}
|
}
|
||||||
Size = ftell (F);
|
Size = ftell (F);
|
||||||
rewind (F);
|
|
||||||
|
/* The input offset must be smaller than the size */
|
||||||
|
if (InputOffs >= 0) {
|
||||||
|
if (InputOffs >= Size) {
|
||||||
|
Error ("Input offset is greater than file size");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Use a zero offset */
|
||||||
|
InputOffs = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Seek to the input offset and correct size to contain the remainder of
|
||||||
|
* the file.
|
||||||
|
*/
|
||||||
|
if (fseek (F, InputOffs, SEEK_SET) != 0) {
|
||||||
|
Error ("Cannot seek on file `%s': %s", InFile, strerror (errno));
|
||||||
|
}
|
||||||
|
Size -= InputOffs;
|
||||||
|
|
||||||
|
/* Limit the size to the maximum input size if one is given */
|
||||||
|
if (InputSize >= 0) {
|
||||||
|
if (InputSize > Size) {
|
||||||
|
Error ("Input size is greater than what is available");
|
||||||
|
}
|
||||||
|
Size = InputSize;
|
||||||
|
}
|
||||||
|
|
||||||
/* If the start address was not given, set it so that the code loads to
|
/* If the start address was not given, set it so that the code loads to
|
||||||
* 0x10000 - Size. This is a reasonable default assuming that the file
|
* 0x10000 - Size. This is a reasonable default assuming that the file
|
||||||
* is a ROM that contains the hardware vectors at $FFFA.
|
* is a ROM that contains the hardware vectors at $FFFA.
|
||||||
*/
|
*/
|
||||||
if (StartAddr < 0) {
|
if (StartAddr < 0) {
|
||||||
if (Size > 0x10000) {
|
if (Size > 0x10000) {
|
||||||
StartAddr = 0;
|
StartAddr = 0;
|
||||||
} else {
|
} else {
|
||||||
StartAddr = 0x10000 - Size;
|
StartAddr = 0x10000 - Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the maximum code size */
|
/* Calculate the maximum code size */
|
||||||
@ -105,7 +130,7 @@ void LoadCode (void)
|
|||||||
|
|
||||||
/* Check if the size is larger than what we can read */
|
/* Check if the size is larger than what we can read */
|
||||||
if (Size == 0) {
|
if (Size == 0) {
|
||||||
Error ("File `%s' contains no data", InFile);
|
Error ("Nothing to read from input file `%s'", InFile);
|
||||||
}
|
}
|
||||||
if (Size > MaxCount) {
|
if (Size > MaxCount) {
|
||||||
Warning ("File `%s' is too large, ignoring %ld bytes",
|
Warning ("File `%s' is too large, ignoring %ld bytes",
|
||||||
|
@ -53,15 +53,17 @@ const char CfgExt[] = ".cfg"; /* Config file extension */
|
|||||||
|
|
||||||
/* Flags and other command line stuff */
|
/* Flags and other command line stuff */
|
||||||
unsigned char DebugInfo = 0; /* Add debug info to the object file */
|
unsigned char DebugInfo = 0; /* Add debug info to the object file */
|
||||||
unsigned char FormFeeds = 0; /* Add form feeds to the output? */
|
unsigned char FormFeeds = 0; /* Add form feeds to the output? */
|
||||||
unsigned char PassCount = 2; /* How many passed do we do? */
|
unsigned char PassCount = 2; /* How many passed do we do? */
|
||||||
long StartAddr = -1; /* Start/load address of the program */
|
long StartAddr = -1L; /* Start/load address of the program */
|
||||||
|
long InputOffs = -1L; /* Offset into input file */
|
||||||
|
long InputSize = -1L; /* Number of bytes to read from input */
|
||||||
|
|
||||||
/* Stuff needed by many routines */
|
/* Stuff needed by many routines */
|
||||||
unsigned char Pass = 0; /* Disassembler pass */
|
unsigned Pass = 0; /* Disassembler pass */
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
unsigned char Comments = 0; /* Add which comments to the output? */
|
unsigned Comments = 0; /* Add which comments to the output? */
|
||||||
|
|
||||||
/* Page formatting */
|
/* Page formatting */
|
||||||
unsigned PageLength = 0; /* Length of a listing page */
|
unsigned PageLength = 0; /* Length of a listing page */
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* File names */
|
/* File stuff */
|
||||||
extern const char* InFile; /* Name of input file */
|
extern const char* InFile; /* Name of input file */
|
||||||
extern const char* OutFile; /* Name of output file */
|
extern const char* OutFile; /* Name of output file */
|
||||||
|
|
||||||
@ -57,15 +57,16 @@ extern unsigned char DebugInfo; /* Add debug info to the object file */
|
|||||||
extern unsigned char FormFeeds; /* Add form feeds to the output? */
|
extern unsigned char FormFeeds; /* Add form feeds to the output? */
|
||||||
extern unsigned char PassCount; /* How many passed do we do? */
|
extern unsigned char PassCount; /* How many passed do we do? */
|
||||||
extern long StartAddr; /* Start/load address of the program */
|
extern long StartAddr; /* Start/load address of the program */
|
||||||
|
extern long InputOffs; /* Offset into input file */
|
||||||
|
extern long InputSize; /* Number of bytes to read from input */
|
||||||
|
|
||||||
/* Stuff needed by many routines */
|
/* Stuff needed by many routines */
|
||||||
extern unsigned char Pass; /* Disassembler pass */
|
extern unsigned Pass; /* Disassembler pass */
|
||||||
|
|
||||||
/* Comments */
|
/* Comments */
|
||||||
#define MIN_COMMENTS 0
|
#define MIN_COMMENTS 0
|
||||||
#define MAX_COMMENTS 4
|
#define MAX_COMMENTS 4
|
||||||
extern unsigned char Comments; /* Add which comments to the output? */
|
extern unsigned Comments; /* Add which comments to the output? */
|
||||||
|
|
||||||
/* Page formatting */
|
/* Page formatting */
|
||||||
#define MIN_PAGE_LEN 32
|
#define MIN_PAGE_LEN 32
|
||||||
|
@ -70,6 +70,8 @@ static void GlobalSection (void)
|
|||||||
{ "COMMENTS", INFOTOK_COMMENTS },
|
{ "COMMENTS", INFOTOK_COMMENTS },
|
||||||
{ "CPU", INFOTOK_CPU },
|
{ "CPU", INFOTOK_CPU },
|
||||||
{ "INPUTNAME", INFOTOK_INPUTNAME },
|
{ "INPUTNAME", INFOTOK_INPUTNAME },
|
||||||
|
{ "INPUTOFFS", INFOTOK_INPUTOFFS },
|
||||||
|
{ "INPUTSIZE", INFOTOK_INPUTSIZE },
|
||||||
{ "OUTPUTNAME", INFOTOK_OUTPUTNAME },
|
{ "OUTPUTNAME", INFOTOK_OUTPUTNAME },
|
||||||
{ "PAGELENGTH", INFOTOK_PAGELENGTH },
|
{ "PAGELENGTH", INFOTOK_PAGELENGTH },
|
||||||
{ "STARTADDR", INFOTOK_STARTADDR },
|
{ "STARTADDR", INFOTOK_STARTADDR },
|
||||||
@ -119,6 +121,21 @@ static void GlobalSection (void)
|
|||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case INFOTOK_INPUTOFFS:
|
||||||
|
InfoNextTok ();
|
||||||
|
InfoAssureInt ();
|
||||||
|
InputOffs = InfoIVal;
|
||||||
|
InfoNextTok ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case INFOTOK_INPUTSIZE:
|
||||||
|
InfoNextTok ();
|
||||||
|
InfoAssureInt ();
|
||||||
|
InfoRangeCheck (1, 0x10000);
|
||||||
|
InputSize = InfoIVal;
|
||||||
|
InfoNextTok ();
|
||||||
|
break;
|
||||||
|
|
||||||
case INFOTOK_OUTPUTNAME:
|
case INFOTOK_OUTPUTNAME:
|
||||||
InfoNextTok ();
|
InfoNextTok ();
|
||||||
InfoAssureStr ();
|
InfoAssureStr ();
|
||||||
|
@ -247,7 +247,7 @@ static void OneOpcode (unsigned RemainingBytes)
|
|||||||
* - ...if we have enough bytes remaining for the code at this address.
|
* - ...if we have enough bytes remaining for the code at this address.
|
||||||
* - ...if the current instruction is valid for the given CPU.
|
* - ...if the current instruction is valid for the given CPU.
|
||||||
* - ...if there is no label somewhere between the instruction bytes.
|
* - ...if there is no label somewhere between the instruction bytes.
|
||||||
* If any of these conditions is true, switch to data mode.
|
* If any of these conditions is false, switch to data mode.
|
||||||
*/
|
*/
|
||||||
if (GetStyleAttr (PC) == atDefault) {
|
if (GetStyleAttr (PC) == atDefault) {
|
||||||
if (D->Size > RemainingBytes) {
|
if (D->Size > RemainingBytes) {
|
||||||
|
@ -68,6 +68,8 @@ typedef enum token_t {
|
|||||||
INFOTOK_COMMENTS,
|
INFOTOK_COMMENTS,
|
||||||
INFOTOK_CPU,
|
INFOTOK_CPU,
|
||||||
INFOTOK_INPUTNAME,
|
INFOTOK_INPUTNAME,
|
||||||
|
INFOTOK_INPUTOFFS,
|
||||||
|
INFOTOK_INPUTSIZE,
|
||||||
INFOTOK_OUTPUTNAME,
|
INFOTOK_OUTPUTNAME,
|
||||||
INFOTOK_PAGELENGTH,
|
INFOTOK_PAGELENGTH,
|
||||||
INFOTOK_STARTADDR,
|
INFOTOK_STARTADDR,
|
||||||
|
Loading…
Reference in New Issue
Block a user