# HG changeset patch # User Matti Hamalainen # Date 1353164648 -7200 # Node ID d13d8770477a0c40bcd16c9fe441e571339a6a09 # Parent 49701129c5dda72a02fb863f08d633676755f551 Add new -L option for forcing loading address on the destination file, or disabling it completely (aka "raw" output) via -L none. diff -r 49701129c5dd -r d13d8770477a objlink.c --- a/objlink.c Sat Nov 17 15:32:42 2012 +0200 +++ b/objlink.c Sat Nov 17 17:04:08 2012 +0200 @@ -74,6 +74,11 @@ MTYPE_RES // RESERVED }; +enum +{ + LA_NONE = -2, + LA_AUTO = -1 +}; /* Memory models */ @@ -132,6 +137,8 @@ ssize_t optCropStart, optCropEnd; BOOL optCropOutput = FALSE; +int optLoadAddress = LA_AUTO; + int optMemModel = 0; const DMMemModel *memModel = NULL; Uint8 *memory = NULL; @@ -154,6 +161,7 @@ { 10, 'i', "initvalue", "Initialize memory with: -i :[bwd]", OPT_ARGREQ }, { 11, 'd', "describe", "Output ASCII memory map description", OPT_NONE }, { 13, 'c', "crop", "Crop output file to: -c - or :", OPT_ARGREQ }, + { 14, 'L', "load-address","Set output file load address (or 'none' for 'raw' output)", OPT_ARGREQ }, }; static const int optListN = sizeof(optList) / sizeof(optList[0]); @@ -474,6 +482,22 @@ } break; + case 14: + // Set loading address + if (strcasecmp(optArg, "none") == 0) + optLoadAddress = LA_NONE; + else + { + optLoadAddress = atoi(optArg); + if (optLoadAddress < 0 || optLoadAddress >= 64*1024) + { + dmError("Invalid or insane loading address %d/$%x!\n", + optLoadAddress); + return FALSE; + } + } + break; + default: dmError("Unknown argument '%s'.\n", currArg); return FALSE; @@ -928,7 +952,11 @@ dmPrint(1, "to '%s'\n", optDestName); // Save loading address - dm_fwrite_le16(dfile, startAddr); + if (optLoadAddress >= 0) + dm_fwrite_le16(dfile, optLoadAddress); + else + if (optLoadAddress == LA_AUTO) + dm_fwrite_le16(dfile, startAddr); // Save the data if (fwrite(&memory[startAddr], dataSize, 1, dfile) < 1)