aboutsummaryrefslogtreecommitdiff
path: root/src/casm.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2016-05-17 08:38:47 +0100
committerIan C <ianc@noddybox.co.uk>2016-05-17 08:38:47 +0100
commit393556d2fc70dc0def5a6bb0463daf234ef23e36 (patch)
treeffeac76300a03bb6e4e34479d11ec2a64afcacfd /src/casm.c
parent34eab58c9a01b90beb0ce23a2a0f6c2156e8d4fd (diff)
Added support for 24 bit address labels.
* Also fixes bug where bank wasn't reset between passes.
Diffstat (limited to 'src/casm.c')
-rw-r--r--src/casm.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/src/casm.c b/src/casm.c
index 1fa6d03..f1de63b 100644
--- a/src/casm.c
+++ b/src/casm.c
@@ -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.