xref: /csrg-svn/lib/libc/quad/TESTS/mul.c (revision 61162)
153798Sbostic /*-
2*61162Sbostic  * Copyright (c) 1992, 1993
3*61162Sbostic  *	The Regents of the University of California.  All rights reserved.
453798Sbostic  *
553798Sbostic  * This software was developed by the Computer Systems Engineering group
653798Sbostic  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
753798Sbostic  * contributed to Berkeley.
853798Sbostic  *
953798Sbostic  * %sccs.include.redist.c%
1053798Sbostic  */
1153798Sbostic 
1253798Sbostic #ifndef lint
13*61162Sbostic static char copyright[] =
14*61162Sbostic "@(#) Copyright (c) 1992, 1993\n\
15*61162Sbostic 	The Regents of the University of California.  All rights reserved.\n";
1653798Sbostic #endif /* not lint */
1753798Sbostic 
1853798Sbostic #ifndef lint
19*61162Sbostic static char sccsid[] = "@(#)mul.c	8.1 (Berkeley) 06/04/93";
2053798Sbostic #endif /* not lint */
2153798Sbostic 
2253798Sbostic #include <stdio.h>
2353798Sbostic 
main()2453798Sbostic main()
2553798Sbostic {
2653798Sbostic 	union { long long q; unsigned long v[2]; } a, b, m;
2753798Sbostic 	char buf[300];
2853798Sbostic 	extern long long __muldi3(long long, long long);
2953798Sbostic 
3053798Sbostic 	for (;;) {
3153798Sbostic 		printf("> ");
3253798Sbostic 		if (fgets(buf, sizeof buf, stdin) == NULL)
3353798Sbostic 			break;
3453798Sbostic 		if (sscanf(buf, "%lu:%lu %lu:%lu",
3553798Sbostic 			    &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 &&
3653798Sbostic 		    sscanf(buf, "0x%lx:%lx 0x%lx:%lx",
3753798Sbostic 			    &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) {
3853798Sbostic 			printf("eh?\n");
3953798Sbostic 			continue;
4053798Sbostic 		}
4153798Sbostic 		m.q = __muldi3(a.q, b.q);
4253798Sbostic 		printf("%lx:%lx * %lx:%lx => %lx:%lx\n",
4353798Sbostic 		    a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]);
4453798Sbostic 		printf("  = %lX%08lX * %lX%08lX => %lX%08lX\n",
4553798Sbostic 		    a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]);
4653798Sbostic 	}
4753798Sbostic 	exit(0);
4853798Sbostic }
49