<tag><tt>--comments n</tt></tag>
Set the comment level for the output. Valid arguments are 0..4. Greater
- values will increase the level of additional information written to the
+ values will increase the level of additional information written to the
output file in form of comments.
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>
The attribute is followed by string value, which gives the name of the
Error ("Cannot seek on file `%s': %s", InFile, strerror (errno));
}
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
* 0x10000 - Size. This is a reasonable default assuming that the file
* is a ROM that contains the hardware vectors at $FFFA.
*/
if (StartAddr < 0) {
- if (Size > 0x10000) {
- StartAddr = 0;
- } else {
- StartAddr = 0x10000 - Size;
- }
+ if (Size > 0x10000) {
+ StartAddr = 0;
+ } else {
+ StartAddr = 0x10000 - Size;
+ }
}
/* Calculate the maximum code size */
/* Check if the size is larger than what we can read */
if (Size == 0) {
- Error ("File `%s' contains no data", InFile);
+ Error ("Nothing to read from input file `%s'", InFile);
}
if (Size > MaxCount) {
Warning ("File `%s' is too large, ignoring %ld bytes",
/* Flags and other command line stuff */
unsigned char DebugInfo = 0; /* Add debug info to the object file */
-unsigned char FormFeeds = 0; /* Add form feeds to the output? */
-unsigned char PassCount = 2; /* How many passed do we do? */
-long StartAddr = -1; /* Start/load address of the program */
+unsigned char FormFeeds = 0; /* Add form feeds to the output? */
+unsigned char PassCount = 2; /* How many passed do we do? */
+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 */
-unsigned char Pass = 0; /* Disassembler pass */
+unsigned Pass = 0; /* Disassembler pass */
/* Comments */
-unsigned char Comments = 0; /* Add which comments to the output? */
+unsigned Comments = 0; /* Add which comments to the output? */
/* Page formatting */
unsigned PageLength = 0; /* Length of a listing page */
-/* File names */
+/* File stuff */
extern const char* InFile; /* Name of input file */
extern const char* OutFile; /* Name of output file */
extern unsigned char FormFeeds; /* Add form feeds to the output? */
extern unsigned char PassCount; /* How many passed do we do? */
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 */
-extern unsigned char Pass; /* Disassembler pass */
+extern unsigned Pass; /* Disassembler pass */
/* Comments */
#define MIN_COMMENTS 0
#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 */
#define MIN_PAGE_LEN 32
{ "COMMENTS", INFOTOK_COMMENTS },
{ "CPU", INFOTOK_CPU },
{ "INPUTNAME", INFOTOK_INPUTNAME },
+ { "INPUTOFFS", INFOTOK_INPUTOFFS },
+ { "INPUTSIZE", INFOTOK_INPUTSIZE },
{ "OUTPUTNAME", INFOTOK_OUTPUTNAME },
{ "PAGELENGTH", INFOTOK_PAGELENGTH },
{ "STARTADDR", INFOTOK_STARTADDR },
InfoNextTok ();
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:
InfoNextTok ();
InfoAssureStr ();
{ "CODE", INFOTOK_CODE },
{ "BYTETABLE", INFOTOK_BYTETAB },
{ "DBYTETABLE", INFOTOK_DBYTETAB },
- { "WORDTABLE", INFOTOK_WORDTAB },
+ { "WORDTABLE", INFOTOK_WORDTAB },
{ "DWORDTABLE", INFOTOK_DWORDTAB },
{ "ADDRTABLE", INFOTOK_ADDRTAB },
{ "RTSTABLE", INFOTOK_RTSTAB },
* - ...if we have enough bytes remaining for the code at this address.
* - ...if the current instruction is valid for the given CPU.
* - ...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 (D->Size > RemainingBytes) {
INFOTOK_COMMENTS,
INFOTOK_CPU,
INFOTOK_INPUTNAME,
+ INFOTOK_INPUTOFFS,
+ INFOTOK_INPUTSIZE,
INFOTOK_OUTPUTNAME,
INFOTOK_PAGELENGTH,
INFOTOK_STARTADDR,
INFOTOK_TYPE,
INFOTOK_CODE,
- INFOTOK_BYTETAB,
+ INFOTOK_BYTETAB,
INFOTOK_DBYTETAB,
INFOTOK_WORDTAB,
INFOTOK_DWORDTAB,