diff options
-rw-r--r-- | doc/casm.html | 35 | ||||
-rw-r--r-- | src/casm.c | 56 | ||||
-rw-r--r-- | src/label.c | 2 | ||||
-rw-r--r-- | src/test/lib2 | 3 | ||||
-rw-r--r-- | src/test/link | 4 |
5 files changed, 95 insertions, 5 deletions
diff --git a/doc/casm.html b/doc/casm.html index 2e95ccc..7696136 100644 --- a/doc/casm.html +++ b/doc/casm.html @@ -454,6 +454,41 @@ word<br> </table> +<h2>Options</h2> + +<p>The core of CASM supports the following options that can be set via the +<b>option</b> command. +</p> + +<table> + +<thead><tr><td class="head">Option</td> +<td class="head">Description</td></tr></thead> + +<tr><td class="cmd"> +option address24, <on|off> +</td> +<td class="def"> +Controls whether addresses have the current bank set in the high word, e.g. + +<pre class="codeblock"> + org $8000 + bank 7 + + option +address24 +label1: ; Label1 == $078000 + + option -address24 +label2: ; Label2 == $8000 +</pre> + +Note that the name is rather misleading; bank numbers are allowed to be greater +than 256. + +</td></tr> + +</table> + <h2>Expressions</h2> <p>In any of the directives above, where a value is defined, an expression can @@ -144,6 +144,48 @@ static ValTableHandler *valtable_handler; static int valtable_count; +/* ---------------------------------------- OPTIONS +*/ + +enum option_t +{ + OPT_ADDRESS24 +}; + +static const ValueTable option_set[] = +{ + {"address24", OPT_ADDRESS24}, + {NULL} +}; + + +typedef struct +{ + int address24; +} Options; + +static Options options = {FALSE}; + + +CommandStatus SetOption(int opt, int argc, char *argv[], + int quoted[], char *err, size_t errsize) +{ + CMD_ARGC_CHECK(1); + + switch(opt) + { + case OPT_ADDRESS24: + options.address24 = ParseTrueFalse(argv[0], FALSE); + break; + default: + break; + } + + return CMD_OK; +} + + + /* ---------------------------------------- PROTOS */ static void CheckLimits(void); @@ -154,6 +196,7 @@ static void RunPass(const char *name, FILE *, int depth); static void ProduceOutput(void); + /* ---------------------------------------- STATIC VALUE TABLE HANDLING */ static void PushValTableHandler(const ValueTable *t, @@ -637,6 +680,7 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } + PushValTableHandler(option_set, SetOption); PushValTableHandler(ListOptions(), ListSetOption); PushValTableHandler(MacroOptions(), MacroSetOption); PushValTableHandler(CodepageOptions(), CodepageSetOption); @@ -658,6 +702,7 @@ int main(int argc, char *argv[]) RunPass(argv[1], fp, 0); rewind(fp); + SetAddressBank(0); SetPC(0); MacroSetDefaults(); AliasClear(); @@ -717,6 +762,8 @@ static void InitProcessors(void) SetWordMode(cpu->word_mode); SetAddressSpace(cpu->address_space); + + options.address24 = FALSE; } @@ -843,7 +890,14 @@ static void RunPass(const char *name, FILE *fp, int depth) /* This may well be updated by a command, but easier to set anyway */ - LabelSet(label, PC(), type); + if (options.address24) + { + LabelSet(label, (Bank() << 16) | PC(), type); + } + else + { + LabelSet(label, PC(), type); + } } /* Check for no command/label only. Still record for macro though. diff --git a/src/label.c b/src/label.c index 449f4d0..440ea8d 100644 --- a/src/label.c +++ b/src/label.c @@ -503,7 +503,7 @@ void LabelDump(FILE *fp, int dump_private) for(f = 0; f < g->no_locals; f++) { - fprintf(fp, "; .%-*s = $%4.4x (%d)\n", MAX_LABEL_SIZE, + fprintf(fp, "; .%-*s = $%8.8x (%d)\n", MAX_LABEL_SIZE, g->locals[f].name, (unsigned)g->locals[f].value, g->locals[f].value); diff --git a/src/test/lib2 b/src/test/lib2 index a1c6224..a16febf 100644 --- a/src/test/lib2 +++ b/src/test/lib2 @@ -1,7 +1,8 @@ option output-file,lib2.lib option output-format,lib - org $8800 + option +address24 + org $078800 start_lib2: ld hl,$4321 diff --git a/src/test/link b/src/test/link index 41d11f1..ec09bd6 100644 --- a/src/test/link +++ b/src/test/link @@ -2,5 +2,5 @@ option +list option list-labels,all - import "lib2.lib",all,-$1000 - import "lib1.lib",all,$1000 + import "lib2.lib" + import "lib1.lib" |