Skip to content

Commit

Permalink
Add file offset command
Browse files Browse the repository at this point in the history
Sometimes you need to specify an offset from the start of the file to
disasm from. The new '>' command does just that.
  • Loading branch information
Neil Johnson committed Sep 18, 2024
1 parent a8c5c18 commit 9633dae
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/dasmxx.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*****************************************************************************
*
* Copyright (C) 2014-2015, Neil Johnson
* Copyright (C) 2014-2024, Neil Johnson
* All rights reserved.
*
* Redistribution and use in source and binary forms,
Expand Down Expand Up @@ -57,11 +57,12 @@
* processing to tell the disassembler what the memory at a particular address
* is for (unknown, code, or some sort of data).
*
* The commands are (where XXXX denotes hexadecimal address):
* The commands are (where XXXX denotes hexadecimal field):
*
* File commands:
* fName input file = `Name'
* iName include file `Name' in place of include command
* >XXXX fast forward to offset XXXX from start of file
*
* Configuration commands:
* tXX string terminator byte (default = 00)
Expand Down Expand Up @@ -169,6 +170,7 @@ struct comment *linecmt = NULL;
struct comment *blockcmt = NULL;

int string_terminator = '\0';
unsigned int file_offset = 0;

/* List of display modes. Defines must match entry position. */
static char datchars[] = "cbsewapvmuz";
Expand Down Expand Up @@ -592,6 +594,10 @@ static void readlist( const char *listfile, struct params *params )
readlist( pbuf, params );
break;

case '>': /* fast forward */
sscanf( pbuf, "%x", &file_offset );
break;

case 'r': /* Xref range */
{
/* Deprecated */
Expand Down Expand Up @@ -775,7 +781,7 @@ static void run_disasm( struct params params )

fseek( f, 0, SEEK_END );
filelength = ftell( f );
fseek( f, 0, SEEK_SET );
fseek( f, file_offset, SEEK_SET );

addr = clist->addr;
mode = clist->mode;
Expand All @@ -784,6 +790,8 @@ static void run_disasm( struct params params )
clist = clist->n;

printf( "%s Processing \"%s\" (%ld bytes)", COMMENT_DELIM, inputfile, filelength ); newline();
if ( file_offset )
printf( "%s File offset: 0x%04X", COMMENT_DELIM, file_offset ); newline();
printf( "%s Disassembly start address: 0x%04X", COMMENT_DELIM, addr ); newline();
printf( "%s String terminator: 0x%02x", COMMENT_DELIM, string_terminator ); newline();
newline();
Expand Down

0 comments on commit 9633dae

Please sign in to comment.