DRAFT test: Add 68-truncate-shift.

* lib/tests/scaffold/68-truncate-shift.c: New file.
* build-aux/check-mescc.sh (mes_tests): Add it.
This commit is contained in:
Janneke Nieuwenhuizen 2023-07-30 09:52:14 +02:00
parent 592a612777
commit 83f26445b0
2 changed files with 62 additions and 0 deletions

View file

@ -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="

View file

@ -0,0 +1,61 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2023 Andrius Štikonas <andrius@stikonas.eu>
* Copyright © 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
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;
}