summaryrefslogtreecommitdiff
path: root/third_party/gsm/add-test
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-07 12:29:46 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-07 12:29:46 +0000
commit3ade1510e72926d02d7c7d4416257449bc0cd3f3 (patch)
treec51d4960cac0fcd8bf3483a8e77444ac5f9a3177 /third_party/gsm/add-test
parentbfd3f58f5b715238fe618d053ddf908a34f1e56c (diff)
Split speex, portaudio, and gsm into third_party directory
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/split-3rd-party@1168 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/gsm/add-test')
-rw-r--r--third_party/gsm/add-test/add_test.c353
-rw-r--r--third_party/gsm/add-test/add_test.dta683
2 files changed, 1036 insertions, 0 deletions
diff --git a/third_party/gsm/add-test/add_test.c b/third_party/gsm/add-test/add_test.c
new file mode 100644
index 00000000..8e832dfb
--- /dev/null
+++ b/third_party/gsm/add-test/add_test.c
@@ -0,0 +1,353 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
+ * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/add_test.c,v 1.2 1994/05/10 20:18:17 jutta Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gsm.h"
+
+#include "../src/add.c"
+
+int interactive = 1;
+
+char * opname;
+longword L_op1, L_op2, L_expect;
+word op1, op2, expect;
+int do_expect;
+
+word M_gsm_add P((word op1, word op2));
+word M_gsm_sub P((word op1, word op2));
+word M_gsm_mult P((word op1, word op2));
+word M_gsm_mult_r P((word op1, word op2));
+word M_gsm_abs P((word op1));
+longword M_gsm_L_mult P((word op1, word op2));
+longword M_gsm_L_add P((longword op1, longword op2));
+
+help()
+{
+puts( " add a b sub a b mult a b div a b" );
+puts( "L_add A B L_sub A B L_mult A B mult_r a b" );
+puts( "" );
+puts( "abs a norm a >> a b << a b" );
+puts( " L_>> A B L_<< A B" );
+
+}
+
+char * strtek P2((str, sep), char * str, char * sep) {
+
+ static char * S = (char *)0;
+ char * c, * base;
+
+ if (str) S = str;
+
+ if (!S || !*S) return (char *)0;
+
+ /* Skip delimiters.
+ */
+ while (*S) {
+ for (c = sep; *c && *c != *S; c++) ;
+ if (*c) *S++ = 0;
+ else break;
+ }
+
+ base = S;
+
+ /* Skip non-delimiters.
+ */
+ for (base = S; *S; S++) {
+
+ for (c = sep; *c; c++)
+ if (*c == *S) {
+ *S++ = 0;
+ return base;
+ }
+ }
+
+ return base == S ? (char *)0 : base;
+}
+
+long value P1((s), char * s)
+{
+ switch (*s) {
+ case '-': switch (s[1]) {
+ case '\0': return MIN_WORD;
+ case '-': return MIN_LONGWORD;
+ default: break;
+ }
+ break;
+
+ case '+': switch (s[1]) {
+ case '\0': return MAX_WORD;
+ case '+': return MAX_LONGWORD;
+ default: break;
+ }
+ default: break;
+ }
+
+ return strtol(s, (char **)0, 0);
+}
+
+char * parse P1((buf), char * buf)
+{
+ char * s, * a;
+ long l;
+
+ if (a = strchr(buf, '=')) *a++ = 0;
+
+ opname = s = strtek(buf, " \t(");
+ if (!s) return (char *)0;
+
+ op1 = op2 = L_op1 = L_op2 = 0;
+
+ if (s = strtek( (char *)0, "( \t,")) {
+ op1 = L_op1 = value(s);
+ if (s = strtek( (char *)0, ", \t)")) op2 = L_op2 = value(s);
+ }
+
+ if (a) {
+ do_expect = 1;
+ while (*a == ' ' || *a == '\t') a++;
+ expect = L_expect = value(a);
+ }
+
+ return opname;
+}
+
+void fprint_word P2((f, w), FILE * f, word w)
+{
+ if (!w) putc('0', f);
+ else fprintf(f, "0x%4.4x (%d%s)",
+ (unsigned int)w,
+ (int)w,
+ w == MIN_WORD? "/-" : (w == MAX_WORD ? "/+" : ""));
+}
+
+void print_word P1((w), word w)
+{
+ fprint_word( stdout, w );
+}
+
+void fprint_longword P2((f, w), FILE * f, longword w)
+{
+ if (!w) putc('0', f);
+ else fprintf(f, "0x%8.8x (%ld%s)",
+ w, w, w == MIN_WORD ? "/-"
+ : (w == MAX_WORD ? "/+"
+ : (w == MIN_LONGWORD ? "/--"
+ : (w == MAX_LONGWORD ? "/++" : ""))));
+}
+
+void print_longword P1((w),longword w)
+{
+ fprint_longword(stdout, w);
+}
+
+void do_longword P1((w), longword w)
+{
+ if (interactive) print_longword(w);
+ if (do_expect) {
+ if (w != L_expect) {
+ if (!interactive) fprint_longword(stderr, w);
+ fprintf(stderr, " != %s (%ld, %ld) -- expected ",
+ opname, L_op1, L_op2 );
+ fprint_longword(stderr, L_expect);
+ putc( '\n', stderr );
+ }
+ } else if (interactive) putchar('\n');
+}
+
+void do_word P1((w), word w )
+{
+ if (interactive) print_word(w);
+ if (do_expect) {
+ if (w != expect) {
+ if (!interactive) fprint_word(stderr, w);
+ fprintf(stderr, " != %s (%ld, %ld) -- expected ",
+ opname, L_op1, L_op2 );
+ fprint_word(stderr, expect);
+ putc('\n', stderr);
+ }
+ } else if (interactive) putchar('\n');
+}
+
+int main(ac, av) char ** av;
+{
+ char buf[299];
+ char * c;
+ FILE * in;
+
+ if (ac > 2) {
+ fprintf(stderr, "Usage: %s [filename]\n", av[0]);
+fail:
+#ifdef EXIT_FAILURE
+ exit(EXIT_FAILURE);
+#else
+ exit(1);
+#endif
+ }
+ if (ac < 2) in = stdin;
+ else if (!(in = fopen(av[1], "r"))) {
+ perror(av[1]);
+ fprintf(stderr, "%s: cannot open file \"%s\" for reading\n",
+ av[0], av[1]);
+ goto fail;
+ }
+
+ interactive = isatty(fileno(in));
+
+ for (;;) {
+ if (interactive) fprintf(stderr, "? ");
+
+ if (!fgets(buf, sizeof(buf), in)) exit(0);
+ if (c = strchr(buf, '\n')) *c = 0;
+
+ if (*buf == ';' || *buf == '#') continue;
+ if (*buf == '\'') {
+ puts(buf + 1);
+ continue;
+ }
+ if (*buf == '\"') {
+ fprintf(stderr, "%s\n", buf + 1);
+ continue;
+ }
+
+ c = parse(buf);
+
+ if (!c) continue;
+ if (!strcmp(c, "add")) {
+ do_word( gsm_add( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "M_add")) {
+ do_word( M_gsm_add( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "sub")) {
+ do_word( gsm_sub( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "M_sub")) {
+ do_word( M_gsm_sub( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "mult")) {
+ do_word( gsm_mult( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "M_mult")) {
+ do_word( M_gsm_mult( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "mult_r")) {
+ do_word( gsm_mult_r(op1, op2));
+ continue;
+ }
+ if (!strcmp(c, "M_mult_r")) {
+ do_word( M_gsm_mult_r(op1, op2));
+ continue;
+ }
+ if (!strcmp(c, "abs" )) {
+ do_word( gsm_abs(op1) );
+ continue;
+ }
+ if (!strcmp(c, "M_abs" )) {
+ do_word( M_gsm_abs(op1) );
+ continue;
+ }
+ if (!strcmp(c, "div" )) {
+ do_word( gsm_div( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "norm" )) {
+ do_word( gsm_norm(L_op1));
+ continue;
+ }
+ if (!strcmp(c, "<<" )) {
+ do_word( gsm_asl( op1, op2));
+ continue;
+ }
+ if (!strcmp(c, ">>" )) {
+ do_word( gsm_asr( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "L_mult")) {
+ do_longword( gsm_L_mult( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "M_L_mult")) {
+ do_longword( M_gsm_L_mult( op1, op2 ));
+ continue;
+ }
+ if (!strcmp(c, "L_add" )) {
+ do_longword( gsm_L_add( L_op1, L_op2 ));
+ continue;
+ }
+ if (!strcmp(c, "M_L_add" )) {
+ do_longword( M_gsm_L_add( L_op1, L_op2 ));
+ continue;
+ }
+ if (!strcmp(c, "L_sub" )) {
+ do_longword( gsm_L_sub( L_op1, L_op2 ));
+ continue;
+ }
+ if (!strcmp(c, "L_<<" )) {
+ do_longword( gsm_L_asl( L_op1, L_op2 ));
+ continue;
+ }
+ if (!strcmp(c, "L_>>")) {
+ do_longword( gsm_L_asr( L_op1, L_op2 ));
+ continue;
+ }
+ help();
+ }
+}
+
+#include "private.h"
+
+/*
+ * Function stubs for macro implementations of commonly used
+ * math functions
+ */
+word M_gsm_add P2((op1, op2),word op1, word op2)
+{
+ longword ltmp;
+ return GSM_ADD(op1, op2);
+}
+
+word M_gsm_sub P2((op1, op2), word op1, word op2)
+{
+ longword ltmp;
+ return GSM_SUB(op1, op2);
+}
+
+word M_gsm_mult P2((op1, op2), word op1, word op2)
+{
+ return GSM_MULT(op1, op2);
+}
+
+word M_gsm_mult_r P2((op1, op2), word op1, word op2)
+{
+ return GSM_MULT_R(op1, op2);
+}
+
+word M_gsm_abs P1((op1), word op1)
+{
+ return GSM_ABS(op1);
+}
+
+longword M_gsm_L_mult P2((op1, op2), word op1, word op2)
+{
+ return GSM_L_MULT(op1, op2);
+}
+
+longword M_gsm_L_add P2((op1, op2), longword op1, longword op2)
+{
+ ulongword utmp;
+ return GSM_L_ADD(op1, op2);
+}
diff --git a/third_party/gsm/add-test/add_test.dta b/third_party/gsm/add-test/add_test.dta
new file mode 100644
index 00000000..fe7402d3
--- /dev/null
+++ b/third_party/gsm/add-test/add_test.dta
@@ -0,0 +1,683 @@
+;
+; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+; Universitaet Berlin. See the accompanying file "COPYRIGHT" for
+; details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+;
+;
+; Lines starting with ' (in the first col) are echoed.
+; Lines starting with " (in the first col) are echoed to stderr.
+; Lines starting with ; or empty lines are ignored.
+;
+; The part after (including) a trailing '=' is what you expect;
+; there will be output if the result is different.
+;
+; - and + by itself mean MIN_WORD and MAX_WORD, respectively;
+; -- and ++ mean MIN_LONGWORD and MAX_LONGWORD.
+;
+
+'test the basic arithmetic operations used for the rpe-ltd filtering.
+'
+'add ================
+' basic
+
+ add 0 0 = 0
+ add 7 4 = 11
+ add 4 6 = 10
+ add 1 1 = 2
+
+' negative operands
+
+ add -7 4 = -3
+ add 4 -6 = -2
+ add -1 -3 = -4
+ add 7 -4 = 3
+ add -4 6 = 2
+
+' positive overflow
+; (max-word = 32767)
+ add + 1 = +
+ add + + = +
+ add -1 + = 32766
+ add 32766 2 = +
+ add 1 32766 = +
+
+' underflow
+; (min-word = 32768)
+
+ add - -1 = -
+ add - - = -
+ add 1 - = -32767
+ add -32767 -2 = -
+ add -1 -32766 = -32767
+ add -32767 -1 = -
+ add - + = -1
+ add + - = -1
+ add 0 - = -
+ add 0 + = +
+'
+
+'L_add ================
+' basic
+
+ L_add 0 0 = 0
+ L_add 7 4 = 11
+ L_add 4 6 = 10
+ L_add 1 1 = 2
+
+' negative operands
+
+ L_add -7 4 = -3
+ L_add 4 -6 = -2
+ L_add -1 -3 = -4
+ L_add 7 -4 = 3
+ L_add -4 6 = 2
+ L_add 0 -1 = -1
+
+' positive overflow
+; (max-longword = 2147483647)
+ L_add ++ 1 = ++
+ L_add ++ ++ = ++
+ L_add -1 ++ = 2147483646
+ L_add 2147483646 2 = ++
+ L_add 1 2147483645 = 2147483646
+
+' underflow
+; (min-longword = -2147483648)
+
+ L_add -- -1 = --
+ L_add -- -- = --
+ L_add 1 -- = -2147483647
+ L_add -2147483647 -2 = --
+ L_add -1 -2147483646 = -2147483647
+ L_add -2147483647 -1 = --
+ L_add -- ++ = -1
+ L_add ++ -- = -1
+ L_add 0 -- = --
+ L_add 0 ++ = ++
+'
+
+'sub ================
+' basic
+
+ sub 0 0 = 0
+ sub 7 4 = 3
+ sub 4 6 = -2
+ sub 1 0 = 1
+
+' negative operands
+
+ sub -7 4 = -11
+ sub 4 -6 = 10
+ sub -1 -3 = 2
+ sub 7 -4 = 11
+ sub -4 6 = -10
+
+' positive overflow
+; (max-word = 32767)
+ sub 1 - = +
+ sub + + = 0
+ sub + 0 = +
+ sub + -1 = +
+ sub + 1 = 32766
+ sub 1 + = -32766
+ sub 0 + = -32767
+
+' underflow
+; (min-word = 32768)
+
+ sub - -1 = -32767
+ sub - 1 = -
+ sub - - = 0
+ sub - + = -
+ sub + - = +
+ sub 1 - = +
+ sub -1 - = +
+ sub -32767 2 = -
+ sub 0 - = +
+'
+
+'L_sub ================
+' basic
+
+ L_sub 0 0 = 0
+ L_sub 7 4 = 3
+ L_sub 4 6 = -2
+ L_sub 1 0 = 1
+
+' negative operands
+
+ L_sub -7 4 = -11
+ L_sub 4 -6 = 10
+ L_sub -1 -3 = 2
+ L_sub 7 -4 = 11
+ L_sub -4 6 = -10
+
+' positive overflow
+ L_sub 1 -- = ++
+ L_sub ++ ++ = 0
+ L_sub ++ 0 = ++
+ L_sub ++ -1 = ++
+ L_sub ++ 1 = 2147483646
+ L_sub 1 ++ = -2147483646
+ L_sub 0 ++ = -2147483647
+
+' underflow
+
+ L_sub -- -1 = -2147483647
+ L_sub -- 1 = --
+ L_sub -- -- = 0
+ L_sub -- ++ = --
+ L_sub + -- = ++
+ L_sub 1 -- = ++
+ L_sub -1 -- = ++
+ L_sub -2147483647 2 = --
+ L_sub 0 -- = ++
+
+'
+'abs ================
+' basic
+
+ abs 0 = 0
+ abs 2 = 2
+ abs -459 = 459
+
+' overflow
+
+ abs + = +
+ abs - = +
+ abs -32767 = +
+ abs 32766 = 32766
+ abs -32766 = 32766
+
+'
+'mult ================
+; actually, a * b >> 15
+
+' basic
+ mult 0 0 = 0
+ mult 0x100 0x100 = 2
+ mult 4711 0x4000 = 2355
+
+' negative operands
+ mult -1 0 = 0
+
+ mult -0x100 0x100 = -2
+ mult 0x100 -0x100 = -2
+ mult -0x100 -0x100 = 2
+
+ mult -4711 0x4000 = -2356
+ mult 4711 -0x4000 = -2356
+ mult -4711 -0x4000 = 2355
+
+' overflow
+ mult + + = 32766
+ mult + 0x4000 = 0x3fff
+ mult 0x4000 + = 0x3fff
+ mult + 1 = 0
+ mult + 2 = 1
+ mult + 3 = 2
+
+' underflow
+ mult - - = +
+ mult - + = -32767
+ mult + - = -32767
+ mult - 1 = -1
+ mult - 2 = -2
+ mult - 3 = -3
+
+'
+'mult_r ================
+; actually, (a * b + 16384) >> 15
+
+' basic
+ mult_r 0 0 = 0
+ mult_r 0x100 0x100 = 2
+ mult_r 4711 0x4000 = 2356
+
+' negative operands
+ mult_r -1 0 = 0
+
+ mult_r -0x100 0x100 = -2
+ mult_r 0x100 -0x100 = -2
+ mult_r -0x100 -0x100 = 2
+
+ mult_r -4711 0x4000 = -2355
+ mult_r 4711 -0x4000 = -2355
+ mult_r -4711 -0x4000 = 2356
+
+' overflow
+ mult_r + + = 32766
+ mult_r + 32766 = 32765
+ mult_r 32766 + = 32765
+ mult_r + 0x4000 = 0x4000
+ mult_r 0x4000 + = 0x4000
+ mult_r + 0x4001 = 0x4000
+ mult_r 0x4001 + = 0x4000
+ mult_r + 2 = 2
+ mult_r + 1 = 1
+ mult_r 1 + = 1
+ mult_r + 0 = 0
+ mult_r 0 + = 0
+
+' underflow
+ mult_r - - = +
+ mult_r - + = -32767
+ mult_r + - = -32767
+ mult_r - 1 = -1
+ mult_r - 2 = -2
+ mult_r - 3 = -3
+
+'
+'L_mult ================
+; actually, (a * b) << 1
+; assert (a != MIN_WORD && b != MIN_WORD)
+
+' basic
+ L_mult 0 0 = 0
+ L_mult 2 3 = 12
+ L_mult 4711 5 = 47110
+
+' negative operands
+
+ L_mult -2 3 = -12
+ L_mult 2 -3 = -12
+ L_mult -2 -3 = 12
+ L_mult -4711 5 = -47110
+ L_mult 4711 -5 = -47110
+ L_mult -4711 -5 = 47110
+
+' overflow
+ L_mult + + = 2147352578
+ L_mult + -32767 = -2147352578
+ L_mult -32767 + = -2147352578
+ L_mult + 2 = 131068
+ L_mult + 1 = 65534
+ L_mult 1 + = 65534
+ L_mult + 0 = 0
+ L_mult 0 + = 0
+
+'
+'div ================
+; actually, (32767 * a) / b
+; assert (a > 0 && b >= a)
+
+' basic
+ div 1 1 = +
+ div 4711 4711 = +
+ div 5 10 = 0x4000
+ div 5 20 = 0x2000
+ div 5 40 = 0x1000
+
+' overflow
+ div + + = +
+ div 0x4000 + = 0x4000
+ div 1 + = 1
+ div 1 2 = 0x4000
+'
+'norm ================
+
+' positive
+ norm 1 = 30
+ norm 2 = 29
+ norm 3 = 29
+ norm 4 = 28
+ norm 5 = 28
+; etc, etc...
+ norm 0x08000000 = 3
+ norm 0x10000000 = 2
+ norm 0x20000000 = 1
+ norm 0x20000001 = 1
+ norm 0x3fffffff = 1
+ norm 0x40000000 = 0
+ norm 0x40000001 = 0
+ norm 0x4ffffffe = 0
+ norm ++ = 0
+
+' negative
+ norm -1 = 31
+ norm -2 = 30
+ norm -3 = 29
+ norm -4 = 29
+ norm -5 = 28
+; etc, etc...
+ norm 0x4fffffff = 0
+ norm -- = 0
+'
+'>> ================
+
+' basic
+ >> 1 1 = 0
+ >> 4 2 = 1
+ >> 0x1100 5 = 0x88
+
+' negative operand
+
+ >> 1 -1 = 2
+ >> 1 -2 = 4
+ >> 0x88 -5 = 0x1100
+
+' overflow
+ >> -1 4711 = -1
+ >> 1 4711 = 0
+ >> -4711 4711 = -1
+ >> 4711 4711 = 0
+ >> + 1 = 16383
+ >> - 1 = -16384
+'
+'L_>> ================
+
+' basic
+ L_>> 1 1 = 0
+ L_>> 4 2 = 1
+ L_>> 0x1100 5 = 0x88
+
+' negative operand
+
+ L_>> 1 -1 = 2
+ L_>> 1 -2 = 4
+ L_>> 0x88 -5 = 0x1100
+
+' overflow
+ L_>> -1 4711 = -1
+ L_>> 1 4711 = 0
+ L_>> -4711 4711 = -1
+ L_>> 4711 4711 = 0
+ L_>> ++ 1 = 1073741823
+ L_>> -- 1 = -1073741824
+
+'
+'<< ================
+
+' basic
+ << 1 1 = 2
+ << 4 2 = 16
+ << 0x0088 5 = 0x1100
+
+' negative operand
+
+ << 1 -1 = 0
+ << 4 -2 = 1
+ << 0x1100 -5 = 0x0088
+
+' overflow
+ << -1 4711 = 0
+ << 1 4711 = 0
+ << -4711 4711 = 0
+ << 4711 4711 = 0
+ << 4711 -4711 = 0
+ << -4711 -4711 = -1
+ << + 1 = 0xfffe
+ << -1 1 = 0xfffe
+ << - 1 = 0
+'
+'L_<< ================
+
+' basic
+ L_<< 1 1 = 2
+ L_<< 4 2 = 16
+ L_<< 0x0088 5 = 0x1100
+
+' negative operand
+
+ L_<< 1 -1 = 0
+ L_<< 4 -2 = 1
+ L_<< 0x1100 -5 = 0x0088
+
+' overflow
+ L_<< -1 4711 = 0
+ L_<< 1 4711 = 0
+ L_<< -4711 4711 = 0
+ L_<< 4711 4711 = 0
+ L_<< 4711 -4711 = 0
+ L_<< -4711 -4711 = -1
+ L_<< ++ 1 = -2
+ L_<< -1 1 = -2
+ L_<< -- 1 = 0
+
+'macros
+'
+'add ================
+' basic
+
+ M_add 0 0 = 0
+ M_add 7 4 = 11
+ M_add 4 6 = 10
+ M_add 1 1 = 2
+
+' negative operands
+
+ M_add -7 4 = -3
+ M_add 4 -6 = -2
+ M_add -1 -3 = -4
+ M_add 7 -4 = 3
+ M_add -4 6 = 2
+
+' positive overflow
+; (max-word = 32767)
+ M_add + 1 = +
+ M_add + + = +
+ M_add -1 + = 32766
+ M_add 32766 2 = +
+ M_add 1 32766 = +
+
+' underflow
+; (min-word = 32768)
+
+ M_add - -1 = -
+ M_add - - = -
+ M_add 1 - = -32767
+ M_add -32767 -2 = -
+ M_add -1 -32766 = -32767
+ M_add -32767 -1 = -
+ M_add - + = -1
+ M_add + - = -1
+ M_add 0 - = -
+ M_add 0 + = +
+'
+
+'L_add ================
+' basic
+
+ M_L_add 0 0 = 0
+ M_L_add 7 4 = 11
+ M_L_add 4 6 = 10
+ M_L_add 1 1 = 2
+
+' negative operands
+
+ M_L_add -7 4 = -3
+ M_L_add 4 -6 = -2
+ M_L_add -1 -3 = -4
+ M_L_add 7 -4 = 3
+ M_L_add -4 6 = 2
+ M_L_add 0 -1 = -1
+
+' positive overflow
+; (max-longword = 2147483647)
+ M_L_add ++ 1 = ++
+ M_L_add ++ ++ = ++
+ M_L_add -1 ++ = 2147483646
+ M_L_add 2147483646 2 = ++
+ M_L_add 1 2147483645 = 2147483646
+
+' underflow
+; (min-longword = -2147483648)
+
+ M_L_add -- -1 = --
+ M_L_add -- -- = --
+ M_L_add 1 -- = -2147483647
+ M_L_add -2147483647 -2 = --
+ M_L_add -1 -2147483646 = -2147483647
+ M_L_add -2147483647 -1 = --
+ M_L_add -- ++ = -1
+ M_L_add ++ -- = -1
+ M_L_add 0 -- = --
+ M_L_add 0 ++ = ++
+'
+
+'sub ================
+' basic
+
+ M_sub 0 0 = 0
+ M_sub 7 4 = 3
+ M_sub 4 6 = -2
+ M_sub 1 0 = 1
+
+' negative operands
+
+ M_sub -7 4 = -11
+ M_sub 4 -6 = 10
+ M_sub -1 -3 = 2
+ M_sub 7 -4 = 11
+ M_sub -4 6 = -10
+
+' positive overflow
+; (max-word = 32767)
+ M_sub 1 - = +
+ M_sub + + = 0
+ M_sub + 0 = +
+ M_sub + -1 = +
+ M_sub + 1 = 32766
+ M_sub 1 + = -32766
+ M_sub 0 + = -32767
+
+' underflow
+; (min-word = 32768)
+
+ M_sub - -1 = -32767
+ M_sub - 1 = -
+ M_sub - - = 0
+ M_sub - + = -
+ M_sub + - = +
+ M_sub 1 - = +
+ M_sub -1 - = +
+ M_sub -32767 2 = -
+ M_sub 0 - = +
+'
+'
+'abs ================
+' basic
+
+ M_abs 0 = 0
+ M_abs 2 = 2
+ M_abs -459 = 459
+
+' overflow
+
+ M_abs + = +
+ M_abs - = +
+ M_abs -32767 = +
+ M_abs 32766 = 32766
+ M_abs -32766 = 32766
+
+'
+'mult ================
+; actually, a * b >> 15
+
+' basic
+ M_mult 0 0 = 0
+ M_mult 0x100 0x100 = 2
+ M_mult 4711 0x4000 = 2355
+
+' negative operands
+ M_mult -1 0 = 0
+
+ M_mult -0x100 0x100 = -2
+ M_mult 0x100 -0x100 = -2
+ M_mult -0x100 -0x100 = 2
+
+ M_mult -4711 0x4000 = -2356
+ M_mult 4711 -0x4000 = -2356
+ M_mult -4711 -0x4000 = 2355
+
+' overflow
+ M_mult + + = 32766
+ M_mult + 0x4000 = 0x3fff
+ M_mult 0x4000 + = 0x3fff
+ M_mult + 1 = 0
+ M_mult + 2 = 1
+ M_mult + 3 = 2
+
+' underflow
+; M_mult - - = + assert !(a == b && b == MIN_WORD)
+ M_mult - -32767 = +
+ M_mult -32767 - = +
+ M_mult - + = -32767
+ M_mult + - = -32767
+ M_mult - 1 = -1
+ M_mult - 2 = -2
+ M_mult - 3 = -3
+
+'
+'mult_r ================
+; actually, (a * b + 16384) >> 15
+
+' basic
+ M_mult_r 0 0 = 0
+ M_mult_r 0x100 0x100 = 2
+ M_mult_r 4711 0x4000 = 2356
+
+' negative operands
+ M_mult_r -1 0 = 0
+
+ M_mult_r -0x100 0x100 = -2
+ M_mult_r 0x100 -0x100 = -2
+ M_mult_r -0x100 -0x100 = 2
+
+ M_mult_r -4711 0x4000 = -2355
+ M_mult_r 4711 -0x4000 = -2355
+ M_mult_r -4711 -0x4000 = 2356
+
+' overflow
+ M_mult_r + + = 32766
+ M_mult_r + 32766 = 32765
+ M_mult_r 32766 + = 32765
+ M_mult_r + 0x4000 = 0x4000
+ M_mult_r 0x4000 + = 0x4000
+ M_mult_r + 0x4001 = 0x4000
+ M_mult_r 0x4001 + = 0x4000
+ M_mult_r + 2 = 2
+ M_mult_r + 1 = 1
+ M_mult_r 1 + = 1
+ M_mult_r + 0 = 0
+ M_mult_r 0 + = 0
+
+' underflow
+; M_mult_r - - = + assert !(a == b && b == MIN_WORD)
+ M_mult_r - -32767 = +
+ M_mult_r -32767 - = +
+ M_mult_r - + = -32767
+ M_mult_r + - = -32767
+ M_mult_r - 1 = -1
+ M_mult_r - 2 = -2
+ M_mult_r - 3 = -3
+
+'
+'L_mult ================
+; actually, (a * b) << 1
+; assert (a != MIN_WORD && b != MIN_WORD)
+
+' basic
+ M_L_mult 0 0 = 0
+ M_L_mult 2 3 = 12
+ M_L_mult 4711 5 = 47110
+
+' negative operands
+
+ M_L_mult -2 3 = -12
+ M_L_mult 2 -3 = -12
+ M_L_mult -2 -3 = 12
+ M_L_mult -4711 5 = -47110
+ M_L_mult 4711 -5 = -47110
+ M_L_mult -4711 -5 = 47110
+
+' overflow
+ M_L_mult + + = 2147352578
+ M_L_mult + -32767 = -2147352578
+ M_L_mult -32767 + = -2147352578
+ M_L_mult + 2 = 131068
+ M_L_mult + 1 = 65534
+ M_L_mult 1 + = 65534
+ M_L_mult + 0 = 0
+ M_L_mult 0 + = 0
+