1 /*-
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This software was developed by the Computer Systems Engineering group
6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
7 * contributed to Berkeley.
8 *
9 * %sccs.include.redist.c%
10 */
11
12 #ifndef lint
13 static char copyright[] =
14 "@(#) Copyright (c) 1992, 1993\n\
15 The Regents of the University of California. All rights reserved.\n";
16 #endif /* not lint */
17
18 #ifndef lint
19 static char sccsid[] = "@(#)mul.c 8.1 (Berkeley) 06/04/93";
20 #endif /* not lint */
21
22 #include <stdio.h>
23
main()24 main()
25 {
26 union { long long q; unsigned long v[2]; } a, b, m;
27 char buf[300];
28 extern long long __muldi3(long long, long long);
29
30 for (;;) {
31 printf("> ");
32 if (fgets(buf, sizeof buf, stdin) == NULL)
33 break;
34 if (sscanf(buf, "%lu:%lu %lu:%lu",
35 &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 &&
36 sscanf(buf, "0x%lx:%lx 0x%lx:%lx",
37 &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) {
38 printf("eh?\n");
39 continue;
40 }
41 m.q = __muldi3(a.q, b.q);
42 printf("%lx:%lx * %lx:%lx => %lx:%lx\n",
43 a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]);
44 printf(" = %lX%08lX * %lX%08lX => %lX%08lX\n",
45 a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]);
46 }
47 exit(0);
48 }
49