aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2018-09-06 11:48:23 +0100
committerIan C <ianc@noddybox.co.uk>2018-09-06 11:48:23 +0100
commite1dcecf9d221f030c041657c5f69f15236cd3c43 (patch)
treea4ef1b1ac4e37d521acfad39c5465f173e1d90ca /src
parenta637b47b962e37d46c4ac7c54dd8090679a679da (diff)
Made '$' expansion account for bank in 24-bit address mode.V1.5
Diffstat (limited to 'src')
-rw-r--r--src/casm.c3
-rw-r--r--src/label.c18
-rw-r--r--src/label.h4
-rw-r--r--src/test/bank6
4 files changed, 29 insertions, 2 deletions
diff --git a/src/casm.c b/src/casm.c
index cd5f116..a22ff34 100644
--- a/src/casm.c
+++ b/src/casm.c
@@ -59,7 +59,7 @@
*/
static const char *casm_usage =
-"Version 1.5 development\n"
+"Version 1.5\n"
"\n"
"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
@@ -176,6 +176,7 @@ CommandStatus SetOption(int opt, int argc, char *argv[],
{
case OPT_ADDRESS24:
options.address24 = ParseTrueFalse(argv[0], FALSE);
+ LabelSetAddress24(options.address24);
break;
default:
break;
diff --git a/src/label.c b/src/label.c
index 946a6ea..72e752c 100644
--- a/src/label.c
+++ b/src/label.c
@@ -56,6 +56,8 @@ static char namespace[MAX_LABEL_SIZE + 1];
static Stack *stack;
+static int address24 = FALSE;
+
/* ---------------------------------------- PRIVATE FUNCTIONS
*/
@@ -297,7 +299,15 @@ int LabelExpand(const char *expr, int *result)
/* Current PC
*/
case '$':
- *result = PC();
+ if (address24)
+ {
+ *result = Bank() << 16 | PC();
+ }
+ else
+ {
+ *result = PC();
+ }
+
return TRUE;
default:
@@ -570,6 +580,12 @@ void LabelReadBlob(FILE *fp, int offset)
}
+void LabelSetAddress24(int onoff)
+{
+ address24 = onoff;
+}
+
+
/*
vim: ai sw=4 ts=8 expandtab
*/
diff --git a/src/label.h b/src/label.h
index a7cb720..04f01d4 100644
--- a/src/label.h
+++ b/src/label.h
@@ -126,6 +126,10 @@ void LabelWriteBlob(FILE *fp);
*/
void LabelReadBlob(FILE *fp, int offset);
+/* Set 24-bit address mode
+*/
+void LabelSetAddress24(int onoff);
+
#endif
diff --git a/src/test/bank b/src/test/bank
index 5b1606b..8610dea 100644
--- a/src/test/bank
+++ b/src/test/bank
@@ -1,4 +1,8 @@
+ option +list
+ option +list-labels
+ option +address24
+
; option output-format,spectrum
option output-bank,code-%u
option output-file,output.tap
@@ -13,4 +17,6 @@
defb 2
org $078000
+label:
defb 3
+labellen: equ $ - label