aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2016-04-20 09:48:51 +0100
committerIan C <ianc@noddybox.co.uk>2016-04-20 09:48:51 +0100
commit519fdd7d64c2d8366a3b3b076a1ec558f63e703e (patch)
tree71f3b3f6a435a8825868f1e5138041fd8d4d1eb0
parenta5984e6f82e9368e719e832764ebb4813ff5e797 (diff)
Removed modulus and added '%' as a binary format marker.
-rw-r--r--doc/casm.html11
-rw-r--r--src/casm.c2
-rw-r--r--src/expr.c9
-rw-r--r--src/label.c2
-rw-r--r--src/test/110
5 files changed, 21 insertions, 13 deletions
diff --git a/doc/casm.html b/doc/casm.html
index dcd21bd..0606a34 100644
--- a/doc/casm.html
+++ b/doc/casm.html
@@ -511,6 +511,13 @@ A binary number, e.g. 00101010b
</td></tr>
<tr><td class="cmd">
+%[01]+
+</td>
+<td class="def">
+A binary number, e.g. %00101010
+</td></tr>
+
+<tr><td class="cmd">
[a-zA-Z_0-9]+
</td>
<td class="def">
@@ -550,10 +557,10 @@ Shift left/shift right.
</td></tr>
<tr><td class="cmd">
-/ * %
+/ *
</td>
<td class="def">
-Division/multiplication/modulus.
+Division/multiplication
</td></tr>
<tr><td class="cmd">
diff --git a/src/casm.c b/src/casm.c
index 9b92bbf..771a7e3 100644
--- a/src/casm.c
+++ b/src/casm.c
@@ -57,7 +57,7 @@
*/
static const char *casm_usage =
-"Version 1.1\n"
+"Version 1.2 development\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"
diff --git a/src/expr.c b/src/expr.c
index 02222d7..77eae8f 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -55,7 +55,6 @@
#define TYPE_EQUALITY 17
#define TYPE_BOOL_AND 18
#define TYPE_BOOL_OR 19
-#define TYPE_MODULUS 20
#define TYPE_LT 21
#define TYPE_GT 22
#define TYPE_LTEQ 23
@@ -79,14 +78,13 @@
#define SYM_EQUALITY "=="
#define SYM_BOOL_AND "&&"
#define SYM_BOOL_OR "||"
-#define SYM_MODULUS "%"
#define SYM_LT "<"
#define SYM_GT ">"
#define SYM_LTEQ "<="
#define SYM_GTEQ ">="
#define SYM_INEQUALITY "!="
-#define OPERATOR_CHARS "{}/*+-~&|^<>=%!"
+#define OPERATOR_CHARS "{}/*+-~&|^<>=!"
#define IS_OPERATOR_TYPE(a) ((a)>=TYPE_OPERATOR)
@@ -146,7 +144,6 @@ static const Operator op_info[]=
{SYM_SHIFTR, 6, TYPE_SHIFTR, OpBinary, TRUE},
{SYM_MULTIPLY, 5, TYPE_MULTIPLY, OpBinary, TRUE},
{SYM_DIVIDE, 5, TYPE_DIVIDE, OpBinary, TRUE},
- {SYM_MODULUS, 5, TYPE_MODULUS, OpBinary, TRUE},
{SYM_ADD, 4, TYPE_ADD, OpBinary, TRUE},
{SYM_SUBTRACT, 4, TYPE_SUBTRACT, OpBinary, TRUE},
{SYM_EQUALITY, 1, TYPE_EQUALITY, OpBinary, TRUE},
@@ -561,10 +558,6 @@ static int EvalPostfix(Stack **stack, int *result)
*result=left*right;
break;
- case TYPE_MODULUS:
- *result=left%right;
- break;
-
case TYPE_ADD:
*result=left+right;
break;
diff --git a/src/label.c b/src/label.c
index 75270ef..0807128 100644
--- a/src/label.c
+++ b/src/label.c
@@ -283,7 +283,7 @@ int LabelExpand(const char *expr, int *result)
}
else if (first == '%')
{
- found = ParseBase(expr, 2, result, '\0');
+ found = ParseBase(expr + 1, 2, result, '\0');
}
else if (last == 'b' || last == 'B')
{
diff --git a/src/test/1 b/src/test/1
index 5531840..724172f 100644
--- a/src/test/1
+++ b/src/test/1
@@ -32,7 +32,7 @@ expr1_7 equ 1 + 2 * 3
expr2_9 equ {1 + 2} * 3
bin1: equ 11110101b
-bin2: equ 11110010b
+bin2: equ %11110010
hex1: equ $1234
hex2 equ 1234h
hex3: equ 0x1234
@@ -68,6 +68,14 @@ two fred ONE * 2
true1 equ one == 1
false1 equ one != 1
+true2 equ 1 == 1 && 2 == 2
+true3 equ 1 == 2 || 2 == 2
+false2 equ 1 == 2 && 2 == 2
+false3 equ 1 == 2 || 2 == 3
+
+and1 equ 0x8123 & 256
+or1 equ 0x8123 | 256
+
endaddr:end
this is ignored