--- /dev/null
+#include <time.h>\r
+#include <conio.h>\r
+#include <ctype.h>\r
+\r
+\r
+/* Number of elements in the progress bar. Use a power of 2 to avoid the\r
+ * multiplication (which is about to be tested).\r
+ */\r
+#define BAR_ELEMENTS 32U\r
+\r
+/* Screen coordinates for the progress meter */\r
+static unsigned char Width, Height;\r
+static unsigned char X, Y;\r
+\r
+static void ProgressMeter (unsigned Val)\r
+/* Print the progress bar */\r
+{\r
+ cclearxy (X, Y, Width);\r
+ gotoxy (X, Y);\r
+ cprintf ("% 6lu/65536", (unsigned long) Val);\r
+}\r
+\r
+\r
+\r
+int main(void)\r
+{\r
+ char C;\r
+\r
+ /* Clock variable */\r
+ clock_t Ticks;\r
+ unsigned Sec;\r
+ unsigned Milli;\r
+\r
+ /* Actual test variables */\r
+ register unsigned lhs = 0;\r
+ register unsigned rhs = 0;\r
+ register unsigned res;\r
+\r
+ /* Clear the screen and output an informational message */\r
+ clrscr ();\r
+ screensize (&Width, &Height);\r
+ cprintf ("This program does an exhaustive test of\r\n"\r
+ "the multiplication routine. It runs\r\n"\r
+ "several days, so please wait very\r\n"\r
+ "patiently (or speedup your emulator)\r\n"\r
+ "\r\n"\r
+ "Progress:\r\n");\r
+\r
+ /* Remember the current position for the progress bar */\r
+ X = wherex ();\r
+ Y = wherey ();\r
+\r
+\r
+ /* Read the clock */\r
+ Ticks = clock();\r
+\r
+\r
+ do {\r
+\r
+ /* Update the progress bar */\r
+ ProgressMeter (lhs);\r
+\r
+ /* Do one row of tests */\r
+ res = 0;\r
+ do {\r
+ if (lhs * rhs != res) {\r
+ gotoxy (X, Y+1);\r
+ cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);\r
+ cprintf ("Press a key ..., 'Q' to quit");\r
+ C = toupper (cgetc ());\r
+ cclearxy (X, Y+1, Width);\r
+ cclearxy (X, Y+2, Width);\r
+ if (C == 'Q') {\r
+ goto Done;\r
+ }\r
+ }\r
+ res += lhs;\r
+ } while (++rhs != 0);\r
+\r
+ } while (++lhs != 0);\r
+\r
+Done:\r
+ /* Calculate the time used */\r
+ Ticks = clock() - Ticks;\r
+ Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);\r
+ Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;\r
+\r
+ /* Print the time used */\r
+ gotoxy (X, Y+1);\r
+ cprintf ("Time used: %u.%03u seconds\n", Sec, Milli);\r
+\r
+ return 0;\r
+}\r
+\r
+\r