aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2016-05-11 09:18:52 +0100
committerIan C <ianc@noddybox.co.uk>2016-05-11 09:18:52 +0100
commite60cc5a36c148ef5ea0e38bcc848cf32f2b54a18 (patch)
tree0170a51b02b56d17e2b9e4c4e4716aaf0e4ac3c5
parent728bbf0dee1e66c30fa57f278d4a82e576f6398b (diff)
Added option to import only labels from library.
-rw-r--r--doc/casm.html5
-rw-r--r--src/casm.c18
-rw-r--r--src/libout.c19
-rw-r--r--src/state.c6
-rw-r--r--src/state.h5
-rw-r--r--src/test/link2
6 files changed, 46 insertions, 9 deletions
diff --git a/doc/casm.html b/doc/casm.html
index 5628b8d..e0f0299 100644
--- a/doc/casm.html
+++ b/doc/casm.html
@@ -346,10 +346,11 @@ the skipped bytes unless the optional <i>fill</i> is supplied.
</td></tr>
<tr><td class="cmd">
-import <i>filename</i></code>
+import <i>filename</i>[, labels]</code>
</td>
<td class="def">
-Includes a simple library file as generated by casm. See the <a href="#libout">section on simple library files</a> for more details.
+Includes a simple library file as generated by casm. See the <a href="#libout">section on simple library files</a> for more details. If the optional second
+argument is set to labels then only the label values are imported.
</td></tr>
<tr><td class="cmd">
diff --git a/src/casm.c b/src/casm.c
index 866b32d..9e5c68e 100644
--- a/src/casm.c
+++ b/src/casm.c
@@ -511,7 +511,23 @@ static CommandStatus IMPORT(const char *label, int argc, char *argv[],
{
CMD_ARGC_CHECK(2);
- return LibLoad(argv[1], LibLoadAll, err, errsize) ? CMD_OK : CMD_FAILED;
+ if (argc == 3)
+ {
+ if (CompareString(argv[2], "labels"))
+ {
+ return LibLoad(argv[1], LibLoadLabels, err, errsize) ?
+ CMD_OK : CMD_FAILED;
+ }
+ else
+ {
+ snprintf(err, errsize, "%s: unknown argument %s", argv[0], argv[2]);
+ return CMD_FAILED;
+ }
+ }
+ else
+ {
+ return LibLoad(argv[1], LibLoadAll, err, errsize) ? CMD_OK : CMD_FAILED;
+ }
}
diff --git a/src/libout.c b/src/libout.c
index 5aed18c..f9ca74f 100644
--- a/src/libout.c
+++ b/src/libout.c
@@ -149,8 +149,12 @@ int LibLoad(const char *filename, LibLoadOption opt,
int min;
int len;
int old_pc;
+ unsigned old_bank;
Byte *p;
+ old_bank = Bank();
+ old_pc = PC();
+
bank = ReadNumber(fp);
min = ReadNumber(fp);
len = ReadNumber(fp);
@@ -159,20 +163,25 @@ int LibLoad(const char *filename, LibLoadOption opt,
fread(buff, 1, len, fp);
- old_pc = PC();
-
SetPC(min);
p = buff;
- while(len-- > 0)
+ if (opt != LibLoadLabels)
{
- PCWrite(*p++);
+ while(len-- > 0)
+ {
+ PCWrite(*p++);
+ }
}
SetPC(old_pc);
+ SetAddressBank(old_bank);
}
- LabelReadBlob(fp);
+ if (opt != LibLoadMemory)
+ {
+ LabelReadBlob(fp);
+ }
fclose(fp);
diff --git a/src/state.c b/src/state.c
index 0e47a05..8a8d227 100644
--- a/src/state.c
+++ b/src/state.c
@@ -188,6 +188,12 @@ void SetAddressBank(unsigned b)
}
+unsigned Bank(void)
+{
+ return currbank;
+}
+
+
void SetWordMode(WordMode mode)
{
wmode = mode;
diff --git a/src/state.h b/src/state.h
index 100aaeb..137670e 100644
--- a/src/state.h
+++ b/src/state.h
@@ -62,6 +62,11 @@ void ClearState(void);
void SetAddressBank(unsigned bank);
+/* Get the current bank
+*/
+unsigned Bank(void);
+
+
/* Move onto the next pass
*/
void NextPass(void);
diff --git a/src/test/link b/src/test/link
index ec09bd6..b30036e 100644
--- a/src/test/link
+++ b/src/test/link
@@ -3,4 +3,4 @@
option list-labels,all
import "lib2.lib"
- import "lib1.lib"
+ import "lib1.lib",labels