From 519fdd7d64c2d8366a3b3b076a1ec558f63e703e Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 20 Apr 2016 09:48:51 +0100 Subject: Removed modulus and added '%' as a binary format marker. --- doc/casm.html | 11 +++++++++-- src/casm.c | 2 +- src/expr.c | 9 +-------- src/label.c | 2 +- src/test/1 | 10 +++++++++- 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 @@ -510,6 +510,13 @@ A hex number, e.g. $2a. A binary number, e.g. 00101010b + +%[01]+ + + +A binary number, e.g. %00101010 + + [a-zA-Z_0-9]+ @@ -550,10 +557,10 @@ Shift left/shift right. -/ * % +/ * -Division/multiplication/modulus. +Division/multiplication 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 -- cgit v1.2.3