aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent34eab58c9a01b90beb0ce23a2a0f6c2156e8d4fd (diff)
Added support for 24 bit address labels.
* Also fixes bug where bank wasn't reset between passes.
Diffstat (limited to 'src')
-rw-r--r--src/casm.c56
-rw-r--r--src/label.c2
-rw-r--r--src/test/lib23
-rw-r--r--src/test/link4
4 files changed, 60 insertions, 5 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.
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"