diff --git a/64tass.c b/64tass.c
index 00c9eb5..39ae6e9 100644
--- a/64tass.c
+++ b/64tass.c
@@ -1,6 +1,6 @@
/*
Turbo Assembler 6502/65C02/65816/DTV
- $Id: 64tass.c 2153 2020-02-01 14:21:10Z soci $
+ $Id: 64tass.c 2156 2020-03-08 12:44:05Z soci $
6502/65C02 Turbo Assembler Version 1.3
(c) 1996 Taboo Productions, Marek Matula
@@ -4073,17 +4073,11 @@ MUST_CHECK Obj *compile(void)
case CMD_CPU: if ((waitfor->skip & 1) != 0)
{ /* .cpu */
struct values_s *vs;
- const struct cpu_list_s {
- const char *name;
- const struct cpu_s *def;
- } *cpui;
- static const struct cpu_list_s cpus[] = {
- {"6502", &c6502}, {"65c02", &c65c02},
- {"65ce02", &c65ce02}, {"6502i", &c6502i},
- {"65816", &w65816}, {"65dtv02", &c65dtv02},
- {"65el02", &c65el02}, {"r65c02", &r65c02},
- {"w65c02", &w65c02}, {"4510", &c4510},
- {"default", NULL}, {NULL, NULL},
+ const struct cpu_s **cpui;
+ static const struct cpu_s default_cpu = {"default", NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0};
+ static const struct cpu_s *cpus[] = {
+ &c6502, &c65c02, &c65ce02, &c6502i, &w65816, &c65dtv02,
+ &c65el02, &r65c02, &w65c02, &c4510, &default_cpu, NULL
};
str_t cpuname;
@@ -4092,9 +4086,9 @@ MUST_CHECK Obj *compile(void)
if (!get_exp(0, 1, 1, &epoint)) goto breakerr;
vs = get_val();
if (tostr(vs, &cpuname)) break;
- for (cpui = cpus; cpui->name != NULL; cpui++) {
- if (cpuname.len == strlen(cpui->name) && memcmp(cpui->name, cpuname.data, cpuname.len) == 0) {
- const struct cpu_s *cpumode = (cpui->def != NULL) ? cpui->def : arguments.cpumode;
+ for (cpui = cpus; *cpui != NULL; cpui++) {
+ if (cpuname.len == strlen((*cpui)->name) && memcmp((*cpui)->name, cpuname.data, cpuname.len) == 0) {
+ const struct cpu_s *cpumode = (*cpui != &default_cpu) ? *cpui : arguments.cpumode;
if (current_address->l_address.bank > cpumode->max_address) {
err_msg_big_address(&epoint);
current_address->l_address.bank &= cpumode->max_address;
@@ -4103,7 +4097,7 @@ MUST_CHECK Obj *compile(void)
break;
}
}
- if (cpui->name == NULL) err_msg2(ERROR___UNKNOWN_CPU, &cpuname, &vs->epoint);
+ if (*cpui == NULL) err_msg2(ERROR___UNKNOWN_CPU, &cpuname, &vs->epoint);
}
break;
case CMD_PRON: /* .pron */
diff --git a/README b/README
index 4c88026..9789b10 100644
--- a/README
+++ b/README
@@ -424,10 +424,11 @@ Byte string constants
Byte strings are like character strings, but hold bytes instead of characters.
-Quoted character strings prefixing by `b', `l', `n', `p', `s' or `x' characters
-can be used to create byte strings. The resulting byte string contains what
-.text, .shiftl, .null, .ptext and .shift would create. Direct hexadecimal entry
-can be done using the `x' prefix which.
+Quoted character strings prefixing by `b', `l', `n', `p', `s', `x' or `z'
+characters can be used to create byte strings. The resulting byte string
+contains what .text, .shiftl, .null, .ptext and .shift would create. Direct
+hexadecimal entry can be done using the `x' prefix and `z' denotes a z85
+encoded byte string.
Byte string operators and functions
y .. x concatenate strings x"12" .. x"34" is x"1234"
@@ -454,8 +455,25 @@ mystr = b"oeU" ;convert text to bytes, like .text
.text l"p2" ;convert to bytes like .shiftl
.text n"p3" ;convert to bytes like .null
.text p"p4" ;convert to bytes like .ptext
+
+Binary data may be embedded in source code by using hexadecimal byte strings.
+This is more compact than using .byte followed by a lot of numbers. As expected
+1 byte becomes 2 characters.
+
.text x"fce2" ;2 bytes: $fc and $e2 (big endian)
+If readability is not a concern then the more compact z85 encoding may be used
+which encodes 4 bytes into 5 characters. Data lengths not a multiple of 4 are
+handled by omitting leading zeros in the last group.
+
+ .text z"FiUj*2M$hf";8 bytes: 80 40 20 10 08 04 02 01
+
+For data lengths of multiple of 4 bytes any z85 encoder will do. Otherwise the
+simplest way to encode a binary file into a z85 string is to create a source
+file which reads it using the line `label = binary('filename')'. Now if the
+labels are listed to a file then there will be a z85 encoded definition for
+this label.
+
Lists and tuples
Lists and tuples can hold a collection of values. Lists are defined from values
@@ -2991,6 +3009,15 @@ Operation options
This is useful for automatic dependency generation to avoid missing target
errors on file rename.
+ The following Makefile uses the rules generated by 64tass (in `.dep') to
+ achieve automatic dependency tracking:
+
+ demo: demo.asm .dep
+ 64tass --make-phony -M.dep $< -o $@
+
+ .dep:
+ -include .dep
+
-E Byte strings are like character strings, but hold bytes instead of characters. Quoted character strings prefixing by Quoted character strings prefixing by Character string constants
b
, l
, n
, p
, s
-or x
characters can be used to create byte strings. The resulting byte
+b
, l
, n
, p
, s
, x
+or z
characters can be used to create byte strings. The resulting byte
string contains what .text
, .shiftl
,
.null
, .ptext
and .shift
would
-create. Direct hexadecimal entry can be done using the x
prefix which.x
prefix and z
denotes a z85 encoded byte string.