DeSmet C88 v3.1b
This commit is contained in:
parent
7b05b54898
commit
b2f79aeb5e
BIN
DeSmet C88 v31b/ASM88.EXE
Normal file
BIN
DeSmet C88 v31b/ASM88.EXE
Normal file
Binary file not shown.
12
DeSmet C88 v31b/ASSERT.H
Normal file
12
DeSmet C88 v31b/ASSERT.H
Normal file
@ -0,0 +1,12 @@
|
||||
# ifdef NDEBUG
|
||||
|
||||
# define assert(e)
|
||||
|
||||
# else
|
||||
|
||||
# define assert(e) if(!(e)) {\
|
||||
printf("Assertion (" # e ") failed: file %s, line %d\n", __FILE__, __LINE__);\
|
||||
abort();\
|
||||
}
|
||||
|
||||
# endif
|
BIN
DeSmet C88 v31b/BIND.EXE
Normal file
BIN
DeSmet C88 v31b/BIND.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/BUF128.EXE
Normal file
BIN
DeSmet C88 v31b/BUF128.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/BUGS!.EXE
Normal file
BIN
DeSmet C88 v31b/BUGS!.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/C.OBJ
Normal file
BIN
DeSmet C88 v31b/C.OBJ
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/C88.EXE
Normal file
BIN
DeSmet C88 v31b/C88.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/C88.LIB
Normal file
BIN
DeSmet C88 v31b/C88.LIB
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/C887.LIB
Normal file
BIN
DeSmet C88 v31b/C887.LIB
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/CLIST.EXE
Normal file
BIN
DeSmet C88 v31b/CLIST.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/COMPARE.EXE
Normal file
BIN
DeSmet C88 v31b/COMPARE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/COMPARE.O
Normal file
BIN
DeSmet C88 v31b/COMPARE.O
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/CSTDIO.S
Normal file
BIN
DeSmet C88 v31b/CSTDIO.S
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/CSTDIO7.S
Normal file
BIN
DeSmet C88 v31b/CSTDIO7.S
Normal file
Binary file not shown.
26
DeSmet C88 v31b/CTYPE.H
Normal file
26
DeSmet C88 v31b/CTYPE.H
Normal file
@ -0,0 +1,26 @@
|
||||
#define _U 0x01 /* Upper case */
|
||||
#define _L 0x02 /* Lower case */
|
||||
#define _N 0x04 /* Numeral (digit) */
|
||||
#define _S 0x08 /* Spacing character */
|
||||
#define _P 0x10 /* Punctuation */
|
||||
#define _C 0x20 /* Control character */
|
||||
#define _B 0x40 /* Blank */
|
||||
#define _X 0x80 /* heXadecimal digit */
|
||||
|
||||
extern char _ctype[];
|
||||
|
||||
#define isalpha(c) ((_ctype + 1)[c] & (_U | _L))
|
||||
#define isupper(c) ((_ctype + 1)[c] & _U)
|
||||
#define islower(c) ((_ctype + 1)[c] & _L)
|
||||
#define isdigit(c) ((_ctype + 1)[c] & _N)
|
||||
#define isxdigit(c) ((_ctype + 1)[c] & _X)
|
||||
#define isalnum(c) ((_ctype + 1)[c] & (_U | _L | _N))
|
||||
#define isspace(c) ((_ctype + 1)[c] & _S)
|
||||
#define ispunct(c) ((_ctype + 1)[c] & _P)
|
||||
#define isprint(c) ((_ctype + 1)[c] & (_P | _U | _L | _N | _B))
|
||||
#define isgraph(c) ((_ctype + 1)[c] & (_P | _U | _L | _N))
|
||||
#define iscntrl(c) ((_ctype + 1)[c] & _C)
|
||||
#define isascii(c) (!((c) & ~0177))
|
||||
#define _toupper(c) ((c) - 'a' + 'A')
|
||||
#define _tolower(c) ((c) - 'A' + 'a')
|
||||
#define toascii(c) ((c) & 0177)
|
BIN
DeSmet C88 v31b/D88.EXE
Normal file
BIN
DeSmet C88 v31b/D88.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/D88.O
Normal file
BIN
DeSmet C88 v31b/D88.O
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/D88REST.O
Normal file
BIN
DeSmet C88 v31b/D88REST.O
Normal file
Binary file not shown.
34
DeSmet C88 v31b/DOS.H
Normal file
34
DeSmet C88 v31b/DOS.H
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
; note: FP_OFF and FP_SEG only work in large case
|
||||
*/
|
||||
|
||||
/* Mode bits for chdir(). Or the bits desired. */
|
||||
|
||||
#define CHDIR_READONLY 1
|
||||
#define CHDIR_HIDDEN 2
|
||||
|
||||
/* #defines for extraction offset and segment from a pointer. */
|
||||
|
||||
struct {unsigned _offset,_segment;};
|
||||
#define FP_OFF(ptr) ((((char *)&ptr))->_offset)
|
||||
#define FP_SEG(ptr) ((((char *)&ptr))->_segment)
|
||||
|
||||
/* Codes for locking and unlocking. Used by locking(). */
|
||||
|
||||
#define LOCK 0
|
||||
#define UNLCK 1
|
||||
|
||||
/* Open modes. */
|
||||
|
||||
#define READ 0
|
||||
#define WRITE 1
|
||||
#define READWRITE 2
|
||||
|
||||
/* Open sharing modes. Add to above open modes. */
|
||||
|
||||
#define COMPAT 0x00 /* compatibility mode */
|
||||
#define DENYRW 0x10 /* deny read/write mode */
|
||||
#define DENYWR 0x20 /* deny write mode */
|
||||
#define DENYRD 0x30 /* deny read mode */
|
||||
#define DENYNO 0x40 /* deny none mode */
|
||||
|
BIN
DeSmet C88 v31b/DUMP.EXE
Normal file
BIN
DeSmet C88 v31b/DUMP.EXE
Normal file
Binary file not shown.
35
DeSmet C88 v31b/E.C
Normal file
35
DeSmet C88 v31b/E.C
Normal file
@ -0,0 +1,35 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef MWC
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
#define DIGITS_TO_FIND 200 /*9009*/
|
||||
|
||||
int main() {
|
||||
|
||||
int N = DIGITS_TO_FIND;
|
||||
int x = 0;
|
||||
int a[ DIGITS_TO_FIND ];
|
||||
int n;
|
||||
|
||||
for (n = N - 1; n > 0; --n) {
|
||||
a[n] = 1;
|
||||
}
|
||||
|
||||
a[1] = 2, a[0] = 0;
|
||||
while (N > 9) {
|
||||
n = N--;
|
||||
while (--n) {
|
||||
a[n] = x % n;
|
||||
|
||||
x = 10 * a[n-1] + x/n;
|
||||
}
|
||||
printf("%d", x);
|
||||
}
|
||||
|
||||
printf( "\ndone\n" );
|
||||
|
||||
return 0;
|
||||
}
|
3
DeSmet C88 v31b/ERRNO.H
Normal file
3
DeSmet C88 v31b/ERRNO.H
Normal file
@ -0,0 +1,3 @@
|
||||
/* david lee made this */
|
||||
|
||||
|
BIN
DeSmet C88 v31b/EXEC.O
Normal file
BIN
DeSmet C88 v31b/EXEC.O
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/EXEC.OBJ
Normal file
BIN
DeSmet C88 v31b/EXEC.OBJ
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/FASTSCR.EXE
Normal file
BIN
DeSmet C88 v31b/FASTSCR.EXE
Normal file
Binary file not shown.
3
DeSmet C88 v31b/FCNTL.H
Normal file
3
DeSmet C88 v31b/FCNTL.H
Normal file
@ -0,0 +1,3 @@
|
||||
/* david lee made this */
|
||||
|
||||
|
21
DeSmet C88 v31b/FLOAT.H
Normal file
21
DeSmet C88 v31b/FLOAT.H
Normal file
@ -0,0 +1,21 @@
|
||||
#define FLT_RADIX 2
|
||||
|
||||
#define FLT_MANT_DIG 24
|
||||
#define FLT_EPSILON 1.19209290E-07
|
||||
#define FLT_DIG 6
|
||||
#define FLT_MIN_EXP -125
|
||||
#define FLT_MIN 1.17549435E-38
|
||||
#define FLT_MIN_10_EXP -37
|
||||
#define FLT_MAX_EXP 128
|
||||
#define FLT_MAX 3.40282347E+38
|
||||
#define FLT_MAX_10_EXP 38
|
||||
|
||||
#define DBL_MANT_DIG 53
|
||||
#define DBL_EPSILON 2.2204460492503131E-16
|
||||
#define DBL_DIG 15
|
||||
#define DBL_MIN_EXP -1021
|
||||
#define DBL_MIN 2.225073858507201E-308
|
||||
#define DBL_MIN_10_EXP -307
|
||||
#define DBL_MAX_EXP +1024
|
||||
#define DBL_MAX 1.797693134862316E+308
|
||||
#define DBL_MAX_10_EXP +308
|
BIN
DeSmet C88 v31b/FREE.EXE
Normal file
BIN
DeSmet C88 v31b/FREE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/GEN.EXE
Normal file
BIN
DeSmet C88 v31b/GEN.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/GREP.EXE
Normal file
BIN
DeSmet C88 v31b/GREP.EXE
Normal file
Binary file not shown.
3
DeSmet C88 v31b/IO.H
Normal file
3
DeSmet C88 v31b/IO.H
Normal file
@ -0,0 +1,3 @@
|
||||
/* david lee made this */
|
||||
|
||||
|
BIN
DeSmet C88 v31b/LIB88.EXE
Normal file
BIN
DeSmet C88 v31b/LIB88.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/LIFE.EXE
Normal file
BIN
DeSmet C88 v31b/LIFE.EXE
Normal file
Binary file not shown.
24
DeSmet C88 v31b/LIMITS.H
Normal file
24
DeSmet C88 v31b/LIMITS.H
Normal file
@ -0,0 +1,24 @@
|
||||
#define CHAR_BIT 8
|
||||
|
||||
#define SCHAR_MIN -127
|
||||
#define SCHAR_MAX 127
|
||||
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
#define CHAR_MIN 0
|
||||
#define CHAR_MAX 255
|
||||
|
||||
#define SHRT_MIN -32767
|
||||
#define SHRT_MAX 32767
|
||||
|
||||
#define USHRT_MAX 65535
|
||||
|
||||
#define INT_MIN -32767
|
||||
#define INT_MAX 32767
|
||||
|
||||
#define UINT_MAX 65535
|
||||
|
||||
#define LONG_MIN -2147483647
|
||||
#define LONG_MAX 2147483647
|
||||
|
||||
#define ULONG_MAX 4294967295
|
4
DeSmet C88 v31b/LLINK.BAT
Normal file
4
DeSmet C88 v31b/LLINK.BAT
Normal file
@ -0,0 +1,4 @@
|
||||
c88 %1 m
|
||||
if errorlevel 1 goto stop
|
||||
link c %1,%1,nul,c88;
|
||||
:stop
|
BIN
DeSmet C88 v31b/LS.EXE
Normal file
BIN
DeSmet C88 v31b/LS.EXE
Normal file
Binary file not shown.
52
DeSmet C88 v31b/MATH.H
Normal file
52
DeSmet C88 v31b/MATH.H
Normal file
@ -0,0 +1,52 @@
|
||||
struct exception {
|
||||
int type;
|
||||
char *name;
|
||||
double arg1;
|
||||
double arg2;
|
||||
double retval;
|
||||
} ;
|
||||
|
||||
struct complex {
|
||||
double x,y;
|
||||
} ;
|
||||
|
||||
#define DOMAIN 1
|
||||
#define SING 2
|
||||
#define OVERFLOW 3
|
||||
#define UNDERFLOW 4
|
||||
#define TLOSS 5
|
||||
#define PLOSS 6
|
||||
|
||||
#define EDOM 33
|
||||
#define ERANGE 34
|
||||
|
||||
extern int errno;
|
||||
|
||||
#define HUGE_VAL 1.797693134862316E+308
|
||||
|
||||
double acos(double);
|
||||
double asin(double);
|
||||
double atan(double);
|
||||
double atan2(double, double);
|
||||
double ceil(double);
|
||||
double cos(double);
|
||||
double exp(double);
|
||||
double fabs(double);
|
||||
double floor(double);
|
||||
double frexp(double, int *);
|
||||
double ldexp(double, double);
|
||||
double log(double);
|
||||
double log10(double);
|
||||
double modf(double, double *);
|
||||
double pow(double, double);
|
||||
double sin(double);
|
||||
double sqrt(double);
|
||||
double tan(double);
|
||||
|
||||
#ifndef atof
|
||||
double strtod(const char *, char **);
|
||||
#define atof(c) strtod((c), (char**)0);
|
||||
#endif
|
||||
|
||||
double _pi(void);
|
||||
double _pi_2(void);
|
BIN
DeSmet C88 v31b/MERGE.EXE
Normal file
BIN
DeSmet C88 v31b/MERGE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/MORE.EXE
Normal file
BIN
DeSmet C88 v31b/MORE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/MSVER1.O
Normal file
BIN
DeSmet C88 v31b/MSVER1.O
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/PCMAKE.EXE
Normal file
BIN
DeSmet C88 v31b/PCMAKE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/PROFEND.EXE
Normal file
BIN
DeSmet C88 v31b/PROFEND.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/PROFILE.EXE
Normal file
BIN
DeSmet C88 v31b/PROFILE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/PROFSTAR.EXE
Normal file
BIN
DeSmet C88 v31b/PROFSTAR.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/RAM.COM
Normal file
BIN
DeSmet C88 v31b/RAM.COM
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/RM.EXE
Normal file
BIN
DeSmet C88 v31b/RM.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/SEE.EXE
Normal file
BIN
DeSmet C88 v31b/SEE.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/SEE.O
Normal file
BIN
DeSmet C88 v31b/SEE.O
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/SENSE87.S
Normal file
BIN
DeSmet C88 v31b/SENSE87.S
Normal file
Binary file not shown.
3
DeSmet C88 v31b/SETJMP.H
Normal file
3
DeSmet C88 v31b/SETJMP.H
Normal file
@ -0,0 +1,3 @@
|
||||
/* setjmp.h -- setjmp(), longjmp() environment */
|
||||
|
||||
typedef char jmp_buf[10];
|
35
DeSmet C88 v31b/SIEVE.C
Normal file
35
DeSmet C88 v31b/SIEVE.C
Normal file
@ -0,0 +1,35 @@
|
||||
/* sieve.c */
|
||||
|
||||
/* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983
|
||||
to compare the speed. */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define SIZE 8190
|
||||
typedef int bool;
|
||||
|
||||
char flags[SIZE+1];
|
||||
|
||||
int main()
|
||||
{
|
||||
int i,k;
|
||||
int prime,count,iter;
|
||||
|
||||
for (iter = 1; iter <= 10; iter++) { /* do program 10 times */
|
||||
count = 0; /* initialize prime counter */
|
||||
for (i = 0; i <= SIZE; i++) /* set all flags TRUE */
|
||||
flags[i] = TRUE;
|
||||
for (i = 0; i <= SIZE; i++) {
|
||||
if (flags[i]) { /* found a prime */
|
||||
prime = i + i + 3; /* twice index + 3 */
|
||||
for (k = i + prime; k <= SIZE; k += prime)
|
||||
flags[k] = FALSE; /* kill all multiples */
|
||||
count++; /* primes found */
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d primes.\n",count); /*primes found in 10th pass */
|
||||
return 0;
|
||||
}
|
5
DeSmet C88 v31b/STDARG.H
Normal file
5
DeSmet C88 v31b/STDARG.H
Normal file
@ -0,0 +1,5 @@
|
||||
typedef char *va_list;
|
||||
|
||||
#define va_start(ap,v) ap = (va_list)&v + sizeof(v)
|
||||
#define va_arg(ap,t) ((t*)(ap += sizeof(t)))[-1]
|
||||
#define va_end(ap) ap = NULL
|
79
DeSmet C88 v31b/STDIO.H
Normal file
79
DeSmet C88 v31b/STDIO.H
Normal file
@ -0,0 +1,79 @@
|
||||
/* STDIO.H Include file for C88 input/output. */
|
||||
|
||||
/* a 'FILE' is simply an integer is this implimentation */
|
||||
|
||||
#define FILE int
|
||||
|
||||
/* Standard input, standard output and standard error. */
|
||||
|
||||
#define stdin (FILE *)0
|
||||
#define stdout (FILE *)1
|
||||
#define stderr (FILE *)2
|
||||
#define stdaux (FILE *)3
|
||||
#define stdprn (FILE *)4
|
||||
|
||||
#ifdef LARGE_CASE
|
||||
|
||||
/* With LARGE case (-B option), */
|
||||
/* Use lower case stdin, stdout etc with fopen(), fread(), getc() etc. */
|
||||
/* Use upper case STDIN, STDOUT etc with open(), read() etc. */
|
||||
|
||||
#define STDIN 0
|
||||
#define STDOUT 1
|
||||
#define STDERR 2
|
||||
#define STDAUX 3
|
||||
#define STDPRN 4
|
||||
|
||||
#endif
|
||||
|
||||
#define NULL (void *)0
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#define EOF (-1)
|
||||
#define ERR (-1)
|
||||
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
#define F_ERR 1
|
||||
#define F_EOF 2
|
||||
|
||||
extern char _flag[];
|
||||
|
||||
#define feof(f) (_flag[(int)f] & F_EOF)
|
||||
#define ferror(f) (_flag[(int)f] & F_ERR)
|
||||
#define clrerror(f) (_flag[(int)f] & ~(F_ERR | F_EOF))
|
||||
|
||||
int closeall(void);
|
||||
int fclose(FILE *);
|
||||
int fflush(FILE *);
|
||||
int fgetc(FILE *);
|
||||
int fgetchar(void);
|
||||
char *fgets(char *, int, FILE *);
|
||||
long filelength(int);
|
||||
int fileno(FILE *);
|
||||
FILE *fopen(char *, char *);
|
||||
int fprintf(FILE *, char *, ... );
|
||||
int fputc(int, FILE *);
|
||||
int fputchar(int);
|
||||
int fputs(char *, FILE *);
|
||||
int fread(char *, int, int, FILE *);
|
||||
FILE *freopen(char *, char *, FILE *);
|
||||
int fscanf(FILE *, char *, ... );
|
||||
long fseek(FILE *, long, int);
|
||||
long ftell(FILE *);
|
||||
int fwrite(char *, int, int, FILE *);
|
||||
int getc(FILE *);
|
||||
int getchar(void);
|
||||
char *gets(char *);
|
||||
int getw(FILE *);
|
||||
int printf(char *, ... );
|
||||
int puts(char *);
|
||||
int putw(int, FILE *);
|
||||
int rewind(FILE *);
|
||||
int scanf(char *, ... );
|
||||
int sprintf(char *, char *, ... );
|
||||
int sscanf(char *, char *, ... );
|
||||
int ungetc(int, FILE *);
|
||||
|
36
DeSmet C88 v31b/STDLIB.H
Normal file
36
DeSmet C88 v31b/STDLIB.H
Normal file
@ -0,0 +1,36 @@
|
||||
extern int errno;
|
||||
|
||||
#define ERANGE 34
|
||||
|
||||
#define HUGE_VAL 1.797693134862316E+308
|
||||
|
||||
#define RAND_MAX 32767
|
||||
|
||||
extern unsigned environ;
|
||||
|
||||
extern unsigned _psp;
|
||||
|
||||
extern char _osmajor, _osminor;
|
||||
|
||||
int abs(int);
|
||||
char *getenv(char *, char *, ...);
|
||||
char *itoa(int, char *, int);
|
||||
long labs(long);
|
||||
char *ltoa(long, char *, int);
|
||||
int putenv(char *, char *);
|
||||
int rand(void);
|
||||
void srand(int);
|
||||
double strtod(const char *, char **);
|
||||
long strtol(const char *, char **, int);
|
||||
|
||||
#ifndef tolower
|
||||
int tolower(int);
|
||||
#endif
|
||||
|
||||
#ifndef toupper
|
||||
int toupper(int);
|
||||
#endif
|
||||
|
||||
#define atoi(c) (int)strtol((c), (char**)0, 0)
|
||||
#define atol(c) strtol((c), (char**)0, 0)
|
||||
#define atof(c) strtod((c), (char**)0);
|
30
DeSmet C88 v31b/STRING.H
Normal file
30
DeSmet C88 v31b/STRING.H
Normal file
@ -0,0 +1,30 @@
|
||||
typedef unsigned size_t;
|
||||
|
||||
void *memccpy( void *, void *, char, size_t );
|
||||
void *memchr( void *, int, size_t );
|
||||
int memcmp( void *, void *, size_t );
|
||||
void *memcpy( void *, void *, size_t );
|
||||
int memicmp( void *, void *, size_t );
|
||||
void *memmove( void *, void *, size_t );
|
||||
void *memset( void *, char, size_t );
|
||||
|
||||
char *strcat(char *, char *);
|
||||
char *strchr(char *, char);
|
||||
int strcmp(char *, char *);
|
||||
int strcmpi(char *, char *);
|
||||
char *strcpy(char *, char *);
|
||||
unsigned strcspn(char *, char *);
|
||||
char *strdup(char *);
|
||||
int stricmp(char *, char *);
|
||||
unsigned strlen(char *);
|
||||
char *strlwr(char *);
|
||||
char *strncat(char *, char *, unsigned int);
|
||||
int strncmp(char *, char *, unsigned int);
|
||||
char *strncpy(char *, char *, unsigned int);
|
||||
char *strrchr(char *, int);
|
||||
char *strrev(char *);
|
||||
char *strset(char *, int);
|
||||
unsigned strspn(char *, char *);
|
||||
char *strstr(char *, char *);
|
||||
char *strtok(char *, char *);
|
||||
char *strupr(char *);
|
3
DeSmet C88 v31b/TIME.H
Normal file
3
DeSmet C88 v31b/TIME.H
Normal file
@ -0,0 +1,3 @@
|
||||
/* david lee made this */
|
||||
|
||||
|
BIN
DeSmet C88 v31b/TOOBJ.EXE
Normal file
BIN
DeSmet C88 v31b/TOOBJ.EXE
Normal file
Binary file not shown.
BIN
DeSmet C88 v31b/TOOLBOX.S
Normal file
BIN
DeSmet C88 v31b/TOOLBOX.S
Normal file
Binary file not shown.
527
DeSmet C88 v31b/TTT.C
Normal file
527
DeSmet C88 v31b/TTT.C
Normal file
@ -0,0 +1,527 @@
|
||||
/*
|
||||
This version builds with old compilers including:
|
||||
Aztec C 1.06 for 8080 & Z80 on CP/M.
|
||||
Microsoft C Compiler V1.04 for 8086 on DOS. (This is Lattice C)
|
||||
Microsoft C Compiler V2.03 for 8086 on DOS. (Still Lattice C)
|
||||
Microsoft C Compiler V3.00 for 8086 on DOS.
|
||||
QuickC 1.0
|
||||
Turbo C 2.0
|
||||
The syntax is old and reminds me of 7th grade summer vacation.
|
||||
Much of this code is awkward to satisfy the lowest common denominator of many compilers.
|
||||
unsigned long isn't supported in many older compilers, so long is used instead.
|
||||
Early DOS and CP/M require register variabes to be int, not char or other types.
|
||||
The perf improvement of using register-int instead of stack-char is worth it.
|
||||
*/
|
||||
|
||||
#define LINT_ARGS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef DOSTIME
|
||||
#include <time.h>
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
#define true 1
|
||||
#define false 0
|
||||
|
||||
/* Function Pointers are the fastest implementation for almost every compiler */
|
||||
#define UseFunPointers 1
|
||||
#define UseWinner2 2
|
||||
#define UseLookForWinner 3
|
||||
#define WinMethod UseFunPointers
|
||||
|
||||
#define ABPrune true /* alpha beta pruning */
|
||||
#define WinLosePrune true /* stop early on win/lose */
|
||||
#define ScoreWin 6
|
||||
#define ScoreTie 5
|
||||
#define ScoreLose 4
|
||||
#define ScoreMax 9
|
||||
#define ScoreMin 2
|
||||
#define DefaultIterations 10
|
||||
|
||||
#define PieceX 1
|
||||
#define PieceO 2
|
||||
#define PieceBlank 0
|
||||
|
||||
typedef char ttype; /* 8-bit and 16-bit cpus do best with char aside from register in locals */
|
||||
|
||||
int g_Iterations = DefaultIterations;
|
||||
ttype g_board[ 9 ];
|
||||
|
||||
#if WinMethod == UseFunPointers
|
||||
|
||||
ttype pos0func()
|
||||
{
|
||||
/* using "register int" instead of "ttype" for x is faster on 8086 and Z80 */
|
||||
register int x = g_board[0];
|
||||
|
||||
if ( ( x == g_board[1] && x == g_board[2] ) ||
|
||||
( x == g_board[3] && x == g_board[6] ) ||
|
||||
( x == g_board[4] && x == g_board[8] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos1func()
|
||||
{
|
||||
register int x = g_board[1];
|
||||
|
||||
if ( ( x == g_board[0] && x == g_board[2] ) ||
|
||||
( x == g_board[4] && x == g_board[7] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos2func()
|
||||
{
|
||||
register int x = g_board[2];
|
||||
|
||||
if ( ( x == g_board[0] && x == g_board[1] ) ||
|
||||
( x == g_board[5] && x == g_board[8] ) ||
|
||||
( x == g_board[4] && x == g_board[6] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos3func()
|
||||
{
|
||||
register int x = g_board[3];
|
||||
|
||||
if ( ( x == g_board[4] && x == g_board[5] ) ||
|
||||
( x == g_board[0] && x == g_board[6] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos4func()
|
||||
{
|
||||
register int x = g_board[4];
|
||||
|
||||
if ( ( x == g_board[0] && x == g_board[8] ) ||
|
||||
( x == g_board[2] && x == g_board[6] ) ||
|
||||
( x == g_board[1] && x == g_board[7] ) ||
|
||||
( x == g_board[3] && x == g_board[5] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos5func()
|
||||
{
|
||||
register int x = g_board[5];
|
||||
|
||||
if ( ( x == g_board[3] && x == g_board[4] ) ||
|
||||
( x == g_board[2] && x == g_board[8] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos6func()
|
||||
{
|
||||
register int x = g_board[6];
|
||||
|
||||
if ( ( x == g_board[7] && x == g_board[8] ) ||
|
||||
( x == g_board[0] && x == g_board[3] ) ||
|
||||
( x == g_board[4] && x == g_board[2] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos7func()
|
||||
{
|
||||
register int x = g_board[7];
|
||||
|
||||
if ( ( x == g_board[6] && x == g_board[8] ) ||
|
||||
( x == g_board[1] && x == g_board[4] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
ttype pos8func()
|
||||
{
|
||||
register int x = g_board[8];
|
||||
|
||||
if ( ( x == g_board[6] && x == g_board[7] ) ||
|
||||
( x == g_board[2] && x == g_board[5] ) ||
|
||||
( x == g_board[0] && x == g_board[4] ) )
|
||||
return x;
|
||||
return PieceBlank;
|
||||
}
|
||||
|
||||
typedef ttype pfunc_t();
|
||||
|
||||
pfunc_t * winner_functions[9] =
|
||||
{
|
||||
pos0func,
|
||||
pos1func,
|
||||
pos2func,
|
||||
pos3func,
|
||||
pos4func,
|
||||
pos5func,
|
||||
pos6func,
|
||||
pos7func,
|
||||
pos8func
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if WinMethod == UseWinner2
|
||||
|
||||
ttype winner2( move ) ttype move;
|
||||
{
|
||||
register int x; /* faster than ttype x on the stack */
|
||||
|
||||
switch( move ) /* msc v3 from 1985 generates a jump table! */
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
x = g_board[ 0 ];
|
||||
if ( ( ( x == g_board[1] ) && ( x == g_board[2] ) ) ||
|
||||
( ( x == g_board[3] ) && ( x == g_board[6] ) ) ||
|
||||
( ( x == g_board[4] ) && ( x == g_board[8] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
x = g_board[ 1 ];
|
||||
if ( ( ( x == g_board[0] ) && ( x == g_board[2] ) ) ||
|
||||
( ( x == g_board[4] ) && ( x == g_board[7] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
x = g_board[ 2 ];
|
||||
if ( ( ( x == g_board[0] ) && ( x == g_board[1] ) ) ||
|
||||
( ( x == g_board[5] ) && ( x == g_board[8] ) ) ||
|
||||
( ( x == g_board[4] ) && ( x == g_board[6] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
x = g_board[ 3 ];
|
||||
if ( ( ( x == g_board[4] ) && ( x == g_board[5] ) ) ||
|
||||
( ( x == g_board[0] ) && ( x == g_board[6] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 4:
|
||||
{
|
||||
x = g_board[ 4 ];
|
||||
if ( ( ( x == g_board[0] ) && ( x == g_board[8] ) ) ||
|
||||
( ( x == g_board[2] ) && ( x == g_board[6] ) ) ||
|
||||
( ( x == g_board[1] ) && ( x == g_board[7] ) ) ||
|
||||
( ( x == g_board[3] ) && ( x == g_board[5] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 5:
|
||||
{
|
||||
x = g_board[ 5 ];
|
||||
if ( ( ( x == g_board[3] ) && ( x == g_board[4] ) ) ||
|
||||
( ( x == g_board[2] ) && ( x == g_board[8] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 6:
|
||||
{
|
||||
x = g_board[ 6 ];
|
||||
if ( ( ( x == g_board[7] ) && ( x == g_board[8] ) ) ||
|
||||
( ( x == g_board[0] ) && ( x == g_board[3] ) ) ||
|
||||
( ( x == g_board[4] ) && ( x == g_board[2] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
x = g_board[ 7 ];
|
||||
if ( ( ( x == g_board[6] ) && ( x == g_board[8] ) ) ||
|
||||
( ( x == g_board[1] ) && ( x == g_board[4] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
x = g_board[ 8 ];
|
||||
if ( ( ( x == g_board[6] ) && ( x == g_board[7] ) ) ||
|
||||
( ( x == g_board[2] ) && ( x == g_board[5] ) ) ||
|
||||
( ( x == g_board[0] ) && ( x == g_board[4] ) ) )
|
||||
return x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return PieceBlank;
|
||||
} /*winner2*/
|
||||
|
||||
#endif
|
||||
|
||||
#if WinMethod == UseLookForWinner
|
||||
|
||||
ttype LookForWinner()
|
||||
{
|
||||
register int p = g_board[0]; /* faster as register int than ttype on 8086 and Z80 */
|
||||
if ( PieceBlank != p )
|
||||
{
|
||||
if ( p == g_board[1] && p == g_board[2] )
|
||||
return p;
|
||||
|
||||
if ( p == g_board[3] && p == g_board[6] )
|
||||
return p;
|
||||
}
|
||||
|
||||
p = g_board[3];
|
||||
if ( PieceBlank != p && p == g_board[4] && p == g_board[5] )
|
||||
return p;
|
||||
|
||||
p = g_board[6];
|
||||
if ( PieceBlank != p && p == g_board[7] && p == g_board[8] )
|
||||
return p;
|
||||
|
||||
p = g_board[1];
|
||||
if ( PieceBlank != p && p == g_board[4] && p == g_board[7] )
|
||||
return p;
|
||||
|
||||
p = g_board[2];
|
||||
if ( PieceBlank != p && p == g_board[5] && p == g_board[8] )
|
||||
return p;
|
||||
|
||||
p = g_board[4];
|
||||
if ( PieceBlank != p )
|
||||
{
|
||||
if ( ( p == g_board[0] ) && ( p == g_board[8] ) )
|
||||
return p;
|
||||
|
||||
if ( ( p == g_board[2] ) && ( p == g_board[6] ) )
|
||||
return p;
|
||||
}
|
||||
|
||||
return PieceBlank;
|
||||
} /*LookForWinner*/
|
||||
|
||||
#endif
|
||||
|
||||
int g_IMoves = 0;
|
||||
|
||||
ttype MinMax( alpha, beta, depth, move ) ttype alpha; ttype beta; ttype depth; ttype move;
|
||||
{
|
||||
ttype pieceMove, score; /* better perf with char than int. out of registers so use stack */
|
||||
register int p, value; /* better perf with these as an int on Z80, 8080, and 8086 */
|
||||
|
||||
g_IMoves++;
|
||||
|
||||
if ( depth >= 4 )
|
||||
{
|
||||
#if WinMethod == UseFunPointers
|
||||
p = ( * winner_functions[ move ] )();
|
||||
#endif
|
||||
#if WinMethod == UseWinner2
|
||||
p = winner2( move );
|
||||
#endif
|
||||
#if WinMethod == UseLookForWinner
|
||||
p = LookForWinner();
|
||||
#endif
|
||||
|
||||
if ( PieceBlank != p )
|
||||
{
|
||||
if ( PieceX == p )
|
||||
return ScoreWin;
|
||||
|
||||
return ScoreLose;
|
||||
}
|
||||
|
||||
if ( 8 == depth )
|
||||
return ScoreTie;
|
||||
}
|
||||
|
||||
if ( depth & 1 )
|
||||
{
|
||||
value = ScoreMin;
|
||||
pieceMove = PieceX;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ScoreMax;
|
||||
pieceMove = PieceO;
|
||||
}
|
||||
|
||||
for ( p = 0; p < 9; p++ )
|
||||
{
|
||||
if ( PieceBlank == g_board[ p ] )
|
||||
{
|
||||
g_board[p] = pieceMove;
|
||||
score = MinMax( alpha, beta, depth + 1, p );
|
||||
g_board[p] = PieceBlank;
|
||||
|
||||
if ( depth & 1 )
|
||||
{
|
||||
#if WinLosePrune /* #if statements must be in first column for MS C 1.0 */
|
||||
if ( ScoreWin == score )
|
||||
return ScoreWin;
|
||||
#endif
|
||||
|
||||
if ( score > value )
|
||||
{
|
||||
value = score;
|
||||
|
||||
#if ABPrune
|
||||
if ( value >= beta )
|
||||
return value;
|
||||
if ( value > alpha )
|
||||
alpha = value;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if WinLosePrune
|
||||
if ( ScoreLose == score )
|
||||
return ScoreLose;
|
||||
#endif
|
||||
|
||||
if ( score < value )
|
||||
{
|
||||
value = score;
|
||||
|
||||
#if ABPrune
|
||||
if ( value <= alpha )
|
||||
return value;
|
||||
if ( value < beta )
|
||||
beta = value;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
} /*MinMax*/
|
||||
|
||||
long g_Moves = 0;
|
||||
|
||||
int FindSolution( position ) ttype position;
|
||||
{
|
||||
register int i;
|
||||
|
||||
for ( i = 0; i < 9; i++ )
|
||||
g_board[ i ] = PieceBlank;
|
||||
|
||||
g_board[ position ] = PieceX;
|
||||
|
||||
for ( i = 0; i < g_Iterations; i++ )
|
||||
{
|
||||
g_IMoves = 0;
|
||||
MinMax( ScoreMin, ScoreMax, 0, position );
|
||||
g_Moves += g_IMoves; /* do the 4-byte long addition once per loop to save work */
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /*FindSolution*/
|
||||
|
||||
#ifdef CPMTIME
|
||||
|
||||
struct CPMTimeValue
|
||||
{
|
||||
int h, m, s, l;
|
||||
};
|
||||
|
||||
void print_time_now()
|
||||
{
|
||||
/* This CP/M BDOS call of 105 is only implemented in NTVCM -- it's not a standard CP/M 2.2 call */
|
||||
|
||||
struct CPMTimeValue t;
|
||||
t.h = t.m = t.s = t.l = 0;
|
||||
|
||||
bdos( 105, &t );
|
||||
printf( "current time: %02d:%02d:%02d.%02d\n", t.h, t.m, t.s, t.l );
|
||||
} /*print_time_now*/
|
||||
|
||||
long get_ms()
|
||||
{
|
||||
/* This CP/M BDOS call of 105 is only implemented in NTVCM -- it's not a standard CP/M 2.2 call */
|
||||
|
||||
long h, m, s, l;
|
||||
struct CPMTimeValue t;
|
||||
t.h = t.m = t.s = t.l = 0;
|
||||
|
||||
bdos( 105, &t );
|
||||
h = t.h;
|
||||
m = t.m;
|
||||
s = t.s;
|
||||
l = t.l;
|
||||
|
||||
return h * 3600000 + m * 60000 + s * 1000 + l * 10;
|
||||
} /*get_ms*/
|
||||
|
||||
#else /* no elif with old compilers */
|
||||
|
||||
#ifdef DOSTIME
|
||||
|
||||
void print_time_now()
|
||||
{
|
||||
/* Make a DOS interrupt call to get the time */
|
||||
|
||||
union REGS wrIn, wrOut;
|
||||
|
||||
wrIn.h.ah = 0x2c;
|
||||
intdos( &wrIn, &wrOut );
|
||||
printf( "current time: %02d:%02d:%02d.%02d\n", wrOut.h.ch, wrOut.h.cl, wrOut.h.dh, wrOut.h.dl );
|
||||
fflush( stdout );
|
||||
} /*print_time_now*/
|
||||
|
||||
long get_ms()
|
||||
{
|
||||
/* this function takes about 3 milliseconds on the original IBM PC */
|
||||
|
||||
long h, m, s, l;
|
||||
union REGS wrIn, wrOut;
|
||||
|
||||
wrIn.h.ah = 0x2c;
|
||||
intdos( &wrIn, &wrOut );
|
||||
|
||||
h = wrOut.h.ch;
|
||||
m = wrOut.h.cl;
|
||||
s = wrOut.h.dh;
|
||||
l = wrOut.h.dl;
|
||||
|
||||
return h * 3600000 + m * 60000 + s * 1000 + l * 10;
|
||||
} /*get_ms*/
|
||||
|
||||
#else
|
||||
|
||||
/* must do this on actual CP/M machines */
|
||||
|
||||
int print_time_now() { return 0; }
|
||||
long get_ms() { return 0; }
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
int main( argc, argv ) int argc; char * argv[];
|
||||
{
|
||||
long start_time, end_time;
|
||||
|
||||
if ( 2 == argc )
|
||||
sscanf( argv[ 1 ], "%d", &g_Iterations ); /* no atoi in MS C 1.0 */
|
||||
|
||||
start_time = get_ms();
|
||||
|
||||
FindSolution( 0 );
|
||||
FindSolution( 1 );
|
||||
FindSolution( 4 );
|
||||
|
||||
end_time = get_ms();
|
||||
|
||||
printf( "runtime in ms: %ld\n", end_time - start_time );
|
||||
printf( "move count: %ld\n", g_Moves ); /* 6493 * g_Iterations */
|
||||
printf( "iteration count: %d\n", g_Iterations );
|
||||
printf( "method: %s\n",
|
||||
( WinMethod == UseFunPointers ) ? "function pointers" :
|
||||
( WinMethod == UseWinner2 ) ? "winner2" :
|
||||
( WinMethod == UseLookForWinner ) ? "look for winner" :
|
||||
"invalid method" );
|
||||
return 0;
|
||||
} /*main*/
|
||||
|
2
DeSmet C88 v31b/m.bat
Normal file
2
DeSmet C88 v31b/m.bat
Normal file
@ -0,0 +1,2 @@
|
||||
ntvdm c88 %1
|
||||
ntvdm bind %1
|
Loading…
Reference in New Issue
Block a user