From bc4339815fd6e4b66439c46e3a756de17a1bb6e7 Mon Sep 17 00:00:00 2001 From: Janneke Nieuwenhuizen Date: Sun, 30 Jul 2023 09:52:14 +0200 Subject: [PATCH] DRAFT test: Add 68-truncate-shift. * lib/tests/scaffold/68-truncate-shift.c: New file. * build-aux/check-mescc.sh (mes_tests): Add it. --- build-aux/check-mescc.sh | 1 + lib/tests/scaffold/68-truncate-shift.c | 61 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lib/tests/scaffold/68-truncate-shift.c diff --git a/build-aux/check-mescc.sh b/build-aux/check-mescc.sh index 9789971b..0410c944 100755 --- a/build-aux/check-mescc.sh +++ b/build-aux/check-mescc.sh @@ -136,6 +136,7 @@ lib/tests/scaffold/64-make-cell.c lib/tests/scaffold/65-read.c lib/tests/scaffold/66-local-char-array.c lib/tests/scaffold/67-m1-overflow-check.c +lib/tests/scaffold/68-truncate-shift.c " tcc_tests=" diff --git a/lib/tests/scaffold/68-truncate-shift.c b/lib/tests/scaffold/68-truncate-shift.c new file mode 100644 index 00000000..f766eee1 --- /dev/null +++ b/lib/tests/scaffold/68-truncate-shift.c @@ -0,0 +1,61 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2023 Andrius Štikonas + * Copyright © 2023 Janneke Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include + +int +main () +{ + int a = 0x1001; + eputs ("a="); + eputs (ntoab (a, 16, 1)); + eputs ("\n"); + + asm (";;//b = a << 20;"); + int b = a << 20; + asm (";;//print b;"); + eputs ("b="); + eputs (ntoab (b, 16, 1)); + eputs ("\n"); + if (b != 0x100000) + return 1; + + asm (";;//c = b >> 20;"); + int c = b >> 20;; + asm (";;//print c;"); + eputs ("c="); + eputs (ntoab (c, 16, 1)); + eputs ("\n"); + if (c != 1) + return 2; + + asm (";;//x = a << 20 >> 20;"); + int x = a << 20 >> 20; + // printf ("x=%d\n", x); + asm (";;//print x;"); + eputs ("x="); + eputs (ntoab (x, 16, 1)); + eputs ("\n"); + if (x != 1) + return 3; + + return 0; +}