diff --git a/Manx Aztec C86 v340a/BIN/ARCV.COM b/Manx Aztec C86 v340a/BIN/ARCV.COM new file mode 100644 index 0000000..2dccca4 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/ARCV.COM differ diff --git a/Manx Aztec C86 v340a/BIN/AS.EXE b/Manx Aztec C86 v340a/BIN/AS.EXE new file mode 100644 index 0000000..40e2710 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/AS.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/BLN.EXE b/Manx Aztec C86 v340a/BIN/BLN.EXE new file mode 100644 index 0000000..daa6a4c Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/BLN.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/C.EXE b/Manx Aztec C86 v340a/BIN/C.EXE new file mode 100644 index 0000000..75947dc Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/C.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/CC.EXE b/Manx Aztec C86 v340a/BIN/CC.EXE new file mode 100644 index 0000000..b78e091 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/CC.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/CCB.EXE b/Manx Aztec C86 v340a/BIN/CCB.EXE new file mode 100644 index 0000000..8f0b5a2 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/CCB.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/CNM.EXE b/Manx Aztec C86 v340a/BIN/CNM.EXE new file mode 100644 index 0000000..2bf71d8 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/CNM.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/CPM.EXE b/Manx Aztec C86 v340a/BIN/CPM.EXE new file mode 100644 index 0000000..df873a9 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/CPM.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/CRC.EXE b/Manx Aztec C86 v340a/BIN/CRC.EXE new file mode 100644 index 0000000..f010c3e Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/CRC.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/CTAGS.COM b/Manx Aztec C86 v340a/BIN/CTAGS.COM new file mode 100644 index 0000000..7462ce6 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/CTAGS.COM differ diff --git a/Manx Aztec C86 v340a/BIN/DB.EXE b/Manx Aztec C86 v340a/BIN/DB.EXE new file mode 100644 index 0000000..2dd73de Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/DB.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/DIFF.EXE b/Manx Aztec C86 v340a/BIN/DIFF.EXE new file mode 100644 index 0000000..f25fb62 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/DIFF.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/GREP.EXE b/Manx Aztec C86 v340a/BIN/GREP.EXE new file mode 100644 index 0000000..bf36239 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/GREP.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/HEX86.EXE b/Manx Aztec C86 v340a/BIN/HEX86.EXE new file mode 100644 index 0000000..84b7511 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/HEX86.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/LB.EXE b/Manx Aztec C86 v340a/BIN/LB.EXE new file mode 100644 index 0000000..1e62e38 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/LB.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/LN.EXE b/Manx Aztec C86 v340a/BIN/LN.EXE new file mode 100644 index 0000000..a8a38c5 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/LN.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/LS.COM b/Manx Aztec C86 v340a/BIN/LS.COM new file mode 100644 index 0000000..2639785 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/LS.COM differ diff --git a/Manx Aztec C86 v340a/BIN/MAKE.EXE b/Manx Aztec C86 v340a/BIN/MAKE.EXE new file mode 100644 index 0000000..de7a09a Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/MAKE.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/OBD.EXE b/Manx Aztec C86 v340a/BIN/OBD.EXE new file mode 100644 index 0000000..95006b9 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/OBD.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/OBJ.EXE b/Manx Aztec C86 v340a/BIN/OBJ.EXE new file mode 100644 index 0000000..f9e0861 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/OBJ.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/ORD.EXE b/Manx Aztec C86 v340a/BIN/ORD.EXE new file mode 100644 index 0000000..939b095 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/ORD.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/PCZ.EXE b/Manx Aztec C86 v340a/BIN/PCZ.EXE new file mode 100644 index 0000000..9918c89 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/PCZ.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/PROF.EXE b/Manx Aztec C86 v340a/BIN/PROF.EXE new file mode 100644 index 0000000..d7d6db1 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/PROF.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/SDB.EXE b/Manx Aztec C86 v340a/BIN/SDB.EXE new file mode 100644 index 0000000..156d48a Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/SDB.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/SQZ.EXE b/Manx Aztec C86 v340a/BIN/SQZ.EXE new file mode 100644 index 0000000..b4a27ff Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/SQZ.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/TERM.EXE b/Manx Aztec C86 v340a/BIN/TERM.EXE new file mode 100644 index 0000000..a6a6561 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/TERM.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/Z.EXE b/Manx Aztec C86 v340a/BIN/Z.EXE new file mode 100644 index 0000000..82c7f46 Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/Z.EXE differ diff --git a/Manx Aztec C86 v340a/BIN/azmake.exe b/Manx Aztec C86 v340a/BIN/azmake.exe new file mode 100644 index 0000000..2de9a0d Binary files /dev/null and b/Manx Aztec C86 v340a/BIN/azmake.exe differ diff --git a/Manx Aztec C86 v340a/CODE/E.C b/Manx Aztec C86 v340a/CODE/E.C new file mode 100644 index 0000000..3c6a84d --- /dev/null +++ b/Manx Aztec C86 v340a/CODE/E.C @@ -0,0 +1,30 @@ +#include + +#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; +} diff --git a/Manx Aztec C86 v340a/CODE/SIEVE.C b/Manx Aztec C86 v340a/CODE/SIEVE.C new file mode 100644 index 0000000..236f1d4 --- /dev/null +++ b/Manx Aztec C86 v340a/CODE/SIEVE.C @@ -0,0 +1,35 @@ +/* sieve.c */ + +/* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983 + to compare the speed. */ + +#include + +#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; + } diff --git a/Manx Aztec C86 v340a/CODE/TM.C b/Manx Aztec C86 v340a/CODE/TM.C new file mode 100644 index 0000000..d9a4c13 --- /dev/null +++ b/Manx Aztec C86 v340a/CODE/TM.C @@ -0,0 +1,169 @@ +#include + +#ifdef AZTEC86 +#include +#endif + +#ifdef HISOFTC +#include +#endif + +#ifdef INTELC +#include +#endif + +#ifdef WATCOM +#include +#include +#endif + + +#ifdef powerc +#define allocs 50 +#else +#ifdef HISOFTC +#define allocs 66 /* not enough RAM with hisoft to go higher */ +#else +/* most c runtimes work up to 69, but use 66 to have a consistent benchmark */ +#define allocs 66 +#endif +#endif + +int logging = 1; + +char * memset_x( p, v, c ) char * p; int v; int c; +{ + unsigned char * pc = (unsigned char *) p; + unsigned char val = (unsigned char) ( v & 0xff ); + int i; + + if ( 0 == p ) + { + printf( "request to memset a null pointer\n" ); + exit( 1 ); + } + + if ( logging ) +#ifdef CPMTIME + printf( " memset p %u, v %d, val %x, c %d\n", p, v, val, c ); +#else + +#ifdef HISOFTC + printf( " memset p %u, v %d, val %x, c %d\n", p, v, val, c ); +#else + printf( " memset p %p, v %d, val %x, c %d\n", p, v, val, c ); +#endif +#endif + + for ( i = 0; i < c; i++ ) + *pc++ = val; + return p; +} + +void chkmem( p, v, c ) char * p; int v; int c; +{ + unsigned char * pc = (unsigned char *) p; + unsigned char val = (unsigned char) ( v & 0xff ); + int i; + + if ( 0 == p ) + { + printf( "request to chkmem a null pointer\n" ); + exit( 1 ); + } + + for ( i = 0; i < c; i++ ) + { + if ( *pc != val ) + { +#ifdef CPMTIME + printf( "memory isn't as expected! p %u, v %d, c %d, *pc %d\n",p, v, c, *pc ); +#else + printf( "memory isn't as expected! p %p, v %d, c %d, *pc %d\n",p, v, c, *pc ); +#endif + exit( 1 ); + } + pc++; + } +} + +int main( argc, argv ) int argc; char * argv[]; +{ + int i, cb, c_cb, j; + char * pc; + char * ap[ allocs ]; + + logging = ( argc > 1 ); + pc = argv[ 0 ]; /* evade compiler warning */ + + for ( j = 0; j < 10; j++ ) + { + if ( logging ) + printf( "in alloc mode\n" ); + + for ( i = 0; i < allocs; i++ ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 5; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + ap[ i ] = (char *) malloc( cb ); + memset_x( ap[ i ], 0xaa, cb ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + + if ( logging ) + printf( "in free mode, even first\n" ); + + for ( i = 0; i < allocs; i += 2 ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 3; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + chkmem( ap[ i ], 0xaa, cb ); + memset_x( ap[ i ], 0xff, cb ); + free( ap[ i ] ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + + if ( logging ) + printf( "in free mode, now odd\n" ); + + for ( i = 1; i < allocs; i += 2 ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 7; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + chkmem( ap[ i ], 0xaa, cb ); + memset_x( ap[ i ], 0xff, cb ); + free( ap[ i ] ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + } + + printf( "success\n" ); + return 0; +} diff --git a/Manx Aztec C86 v340a/CODE/TTT.C b/Manx Aztec C86 v340a/CODE/TTT.C new file mode 100644 index 0000000..92c5eef --- /dev/null +++ b/Manx Aztec C86 v340a/CODE/TTT.C @@ -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 + +#ifdef DOSTIME +#include +#include +#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*/ + diff --git a/Manx Aztec C86 v340a/CODE/m.bat b/Manx Aztec C86 v340a/CODE/m.bat new file mode 100644 index 0000000..a8206fd --- /dev/null +++ b/Manx Aztec C86 v340a/CODE/m.bat @@ -0,0 +1,4 @@ +ntvdm -e:include=c:\include,path=c:\bin -r:.. ..\bin\cc -DAZTEC86 +F +A %1.c +del ctmp* 1>nul 2>nul +ntvdm -r:.. -e:lib=c:\lib ..\bin\ln %1 c:\lib\m.lib c:\lib\c.lib + diff --git a/Manx Aztec C86 v340a/DOC/README b/Manx Aztec C86 v340a/DOC/README new file mode 100644 index 0000000..6548682 --- /dev/null +++ b/Manx Aztec C86 v340a/DOC/README @@ -0,0 +1,59 @@ +Dear Aztec C user: + + Here are some changes made to the package since the release doc was +printed. They are divided into two sections 3.40a and 3.40b. + +Version 3.40a: + + C driver: the -n option for the linker should be -N. This is a doc +error. + + Linker: the CLIB environment variable may now be a list of path +prefixes, separated by semicolons or spaces. + When using the -l option and the CLIB environment variable, the linker +will NOT search the current directory unless explicitly specified by an empty +prefix. + For example: + CLIB=/path1/;/path2/; will search path1 first, then path2, + then the current directory. + CLIB=;/path1/;;/path2/ will cause a search of the current + directory, then path1, then the current directory + again, then path2. + + New linker search algorithm. The linker will now search for your object +file in 3 different ways. 1) it will take the name you give and search the +current directory. if not found then 2) it will append .o (if no extension was +given) and search again. If still not found, then 3) it will take the name, +append .o if none given, and search the path given in the CLIB variable. If +still not found then an error message is given and the linker will quit. + + Stksiz.c: stksiz.c has been changed to add a variable that is used by +the stack overflow checking logic. If you are using stksiz.c, you will need to +use the version supplied in this release and make any changes required for your +own use. + +Differences between v3.40A and v3.40B: + + v3.40B contains some fixes to the libraries, utilities, and the linker. +These changes do NOT affect the documentation in any way. + +NOTE: The sign-on messages which contain the version of the compiler, +assembler, linker, and utilities, are changed ONLY when the software changes. +(For example, in version 3.40B the linker will sign on as 3.40B while the +compiler and assembler will sign on as 3.40A.) + +They changes are as follows: + 1) gchar is no longer multiply defined when scanf and fscanf are +used together. + 2) cswit is no longer undefined when linking with third-party libraries. + 3) malloc now works properly in large data programs. + 4) obj -s and -u command now works correctly. + 5) obj now ignores sdb info (no need to use -n upon compilation) + 6) ord now works with large code files. + 7) hex86 options -j and -e can now be used together. + + We hope you enjoy using the MANX Aztec C system. Please read the release +doc as it contains a lot of useful information. Any problems with our software +can be reported via our tech line from 9am-6pm EST or by mail. The phone number +and address as well as some info to have handy can be found towards the end of +the release doc. diff --git a/Manx Aztec C86 v340a/DOC/README.SDB b/Manx Aztec C86 v340a/DOC/README.SDB new file mode 100644 index 0000000..96745cf --- /dev/null +++ b/Manx Aztec C86 v340a/DOC/README.SDB @@ -0,0 +1,5 @@ +Dear Aztec C86 user, + Sdb has been modified. The new crc is 2c7a. Please ignore the one in the +crclist. + Thank you. +. diff --git a/Manx Aztec C86 v340a/EMU/CPM.DOC b/Manx Aztec C86 v340a/EMU/CPM.DOC new file mode 100644 index 0000000..a1b19a5 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/CPM.DOC @@ -0,0 +1,136 @@ +Copyright (c) 1985-1997 Jim Lopushinsky + +email: jimlop@ix.netcom.com + +This is my original documentation: + +Dec 10, 1985 +Jim Lopushinsky + +CPM.EXE allows execution of CP/M-86 .CMD files under MS-DOS and PC-DOS. + +A>CPM + +To run CP/M-80 .COM files, run the Z80 emulator under the CPM emulator: + +A>CPM Z80 + +Don't try running any funny CP/M stuff that calls the BIOS disk I/O +functions directly. It won't work. Other than that, virtually any +CP/M-86 .CMD program will be successfully executed. Note that programs +which make use of MP/M or Concurrent extended functions will not work. + +All functions except one are totally machine independent, and should +run on any hardware configuration of MS-DOS version 3.0 or greater. +The only exception: There is no DOS function call for printer status, +and the CP/M printer status request is translated to INT 17H. This +should work fine on any PC or PC Clone. + + +Nov 30/97: + +ANSI.SYS is required if you plan to run .CMD files that use IBM CP/M-86 +version 1.1 or newer (or CCPM, CDOS etc) escape sequences. The following +CP/M escape sequences are converted to ANSI escape sequences: + +ESC A cursor up +ESC B cursor down +ESC C cursor forward +ESC D cursor back +ESC E clear screen and cursor home +ESC H cursor home +ESC K clear to end of line from cursor position +ESC Y set cursor position +ESC : program function key +ESC a set video mode +ESC b set forground color +ESC c set background color +ESC j save cursor position +ESC k restore cursor position +ESC m cursor on +ESC n cursor off +ESC p reverse video on +ESC q reverse video off +ESC r intensity on +ESC s blink on +ESC t blink off +ESC u intensity off + + +WordStar key translations are preformed based on an IBM compatible keyboard +as follows: + +ALT-X ^KX Save and exit +Up Arrow ^E Cursor up +Down Arrow ^X Cursor down +Left Arrow ^S Cursor left +Right Arrow ^D Cursor right +Page Up ^R Scroll screen up +Page Down ^C Scroll screen down +Insert ^V Toggle insert mode +Delete ^G Delete character at cursor +Home ^QS Beginning of line +End ^QD End of line +Ctrl-Page Down ^QC End of document +Ctrl-Page Up ^QR Beginning of document + +------------------------------ + +Configuration options: + +You will need a hex editor to change configuration. Search for the +string "USER OPTIONS" in CPM.EXE. Currently, the following options +can be changed: + +BDOS call frequencies. + +Offset 655 hex. 0 = no frequencies, 1 = tabulate CP/M BDOS call +frequencies. Default = off. If this option is set, after any CP/M-86 +CMD file terminates, run CPMFREQ.EXE and examine CPMFREQ.TXT. +CPMFREQ.EXE requires CPM.TXT and CPMFREQ.DAT. CPMFREQ.DAT is produced +by the CP/M emulator. + +WordStar key translation. + +Offset 685 hex. 0 = no translation, 1 = translate to WS key sequences. +Default = on. + +IBM-PC CP/M-86 screen escape sequences. + +Offset 6B5 hex. 0 = no translation, 1 = translate CP/M-86 screen codes +to ANSI. Default = on. ANSI.SYS required if enabled. + +BDOS version. + +Offset 6E5 hex. This is a BCD value for the BDOS version that CP/M +function 12 returns. Default value = 31 hex. Change to 22 hex for +CP/M-86. + +CP/M compatibility. + +Offset 715 hex. 0 = CP/M compatible, 1 = CCP/M, CDOS compatible. +Default = 0 (CP/M compatible). This changes how BDOS functions 31 +(get_DBP) and 53 (mc_max) operate: + +CP/M compatible: Function 31 (get DBP) returns SPT (sectors per + track) as the number of logical 128 byte sectors. + Function 53 (get max memory) does not allocate + the memory. + +CCP/M compatible: Function 31 (get DBP) returns SPT as the number + of physical sectors. + Function 53 (get max memory) allocates the memory. + +------------------------------- + +Revision history: + +12/10/85 Initial version + +10/06/96 1.1 Added option to record frequency of CP/M BDOS calls. + +11/03/97 1.2 Implemented segment relocation fixups. Now DRC.CMD works. + +11/30/97 1.3 Implemented Wordstar key translation for IBM keyboard. + Implemented CP/M-86 for IBM-PC screen escape sequences. + Translates to ANSI. ANSI.SYS required. diff --git a/Manx Aztec C86 v340a/EMU/CPM.EXE b/Manx Aztec C86 v340a/EMU/CPM.EXE new file mode 100644 index 0000000..df873a9 Binary files /dev/null and b/Manx Aztec C86 v340a/EMU/CPM.EXE differ diff --git a/Manx Aztec C86 v340a/EMU/CPM.TXT b/Manx Aztec C86 v340a/EMU/CPM.TXT new file mode 100644 index 0000000..c7901da --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/CPM.TXT @@ -0,0 +1,256 @@ + 0 System Reset + 1 Console Input + 2 Console Output + 3 Auxillary Input + 4 Auxillary Output + 5 List Output + 6 Direct Console I/O + 7 Auxillary Input Status + 8 Auxillary Output Status + 9 Print String + 10 Read Console Buffer + 11 Get Console Status + 12 Return Version Number + 13 Reset Disk System + 14 Select Disk + 15 Open File + 16 Close File + 17 Search for First + 18 Search for Next + 19 Delete File + 20 Read Sequential + 21 Write Sequential + 22 Make File + 23 Rename File + 24 Return Login Vector + 25 Return Current Disk + 26 Set DMA Address + 27 Get Addr (Alloc) + 28 Write Protect Disk + 29 Get R/O Vector + 30 Set File Attributes + 31 Get Addr (DBP) + 32 Set/Get User Code + 33 Read Random + 34 Write Random + 35 Compute File Size + 36 Set Random Record + 37 Reset Drive + 38 Access Drive + 39 Free Drive + 40 Write Random w/Zero Fill + 41 Test and Write Record + 42 Lock Record + 43 Unlock Record + 44 Set Multi-sector Cnt + 45 Set BDOS Error Mode + 46 Get Disk Free Space + 47 Chain to Program + 48 Flush Buffers + 49 Get/Set SCB + 50 Direct Bios Calls + 51 Set DMA Segment + 52 Return Addr DMA + 53 Allocate Max Memory + 54 Max Allocate Specific Memory + 55 Allocate Memory Segment + 56 Allocate Specific Memory + 57 Free Specified Mem Segment + 58 Free All Memory + 59 Load Overlay + 60 Call RSX + 61 + 62 + 63 + 64 Login + 65 Logoff + 66 Send Message + 67 Receive Message + 68 Get Network Status + 69 Get Config Table Addr + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 Get System Time + 84 Set System Time + 85 Get System Date + 86 Set System Date + 87 Allocate system Flag + 88 Free system Flag + 89 Allocate SYSDAT Buffer + 90 Lock physical Drive + 91 Unlock physical Drive + 92 Scan Path for Exec File + 93 Load and Execute Command + 94 Get/Set Process Exit Code + 95 Set Country Code + 96 Return Country Info + 97 + 98 Free Blocks + 99 Truncate File +100 Set Directory Label +101 Return Dir Label Data +102 Read File Date Stamps +103 Write File XFCB +104 Set Date and Time +105 Get Date and Time +106 Set Default Password +107 Return Serial Number +108 Get/Set Return Code +109 Get/Set Console Mode +110 Get/Set Output Delim +111 Print Block +112 List Block +113 MSDOS File Functions +114 +115 +116 Set File Time/Date Stamps +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 Allocate Memory Segment +129 Allocate Memory Segment +130 Free Memory Segment +131 Poll a Device +132 Wait for a system Flag +133 Set a system Flag +134 Make Queue +135 Open Queue +136 Delete Queue +137 Queue Read +138 Cond Queue Read +139 Queue Write +140 Cond Queue Write +141 Delay Specified Ticks +142 Call Dispatcher +143 Terminate Calling Process +144 Create a Process +145 Set Priority +146 Attach Console +147 Detach Console +148 Set Default Console +149 Assign Console to Process +150 Execute Command Line +151 Resident Procedure Library +152 Parse Filename +153 Return Def Console +154 Return Addr SysDat Segment +155 Get System Time and Day +156 Return Addr Process Descriptor +157 Terminate Process +158 Attach Def List Device +159 Detach Def List Device +160 Set Default List Device +161 Cond Attach Def List Device +162 Cond Attach Def Console +163 Return OS Release/Version +164 Return Default List Device +165 Attach Default Aux Device +166 Detach Aux Device +167 Cond Attach Def Aux Device +168 Set Default Aux Device +169 Return Default Aux Device +170 +171 +172 Block Read Aux Device +173 Block Write Aux Device +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 diff --git a/Manx Aztec C86 v340a/EMU/CPMFREQ.EXE b/Manx Aztec C86 v340a/EMU/CPMFREQ.EXE new file mode 100644 index 0000000..9d2a2b3 Binary files /dev/null and b/Manx Aztec C86 v340a/EMU/CPMFREQ.EXE differ diff --git a/Manx Aztec C86 v340a/EMU/FILE_ID.DIZ b/Manx Aztec C86 v340a/EMU/FILE_ID.DIZ new file mode 100644 index 0000000..585dd3d --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/FILE_ID.DIZ @@ -0,0 +1,12 @@ +A CP/M-86 and CP/M-80 emulator for MS-DOS. +All normall CP/M-86 stuff should run including +CMD files with overlays. Use CPM +. If the .CMD file is not found in +the current directory, the DOS path will be +searched. For CP/M-80, run the Z80 emulator +under the CP/M-86 emulator: +CPM Z80 . +All CP/M-80 .COM files must be renamed to +.CPM. Z80.CMD will also run under a vanilla +CP/M-86, Concurrent DOS, or other system that +can execute .CMD files. diff --git a/Manx Aztec C86 v340a/EMU/QTIBM.MAC b/Manx Aztec C86 v340a/EMU/QTIBM.MAC new file mode 100644 index 0000000..77fb74f --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/QTIBM.MAC @@ -0,0 +1,176 @@ + .z80 + +;QTERM overlay for IBM PC compatible running Jim Lopushinsky's +;CP/M-80 emulator. Note: this may even work in MYZ80, altho +;I haven't tried it. + + aseg + +basep equ 0 ;base of 8250 + +datap equ basep ;data input/output register +inte equ basep+1 ;interrupt enable register +intid equ basep+2 ;interrupt id register +linec equ basep+3 ;line control register +modemc equ basep+4 ;modem control register +linest equ basep+5 ;line status register +modemst equ basep+6 ;modem status register +divl equ basep ;divisor low register +divh equ basep+1 ;divisor high register + +printc equ 109h ;print character in C + +;modem input status routine + + org 110h + in a,(linest) + and 1 + ret + +;read modem character + + org 120h + in a,(datap) + ret + +;modem output status + + org 130h + in a,(linest) + and 20h + ret + +;write modem character + + org 140h + out (datap),a + ret + +;start break + org 150h + in a,(linec) + or 40h + out (linec),a + ret + +;end break + org 160h + in a,(linec) + and 0bfh + out (linec),a + ret + +;drop dtr + org 170h + ld a,2 + out (modemc),a + ret + +;restore dtr + org 180h + ld a,3 + out (modemc),a + ret + +;set baud rate + org 190h + ld c,linec + in e,(c) + set 7,e + out (c),e + out (divl),a + res 7,e + out (c),e + ret + +;baud rate table + org 1a0h + db 3,0ffh ;38400 + db 6,0ffh ;19200 + db 12,0ffh ;9600 + db 24,0ffh ;4800 + db 48,0ffh ;2400 + db 96,0ffh ;1200 + db 192,0ffh ;600 + db 0,0 ;300 - not available + +;set communications mode + org 1b0h + out (linec),a + ret + +;communication mode table + org 1c0h + db 22h ;7n1 + db 23h ;8n1 + db 26h ;7n2 + db 27h ;8n2 + db 1ah ;7e1 + db 1bh ;8e1 + db 1eh ;7e2 + db 1fh ;8e2 + db 0ah ;7o1 + db 0bh ;8o1 + db 0eh ;7o2 + db 0fh ;8o2 + + db 0 ;reserved + db 8 ;protocol transfer size + db 3 ;processor speed + db 27 ;escape character + +;signon message + org 1d0h + db 'Z80 emulator - IBM PC',0 + +;clear screen string + org 1f0h + db 27,'E',0 + +;cursor position + org 200h + push hl + ld c,27 + call printc + ld c,'Y' + call printc + pop hl + ld a,h + push hl + add a,20h + ld c,a + call printc + pop hl + ld a,l + add a,20h + ld c,a + jp printc + +;terminal capability bitmap + org 22fh + db 43h ;end highlight, start highlight, clear to eol + +;terminal capability strings + db 27,'q',0 ;end reverse video + org 238h + db 27,'p',0 ;start reverse video + org 260h + db 27,'K',0 ;clear to end of line + +;entry subroutine + org 270h + ret + +;exit subroutine + org 273h + ret + +;user subroutine + org 276h + ret + +;keyboard mapping + org 279h + ret + + end diff --git a/Manx Aztec C86 v340a/EMU/Z80.CMD b/Manx Aztec C86 v340a/EMU/Z80.CMD new file mode 100644 index 0000000..9368675 Binary files /dev/null and b/Manx Aztec C86 v340a/EMU/Z80.CMD differ diff --git a/Manx Aztec C86 v340a/EMU/Z80.DOC b/Manx Aztec C86 v340a/EMU/Z80.DOC new file mode 100644 index 0000000..93ee735 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/Z80.DOC @@ -0,0 +1,45 @@ +Copyright (c) 1985-1997 Jim Lopushinsky + +email: jimlop@ix.netcom.com + +This is my original documentation: + +Dec 10, 1985 +Jim Lopushinsky + +Z80.CMD allows execution of CP/M-80 .COM files under CP/M-86 and CPCDOS. +CP/M-80 .COM files must be renamed to .CPM files. That is, NSWP.COM is +renamed to NSWP.CPM. + +A>Z80 + +Don't try running any funny CP/M stuff that calls the BIOS disk I/O +functions directly. It won't work. Other than that, virtually any +CP/M-80 program will be successfully executed. Note that programs +which make use of MP/M or Concurrent extended functions will not work. + +Z80 emulates the entire Z80 instruction set, and builds the CP/M-80 +environment. The execution speed on a 5 MHZ 8088 is about 1/8 the +true execution speed on a 4 MHZ Z80. + + +Nov 30, 1997: + +Z80F.CMD is a version assembled with the freq flag set on (see below). + +11/20/85 Initial version + +09/08/96 1.1 Added option to record frequency of Z80 instructions. + Use Z80F.CMD and after any CP/M-80 .CPM file terminates, + run Z80FREQ.EXE and examine Z80FREQ.TXT. Z80FREQ.EXE + requires Z80.TXT, Z80CB.TXT, Z80ED.TXT, Z80XD.TXT, + Z80XDCB.TXT and Z80FREQ.DAT. Z80FREQ.DAT is produced + by the Z80 emulator. + +11/30/97 1.3 IN and OUT instructions are rerouted to COM 1 with a zero base. + To change to a different COM port, you need a hex editor. + Edit Z80.CMD (or Z80F.CMD) and change the value at offset + E1 hex. Valid values are ASCII 1, 2, 3 or 4. + + A QTERM overlay is included (QTIBM.MAC). See the instructions + supplied with QTERM for implemetation. diff --git a/Manx Aztec C86 v340a/EMU/Z80.TXT b/Manx Aztec C86 v340a/EMU/Z80.TXT new file mode 100644 index 0000000..42c68e3 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/Z80.TXT @@ -0,0 +1,256 @@ +00 NOP +01 LD BC,nnnn +02 LD (BC),A +03 INC BC +04 INC B +05 DEC B +06 LD B,nn +07 RLCA +08 EX AF,AF' +09 ADD HL,BC +0A LD A,(BC) +0B DEC BC +0C INC C +0D DEC C +0E LD C,nn +0F RRCA +10 DJNZ dd +11 LD DE,nnnn +12 LD DE,A +13 INC DE +14 INC D +15 DEC D +16 LD D,nn +17 RLA +18 JR dd +19 ADD HL,DE +1A LD A,DE +1B DEC DE +1C INC E +1D DEC E +1E LD E,nn +1F RRA +20 JR NZ,dd +21 LD HL,nnnn +22 LD (nnnn),HL +23 INC HL +24 INC H +25 DEC H +26 LD H,nn +27 DAA +28 JR Z,dd +29 ADD HL,HL +2A LD HL,(nnnn) +2B DEC HL +2C INC L +2D DEC L +2E LD L,nn +2F CPL +30 JR NC,dd +31 LD SP,nnnn +32 LD (nnnn),A +33 INC SP +34 INC (HL) +35 DEC (HL) +36 LD (HL),nn +37 SCF +38 JR C,dd +39 ADD HL,SP +3A LD A,(nnnn) +3B DEC SP +3C INC A +3D DEC A +3E LD A,nn +3F CCF +40 LD B,B +41 LD B,C +42 LD B,D +43 LD B,E +44 LD B,H +45 LD B,L +46 LD B,(HL) +47 LD B,A +48 LD C,B +49 LD C,C +4A LD C,D +4B LD C,E +4C LD C,H +4D LD C,L +4E LD C,(HL) +4F LD C,A +50 LD D,B +51 LD D,C +52 LD D,D +53 LD D,E +54 LD D,H +55 LD D,L +56 LD D,(HL) +57 LD D,A +58 LD E,B +59 LD E,C +5A LD E,D +5B LD E,E +5C LD E,H +5D LD E,L +5E LD E,(HL) +5F LD E,A +60 LD H,B +61 LD H,C +62 LD H,D +63 LD H,E +64 LD H,H +65 LD H,L +66 LD H,(HL) +67 LD H,A +68 LD L,B +69 LD L,C +6A LD L,D +6B LD L,E +6C LD L,H +6D LD L,L +6E LD L,(HL) +6F LD L,A +70 LD (HL),B +71 LD (HL),C +72 LD (HL),D +73 LD (HL),E +74 LD (HL),H +75 LD (HL),L +76 HALT +77 LD (HL),A +78 LD A,B +79 LD A,C +7A LD A,D +7B LD A,E +7C LD A,H +7D LD A,L +7E LD A,(HL) +7F LD A,A +80 ADD A,B +81 ADD A,C +82 ADD A,D +83 ADD A,E +84 ADD A,H +85 ADD A,L +86 ADD A,(HL) +87 ADD A,A +88 ADC A,B +89 ADC A,C +8A ADC A,D +8B ADC A,E +8C ADC A,H +8D ADC A,L +8E ADC A,(HL) +8F ADC A,A +90 SUB B +91 SUB C +92 SUB D +93 SUB E +94 SUB H +95 SUB L +96 SUB (HL) +97 SUB A +98 SBC A,B +99 SBC A,C +9A SBC A,D +9B SBC A,E +9C SBC A,H +9D SBC A,L +9E SBC A,(HL) +9F SBC A,A +A0 AND B +A1 AND C +A2 AND D +A3 AND E +A4 AND H +A5 AND L +A6 AND (HL) +A7 AND A +A8 XOR B +A9 XOR C +AA XOR D +AB XOR E +AC XOR H +AD XOR L +AE XOR (HL) +AF XOR A +B0 OR B +B1 OR C +B2 OR D +B3 OR E +B4 OR H +B5 OR L +B6 OR (HL) +B7 OR A +B8 CP B +B9 CP C +BA CP D +BB CP E +BC CP H +BD CP L +BE CP (HL) +BF CP A +C0 RET NZ +C1 POP BC +C2 JP NZ,nnnn +C3 JP nnnn +C4 CALL NZ,nnnn +C5 PUSH BC +C6 ADD A,nn +C7 RST 0 +C8 RET Z +C9 RET +CA JP Z,nnnn +CB +CC CALL Z,nnnn +CD CALL nnnn +CE ADC A,nn +CF RST 8 +D0 RET NC +D1 POP DE +D2 JP NC,nnnn +D3 OUT (nn),A +D4 CALL NC,nnnn +D5 PUSH DE +D6 SUB nn +D7 RST 10H +D8 RET C +D9 EXX +DA JP C,nnnn +DB IN A,(nn) +DC CALL C,nnnn +DD +DE SBC A,nn +DF RST 18H +E0 RET PO +E1 POP HL +E2 JP PO,nnnn +E3 EX (SP),HL +E4 CALL PO,nnnn +E5 PUSH HL +E6 AND nn +E7 RST 20H +E8 RET PE +E9 JP (HL) +EA JP PE,nnnn +EB EX DE,HL +EC CALL PE,nnnn +ED +EE XOR nn +EF RST 28H +F0 RET P +F1 POP AF +F2 JP P,nnnn +F3 DI +F4 CALL P,nnnn +F5 PUSH AF +F6 OR nn +F7 RST 30H +F8 RET M +F9 LD SP,HL +FA JP M,nnnn +FB EI +FC CALL M,nnnn +FD +FE CP nn +FF RST 38H diff --git a/Manx Aztec C86 v340a/EMU/Z80CB.TXT b/Manx Aztec C86 v340a/EMU/Z80CB.TXT new file mode 100644 index 0000000..fd971a8 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/Z80CB.TXT @@ -0,0 +1,256 @@ +00 RLC B +01 RLC C +02 RLC D +03 RLC E +04 RLC H +05 RLC L +06 RLC (HL) +07 RLC A +08 RRC B +09 RRC C +0A RRC D +0B RRC E +0C RRC H +0D RRC L +0E RRC (HL) +0F RRC A +10 RL B +11 RL C +12 RL D +13 RL E +14 RL H +15 RL L +16 RL (HL) +17 RL A +18 RR B +19 RR C +1A RR D +1B RR E +1C RR H +1D RR L +1E RR (HL) +1F RR A +20 SLA B +21 SLA C +22 SLA D +23 SLA E +24 SLA H +25 SLA L +26 SLA (HL) +27 SLA A +28 SRA B +29 SRA C +2A SRA D +2B SRA E +2C SRA H +2D SRA L +2E SRA (HL) +2F SRA A +30 SLIA B +31 SLIA C +32 SLIA D +33 SLIA E +34 SLIA H +35 SLIA L +36 SLIA (HL) +37 SLIA A +38 SRL B +39 SRL C +3A SRL D +3B SRL E +3C SRL H +3D SRL L +3E SRL (HL) +3F SRL A +40 BIT 0,B +41 BIT 0,C +42 BIT 0,D +43 BIT 0,E +44 BIT 0,H +45 BIT 0,L +46 BIT 0,(HL) +47 BIT 0,A +48 BIT 1,B +49 BIT 1,C +4A BIT 1,D +4B BIT 1,E +4C BIT 1,H +4D BIT 1,L +4E BIT 1,(HL) +4F BIT 1,A +50 BIT 2,B +51 BIT 2,C +52 BIT 2,D +53 BIT 2,E +54 BIT 2,H +55 BIT 2,L +56 BIT 2,(HL) +57 BIT 2,A +58 BIT 3,B +59 BIT 3,C +5A BIT 3,D +5B BIT 3,E +5C BIT 3,H +5D BIT 3,L +5E BIT 3,(HL) +5F BIT 3,A +60 BIT 4,B +61 BIT 4,C +62 BIT 4,D +63 BIT 4,E +64 BIT 4,H +65 BIT 4,L +66 BIT 4,(HL) +67 BIT 4,A +68 BIT 5,B +69 BIT 5,C +6A BIT 5,D +6B BIT 5,E +6C BIT 5,H +6D BIT 5,L +6E BIT 5,(HL) +6F BIT 5,A +70 BIT 6,B +71 BIT 6,C +72 BIT 6,D +73 BIT 6,E +74 BIT 6,H +75 BIT 6,L +76 BIT 6,(HL) +77 BIT 6,A +78 BIT 7,B +79 BIT 7,C +7A BIT 7,D +7B BIT 7,E +7C BIT 7,H +7D BIT 7,L +7E BIT 7,(HL) +7F BIT 7,A +80 RES 0,B +81 RES 0,C +82 RES 0,D +83 RES 0,E +84 RES 0,H +85 RES 0,L +86 RES 0,(HL) +87 RES 0,A +88 RES 1,B +89 RES 1,C +8A RES 1,D +8B RES 1,E +8C RES 1,H +8D RES 1,L +8E RES 1,(HL) +8F RES 1,A +90 RES 2,B +91 RES 2,C +92 RES 2,D +93 RES 2,E +94 RES 2,H +95 RES 2,L +96 RES 2,(HL) +97 RES 2,A +98 RES 3,B +99 RES 3,C +9A RES 3,D +9B RES 3,E +9C RES 3,H +9D RES 3,L +9E RES 3,(HL) +9F RES 3,A +A0 RES 4,B +A1 RES 4,C +A2 RES 4,D +A3 RES 4,E +A4 RES 4,H +A5 RES 4,L +A6 RES 4,(HL) +A7 RES 4,A +A8 RES 5,B +A9 RES 5,C +AA RES 5,D +AB RES 5,E +AC RES 5,H +AD RES 5,L +AE RES 5,(HL) +AF RES 5,A +B0 RES 6,B +B1 RES 6,C +B2 RES 6,D +B3 RES 6,E +B4 RES 6,H +B5 RES 6,L +B6 RES 6,(HL) +B7 RES 6,A +B8 RES 7,B +B9 RES 7,C +BA RES 7,D +BB RES 7,E +BC RES 7,H +BD RES 7,L +BE RES 7,(HL) +BF RES 7,A +C0 SET 0,B +C1 SET 0,C +C2 SET 0,D +C3 SET 0,E +C4 SET 0,H +C5 SET 0,L +C6 SET 0,(HL) +C7 SET 0,A +C8 SET 1,B +C9 SET 1,C +CA SET 1,D +CB SET 1,E +CC SET 1,H +CD SET 1,L +CE SET 1,(HL) +CF SET 1,A +D0 SET 2,B +D1 SET 2,C +D2 SET 2,D +D3 SET 2,E +D4 SET 2,H +D5 SET 2,L +D6 SET 2,(HL) +D7 SET 2,A +D8 SET 3,B +D9 SET 3,C +DA SET 3,D +DB SET 3,E +DC SET 3,H +DD SET 3,L +DE SET 3,(HL) +DF SET 3,A +E0 SET 4,B +E1 SET 4,C +E2 SET 4,D +E3 SET 4,E +E4 SET 4,H +E5 SET 4,L +E6 SET 4,(HL) +E7 SET 4,A +E8 SET 5,B +E9 SET 5,C +EA SET 5,D +EB SET 5,E +EC SET 5,H +ED SET 5,L +EE SET 5,(HL) +EF SET 5,A +F0 SET 6,B +F1 SET 6,C +F2 SET 6,D +F3 SET 6,E +F4 SET 6,H +F5 SET 6,L +F6 SET 6,(HL) +F7 SET 6,A +F8 SET 7,B +F9 SET 7,C +FA SET 7,D +FB SET 7,E +FC SET 7,H +FD SET 7,L +FE SET 7,(HL) +FF SET 7,A diff --git a/Manx Aztec C86 v340a/EMU/Z80ED.TXT b/Manx Aztec C86 v340a/EMU/Z80ED.TXT new file mode 100644 index 0000000..e977d93 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/Z80ED.TXT @@ -0,0 +1,256 @@ +00 IN0 B,(nn) +01 OUT0 (nn),B +02 +03 +04 TST B +05 +06 +07 +08 IN0 C,(nn) +09 OUT0 (nn),C +0A +0B +0C TST C +0D +0E +0F +10 IN0 D,(nn) +11 OUT0 (nn),D +12 +13 +14 TST D +15 +16 +17 +18 IN0 E,(nn) +19 OUT0 (nn),E +1A +1B +1C TST E +1D +1E +1F +20 IN0 H,(nn) +21 OUT0 (nn),H +22 +23 +24 TST H +25 +26 +27 +28 IN0 L,(nn) +29 OUT0 (nn),L +2A +2B +2C TST L +2D +2E +2F +30 IN0 (nn) +31 +32 +33 +34 TST (HL) +35 +36 +37 +38 IN0 A,(nn) +39 OUT0 (nn),A +3A +3B +3C TST A +3D +3E +3F +40 IN B,(C) +41 OUT (C),B +42 SBC HL,BC +43 LD (nnnn),BC +44 NEG +45 RETN +46 IM 0 +47 LD I,A +48 IN C,(C) +49 OUT (C),C +4A ADC HL,BC +4B LD BC,(nnnn) +4C MULT BC +4D RETI +4E +4F LD R,A +50 IN D,(C) +51 OUT (C),D +52 SBC HL,DE +53 LD (nnnn),DE +54 +55 +56 IM 1 +57 LD A,I +58 IN E,(C) +59 OUT (C),E +5A ADC HL,DE +5B LD DE,(nnnn) +5C MULT DE +5D +5E IM 2 +5F LD A,R +60 IN H,(C) +61 OUT (C),H +62 SBC HL,HL +63 LD (nnnn),HL +64 TST nn +65 +66 +67 RRD +68 IN L,(C) +69 OUT (C),L +6A ADC HL,HL +6B LD HL,(nnnn) +6C MULT HL +6D +6E +6F RLD +70 IN (C) +71 OUT (C),0 +72 SBC HL,SP +73 LD (nnnn),SP +74 TSTIO nn +75 +76 SLP +77 +78 IN A,(C) +79 OUT (C),A +7A ADC HL,SP +7B LD SP,(nnnn) +7C MULT SP +7D +7E +7F +80 +81 +82 +83 OTIM +84 +85 +86 +87 +88 +89 +8A +8B OTDM +8C +8D +8E +8F +90 +91 +92 +93 OTIMR +94 +95 +96 +97 +98 +99 +9A +9B OTDMR +9C +9D +9E +9F +A0 LDI +A1 CPI +A2 INI +A3 OUTI +A4 +A5 +A6 +A7 +A8 LDD +A9 CPD +AA IND +AB OUTD +AC +AD +AE +AF +B0 LDIR +B1 CPIR +B2 INIR +B3 OTIR +B4 +B5 +B6 +B7 +B8 LDDR +B9 CPDR +BA INDR +BB OTDR +BC +BD +BE +BF +C0 +C1 +C2 +C3 +C4 +C5 +C6 +C7 +C8 +C9 +CA +CB +CC +CD +CE +CF +D0 +D1 +D2 +D3 +D4 +D5 +D6 +D7 +D8 +D9 +DA +DB +DC +DD +DE +DF +E0 +E1 +E2 +E3 +E4 +E5 +E6 +E7 +E8 +E9 +EA +EB +EC +ED +EE +EF +F0 +F1 +F2 +F3 +F4 +F5 +F6 +F7 +F8 +F9 +FA +FB +FC +FD +FE +FF diff --git a/Manx Aztec C86 v340a/EMU/Z80F.CMD b/Manx Aztec C86 v340a/EMU/Z80F.CMD new file mode 100644 index 0000000..d30c58c Binary files /dev/null and b/Manx Aztec C86 v340a/EMU/Z80F.CMD differ diff --git a/Manx Aztec C86 v340a/EMU/Z80FREQ.EXE b/Manx Aztec C86 v340a/EMU/Z80FREQ.EXE new file mode 100644 index 0000000..510d2c7 Binary files /dev/null and b/Manx Aztec C86 v340a/EMU/Z80FREQ.EXE differ diff --git a/Manx Aztec C86 v340a/EMU/Z80XD.TXT b/Manx Aztec C86 v340a/EMU/Z80XD.TXT new file mode 100644 index 0000000..55f2164 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/Z80XD.TXT @@ -0,0 +1,256 @@ +00 +01 +02 +03 +04 +05 +06 +07 +08 +09 ADD IX,BC +0A +0B +0C +0D +0E +0F +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 ADD IX,DE +1A +1B +1C +1D +1E +1F +20 +21 LD IX,nnnn +22 LD (nnnn),IX +23 INC IX +24 INC HX +25 DEC HX +26 LD HX,nn +27 +28 +29 ADD IX,IX +2A LD IX,(nnnn) +2B DEC IX +2C INC LX +2D DEC LX +2E LD LX,nn +2F +30 +31 +32 +33 +34 INC (IX+dd) +35 DEC (IX+dd) +36 LD (IX+dd),nn +37 +38 +39 ADD IX,SP +3A +3B +3C +3D +3E +3F +40 +41 +42 +43 +44 LD B,HX +45 LD B,LX +46 LD B,(IX+dd) +47 +48 +49 +4A +4B +4C LD C,HX +4D LD C,LX +4E LD C,(IX+dd) +4F +50 +51 +52 +53 +54 LD D,HX +55 LD D,LX +56 LD D,(IX+dd) +57 +58 +59 +5A +5B +5C LD E,H +5D LD E,L +5E LD E,(IX+dd) +5F +60 LD HX,B +61 LD HX,C +62 LD HX,D +63 LD HX,E +64 LD HX,HX +65 LD HX,LX +66 LD H,(IX+dd) +67 LD HX,A +68 LD LX,B +69 LD LX,C +6A LD LX,D +6B LD LX,E +6C LD LX,HX +6D LD LX,LX +6E LD L,(IX+dd) +6F LD LX,A +70 LD (IX+dd),B +71 LD (IX+dd),C +72 LD (IX+dd),D +73 LD (IX+dd),E +74 LD (IX+dd),H +75 LD (IX+dd),L +76 +77 LD (IX+dd),A +78 +79 +7A +7B +7C LD A,HX +7D LD A,LX +7E LD A,(IX+dd) +7F +80 +81 +82 +83 +84 ADD A,HX +85 ADD A,LX +86 ADD A,(IX) +87 +88 +89 +8A +8B +8C ADC A,HX +8D ADC A,LX +8E ADC A,(IX) +8F +90 +91 +92 +93 +94 SUB HX +95 SUB LX +96 SUB (IX+dd) +97 +98 +99 +9A +9B +9C SBC A,HX +9D SBC A,LX +9E SBC A,(IX+dd) +9F +A0 +A1 +A2 +A3 +A4 AND HX +A5 AND LX +A6 AND (IX+dd) +A7 +A8 +A9 +AA +AB +AC XOR HX +AD XOR LX +AE XOR (IX+dd) +AF +B0 +B1 +B2 +B3 +B4 OR HX +B5 OR LX +B6 OR (IX+dd) +B7 +B8 +B9 +BA +BB +BC CP HX +BD CP LX +BE CP (IX+dd) +BF +C0 +C1 +C2 +C3 +C4 +C5 +C6 +C7 +C8 +C9 +CA +CB +CC +CD +CE +CF +D0 +D1 +D2 +D3 +D4 +D5 +D6 +D7 +D8 +D9 +DA +DB +DC +DD +DE +DF +E0 +E1 POP IX +E2 +E3 EX (SP),IX +D4 +E5 PUSH IX +E6 +E7 +E8 +E9 JP (IX) +EA +EB +EC +ED +EE +EF +F0 +F1 +F2 +F3 +F4 +F5 +F6 +F7 +F8 +F9 LD SP,IX +FA +FB +FC +FD +FE +FF diff --git a/Manx Aztec C86 v340a/EMU/Z80XDCB.TXT b/Manx Aztec C86 v340a/EMU/Z80XDCB.TXT new file mode 100644 index 0000000..ae13112 --- /dev/null +++ b/Manx Aztec C86 v340a/EMU/Z80XDCB.TXT @@ -0,0 +1,256 @@ +00 RLC (IX+dd)->B +01 RLC (IX+dd)->C +02 RLC (IX+dd)->D +03 RLC (IX+dd)->E +04 RLC (IX+dd)->H +05 RLC (IX+dd)->L +06 RLC (IX+dd) +07 RLC (IX+dd)->A +08 RRC (IX+dd)->B +09 RRC (IX+dd)->C +0A RRC (IX+dd)->D +0B RRC (IX+dd)->E +0C RRC (IX+dd)->H +0D RRC (IX+dd)->L +0E RRC (IX+dd) +0F RRC (IX+dd)->A +10 RL (IX+dd)->B +11 RL (IX+dd)->C +12 RL (IX+dd)->D +13 RL (IX+dd)->E +14 RL (IX+dd)->H +15 RL (IX+dd)->L +16 RL (IX+dd) +17 RL (IX+dd)->A +18 RR (IX+dd)->B +19 RR (IX+dd)->C +1A RR (IX+dd)->D +1B RR (IX+dd)->E +1C RR (IX+dd)->H +1D RR (IX+dd)->L +1E RR (IX+dd) +1F RR (IX+dd)->A +20 SLA (IX+dd)->B +21 SLA (IX+dd)->C +22 SLA (IX+dd)->D +23 SLA (IX+dd)->E +24 SLA (IX+dd)->H +25 SLA (IX+dd)->L +26 SLA (IX+dd) +27 SLA (IX+dd)->A +28 SRA (IX+dd)->B +29 SRA (IX+dd)->C +2A SRA (IX+dd)->D +2B SRA (IX+dd)->E +2C SRA (IX+dd)->H +2D SRA (IX+dd)->L +2E SRA (IX+dd) +2F SRA (IX+dd)->A +30 SLIA (IX+dd)->B +31 SLIA (IX+dd)->C +32 SLIA (IX+dd)->D +33 SLIA (IX+dd)->E +34 SLIA (IX+dd)->H +35 SLIA (IX+dd)->L +36 SLIA (IX+dd) +37 SLIA (IX+dd)->A +38 SRL (IX+dd)->B +39 SRL (IX+dd)->C +3A SRL (IX+dd)->D +3B SRL (IX+dd)->E +3C SRL (IX+dd)->H +3D SRL (IX+dd)->L +3E SRL (IX+dd) +3F SRL (IX+dd)->A +40 BIT 0,(IX+dd) +41 BIT 0,(IX+dd) +42 BIT 0,(IX+dd) +43 BIT 0,(IX+dd) +44 BIT 0,(IX+dd) +45 BIT 0,(IX+dd) +46 BIT 0,(IX+dd) +47 BIT 0,(IX+dd) +48 BIT 1,(IX+dd) +49 BIT 1,(IX+dd) +4A BIT 1,(IX+dd) +4B BIT 1,(IX+dd) +4C BIT 1,(IX+dd) +4D BIT 1,(IX+dd) +4E BIT 1,(IX+dd) +4F BIT 1,(IX+dd) +50 BIT 2,(IX+dd) +51 BIT 2,(IX+dd) +52 BIT 2,(IX+dd) +53 BIT 2,(IX+dd) +54 BIT 2,(IX+dd) +55 BIT 2,(IX+dd) +56 BIT 2,(IX+dd) +57 BIT 2,(IX+dd) +58 BIT 3,(IX+dd) +59 BIT 3,(IX+dd) +5A BIT 3,(IX+dd) +5B BIT 3,(IX+dd) +5C BIT 3,(IX+dd) +5D BIT 3,(IX+dd) +5E BIT 3,(IX+dd) +5F BIT 3,(IX+dd) +60 BIT 4,(IX+dd) +61 BIT 4,(IX+dd) +62 BIT 4,(IX+dd) +63 BIT 4,(IX+dd) +64 BIT 4,(IX+dd) +65 BIT 4,(IX+dd) +66 BIT 4,(IX+dd) +67 BIT 4,(IX+dd) +68 BIT 5,(IX+dd) +69 BIT 5,(IX+dd) +6A BIT 5,(IX+dd) +6B BIT 5,(IX+dd) +6C BIT 5,(IX+dd) +6D BIT 5,(IX+dd) +6E BIT 5,(IX+dd) +6F BIT 5,(IX+dd) +70 BIT 6,(IX+dd) +71 BIT 6,(IX+dd) +72 BIT 6,(IX+dd) +73 BIT 6,(IX+dd) +74 BIT 6,(IX+dd) +75 BIT 6,(IX+dd) +76 BIT 6,(IX+dd) +77 BIT 6,(IX+dd) +78 BIT 7,(IX+dd) +79 BIT 7,(IX+dd) +7A BIT 7,(IX+dd) +7B BIT 7,(IX+dd) +7C BIT 7,(IX+dd) +7D BIT 7,(IX+dd) +7E BIT 7,(IX+dd) +7F BIT 7,(IX+dd) +80 RES 0,(IX+dd)->B +81 RES 0,(IX+dd)->C +82 RES 0,(IX+dd)->D +83 RES 0,(IX+dd)->E +84 RES 0,(IX+dd)->H +85 RES 0,(IX+dd)->L +86 RES 0,(IX+dd) +87 RES 0,(IX+dd)->A +88 RES 1,(IX+dd)->B +89 RES 1,(IX+dd)->C +8A RES 1,(IX+dd)->D +8B RES 1,(IX+dd)->E +8C RES 1,(IX+dd)->H +8D RES 1,(IX+dd)->L +8E RES 1,(IX+dd) +8F RES 1,(IX+dd)->A +90 RES 2,(IX+dd)->B +91 RES 2,(IX+dd)->C +92 RES 2,(IX+dd)->D +93 RES 2,(IX+dd)->E +94 RES 2,(IX+dd)->H +95 RES 2,(IX+dd)->L +96 RES 2,(IX+dd) +97 RES 2,(IX+dd)->A +98 RES 3,(IX+dd)->B +99 RES 3,(IX+dd)->C +9A RES 3,(IX+dd)->D +9B RES 3,(IX+dd)->E +9C RES 3,(IX+dd)->H +9D RES 3,(IX+dd)->L +9E RES 3,(IX+dd) +9F RES 3,(IX+dd)->A +A0 RES 4,(IX+dd)->B +A1 RES 4,(IX+dd)->C +A2 RES 4,(IX+dd)->D +A3 RES 4,(IX+dd)->E +A4 RES 4,(IX+dd)->H +A5 RES 4,(IX+dd)->L +A6 RES 4,(IX+dd) +A7 RES 4,(IX+dd)->A +A8 RES 5,(IX+dd)->B +A9 RES 5,(IX+dd)->C +AA RES 5,(IX+dd)->D +AB RES 5,(IX+dd)->E +AC RES 5,(IX+dd)->H +AD RES 5,(IX+dd)->L +AE RES 5,(IX+dd) +AF RES 5,(IX+dd)->A +B0 RES 6,(IX+dd)->B +B1 RES 6,(IX+dd)->C +B2 RES 6,(IX+dd)->D +B3 RES 6,(IX+dd)->E +B4 RES 6,(IX+dd)->H +B5 RES 6,(IX+dd)->L +B6 RES 6,(IX+dd) +B7 RES 6,(IX+dd)->A +B8 RES 7,(IX+dd)->B +B9 RES 7,(IX+dd)->C +BA RES 7,(IX+dd)->D +BB RES 7,(IX+dd)->E +BC RES 7,(IX+dd)->H +BD RES 7,(IX+dd)->L +BE RES 7,(IX+dd) +BF RES 7,(IX+dd)->A +C0 SET 0,(IX+dd)->B +C1 SET 0,(IX+dd)->C +C2 SET 0,(IX+dd)->D +C3 SET 0,(IX+dd)->E +C4 SET 0,(IX+dd)->H +C5 SET 0,(IX+dd)->L +C6 SET 0,(IX+dd) +C7 SET 0,(IX+dd)->A +C8 SET 1,(IX+dd)->B +C9 SET 1,(IX+dd)->C +CA SET 1,(IX+dd)->D +CB SET 1,(IX+dd)->E +CC SET 1,(IX+dd)->H +CD SET 1,(IX+dd)->L +CE SET 1,(IX+dd) +CF SET 1,(IX+dd)->A +D0 SET 2,(IX+dd)->B +D1 SET 2,(IX+dd)->C +D2 SET 2,(IX+dd)->D +D3 SET 2,(IX+dd)->E +D4 SET 2,(IX+dd)->H +D5 SET 2,(IX+dd)->L +D6 SET 2,(IX+dd) +D7 SET 2,(IX+dd)->A +D8 SET 3,(IX+dd)->B +D9 SET 3,(IX+dd)->C +DA SET 3,(IX+dd)->D +DB SET 3,(IX+dd)->E +DC SET 3,(IX+dd)->H +DD SET 3,(IX+dd)->L +DE SET 3,(IX+dd) +DF SET 3,(IX+dd)->A +E0 SET 4,(IX+dd)->B +E1 SET 4,(IX+dd)->C +E2 SET 4,(IX+dd)->D +E3 SET 4,(IX+dd)->E +E4 SET 4,(IX+dd)->H +E5 SET 4,(IX+dd)->L +E6 SET 4,(IX+dd) +E7 SET 4,(IX+dd)->A +E8 SET 5,(IX+dd)->B +E9 SET 5,(IX+dd)->C +EA SET 5,(IX+dd)->D +EB SET 5,(IX+dd)->E +EC SET 5,(IX+dd)->H +ED SET 5,(IX+dd)->L +EE SET 5,(IX+dd) +EF SET 5,(IX+dd)->A +F0 SET 6,(IX+dd)->B +F1 SET 6,(IX+dd)->C +F2 SET 6,(IX+dd)->D +F3 SET 6,(IX+dd)->E +F4 SET 6,(IX+dd)->H +F5 SET 6,(IX+dd)->L +F6 SET 6,(IX+dd) +F7 SET 6,(IX+dd)->A +F8 SET 7,(IX+dd)->B +F9 SET 7,(IX+dd)->C +FA SET 7,(IX+dd)->D +FB SET 7,(IX+dd)->E +FC SET 7,(IX+dd)->H +FD SET 7,(IX+dd)->L +FE SET 7,(IX+dd) +FF SET 7,(IX+dd)->A diff --git a/Manx Aztec C86 v340a/INCLUDE/ASSERT.H b/Manx Aztec C86 v340a/INCLUDE/ASSERT.H new file mode 100644 index 0000000..a03a101 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/ASSERT.H @@ -0,0 +1,8 @@ +#ifndef NDEBUG +#ifndef stderr +#include +#endif +#define assert(x) if (!(x)) {fprintf(stderr,"Assertion failed: x, file %s, line %d\n",__FILE__,__LINE__); exit(1);} +#else +#define assert(x) +#endif diff --git a/Manx Aztec C86 v340a/INCLUDE/COLOR.H b/Manx Aztec C86 v340a/INCLUDE/COLOR.H new file mode 100644 index 0000000..d67e39a --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/COLOR.H @@ -0,0 +1,13 @@ +#define BLACK 0 +#define BLUE 1 +#define GREEN 2 +#define CYAN 3 +#define RED 4 +#define MAGENTA 5 +#define YELLOW 6 +#define WHITE 7 + +#define BLINK 1 +#define NO_BLINK 0 +#define HIGH 1 +#define LOW 0 diff --git a/Manx Aztec C86 v340a/INCLUDE/CTYPE.H b/Manx Aztec C86 v340a/INCLUDE/CTYPE.H new file mode 100644 index 0000000..390ffb3 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/CTYPE.H @@ -0,0 +1,20 @@ +/* Copyright (C) 1984 by Manx Software Systems */ + +extern char ctp_[]; + +#define isalpha(x) (ctp_[(x)+1]&0x03) +#define isupper(x) (ctp_[(x)+1]&0x01) +#define islower(x) (ctp_[(x)+1]&0x02) +#define isdigit(x) (ctp_[(x)+1]&0x04) +#define isxdigit(x) (ctp_[(x)+1]&0x08) +#define isalnum(x) (ctp_[(x)+1]&0x07) +#define isspace(x) (ctp_[(x)+1]&0x10) +#define ispunct(x) (ctp_[(x)+1]&0x40) +#define iscntrl(x) (ctp_[(x)+1]&0x20) +#define isprint(x) (ctp_[(x)+1]&0xc7) +#define isgraph(x) (ctp_[(x)+1]&0x47) +#define isascii(x) (((x)&0x80)==0) + +#define toascii(x) ((x)&127) +#define _tolower(x) ((x)|0x20) +#define _toupper(x) ((x)&0x5f) diff --git a/Manx Aztec C86 v340a/INCLUDE/DIOCTL.H b/Manx Aztec C86 v340a/INCLUDE/DIOCTL.H new file mode 100644 index 0000000..092740d --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/DIOCTL.H @@ -0,0 +1,26 @@ +/* Copyright (C) 1983 by Manx Software Systems */ + +#define TIOCGETP 0 /* read contents of tty control structure */ +#define TIOCSETP 1 /* set contents of tty control structure */ +#define TIOCSETN 1 /* ditto only don't wait for output to flush */ + +/* special codes for MSDOS 2.x only */ +#define TIOCREAD 2 /* read control info from device */ +#define TIOCWRITE 3 /* write control info to device */ +#define TIOCDREAD 4 /* same as 2 but for drives */ +#define TIOCDWRITE 5 /* same as 3 but for drives */ +#define GETISTATUS 6 /* get input status */ +#define GETOSTATUS 7 /* get output status */ + +struct sgttyb { + short sg_flags; /* control flags */ + char sg_erase; /* ignored */ + char sg_kill; /* ignored */ +}; + +/* settings for flags */ +#define RAW 0x20 /* no echo or mapping of input/output BDOS(6) */ + +/* Refer to the MSDOS technical reference for detailed information on + * the remaining flags. + */ diff --git a/Manx Aztec C86 v340a/INCLUDE/ERRNO.H b/Manx Aztec C86 v340a/INCLUDE/ERRNO.H new file mode 100644 index 0000000..2ab0591 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/ERRNO.H @@ -0,0 +1,29 @@ +extern int errno; +extern char *sys_errlist[]; +extern int sys_nerr; + +/* MsDos return codes */ +#define EINVAL 1 +#define ENOENT 2 +#define ENOTDIR 3 +#define EMFILE 4 +#define EACCES 5 +#define EBADF 6 +#define EARENA 7 +#define ENOMEM 8 +#define EFAULT 9 +#define EINVENV 10 +#define EBADFMT 11 +#define EINVACC 12 +#define EINVDAT 13 +#define ENODEV 15 +#define ERMCD 16 +#define EXDEV 17 +#define ENOMORE 18 + +/* additional codes used by Aztec C */ +#define EEXIST 19 +#define ENOTTY 20 +/* used by the math library */ +#define ERANGE 21 +#define EDOM 22 diff --git a/Manx Aztec C86 v340a/INCLUDE/EXMPL.C b/Manx Aztec C86 v340a/INCLUDE/EXMPL.C new file mode 100644 index 0000000..84ac78e --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/EXMPL.C @@ -0,0 +1,9 @@ +main() +{ + char buffer[100]; + + printf("Please enter your name: "); + gets(buffer); + printf("Hello %s, welcome to the growing family of AZTEC C users.\n", + buffer); +} diff --git a/Manx Aztec C86 v340a/INCLUDE/FCNTL.H b/Manx Aztec C86 v340a/INCLUDE/FCNTL.H new file mode 100644 index 0000000..e394bf9 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/FCNTL.H @@ -0,0 +1,13 @@ +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 +#define O_DENYRW 0x10 +#define O_DENYW 0x20 +#define O_DENYR 0x30 +#define O_DENYN 0x40 +#define O_INHER 0x80 +#define O_COMP 0x00 +#define O_CREAT 0x0100 +#define O_TRUNC 0x0200 +#define O_EXCL 0x0400 +#define O_APPEND 0x0800 diff --git a/Manx Aztec C86 v340a/INCLUDE/IO.H b/Manx Aztec C86 v340a/INCLUDE/IO.H new file mode 100644 index 0000000..d78d6a3 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/IO.H @@ -0,0 +1,82 @@ +/* Copyright (C) 1982 by Manx Software Systems */ +/* + * if MAXCHAN is changed then the initialization of chantab in croot.c + * should be adjusted so that it initializes EXACTLY MAXCHAN elements of + * the array. If this is not done, the I/O library may exhibit + * strange behavior. + */ +#define MAXCHAN 11 /* maximum number of I/O channels */ + +/* + * argument to device routines. + * this is a typedef to allow future redeclaration to guarantee + * enough space to store either a pointer or an integer. + */ +typedef char *_arg; + +/* + * device control structure + */ +struct device { + char d_read; + char d_write; + char d_ioctl; /* used by character special devices (eg CON:) */ + char d_seek; /* used by random I/O devices (eg: a file) */ + int (*d_open)(); /* for special open handling */ +}; + +/* + * device table, contains names and pointers to device entries + */ +struct devtabl { + char *d_name; + struct device *d_dev; + _arg d_arg; +}; + +/* + * channel table: relates fd's to devices + */ +struct channel { + char c_read; + char c_write; + char c_ioctl; + char c_seek; + int (*c_close)(); + _arg c_arg; +} ; +extern struct channel chantab[MAXCHAN]; + +struct fcb { + char f_driv; + char f_name[8]; + char f_type[3]; + char f_ext; + char f_resv[2]; + char f_rc; + char f_sydx[16]; + char f_cr; + unsigned f_record; char f_overfl; +}; + +struct fcbtab { + struct fcb fcb; + char offset; + char flags; + char user; +}; + +#define OPNFIL 15 +#define CLSFIL 16 +#define DELFIL 19 +#define READSQ 20 +#define WRITSQ 21 +#define MAKFIL 22 +#define SETDMA 26 +#define GETUSR 32 +#define READRN 33 +#define WRITRN 34 +#define FILSIZ 35 +#define SETREC 36 + +#define Wrkbuf ((char *)0x80) diff --git a/Manx Aztec C86 v340a/INCLUDE/LIBC.H b/Manx Aztec C86 v340a/INCLUDE/LIBC.H new file mode 100644 index 0000000..3775f8e --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/LIBC.H @@ -0,0 +1,49 @@ +/* Copyright (C) 1981, 1982 by Manx Software Systems */ +#define fgetc getc +#define fputc putc + +extern int errno; +#define FLT_FAULT 0 /* vector for floating-point faults */ +extern int (*Sysvec[])(); + +#define NULL (void *)0 +#define EOF -1 +#define BUFSIZ 1024 +#define MAXSTREAM 20 + +#define _BUSY 0x01 +#define _ALLBUF 0x02 +#define _DIRTY 0x04 +#define _EOF 0x08 +#define _IOERR 0x10 +#define _TEMP 0x20 /* temporary file (delete on close) */ + +typedef struct { + char *_bp; /* current position in buffer */ + char *_bend; /* last character in buffer + 1 */ + char *_buff; /* address of buffer */ + char _flags; /* open mode, etc. */ + char _unit; /* token returned by open */ + char _bytbuf; /* single byte buffer for unbuffer streams */ + int _buflen; /* length of buffer */ + char *_tmpname; /* name of file for temporaries */ +} FILE; + +extern FILE Cbuffs[]; +extern char *Stdbufs; /* free list of buffers */ +FILE *fopen(); +long ftell(); + +#define stdin (&Cbuffs[0]) +#define stdout (&Cbuffs[1]) +#define stderr (&Cbuffs[2]) +#define getchar() agetc(stdin) +#define putchar(c) aputc(c, stdout) +#define feof(fp) (((fp)->_flags&_EOF)!=0) +#define ferror(fp) (((fp)->_flags&_IOERR)!=0) +#define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF)) +#define fileno(fp) ((fp)->_unit) +#define fflush(fp) flsh_(fp,-1) + +#define P_tmpdir "" +#define L_tmpnam 40 diff --git a/Manx Aztec C86 v340a/INCLUDE/LMACROS.H b/Manx Aztec C86 v340a/INCLUDE/LMACROS.H new file mode 100644 index 0000000..c3686de --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/LMACROS.H @@ -0,0 +1,210 @@ + nlist +; Copyright (C) 1985 by Manx Software Systems, Inc. +; :ts=8 + ifndef MODEL +MODEL equ 0 + endif + if MODEL and 1 + largecode +FARPROC equ 1 +FPTRSIZE equ 4 + else +FPTRSIZE equ 2 + endif + if MODEL and 2 +LONGPTR equ 1 + endif + +;this macro to be used on returning +;restores bp and registers +pret macro +if havbp + pop bp +endif + ret + endm + +internal macro pname + public pname +pname proc + endm + +intrdef macro pname + public pname +ifdef FARPROC + pname label far +else + pname label near +endif + endm + +procdef macro pname, args + public pname&_ +ifdef FARPROC + _arg = 6 + pname&_ proc far +else + _arg = 4 + pname&_ proc near +endif +ifnb + push bp + mov bp,sp + havbp = 1 + decll +else + havbp = 0 +endif + endm + +entrdef macro pname, args + public pname&_ +ifdef FARPROC + _arg = 6 + pname&_: +else + _arg = 4 + pname&_: +endif +ifnb +if havbp + push bp + mov bp,sp +else + error must declare main proc with args, if entry has args +endif + decll +endif + endm + +;this macro equates 'aname' to arg on stack +decl macro aname, type +;;'byte' or anything else +havtyp = 0 +ifidn , + aname equ byte ptr _arg[bp] + _arg = _arg + 2 + havtyp = 1 +endif +ifidn , + aname equ dword ptr _arg[bp] + _arg = _arg + 4 + havtyp = 1 +endif +ifidn , + aname equ qword ptr _arg[bp] + _arg = _arg + 8 + havtyp = 1 +endif +ifidn , + ifdef LONGPTR + aname equ dword ptr _arg[bp] + _arg = _arg + 4 + else + aname equ word ptr _arg[bp] + _arg = _arg + 2 + endif + havtyp = 1 +endif +ifidn , + ifdef FARPROC + aname equ dword ptr _arg[bp] + _arg = _arg + 4 + else + aname equ word ptr _arg[bp] + _arg = _arg + 2 + endif + havtyp = 1 +endif +ifidn , + aname equ word ptr _arg[bp] + _arg = _arg + 2 + havtyp = 1 +endif +ife havtyp + error -- type is unknown. +endif + endm + +;this macro loads an arg pointer into DEST, with optional SEGment +ldptr macro dest, argname, seg +ifdef LONGPTR + ifnb ;;get segment if specified + ifidn , + les dest,argname + else + ifidn , + lds dest,argname + else + mov dest, word ptr argname + mov seg, word ptr argname[2] + endif + endif + else + ifidn , ;;si gets seg in ds + lds si, argname + else + ifidn , ;;or, es:di + les di, argname + else + garbage error: no seg for long pointer + endif + endif + endif +else + mov dest, word ptr argname ;;get the pointer +ENDIF + ENDM + +decll macro list + IRP i, + decl i + ENDM + ENDM + +pend macro pname +pname&_ endp + endm + +retptrm macro src,seg +mov ax, word ptr src +ifdef LONGPTR + mov dx, word ptr src+2 +endif + endm + +retptrr macro src,seg +mov ax,src +ifdef LONGPTR + ifnb + mov dx, seg + endif +endif + endm + +retnull macro +ifdef LONGPTR + sub dx,dx +endif + sub ax,ax + endm + +pushds macro + ifdef LONGPTR + push ds + endif + endm + +popds macro + ifdef LONGPTR + pop ds + endif + endm + +finish macro +codeseg ends + endm + + list +codeseg segment byte public 'code' + assume cs:codeseg diff --git a/Manx Aztec C86 v340a/INCLUDE/MATH.H b/Manx Aztec C86 v340a/INCLUDE/MATH.H new file mode 100644 index 0000000..bc2ebd7 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/MATH.H @@ -0,0 +1,11 @@ +double sin(), cos(), tan(), cotan(); +double asin(), acos(), atan(), atan2(); +double ldexp(), frexp(), modf(); +double floor(), ceil(), fabs(); +double log(), log10(), exp(), sqrt(), pow(); +double sinh(), cosh(), tanh(); + +#define HUGE_VAL 1.79e+308 +#define LOGHUGE 709.778 +#define TINY_VAL 2.2e-308 +#define LOGTINY -708.396 diff --git a/Manx Aztec C86 v340a/INCLUDE/MEMORY.H b/Manx Aztec C86 v340a/INCLUDE/MEMORY.H new file mode 100644 index 0000000..3d8d0c1 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/MEMORY.H @@ -0,0 +1,2 @@ +extern char *memcpy(), *memchr(), *memccpy(), memset(); +extern int memcmp(); diff --git a/Manx Aztec C86 v340a/INCLUDE/MODEL.H b/Manx Aztec C86 v340a/INCLUDE/MODEL.H new file mode 100644 index 0000000..8889f3e --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/MODEL.H @@ -0,0 +1,7 @@ +#if (sizeof(int (*)()) == 4) +#define _LARGECODE +#endif + +#if (sizeof(char *) == 4) +#define _LARGEDATA +#endif diff --git a/Manx Aztec C86 v340a/INCLUDE/SETJMP.H b/Manx Aztec C86 v340a/INCLUDE/SETJMP.H new file mode 100644 index 0000000..19d512e --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/SETJMP.H @@ -0,0 +1,4 @@ +/* Copyright (C) 1983 by Manx Software Systems */ +#define JBUFSIZE (6*sizeof(char *)) + +typedef char jmp_buf[JBUFSIZE]; diff --git a/Manx Aztec C86 v340a/INCLUDE/SGTTY.H b/Manx Aztec C86 v340a/INCLUDE/SGTTY.H new file mode 100644 index 0000000..a2a5cad --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/SGTTY.H @@ -0,0 +1,19 @@ +/* Copyright (C) 1983 by Manx Software Systems */ + +#define TIOCGETP 0 /* read contents of tty control structure */ +#define TIOCSETP 1 /* set contents of tty control structure */ +#define TIOCSETN 1 /* ditto only don't wait for output to flush */ + +struct sgttyb { + char sg_erase; /* ignored */ + char sg_kill; /* ignored */ + short sg_flags; /* control flags */ +}; + +/* settings for flags */ +#define _VALID 0x3a +#define RAW 0x20 /* no echo or mapping of input/output BDOS(6) */ +#define CRMOD 0x10 /* map input CR to NL, output NL to CR LF */ +#define ECHO 0x08 /* ignored unless CBREAK is set */ +#define CBREAK 0x02 /* input using BDOS(1), unless echo off then */ + /* same as RAW */ diff --git a/Manx Aztec C86 v340a/INCLUDE/SIGNAL.H b/Manx Aztec C86 v340a/INCLUDE/SIGNAL.H new file mode 100644 index 0000000..2bea52f --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/SIGNAL.H @@ -0,0 +1,15 @@ +/* Copyright (C) 1985 by Manx Software Systems, Inc. */ + +#define SIG_DFL ((void (*)())0) +#define SIG_IGN ((void (*)())1) +#define SIG_ERR ((void (*)())-1) + +#define SIGINT 1 +#define SIGTERM 2 +#define SIGABRT 3 +#define SIGFPE 4 +#define SIGILL 5 +#define SIGSEGV 6 + +#define _NUMSIG 6 +#define _FSTSIG 1 diff --git a/Manx Aztec C86 v340a/INCLUDE/STAT.H b/Manx Aztec C86 v340a/INCLUDE/STAT.H new file mode 100644 index 0000000..5e10dba --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/STAT.H @@ -0,0 +1,29 @@ +/* Copyright (C) 1984 by Manx Software Systems */ + +struct stat { + char st_attr; + long st_mtime; + long st_size; +}; + +/* settings of the st_attr field */ +#define ST_RDONLY 0x01 /* read only file */ +#define ST_HIDDEN 0x02 /* hidden file */ +#define ST_SYSTEM 0x04 /* system file */ +#define ST_VLABEL 0x08 /* volume label */ +#define ST_DIRECT 0x10 /* file is a sub-directory */ +#define ST_ARCHIV 0x20 /* set when file has been written and closed */ + +/* the format of the st_mtime field is: + < year > < month> < day > < hours > < minutes > < sec/2 > + 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + +where: + year is from 0-119 for 1980-2099 + month is 1-12 + day is 1-31 + hours is 0-23 + minutes is 0-59 + sec/2 is 0-29 +*/ diff --git a/Manx Aztec C86 v340a/INCLUDE/STDIO.H b/Manx Aztec C86 v340a/INCLUDE/STDIO.H new file mode 100644 index 0000000..012c685 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/STDIO.H @@ -0,0 +1,46 @@ +/* Copyright (C) 1982, 1984 by Manx Software Systems */ +#define fgetc getc +#define fputc putc +#define NULL (void *)0 +#define EOF -1 + + +#define BUFSIZ 1024 +#define MAXSTREAM 20 + +#define _BUSY 0x01 +#define _ALLBUF 0x02 +#define _DIRTY 0x04 +#define _EOF 0x08 +#define _IOERR 0x10 +#define _TEMP 0x20 /* temporary file (delete on close) */ + +typedef struct { + char *_bp; /* current position in buffer */ + char *_bend; /* last character in buffer + 1 */ + char *_buff; /* address of buffer */ + char _flags; /* open mode, etc. */ + char _unit; /* token returned by open */ + char _bytbuf; /* single byte buffer for unbuffer streams */ + int _buflen; /* length of buffer */ + char *_tmpname; /* name of file for temporaries */ +} FILE; + +extern FILE Cbuffs[]; +FILE *fopen(), *freopen(); +FILE *fdopen(); +long ftell(); + +#define stdin (&Cbuffs[0]) +#define stdout (&Cbuffs[1]) +#define stderr (&Cbuffs[2]) +#define getchar() agetc(stdin) +#define putchar(c) aputc(c, stdout) +#define feof(fp) (((fp)->_flags&_EOF)!=0) +#define ferror(fp) (((fp)->_flags&_IOERR)!=0) +#define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF)) +#define fileno(fp) ((fp)->_unit) +#define fflush(fp) flsh_(fp,-1) + +#define P_tmpdir "" +#define L_tmpnam 40 diff --git a/Manx Aztec C86 v340a/INCLUDE/TIME.H b/Manx Aztec C86 v340a/INCLUDE/TIME.H new file mode 100644 index 0000000..07c73a4 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/TIME.H @@ -0,0 +1,22 @@ +/* Copyright (C) 1984, 1985 by Manx Software Systems */ + +#define CLK_TCK 100 +typedef long time_t; +typedef long clock_t; + +struct tm { + short tm_sec; + short tm_min; + short tm_hour; + short tm_mday; + short tm_mon; + short tm_year; + short tm_wday; + short tm_yday; + short tm_isdst; + short tm_hsec; +}; + +struct tm *gmtime(), *localtime(); +char *asctime(), *ctime(); +time_t time(); diff --git a/Manx Aztec C86 v340a/INCLUDE/regs.h b/Manx Aztec C86 v340a/INCLUDE/regs.h new file mode 100644 index 0000000..f7395c8 --- /dev/null +++ b/Manx Aztec C86 v340a/INCLUDE/regs.h @@ -0,0 +1,55 @@ +/* regs.h for aztec.c (C) Copyright Bill Buckels 2008. All rights reserved. */ + +#ifndef REGS_DEFINED + +/* word registers */ +/* different than M$oft so don't mix the two */ +struct WORDREGS { + unsigned int ax; + unsigned int bx; + unsigned int cx; + unsigned int dx; + unsigned int si; + unsigned int di; + unsigned int ds; + unsigned int es; + }; + +/* byte registers */ +/* I made these the same as M$oft since + the first 6 word regs are the same between the two */ +struct BYTEREGS { + unsigned char al, ah; + unsigned char bl, bh; + unsigned char cl, ch; + unsigned char dl, dh; + }; + +/* general purpose registers union - + * overlays the corresponding word and byte registers. + */ + +union REGS { + struct WORDREGS x; + struct BYTEREGS h; + }; + + +/* segment registers */ +/* different than M$oft so don't mix the two */ +struct SREGS { + unsigned int cs; + unsigned int ss; + unsigned int ds; + unsigned int es; + }; + + +/* the following makes it a little easier + to port code from M$soft and Turbo C + over to Aztec C unless you want to be + an Aztec C purist */ +#define int86(x,y,z) sysint(x,y,z) + +#define REGS_DEFINED 1 +#endif \ No newline at end of file diff --git a/Manx Aztec C86 v340a/LIB/C.LIB b/Manx Aztec C86 v340a/LIB/C.LIB new file mode 100644 index 0000000..126d0a7 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/C.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/C86.LIB b/Manx Aztec C86 v340a/LIB/C86.LIB new file mode 100644 index 0000000..ddeb8e3 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/C86.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/CL.LIB b/Manx Aztec C86 v340a/LIB/CL.LIB new file mode 100644 index 0000000..045d79c Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/CL.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/CLC.LIB b/Manx Aztec C86 v340a/LIB/CLC.LIB new file mode 100644 index 0000000..1c62b1d Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/CLC.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/CLD.LIB b/Manx Aztec C86 v340a/LIB/CLD.LIB new file mode 100644 index 0000000..be215f5 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/CLD.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/D11.LIB b/Manx Aztec C86 v340a/LIB/D11.LIB new file mode 100644 index 0000000..55a837a Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/D11.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/G.LIB b/Manx Aztec C86 v340a/LIB/G.LIB new file mode 100644 index 0000000..6c5fe3e Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/G.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/GL.LIB b/Manx Aztec C86 v340a/LIB/GL.LIB new file mode 100644 index 0000000..0ff3dc3 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/GL.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/GLC.LIB b/Manx Aztec C86 v340a/LIB/GLC.LIB new file mode 100644 index 0000000..2c582ec Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/GLC.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/GLD.LIB b/Manx Aztec C86 v340a/LIB/GLD.LIB new file mode 100644 index 0000000..47e3b43 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/GLD.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M.LIB b/Manx Aztec C86 v340a/LIB/M.LIB new file mode 100644 index 0000000..4b0ee28 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87.LIB b/Manx Aztec C86 v340a/LIB/M87.LIB new file mode 100644 index 0000000..bb76f18 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87L.LIB b/Manx Aztec C86 v340a/LIB/M87L.LIB new file mode 100644 index 0000000..f78d77c Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87L.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87LC.LIB b/Manx Aztec C86 v340a/LIB/M87LC.LIB new file mode 100644 index 0000000..531ec01 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87LC.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87LD.LIB b/Manx Aztec C86 v340a/LIB/M87LD.LIB new file mode 100644 index 0000000..62dfdf7 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87LD.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87S.LIB b/Manx Aztec C86 v340a/LIB/M87S.LIB new file mode 100644 index 0000000..6ac90ef Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87S.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87SL.LIB b/Manx Aztec C86 v340a/LIB/M87SL.LIB new file mode 100644 index 0000000..050a64b Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87SL.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87SLC.LIB b/Manx Aztec C86 v340a/LIB/M87SLC.LIB new file mode 100644 index 0000000..c25d2d6 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87SLC.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/M87SLD.LIB b/Manx Aztec C86 v340a/LIB/M87SLD.LIB new file mode 100644 index 0000000..f24c550 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/M87SLD.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/ML.LIB b/Manx Aztec C86 v340a/LIB/ML.LIB new file mode 100644 index 0000000..ea9f39b Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/ML.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/MLC.LIB b/Manx Aztec C86 v340a/LIB/MLC.LIB new file mode 100644 index 0000000..6f4f4fb Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/MLC.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/MLD.LIB b/Manx Aztec C86 v340a/LIB/MLD.LIB new file mode 100644 index 0000000..7cde525 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/MLD.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/S.LIB b/Manx Aztec C86 v340a/LIB/S.LIB new file mode 100644 index 0000000..ac2ba7c Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/S.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/SL.LIB b/Manx Aztec C86 v340a/LIB/SL.LIB new file mode 100644 index 0000000..4d40a90 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/SL.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/SLC.LIB b/Manx Aztec C86 v340a/LIB/SLC.LIB new file mode 100644 index 0000000..1eeae98 Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/SLC.LIB differ diff --git a/Manx Aztec C86 v340a/LIB/SLD.LIB b/Manx Aztec C86 v340a/LIB/SLD.LIB new file mode 100644 index 0000000..de4199f Binary files /dev/null and b/Manx Aztec C86 v340a/LIB/SLD.LIB differ diff --git a/Manx Aztec C86 v340a/OBJ/CRT0.OBJ b/Manx Aztec C86 v340a/OBJ/CRT0.OBJ new file mode 100644 index 0000000..2e03c2a Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/CRT0.OBJ differ diff --git a/Manx Aztec C86 v340a/OBJ/LCROM.O b/Manx Aztec C86 v340a/OBJ/LCROM.O new file mode 100644 index 0000000..e9d746e Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/LCROM.O differ diff --git a/Manx Aztec C86 v340a/OBJ/LDROM.O b/Manx Aztec C86 v340a/OBJ/LDROM.O new file mode 100644 index 0000000..4dfc6b2 Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/LDROM.O differ diff --git a/Manx Aztec C86 v340a/OBJ/LROM.O b/Manx Aztec C86 v340a/OBJ/LROM.O new file mode 100644 index 0000000..e9d746e Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/LROM.O differ diff --git a/Manx Aztec C86 v340a/OBJ/OVBGN.O b/Manx Aztec C86 v340a/OBJ/OVBGN.O new file mode 100644 index 0000000..3b7a208 Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/OVBGN.O differ diff --git a/Manx Aztec C86 v340a/OBJ/OVLD.O b/Manx Aztec C86 v340a/OBJ/OVLD.O new file mode 100644 index 0000000..6d19fcd Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/OVLD.O differ diff --git a/Manx Aztec C86 v340a/OBJ/OVLDPATH.O b/Manx Aztec C86 v340a/OBJ/OVLDPATH.O new file mode 100644 index 0000000..d1b5bac Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/OVLDPATH.O differ diff --git a/Manx Aztec C86 v340a/OBJ/SROM.O b/Manx Aztec C86 v340a/OBJ/SROM.O new file mode 100644 index 0000000..4dfc6b2 Binary files /dev/null and b/Manx Aztec C86 v340a/OBJ/SROM.O differ diff --git a/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.C b/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.C new file mode 100644 index 0000000..9318228 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.C @@ -0,0 +1,473 @@ +/* BATCH.C (C) Copyright Bill Buckels 1990-2008. All rights reserved. */ + +/* demo for embedded .BSV files in aztec C */ +/* compiles in CP/M 86 and MS-DOS */ +/* these files can be created in the THEDRAW or in GWBASIC, etc. */ +/* arrays are encoded using my utility bsaveinc */ + +unsigned char BATCH000[]={ +255, 32,255, 32,242, 32,193,218,231,196,193,194,197,196,191,225, 32, +179,198, 32,199,220,195, 32,199,220,195, 32,199,220,198, 32,179,197, 32, +179,225, 32,179,199, 32,194,220,195, 32,194,220,195, 32,194,220,195, 32, +194,220,195, 32,194,220,195, 32,194,220,197, 32,179, 32,194, 66, 80, + 32,179,225, 32,179,199, 32,198,220,196, 32,198,220,196, 32,198,220, +198, 32,179, 32,195,219, 32,179,225, 32,179,199, 32,194,220,195, 32, +194,220,195, 32,194,220,195, 32,194,220,195, 32,194,220,202, 32,179, +197, 32,179,225, 32,179,198, 32,199,220,195, 32,199,220,196, 32,194,220, +202, 32,179,197, 32,179,225, 32,179,231, 32,179,194, 32,193,249,194, 32, +179,225, 32,179,198, 32, 66,105,194,108, 32, 66,117, 99,107,101,108, +115, 32, 80,114,111,100,117, 99,116,105,111,110,115, 32, 49, 57,194, 56, +196, 32,179,194, 32,111,194, 32,179,225, 32,179,194, 32, 40, 67, 41, + 32, 67,111,112,121, 76,101,102,116, 32, 66,105,194,108, 32, 66,117, + 99,107,101,108,115, 32, 49, 57,194, 56, 45, 50,194, 48, 54,194, 32, +179,197, 32,179,225, 32,179,198, 32, 65,194,108, 32, 82,105,103,104, +116,115, 32, 82,101,118,101,114,115,101,100, 46,205, 32,179,194, 32, +111,194, 32,179,225, 32,179,231, 32,179,197, 32,179,225, 32,179,231, 32, +179,194, 32,111,194, 32,179,225, 32,193,192,231,196,193,193,197,196, +193,217,234, 32,193,219,219, 32,193,219,231, 32,193,218,244,196,191, +218, 32,179,194, 32,193,218,195,196,191,202, 32,193,218,207,196,191, +193,218,207,196,191, 32,179,218, 32,179,194, 32,179,194, 66, 80,179, +202, 32,179,195, 32,196,196, 18,196,196, 32,193,254, 32,194,179,207, 32, +179, 32,179,218, 32,179,194, 32,193,192,195,196,193,217,202, 32,193,195, +207,196,180,179,203, 32,193,254, 32,193,254, 32,179, 32,179,218, 32, +179, 32,206,186,194, 32,179,195, 32,196,196, 18,196,196, 32,193,254, + 32,194,179,207, 32,179, 32,179,218, 32,179, 32,206,186,194, 32,193,192, +207,196,193,217,193,192,207,196,193,217, 32,179,218, 32,193,192,244,196, +193,217,255, 32,222, 32, 80,114,101,194,115, 32, 65,110,121, 32, 75, +101,121, 32,116,111, 32, 99,111,110,116,105,110,117,101,195, 46,206, 32, + 80,114,101,194,115, 32, 91, 65, 76, 84, 93, 43, 91, 69,110,116,101, +114, 93,193,255,102,111,114,193,255, 70,117,194,108, 32, 83, 99,114, +194,101,110,195, 46,208, 7,240, 9,224, 7,240, 9,224, 7,239, 96, + 6,224, 7, 96,197, 7,222, 9,196, 7,199, 96,225, 7, 96,197, 7, +222, 9,196, 3,199, 96,225, 7, 96,197, 7,222, 9,196, 7,199, 96, +225, 7, 96,197, 7,222, 9,196, 7,199, 96,225, 7, 96,197, 7,222, 9, +196, 7,199, 96,225, 7, 96,197, 7,222, 9,196, 7,199, 96,225, 7, + 96,197, 7,226, 14,199, 96,208, 7, 14,208, 7, 96,194, 7,227, 14, +194, 7,199, 96,225, 7, 96,198, 7,212, 14,205, 7,199, 96,225, 7, + 96,231, 7,199, 96,225, 7, 96,231, 7,199, 96,225, 7,239, 96,232, 7, +225, 9,229, 7,246, 96,218, 7,195, 96,197, 9,202, 96,226, 9,194, 96, +218, 7,195, 96,197, 9,202, 96,226, 9,194, 96,218, 7,195, 96,197, 9, +202, 96,226, 9,194, 96,218, 7,194, 96,206, 9,194, 96,226, 9,194, 96, +218, 7,194, 96,206, 9,194, 96,226, 9,194, 96,218, 7,246, 96,255, 7, +222, 7,255, 31,209, 31, +0}; /* terminator */ + +unsigned char BATCH001[]={ +194, 32,193,201,255,205,202,205,187,197, 32,186,203, 32,204,220,197, 32, +204,220,197, 32,204,220,208, 32,186,197, 32,186,203, 32,206,220,195, 32, +206,220,195, 32,206,220,206, 32,186,197, 32,186,205, 32,196,220,196, 32, +196,220,197, 32,196,220,196, 32,196,220,197, 32,196,220,196, 32,196,220, +206, 32,186,197, 32,186,205, 32,203,220,198, 32,203,220,198, 32,203,220, +207, 32,186,197, 32,186,205, 32,203,220,198, 32,203,220,198, 32,202,220, +208, 32,186,197, 32,186,205, 32,196,220,196, 32,196,220,197, 32,196,220, +196, 32,196,220,197, 32,196,220,214, 32,186,197, 32,186,203, 32,206,220, +195, 32,206,220,195, 32,200,220,212, 32,186,197, 32,186,203, 32,204,220, +197, 32,204,220,197, 32,200,220,212, 32,186,197, 32,193,204,255,205, +202,205,185,197, 32,186,207, 32, 66,105,194,108, 32, 66,117, 99,107, +101,108,115, 32, 80,114,111,100,117, 99,116,105,111,110,115, 32, 49, + 57,194, 56, 32,112,114,101,115,101,110,116,115,212, 32,186,197, 32, +186,207, 32, 79, 98,115,101,114,118, 97,116,105,111,110,115, 32,111, +110, 32, 80, 67, 68, 79, 83, 32, 66, 97,116, 99,104, 32, 80,114,111, + 99,101,194,115,105,110,103,212, 32,186,197, 32,186,212, 32, 79,110, + 32,116,104,101, 32, 73, 66, 77, 32, 80, 67, 32, 97,110,100, 32, 67, +111,109,112, 97,116,105, 98,108,101,115,216, 32,186,197, 32,193,204, +255,205,202,205,185,197, 32,186,204, 32,200,220,194, 32,204,220,196, 32, +199,220,199, 32,199,220,206, 32,186,197, 32,186,204, 32,200,220,194, 32, +206,220,194, 32,200,220,197, 32,200,220,206, 32,186,197, 32,186,206, 32, +196,220,198, 32,196,220,196, 32,196,220,196, 32,199,220,195, 32,199,220, +208, 32,186,197, 32,186,206, 32,196,220,198, 32,203,220,197, 32,200,220, + 32,200,220,208, 32,186,197, 32,186,206, 32,196,220,198, 32,203,220, +197, 32,196,220, 32,199,220, 32,196,220,208, 32,186,197, 32,186,206, 32, +196,220,198, 32,196,220,196, 32,196,220,196, 32,196,220,194, 32,197,220, +194, 32,196,220,208, 32,186,197, 32,186,204, 32,200,220,194, 32,206,220, +194, 32,198,220,195, 32,195,220,195, 32,198,220,206, 32,186,197, 32, +186,204, 32,200,220,194, 32,204,220,196, 32,198,220,196, 32,193,220, +196, 32,198,220,206, 32,186,197, 32,193,200,255,205,202,205,188,255, 32, +212, 32,193,255, 49, 45, 51,193,255,112, 97,103,101,193,255,100,105, +114,101, 99,116,209,255, 83,112, 97, 99,101, 98, 97,114, 47, 69,110, +116,101,114, 32,110,101,120,116,206, 32,197,255, 69,115, 99,193,255, +101,120,105,116,193,255,194, 9,255, 4,204, 4,197, 9, 4,202, 7, +242, 9,205, 7, 4,197, 9, 4,202, 7,242, 9,205, 7, 4,197, 9, + 4,202, 7,242, 9,205, 7, 4,197, 9, 4,202, 7,242, 9,205, 7, + 4,197, 9, 4,202, 7,242, 9,205, 7, 4,197, 9, 4,202, 7,242, 9, +205, 7, 4,197, 9, 4,202, 7,242, 9,205, 7, 4,197, 9, 4,202, 7, +242, 9,205, 7, 4,197, 9,255, 4,204, 4,197, 9, 4,205, 71,236, 79, +208, 71, 4,197, 9, 4,205, 71,236, 79,208, 71, 4,197, 9, 4,205, 71, +236, 79,208, 71, 4,197, 9,255, 4,204, 4,197, 9, 4,203, 7,241, 9, +205, 7, 4,197, 9, 4,203, 7,241, 9,205, 7, 4,197, 9, 4,203, 7, +241, 9,205, 7, 4,197, 9, 4,203, 7,241, 9,205, 7, 4,197, 9, + 4,203, 7,241, 9,205, 7, 4,197, 9, 4,203, 7,244, 9,202, 7, + 4,197, 9, 4,203, 7,244, 9,202, 7, 4,197, 9, 4,203, 7,244, 9, +202, 7, 4,197, 9,255, 4,204, 4,195, 9,255, 7,204, 7,197, 9, +255, 31,209, 31, +0}; /* terminator */ + + +unsigned char BATCH002[]={ +194,255, 32,193,201,255,205,202,205,187,196,255, 32,186,255, 32,202, 32, +186,196,255, 32,186,195, 32, 84,104,101, 32, 73, 66, 77, 32, 80, 67, + 32,111,112,101,114, 97,116,105,110,103, 32,115,121,115,116,101,109, + 32, 40, 68, 79, 83, 41, 32,105,115, 32,116,104,101, 32,109,111,115, +116, 32,101,194,102,105, 99,105,101,110,116, 32,119, 97,121, 32,102, +111,114,199, 32,186,196,255, 32,186,195, 32,116,104,101, 32, 97,118, +101,114, 97,103,101, 32,117,115,101,114, 32,116,111, 32,105,194,115, +117,101, 32,105,110,115,116,114,117, 99,116,105,111,110,115, 32,116, +111, 32,116,104,101, 32,112,114,111, 99,101,194,115,111,114, 44, 32, + 98,117,116, 32,105,116, 32,105,115,196, 32,186,196,255, 32,186,195, 32, + 97,108,115,111, 32,116,104,101, 32,109,111,115,116, 32,111,118,101, +114,108,194,111,107,101,100, 32,119,104,101,110, 32,105,116, 32, 99, +111,109,101,115, 32,116,105,109,101, 32,102,111,114, 32,109,111,115, +116, 32,111,102, 32,117,115, 32,116,111,201, 32,186,196,255, 32,186, +195, 32, 99,111,110,115,105,100,101,114, 32,119, 97,121,115, 32, 97, +110,100, 32,109,101, 97,110,115, 32,116,111, 32,112,114,111, 99,101, +194,115, 32,111,117,114, 32,118, 97,114,105,111,117,115, 32, 99,111, +109,112,117,116,105,110,103, 32,116, 97,115,107,115, 46,199, 32,186, +196,255, 32,186,255, 32,202, 32,186,196,255, 32,186,195, 32, 65,194,108, + 32,116,194,111, 32,111,102,116,101,110, 32,119,101, 32,111,112,116, + 32,102,111,114, 32, 97, 32,109,101,109,111,114,121, 32,104,111,103, + 32,111,102, 32, 97, 32,102, 97,109,105,108,105, 97,114, 32, 97,194,112, +108,105, 99, 97,116,105,111,110,115,198, 32,186,196,255, 32,186,195, 32, +112,114,111,103,114, 97,109, 32,111,114, 32, 97, 32,114,111,117,116, +105,110,101, 32,115,101,118,101,114, 97,108, 32,108, 97,121,101,114, +115, 32,116,104,105, 99,107, 32,105,110, 32, 66, 65, 83, 73, 67, 39, +115, 32, 34, 98,111,103, 32, 97,110,100, 32,109,105,114,101, 34,195, 32, +186,196,255, 32,186,195, 32,116,111, 32,105,194,115,117,101, 32,111, +110,101, 32,111,114, 32,116,119,111, 32,108,105,194,116,108,101, 32, +105,110,115,116,114,117, 99,116,105,111,110,115, 32,116,104, 97,116, + 32, 97,114,101, 32,112,114,111, 98, 97, 98,108,121, 32, 97,118, 97, +105,108, 97, 98,108,101,195, 32,186,196,255, 32,186,195, 32,105,110, + 32, 97, 32,116,105,110,121, 32, 46, 67,111,109, 32,112,114,111,103, +114, 97,109, 32,116,104, 97,116, 32, 99, 97,109,101, 32,119,105,116, +104, 32,116,104, 97,116, 32, 99,111,110,102,117,115,105,110,103, 32, +112,105,108,101, 32,111,102, 32,115,116,117,194,102,196, 32,186,196,255, + 32,186,195, 32,111,110, 32,111,117,114, 32, 68,111,115, 32, 68,105, +115,107, 46, 32, 40, 73,102, 32,119,101, 32,104, 97,100, 32,116, 97, +107,101,110, 32,116,104,101, 32,116,105,109,101, 32,116,111, 32,119, + 97,100,101, 32,116,104,114,111,117,103,104, 32,116,104,101,200, 32, +186,196,255, 32,186,195, 32,109,111,117,110,100,115, 32,111,102, 32, +100,111, 99,117,109,101,110,116, 97,116,105,111,110, 32,119,101, 32, +119,111,117,108,100, 32,117,110,100,101,114,115,116, 97,110,100, 32, +116,104, 97,116, 32,116,104,101, 32, 77, 97,110,121, 32, 70,101, 97, +116,117,114,101,115,196, 32,186,196,255, 32,186,195, 32,111,110, 32, +116,104,101, 32, 70, 97, 99,101, 32,111,102, 32, 68,111,115, 32, 97, +114,101, 32, 97, 32,100,101,108,105, 98,101,114, 97,116,101, 32,101, +194,102,111,114,116, 32,116,111, 32,109, 97,107,101, 32,116,104,101, + 32,115,121,115,116,101,109, 32,109,111,114,101,196, 32,186,196,255, + 32,186,195, 32,102,114,105,101,110,100,108,121, 32, 97,110,100, 32, +101,194,102,105, 99,105,101,110,116, 32,116,104, 97,110, 32, 99,111, +110,102,117,115,105,110,103, 32, 97,110,100, 32,116,105,109,101, 45, + 99,111,110,115,117,109,105,110,103, 46, 41,204, 32,186,196,255, 32, +186,255, 32,202, 32,186,196,255, 32,186,195, 32, 84,104,105,115, 32, +105,115, 32,119,104,101,114,101, 32,109,111,115,116, 32,111,102, 32, +117,115, 32, 97,115, 32,117,115,101,114,115, 32,102, 97,105,108, 44, + 32, 97,110,100, 32, 97,102,116,101,114, 32, 34,119,101, 97,114,105, +110,103, 32,111,117,114,200, 32,186,196,255, 32,186,195, 32,102,105, +110,103,101,114,115, 32,116,111, 32,116,104,101, 32, 98,111,110,101, + 34, 32,116,121,112,105,110,103, 32,101, 97, 99,104, 32, 97,110,100, + 32,101,118,101,114,121, 32, 99,111,194,109, 97,110,100, 32,105,110, + 32,115,111,114,116, 32,111,102, 32, 97,110,198, 32,186,196,255, 32, +186,195, 32,101,109,117,108, 97,116,105,111,110, 32,111,102, 32, 34, +104,117,110,116, 32, 97,110,100, 32,112,101, 99,107, 34, 32,111,110, + 32,116,104,101, 32,109, 97,110,117, 97,108, 32,116,121,112,101,119, +114,105,116,101,114, 44, 32,119,101, 32,115,112,114,105,110,103, 32, +102,111,114,194, 32,186,196,255, 32,186,195, 32,116,104,101, 32,108, + 97,116,101,115,116, 32,118,101,114,115,105,111,110, 32,111,102, 32, + 34, 84,104,101, 32, 70, 97,107,101,119, 97,114,101, 32, 87,105,110, +100,111,119, 32, 77,101,110,117, 32, 77,111,117,115,101, 32, 67,111, +194,109, 97,110,100,111, 34,199, 32,186,196,255, 32,186,195, 32, 97, +110,100, 32, 98,101, 99,111,109,101, 32,102,111,114,101,118,101,114, + 32,105,110,101,194,102,101, 99,116,105,118,101, 32,119,104,105,110, +105,110,103, 32, 34,109,101,109,111,114,121, 32,106,117,110,107,105, +101,115, 46, 34,206, 32,186,196,255, 32,186,255, 32,202, 32,186,196,255, + 32,193,200,255,205,202,205,188,196,255,255, 32,204, 32,196,255, 48, + 45, 51,193,255,112, 97,103,101, 32,100,105,114,101, 99,116,209, 32, + 83,112, 97, 99,101, 98, 97,114, 47, 69,110,116,101,114,193,255,110, +101,120,116, 32,208,255, 69,115, 99, 32,112, 97,103,101, 32, 48,193,255, +255, 12,255, 12,233, 12,255, 11,199, 11,202, 12,255, 11,199, 11,202, 12, +255, 11,199, 11,202, 12,255, 11,199, 11,202, 12,255, 7,199, 7,255, 12, +255, 12,255, 12,255, 12,255, 12,255, 12,255, 12,255, 12,255, 12,255, 12, +212, 12,255, 7,199, 7,202, 12,255, 11,199, 11,202, 12,255, 11,199, 11, +202, 12,255, 11,199, 11,202, 12,255, 11,199, 11,202, 12,255, 11,199, 11, +255, 12,255, 12,229, 12,199, 1,255, 7,199, 7,195, 12,255, 31,209, 31, +0}; /* terminator */ + + +unsigned char BATCH003[]={ +195, 32,193,201,255,205,201,205,187,198, 32,186,211, 32, 67,111,194,109, + 97,110,100, 46, 67,111,109, 32, 97,110,100, 32,116,104,101, 32, 34, + 84,114, 97,105,110, 32,111,102, 32, 67,111,194,109, 97,110,100, 34, +207, 32,186,198, 32,186,199, 32,195,219,196, 32,193,219,194,223,193,219, +246, 32,186,198, 32,186,200, 32,193,219,197, 32,193,219,194, 32,193,219, + 32,198,219,200, 32,198,219,200, 32,198,219, 32,198,219,196, 32,193,219, +193,223,193,219,197, 32,186,198, 32,186,199, 32,203,219, 95,198,219, + 95,198, 32, 95,198,219, 95,198, 32, 95,198,219, 95,198,219, 95,193,223, +199,219,193,223,194, 32,186,198, 32,186,199, 32,203,219, 32,198,219, + 32,198,219, 32,198,219, 32,198,219, 32,198,219, 32,198,219, 32,193,192, +199,219,193,217,194, 32,186,198, 32,186,198, 32,193,219,194, 32, 79, +197, 32, 79,196, 32, 79,194, 32, 79,195, 32, 79,194, 32, 79,195, 32, + 79,194, 32, 79,195, 32, 79,194, 32, 79,195, 32, 79,194, 32, 79,195, 32, + 79,194, 32, 79,196, 32, 79,195, 32, 79,196, 32,186,198, 32,186,255, 32, +201, 32,186,198, 32,186,195, 32, 66,117,116, 32,105,109, 97,103,105, +110,101, 32,102,111,114, 32, 97, 32,109,111,109,101,110,116, 32,105, +102, 32,121,111,117, 32,107,110,101,119, 32,116,104,101, 32,109,111, +100,117,108,101,115, 32,111,102, 32, 68, 79, 83, 32,119,101,194,108, + 32,101,110,111,117,103,104,194, 32,186,198, 32,186,195, 32,116,104, + 97,116, 32,121,111,117, 32, 99,111,117,108,100, 32, 99,111,109, 98, +105,110,101, 32,101, 97, 99,104, 32,111,110,101, 32,116,104, 97,116, + 32,100,111,101,115, 32,111,110,101, 32,106,111, 98, 32,119,101,194,108, + 32,105,110,116,111, 32, 97, 32, 98, 97,116, 99,104,194, 32,186,198, 32, +186,195, 32,106,111, 98, 32, 40,111,114, 32, 99,104, 97,105,110, 32, +111,102, 32, 99,111,194,109, 97,110,100, 32, 97,115, 32,105,116, 32, +119,101,114,101, 41, 32, 97,110,100, 32,116,111, 32,115, 97,118,101, + 32, 97,194,108, 32,116,104, 97,116, 32,116,101,100,105,111,117,115, +196, 32,186,198, 32,186,195, 32,116,121,112,105,110,103, 44, 32,121, +111,117, 32,108,101,116, 32,116,104,101, 32,115,104,111,114,116, 32, + 34,112,114,111,103,114, 97,109, 34, 32,116,104, 97,116, 32,121,111, +117, 32,104, 97,118,101, 32, 99,114,101, 97,116,101,100, 32,105,110, + 32,121,111,117,114,196, 32,186,198, 32,186,195, 32,119,111,114,100, + 45,112,114,111, 99,101,194,115,111,114, 32,115,105,109,112,108,121, + 32, 34,100,117,109,112, 34, 32,101, 97, 99,104, 32, 99,111,194,109, + 97,110,100, 32,111,110,101, 45, 98,121, 45,111,110,101, 32,111,110, + 32,116,104,101, 32,115,121,115,116,101,109,195, 32,186,198, 32,186, +195, 32, 97,110,100, 32,119,105,116,104, 32,110,111, 32, 34, 98,101, +194,108,115, 32, 97,110,100, 32,119,104,105,115,116,108,101,115, 34, + 32,116,104,101, 32,106,111, 98, 32,105,115, 32,100,111,110,101, 46, +212, 32,186,198, 32,186,255, 32,201, 32,186,198, 32,186,195, 32, 87, +105,116,104,111,117,116, 32, 97,194,108, 32,116,104,101, 32, 34,111, +118,101,114,104,101, 97,100, 34, 32,111,102, 32,114,117,194,110,105, +110,103, 32, 97,110, 32,105,110,116,101,114, 97, 99,116,105,118,101, + 32, 99,111,194,109, 97,110,100,201, 32,186,198, 32,186,195, 32,105, +110,116,101,114,112,114,101,116,101,114, 32, 98, 97,116, 99,104, 32, +106,111, 98,115, 32,114,117,110, 32,105,110, 32, 97, 32,102,114, 97, + 99,116,105,111,110, 32,111,102, 32,116,104,101, 32,116,105,109,101, +195, 46,119,105,116,104, 32, 97,193,255, 98,105,116,193,255,111,102, + 32,186,198, 32,186,195, 32,102,111,114,101,116,104,111,117,103,104, +116, 32, 97,110,100, 32,107,110,111,119,108,101,100,103,101, 32,111, +110, 32,116,104,101, 32,112, 97,114,116, 32,111,102, 32,116,104,101, + 32,117,115,101,114, 46,211, 32,186,198, 32,186,255, 32,201, 32,186, +198, 32,186,195, 32, 70,111,114, 32,109, 97,110,121, 32,116, 97,115, +107,115, 32,116,104,101, 32, 98, 97,116, 99,104, 32,106,111, 98, 32, +105,115, 32,116,104,101, 32,115,104,111,114,116,101,115,116, 32,100, +105,115,116, 97,110, 99,101, 32, 98,101,116,119,194,101,110, 32,112, +111,105,110,116,115, 32,186,198, 32,186,195, 32, 97,110,100, 32, 97, +194,108, 32,115,101,114,105,111,117,115, 32, 68, 79, 83, 32,117,115, +101,114,115, 32,115,104,111,117,108,100, 32, 98,101, 32,102,117,194,108, +121, 32,102, 97,109,105,108,105, 97,114, 32,119,105,116,104, 32,105, +116,115, 32,117,115, 97,103,101, 46,195, 32,186,198, 32,186,255, 32, +201, 32,186,198, 32,193,200,255,205,201,205,188,255, 32,212, 32,193,255, + 48, 45, 51,193,255,112, 97,103,101,193,255,100,105,114,101, 99,116, +209,255, 83,112, 97, 99,101, 98, 97,114, 47, 69,110,116,101,114, 32, +110,101,120,116,208, 32,193,255, 69,115, 99, 32,112, 97,103,101, 32, + 48,193,255,255, 12,255, 12,230, 12,255, 10,201, 10,200, 12,255, 10, +201, 10,200, 12,255, 10,201, 10,200, 12,255, 10,201, 10,200, 12,255, 10, +201, 10,200, 12,255, 10,201, 10,255, 12,255, 12,255, 12,255, 12,255, 12, +255, 12,255, 12,242, 12,255, 7,198, 7,200, 12,255, 10,201, 10,200, 12, +255, 10,201, 10,200, 12,255, 10,201, 10,200, 12,255, 10,201, 10,255, 12, +255, 12,255, 12,255, 12,255, 12,208, 12,255, 7,202, 7,255, 31,209, 31, +0}; /* terminator */ + + +unsigned char BATCH004[]={ +193,201,255,205,207,205,187,186,211, 32,193,201,234,205,187,207, 32, +194,186,211, 32,186,234, 32,186,207, 32,194,186,211, 32,186,194, 32, + 66, 97,116, 99,104,101,115, 32, 97,114,101, 32,110,111,116, 32,116, +104,101, 32, 85,110,105,118,101,114,115, 97,108, 32, 80, 97,110, 97, + 99,101, 97,195, 32,186,207, 32,194,186,211, 32,186,194, 32, 98,117, +116, 32, 97,114,101, 32, 97, 32,109,111,115,116, 32,101,194,102,105, + 99,105,101,110,116, 32,119, 97,121, 32,116,111, 32, 98,101,103,105, +110,195, 32,186,207, 32,194,186,211, 32,186,194, 32,109, 97,107,105, +110,103, 32, 98,101,115,116, 32,117,115,101, 32,111,102, 32,116,104, +101, 32,101,110,118,105,114,111,110,109,101,110,116, 46,197, 32,186, +207, 32,194,186,211, 32,186,234, 32,186,207, 32,194,186,211, 32,186, +194, 32, 87,105,116,104, 32,116,104,101, 32, 80, 67, 32, 99, 97,109, +101, 32,116,104,101, 32, 97, 98,105,108,105,116,121, 32,111,102, 32, +116,104,101,197, 32,186,207, 32,194,186,211, 32,186,194, 32, 97,194,112, +108,105, 99, 97,116,105,111,110,115, 32,111,112,101,114, 97,116,111, +114, 32,116,111, 32,109, 97,110, 97,103,101, 32,116,104,101,197, 32, +186,207, 32,194,186,211, 32,186,194, 32,101,110,118,105,114,111,110, +109,101,110,116, 32, 97,115, 32,119,101,194,108, 32, 97,115, 32,116, +104,101, 32, 68, 97,116, 97, 46,200, 32,186,207, 32,194,186,211, 32, +186,234, 32,186,207, 32,194,186,211, 32,186,194, 32, 87,105,116,104, + 32,116,104, 97,116, 32, 97, 98,105,108,105,116,121, 32, 99,111,109, +101,115, 32,116,104,101, 32,111, 98,108,105,103, 97,116,105,111,110, +194, 32,186,207, 32,194,186,211, 32,186,194, 32,116,111, 32,117,115, +101, 32,116,104, 97,116, 32,112,111,119,101,114, 32,119,105,115,101, +108,121, 46,207, 32,186,207, 32,194,186,211, 32,186,234, 32,186,207, 32, +194,186,211, 32,186,194, 32, 77, 97,121, 32, 84,104,101, 32, 70,111, +114, 99,101, 32, 66,101, 32, 87,105,116,104, 32, 89,111,117, 46,206, 32, +186,207, 32,194,186,211, 32,186,234, 32,186,207, 32,194,186,211, 32, +186,212, 32, 45, 66,105,194,108, 32, 66,117, 99,107,101,108,115,194, 32, + 49, 57,194, 56,195, 32,186,207, 32,194,186,211, 32,193,200,234,205, +188,207, 32,194,186,210, 32,238,220,206, 32,194,186,227, 32,193,218, +205,196,191,193,218,205,196,191,205, 32,194,186,210, 32,198,221,203, 32, +179,196,205,193,192,195,196,193,217,196,205,194,179,196,205,193,192, +195,196,193,217,196,205,179,205, 32,194,186,227, 32,193,192,205,196, +193,217,193,192,205,196,193,217,205, 32,186,193,200,255,205,207,205, +188,255, 32,209, 32,193,255, 48, 45, 50,193,255,112, 97,103,101,193,255, +100,105,114,101, 99,116,209,255, 83,112, 97, 99,101, 98, 97,114, 47, + 69,110,116,101,114, 32,110,101,120,116,207, 32,194,255, 69,115, 99, + 32,112, 97,103,101, 32, 48,193,255,255, 12,221, 12, 11,197, 12,194, 7, +236, 31, 9,204, 7,207, 12, 11,197, 12,194, 7, 31,234, 7, 31,205, 7, +207, 12, 11,197, 12,194, 7, 31,194, 7,230, 12,194, 7, 31,205, 7, +207, 12, 11,197, 12,194, 7, 31,194, 7,230, 12,194, 7, 31,205, 7, +207, 12, 11,197, 12,194, 7, 31,194, 7,230, 12,194, 7, 31,205, 7, +207, 12, 11,197, 12,194, 7, 31,234, 7, 31,205, 7,207, 12, 11,197, 12, +194, 7, 31, 7,233, 10, 31,205, 7,207, 12, 11,197, 12,194, 7, 31, + 7,233, 10, 31,205, 7,207, 12, 11,197, 12,194, 7, 31, 7,233, 10, + 31,205, 7,207, 12, 11,197, 12,194, 7, 31,234, 7, 31,205, 7,207, 12, + 11,197, 12,194, 7, 31,194, 7,230, 11,194, 7, 31,205, 7,207, 12, + 11,197, 12,194, 7, 31,194, 7,230, 11,194, 7, 31,205, 7,207, 12, + 11,197, 12,194, 7, 31,194, 7,219, 12,205, 7, 31,205, 7,207, 12, + 11,197, 12,194, 7, 31,194, 7,219, 12,205, 7, 31,205, 7,207, 12, + 11,197, 12,194, 7, 31,194, 7,232, 10, 31,205, 7,207, 12, 11,197, 12, +194, 7, 31,194, 7,232, 10, 31,205, 7,207, 12, 11,197, 12,194, 7, +236, 31,205, 7,207, 12, 11,197, 12,240, 31,203, 7,207, 12, 11,197, 12, +240, 31,203, 7,207, 12, 11,197, 12,240, 31,203, 7,207, 12, 11,197, 12, +240, 31,203, 7,255, 12,212, 12,255, 7,209, 7,255, 31,209, 31, +0}; /* terminator */ + + + +struct regs{ + int AX; + int BX; + int CX; + int DX; + int SI; + int DI; + int DS; + int ES; +}inregs,outregs; + +#define SCREENSIZE 4000 +unsigned int SCREENSEG= 0xb000; + +#define TERMINATOR 1 + +showpic(argc, argv) +int argc; +unsigned char *argv; +{ + + unsigned int byteoff=0,secondoff=1,packet; + unsigned char byte,bytecount; + int wordcount,target; + unsigned char *databuf; + unsigned int segregs[4]; + char *malloc(); + + target = argc-TERMINATOR; + databuf = (unsigned char *)malloc(SCREENSIZE); + + wordcount=0; + do{ bytecount=1; /* start with a seed count */ + byte=argv[wordcount]; + wordcount++; + /* check to see if its raw */ + if(0xC0 == (0xC0 &byte)){ /* if its not, run encoded */ + bytecount= 0x3f &byte; + byte=argv[wordcount]; + wordcount++; + } + for(packet=0;packet4)i=1;break; + } + } + + } + + /* clear screen and turn cursor on */ + #asm + mov ah,6 + mov al,0 + mov cx,0 + mov dh,24 + mov dl,79 + mov bh,0eh + int 10h + xor ax,ax + mov ah,1 + mov cx,0607h + int 10h + #endasm + exit(0); +} + diff --git a/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.CMD b/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.CMD new file mode 100644 index 0000000..428a9aa Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.CMD differ diff --git a/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.COM b/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.COM new file mode 100644 index 0000000..f2f2ab4 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/BATCH/BATCH.COM differ diff --git a/Manx Aztec C86 v340a/SAMPLES/BATCH/MAKEFILE b/Manx Aztec C86 v340a/SAMPLES/BATCH/MAKEFILE new file mode 100644 index 0000000..c3ec778 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/BATCH/MAKEFILE @@ -0,0 +1,13 @@ +# ----------------------------------- +# makefile by bill buckels 2008 +# ----------------------------------- +PRG=batch +$(PRG).com: $(PRG).o + ln -o $(PRG).com $(PRG).o c.lib + ln -o $(PRG).cmd $(PRG).o c86.lib + del $(PRG).o + @echo All Done! + +$(PRG).o: $(PRG).c + cc $(PRG).c + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SAMPLES/BATCH/demo.bat b/Manx Aztec C86 v340a/SAMPLES/BATCH/demo.bat new file mode 100644 index 0000000..6a1426f --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/BATCH/demo.bat @@ -0,0 +1,3 @@ +@echo off +mode CON COLS=80 LINES=25 +batch \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SAMPLES/BSAVEINC/BSAVEINC.C b/Manx Aztec C86 v340a/SAMPLES/BSAVEINC/BSAVEINC.C new file mode 100644 index 0000000..3ad9af4 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/BSAVEINC/BSAVEINC.C @@ -0,0 +1,253 @@ +/* + BSAVEINC.c (C) Copyright Bill Buckels 1990-2008. All rights reserved. + written in AZTEC C small model + + Supported Screen Mode is CGA COLOR TEXT Mode 4. + + This is a companion utility to be used with BSAVED text images + I hope this code proves informative to those of you interested in + computer graphics. + + This is also a limited example of applied "Run Length Encoding." + + The IBM-PC 80- column text screen buffer-attribute pair arrangement + is suited to a 2-pass crunching algorithm. + + In purely poetic terms.... + + Blocks of repeats occur on increments of every second byte so + I leapfrog through the file using the .PCX encoding technique + but I skip every second byte, and encode the ascuii value of + the text character only, then when I am done I make a second + pass to encode the bytes that have been skipped on first pass, + encoding the screen attributes. + + Function: + + converts a BASIC BSAVED .BSV IMAGE FILE (full screen CGA text) + to a .inc inlude file for a C program in the form of character array. + ( similar to the ZSOFT .PCX format image file per the + VERSION 2.8 STANDARD without Color Map.) + + +*/ + +#include +#include +#include + +#define SCREENSIZE 4000 + +FILE *incfile; + +/* a microsoft compatible bsaved memory image format descriptor */ +unsigned char BSV_header[7]={ + + '\xfd', /* ID Flag = file descriptor identifier bsaved file */ + + /* afew words about what BASIC does with this header */ + /* and afew words about extending BASIC's ability to */ + /* read and use BINARY files created in this manner. */ + + /* BASIC will use original segment and offset information */ + /* to reload a memory image unless "DEF SEG" has been used */ + /* and then an explicit offset is used as the second arg */ + /* of the bload command. */ + + /* subsequently, once DEF SEG is invoked */ + /* If an offset is specified without then */ + /* first calling DEF SEG, The image will then be loaded to */ + /* the segment specified in the last segment pointed to */ + /* by the last call to DEF SEG. DEF SEG without args returns */ + /* to DGROUP (the default data segment) and resets the thing.*/ + + /* we can also implement and store an array in memory by use of */ + /* VARSEG and VARPTR to obtain the window for the array's */ + /* memory location, i.e. override the defaults by windowing */ + /* to the array base using DEF SEG = VARSEG(arrayname) then to */ + /* fill the array we would use BLOAD bsaved.bsv, VARPTR(arrayname) */ + /* using VARPTR to point to the offset from the memory base segment*/ + + '\x00', '\xb8', /* base address = MSB | LSB original segment */ + '\x00', '\x00', /* offset from base = MSB | LSB original offset */ + + '\xA0', '\x0F' /* file size = MSB | LSB of bytes to be loaded + */ + /* size of descriptors in bytes (8) */ + }; + +unsigned char BSAVED_tailer[1]={ /* for reference only */ + '\x1A' + }; + + +int encline(inbuff,inlen)/* encodes a raw line and writes it out */ +unsigned char *inbuff; +int inlen; +{ + unsigned char this,last; + int srcindex,i; + register int total; + register unsigned char runcount; + total=0; + last = *(inbuff); runcount=1; + +for(srcindex=1;srcindex!=inlen;srcindex++){ + this= *(++inbuff); + if(this==last){ + runcount++; + if(runcount==63){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + runcount=0; + } + } + else{ + if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + } + last=this; + runcount=1; + } + } + +if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + return(total+i); + } + return (total); + +} + + +int linelen=0; +int encput(byt,cnt) /* the writer for the encline function */ +unsigned char byt,cnt; +{ + if(linelen>16){ + fprintf(incfile,"\n"); + linelen=0; + } + + if(cnt){ + if((cnt==1)&& (0xc0 != (0xc0 &byt))){ + fprintf(incfile,"%3d,",(int)byt); + linelen++; + return(1); + } + else{ + fprintf(incfile,"%3d,",(int)(0xc0|cnt)); + fprintf(incfile,"%3d,",(int)byt); + linelen+=2; + return(2); + } + } + return(0); +} + + + + +int BSV2INC(name1, name2, name3) +char *name1, *name2, *name3; +{ + unsigned char *scratchbuffer; + unsigned char *buf; + char *malloc(); + + unsigned char header[7]; + int i,j,k; + + int fh; + + if((fh = open(name1,O_RDONLY)) == -1)return -1; + read(fh,header,7); + + /* make sure that we have a valid BSAVED file format */ + /* we can only check the first 2-bytes since it may */ + /* have been made on the HERCULES */ + + if(header[0]!=BSV_header[0] || header[1]!=BSV_header[1]) + { + close(fh); + return -2; + } + + printf("BSAVEINC(C) Copyright by Bill Buckels\n\n"); + printf("Input File: %s\n",name1); + printf("Output File: %s\n",name2); + + scratchbuffer=(unsigned char *)malloc(SCREENSIZE); + buf=(unsigned char *)malloc(SCREENSIZE/2); + + read(fh,scratchbuffer,SCREENSIZE); + close(fh); + + /* seperate the attribute bytes */ + /* use the two-tank system. */ + + incfile=fopen(name2,"w"); + fprintf(incfile,"unsigned char %s[]={\n",name3); + + for(k=0;k!=2;k++) + { + j=0; + for(i=k;i +#include +#include + + +main(argc, argv) +int argc; +char **argv; +{ + FILE *fp; + int fh; + unsigned char *bigbuffer; + char buffer[128]; + char header[7]; + int limit = 24, col=79; + int ctr=0,rows,columns; + + char *malloc(); + + + switch(argc){ + case 5: col=atoi(argv[4]); + if (col<1||col>80)col = 79; + + case 4: limit=atoi(argv[3]); + if(limit<1||limit>25)limit==24; + case 3: + + if((fh = open(argv[1],O_RDONLY)) == -1)break; + read(fh,header,7); + bigbuffer=(unsigned char *)malloc(4000); + read(fh,bigbuffer,4000) ; + close(fh); + + if((fp=fopen(argv[2],"w"))!=NULL){ + for(rows=0;rows!=limit;rows++){ + for(columns=0;columns<80;columns++){ + buffer[columns]=bigbuffer[ctr]; + ctr+=2; + } + + buffer[col]=0x00; + if (col != 80) { + columns=col; + while(columns!=0){ + if(buffer[columns]==' '){ + buffer[columns]=0x00; + columns--; + } + else columns=0; + } + fprintf(fp,"%s\n",buffer); + } + else + fprintf(fp,"%s",buffer); + } + fclose(fp); + } + free(bigbuffer); + break; + + default:printf("USAGE is \"BSV2TXT [infile] [outfile] [lines-optional] [cols-optional]\"\n"); + } + exit(0); +} diff --git a/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/BSV2TXT.COM b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/BSV2TXT.COM new file mode 100644 index 0000000..a664d95 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/BSV2TXT.COM differ diff --git a/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/DOZY.BSV b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/DOZY.BSV new file mode 100644 index 0000000..adfd869 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/DOZY.BSV differ diff --git a/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/DOZY.TXT b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/DOZY.TXT new file mode 100644 index 0000000..b34d7c6 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/DOZY.TXT @@ -0,0 +1,24 @@ + ÜßßÜ °° + Üß ßÜ °° + Üß ßÜ °° + Üß ÕѸ ßÜ °° + Üß Æص ßÜ Ú¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + Üß ÔϾ ß³ ³ ³I'll Be Up To See You Shortly Dear + Üß ßܳ ³....... I'm Right In The Middle of + ÜßÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ßÜ ³a Download from Dozy's Den....!!!! + Üß ³Harold what are you doing?³ ßÜ ÀÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ + Üß ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÙ ßÜ ÀÄ¿ + ÿÜß ÀÄ¿ ßÜ À¿ + Üß³ ÕÑѸ ÕÑѸ ÀÕÑѸ ³ßÜ À¿ + ³ ÆØص ÆØص ÆØص ³ ³ + ³ ÔÏϾ ÔÏϾ ÔÏϾ ³ ÀÄ¿ ÜþÜ + ³ ³ ³Üß ßÜ + ³ ³ Üß ( ßÜ + ³ HERS ³ Üß ßÜ + ³ ÚÄÄÄÄÄÄÄ¿ ³ Üß³ HIS ³ßÜ + ³ ÕÑѸ ³ÖÒ· ÖÒ·³ ÕÑѸ ³ ³ ÚÄÄÄÄÄÄÄ¿ ³ + ³ ÆØص ³Ç׶ Ç׶³ ÆØص ³ ³ ³ ³ ³ + ³ ÔÏϾ ³Ç׶ Ç׶³ ÔÏϾ ³ ³ ³ ³ ³ + ³ ³Ç׶ Ç׶³ ³ ³ ³ ³ ³ + ³ ³Ç׶ Ç׶³ ³ ³ ³ ³ ³ + diff --git a/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/MAKEFILE b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/MAKEFILE new file mode 100644 index 0000000..778c2fb --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/BSV2TXT/MAKEFILE @@ -0,0 +1,12 @@ +# ----------------------------------- +# makefile by bill buckels 2008 +# ----------------------------------- +PRG=bsv2txt +$(PRG).exe: $(PRG).o + ln -o $(PRG).com $(PRG).o c.lib + del $(PRG).o + @echo All Done! + +$(PRG).o: $(PRG).c + cc $(PRG).c + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SAMPLES/EXMPL/EXMPL.C b/Manx Aztec C86 v340a/SAMPLES/EXMPL/EXMPL.C new file mode 100644 index 0000000..84ac78e --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/EXMPL/EXMPL.C @@ -0,0 +1,9 @@ +main() +{ + char buffer[100]; + + printf("Please enter your name: "); + gets(buffer); + printf("Hello %s, welcome to the growing family of AZTEC C users.\n", + buffer); +} diff --git a/Manx Aztec C86 v340a/SAMPLES/EXMPL/EXMPL.COM b/Manx Aztec C86 v340a/SAMPLES/EXMPL/EXMPL.COM new file mode 100644 index 0000000..88025e3 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/EXMPL/EXMPL.COM differ diff --git a/Manx Aztec C86 v340a/SAMPLES/EXMPL/MAKEFILE b/Manx Aztec C86 v340a/SAMPLES/EXMPL/MAKEFILE new file mode 100644 index 0000000..b4aa260 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/EXMPL/MAKEFILE @@ -0,0 +1,12 @@ +# ----------------------------------- +# makefile by bill buckels 2008 +# ----------------------------------- +PRG=exmpl +$(PRG).com: $(PRG).o + ln -o $(PRG).com $(PRG).o c.lib + del $(PRG).o + @echo All Done! + +$(PRG).o: $(PRG).c + cc $(PRG).c + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/MAKEFILE b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/MAKEFILE new file mode 100644 index 0000000..f19aa8a --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/MAKEFILE @@ -0,0 +1,29 @@ +# ------------------------------------------------------------ +# makefile(C) Copyright Bill Buckels 2008. All rights reserved. +# ------------------------------------------------------------ + +PRG=ov +OV1=ov1 +OV2=ov2 + +# The command to link the root reserves 0x4000 bytes for the overlay’s code +# and 0x1000 bytes for its data. +$(PRG).EXE: $(PRG).o $(OV1).o $(OV2).o + ln -o $(PRG).EXE -R +C 4000 +D 1000 $(PRG).o ovld.o -lc + ln $(OV1).o ovbgn.o $(PRG).rsm -lc + ln $(OV2).o ovbgn.o $(PRG).rsm -lc + del $(PRG).o + del $(OV1).o + del $(OV2).o + del $(PRG).rsm + + +$(PRG).o: $(PRG).c + cc $(PRG).c + +$(OV1).o: $(OV1).c + cc $(OV1).c + +$(OV2).o: $(OV2).c + cc $(OV2).c + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV.C b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV.C new file mode 100644 index 0000000..19795a4 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV.C @@ -0,0 +1,16 @@ + +main() +{ + int a; + + printf("overlay tester\n"); + a = ovloader("ov1", "first message"); + printf("in main. ov1 returned %d\n", a); + a = ovloader("ov2", "second message"); + printf("in main. ov2 returned %d\n", a); + printf("Press a key..."); + + a = getchar(); + exit(0); +} + diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV.EXE b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV.EXE new file mode 100644 index 0000000..f4c51dd Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV.EXE differ diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV1.C b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV1.C new file mode 100644 index 0000000..940adb3 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV1.C @@ -0,0 +1,7 @@ +ovmain(a) +char *a; +{ + printf("in ov1. %s\n", a); + return(1); +} + diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV1.OVR b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV1.OVR new file mode 100644 index 0000000..72d353f Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV1.OVR differ diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV2.C b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV2.C new file mode 100644 index 0000000..0b5bfc0 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV2.C @@ -0,0 +1,7 @@ +ovmain(a) +char *a; +{ + printf("in ov2. %s\n", a); + return(2); +} + diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV2.OVR b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV2.OVR new file mode 100644 index 0000000..f44fc3c Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OV2.OVR differ diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OVBGN.O b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OVBGN.O new file mode 100644 index 0000000..3b7a208 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OVBGN.O differ diff --git a/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OVLD.O b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OVLD.O new file mode 100644 index 0000000..6d19fcd Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/OVERLAY/OVLD.O differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/BPIC.CMD b/Manx Aztec C86 v340a/SAMPLES/PIC/BPIC.CMD new file mode 100644 index 0000000..b11fe97 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/BPIC.CMD differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/BPIC.COM b/Manx Aztec C86 v340a/SAMPLES/PIC/BPIC.COM new file mode 100644 index 0000000..c34e85b Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/BPIC.COM differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/Change.BAS b/Manx Aztec C86 v340a/SAMPLES/PIC/Change.BAS new file mode 100644 index 0000000..a05fa27 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/Change.BAS differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/MAKEFILE b/Manx Aztec C86 v340a/SAMPLES/PIC/MAKEFILE new file mode 100644 index 0000000..5da0bcb --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/PIC/MAKEFILE @@ -0,0 +1,22 @@ +# ------------------------------------------------------------- +# makefile(C) Copyright Bill Buckels 2008. All rights reserved. +# +# This makefile uses a separate compiler and assembler pass +# to generate an object (.o) file. +# It then links to the CP/M-86 library to produce a CPM .CMD +# and also links to the DOS library to produce a .COM +# By creating a DOS 2.0 .COM as well as a CPM .CMD I wanted +# to provide the option of testing the program under the +# XP cmd window with and without the CPM86.EXE emulator. +# ------------------------------------------------------------- +PRG=bpic +$(PRG).com: $(PRG).o + ln -o $(PRG).cmd $(PRG).o g.lib c86.lib + ln -o $(PRG).com $(PRG).o g.lib c.lib + del $(PRG).o + @echo All Done! + +$(PRG).o: $(PRG).c + cc -A $(PRG).c + as $(PRG).asm + del $(PRG).asm diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/NO1.BAS b/Manx Aztec C86 v340a/SAMPLES/PIC/NO1.BAS new file mode 100644 index 0000000..6823de6 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/NO1.BAS differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT1.BAS b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT1.BAS new file mode 100644 index 0000000..460d3b3 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT1.BAS differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT2.BAS b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT2.BAS new file mode 100644 index 0000000..43162e2 Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT2.BAS differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT3.BAS b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT3.BAS new file mode 100644 index 0000000..b168c0c Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT3.BAS differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT4.BAS b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT4.BAS new file mode 100644 index 0000000..bd5a10d Binary files /dev/null and b/Manx Aztec C86 v340a/SAMPLES/PIC/PEANUT4.BAS differ diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/bpic.c b/Manx Aztec C86 v340a/SAMPLES/PIC/bpic.c new file mode 100644 index 0000000..1560eab --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/PIC/bpic.c @@ -0,0 +1,148 @@ + +/* bpic.c (C) Copyright 2008 Bill Buckels. All rights reserved. */ + +/* A BASIC BSaved graphics image loader for + DOS 2.0 or CP/M-86 + + Written in Aztec C86 v3X + + Handles CGA 320 x 200 x 4-Color or 640 x 200 x 2 Color screens. + + For more info on these See my Wikipedia Article at: + + http://en.wikipedia.org/wiki/BSAVE_(graphics_image_format) + + For a program to create these in Windows XP from a variety of + sources download a copy of my ClipShop program at: + + www.clipshop.ca + + */ + +#include + +/* one of my headers */ +#include + +/* no need to load the entire image + just load the 192 bytes between the interleaves + to simplify for a contiguous load */ + +#define SCREENSIZE 16192 +#define SCREENSEG 0xb800 + +/* a read buffer */ +char databuf[SCREENSIZE]; + +/* a microsoft compatible bsaved image format descriptor */ +char bsave_header[7]={'\xfd','\x00','\xb8','\x00','\x00','\x00','\x40'}; + +/* for verification... check the first 5 bytes only! + + the marker byte 0xfd is followed by 3 intel 16 bit integers + giving originating segment, offset, and filelength of the image. + + The filelength can vary here but the first 5 bytes are + pretty mich invariant. As far as length most of these were 0x4000 + (16384) bytes not including the 7 byte header and BASIC's ubiquituous + [CTRL]-Z (0x1a) footer (which was reminiscent of the early x86 file systems + but wasn't always present at the end of these either depending on who and how). + + The reason that most of us saved them that way was probably because + of the example in the GWBASIC manual... and IBM PC StoryBoard's + PicturMaker (PM.EXE) v1 saved them that way as well... perhaps they read the + same manual. + + But John Bridges saved these in PicEM the same way I am loading + them here... without the padding on the end. (John didn't code in BASIC + even in those days), and Eugene Ying who did saved them as 16512 bytes + in PCPG which doesn't make much sense to me. + + That was a long time ago anyway. + + */ + +/* K & R style function body */ +main(argc, argv) +int argc; +char **argv; +{ + + int fh, idx, status, vmode = 'M'; + union REGS inregs, outregs; + struct SREGS sregs; + + if (argc < 2) { + printf("Usage: bpic [my.bas] [options 'H' for hires or 'M' for medres]\n"); + exit(1); + + } + + /* check for video mode */ + if (argc > 2) { + if (argv[2][0] == '-')idx =1; + else idx = 0; + if (argv[2][idx] == 'h' || argv[2][idx] == 'H')vmode = 'H'; + + } + + sysint(0x11,&inregs,&outregs); /* get equipment list from the bios */ + + /* get display type (bits 4 and 5 of ax) */ + if (!((outregs.x.ax & 0x30) < 0x30)) { + printf("CGA compatible displays only! Exiting.\n"); + exit(1); + } + + + fh = open(argv[1],O_RDONLY); + + + if (fh == -1) { + printf("Unable to open %s!\n",argv[1]); + exit(1); + } + + + + read(fh,databuf,7); + for (idx = 0; idx < 5; idx++) { + if(databuf[idx]!= bsave_header[idx]) { + close(fh); + printf("Unsupported Format!\n"); + exit(1); + } + + } + + /* we are in small memory model so need to get the segment + that we are running-in to move image data direct + to the CGA screen address... */ + segread(&sregs); + + read(fh,&databuf[0],SCREENSIZE); + close(fh); + + mode(vmode); + + /* note that I am using the ds register value with + the datasegment address of my near pointer + for my image data buffer as the base address for + the source of my memory block move... */ + movblock(&databuf[0],sregs.ds,0,SCREENSEG,SCREENSIZE); + + /* wait for a key press */ + /* use sysint to generate int 16h */ + + inregs.x.ax = 0x0000; + inregs.x.dx = 0x0000; + sysint(0x16,&inregs,&outregs); + /* return the low order char */ + status = outregs.x.ax&0x00ff; + + mode('L'); + + exit(status); + + + } diff --git a/Manx Aztec C86 v340a/SAMPLES/PIC/demo.bat b/Manx Aztec C86 v340a/SAMPLES/PIC/demo.bat new file mode 100644 index 0000000..327af59 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/PIC/demo.bat @@ -0,0 +1,23 @@ +@echo of +if "%CLIB%" == "" goto START +rem this demo uses the cpm emulator +cpm bpic.cmd NO1.BAS h +cpm bpic.cmd NO1.BAS m +cpm bpic.cmd PEANUT1.BAS +cpm bpic.cmd PEANUT2.BAS +cpm bpic.cmd PEANUT3.BAS +cpm bpic.cmd PEANUT4.BAS +cpm bpic.cmd Change.BAS h +cpm bpic.cmd Change.BAS m +goto END +:START +rem this demo uses the dos version +bpic.com NO1.BAS h +bpic.com NO1.BAS m +bpic.com PEANUT1.BAS +bpic.com PEANUT2.BAS +bpic.com PEANUT3.BAS +bpic.com PEANUT4.BAS +bpic.com Change.BAS h +bpic.com Change.BAS m +:END diff --git a/Manx Aztec C86 v340a/SAMPLES/PTXMAKE/MAKEFILE b/Manx Aztec C86 v340a/SAMPLES/PTXMAKE/MAKEFILE new file mode 100644 index 0000000..3e3188e --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/PTXMAKE/MAKEFILE @@ -0,0 +1,12 @@ +# ----------------------------------- +# makefile by bill buckels 2008 +# ----------------------------------- +PRG=ptxmake +$(PRG).exe: $(PRG).o + ln $(PRG).o c.lib + del $(PRG).o + @echo All Done! + +$(PRG).o: $(PRG).c + cc $(PRG).c + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SAMPLES/PTXMAKE/PTXMAKE.C b/Manx Aztec C86 v340a/SAMPLES/PTXMAKE/PTXMAKE.C new file mode 100644 index 0000000..ef71808 --- /dev/null +++ b/Manx Aztec C86 v340a/SAMPLES/PTXMAKE/PTXMAKE.C @@ -0,0 +1,298 @@ +/* + PTXMAKE.c by Bill Buckels 1990 + written in AZTEC C small model + + Supported Screen Mode is CGA COLOR TEXT Mode 4. + + This is a companion utility to be used with BSAVED text images + and with my .PTX fileviewer PTXVU.EXE which was also written for fun. + I hope this code proves informative to those of you interested in + computer graphics. + + This is also a limited example of applied "Run Length Encoding." + + The IBM-PC 80- column text screen buffer-attribute pair arrangement + is suited to a 2-pass crunching algorithm. + + In purely poetic terms.... + + Blocks of repeats occur on increments of every second byte so + I leapfrog through the file using the .PCX encoding technique + but I skip every second byte, and encode the ascuii value of + the text character only, then when I am done I make a second + pass to encode the bytes that have been skipped on first pass, + encoding the screen attributes. + + Function: + + converts a BASIC BSAVED .BSV IMAGE FILE (full screen CGA text) + to a .PTX ( similar to the ZSOFT .PCX format image file per the + VERSION 2.8 STANDARD without Color Map.) + + +*/ + +#include +#include +#include + +#define SCREENSIZE 4000 + +FILE *ptxfile; + + +/* type conversion functions */ +unsigned char lsb(word) +unsigned int word; +{ + return word &0xff; +} + +unsigned char msb(word) +unsigned int word; +{ + return word >>8; +} + +unsigned char ptxheader[128]; + +/* a microsoft compatible bsaved memory image format descriptor */ +unsigned char BSV_header[7]={ + + '\xfd', /* ID Flag = file descriptor identifier bsaved file */ + + /* afew words about what BASIC does with this header */ + /* and afew words about extending BASIC's ability to */ + /* read and use BINARY files created in this manner. */ + + /* BASIC will use original segment and offset information */ + /* to reload a memory image unless "DEF SEG" has been used */ + /* and then an explicit offset is used as the second arg */ + /* of the bload command. */ + + /* subsequently, once DEF SEG is invoked */ + /* If an offset is specified without then */ + /* first calling DEF SEG, The image will then be loaded to */ + /* the segment specified in the last segment pointed to */ + /* by the last call to DEF SEG. DEF SEG without args returns */ + /* to DGROUP (the default data segment) and resets the thing.*/ + + /* we can also implement and store an array in memory by use of */ + /* VARSEG and VARPTR to obtain the window for the array's */ + /* memory location, i.e. override the defaults by windowing */ + /* to the array base using DEF SEG = VARSEG(arrayname) then to */ + /* fill the array we would use BLOAD bsaved.bsv, VARPTR(arrayname) */ + /* using VARPTR to point to the offset from the memory base segment*/ + + '\x00', '\xb8', /* base address = MSB | LSB original segment */ + '\x00', '\x00', /* offset from base = MSB | LSB original offset */ + + '\xA0', '\x0F' /* file size = MSB | LSB of bytes to be loaded + */ + /* size of descriptors in bytes (8) */ + }; + +unsigned char BSAVED_tailer[1]={ /* for reference only */ + '\x1A' + }; + + +int encline(inbuff,inlen)/* encodes a raw line and writes it out */ +unsigned char *inbuff; +int inlen; +{ + unsigned char this,last; + int srcindex,i; + register int total; + register unsigned char runcount; + total=0; + last = *(inbuff); runcount=1; + +for(srcindex=1;srcindex!=inlen;srcindex++){ + this= *(++inbuff); + if(this==last){ + runcount++; + if(runcount==63){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + runcount=0; + } + } + else{ + if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + } + last=this; + runcount=1; + } + } + +if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + return(total+i); + } + return (total); + +} + +int encput(byt,cnt) /* the writer for the encline function */ +unsigned char byt,cnt; +{ + if(cnt){ + if((cnt==1)&& (0xc0 != (0xc0 &byt))){ + if(EOF == fputc((int)byt,ptxfile)) + return(0); + return(1); + } + else{ + if(EOF ==fputc((int)0xc0|cnt,ptxfile)) + return(0); + if(EOF ==fputc((int)byt,ptxfile)) + return(0); + return(2); + } + } + return(0); + +} + + +/* the zsoft technical reference manual details the */ +/* structure of the following header */ +int makeheader() +{ + /* makes a standard header for a .PTX CGA FULL-SCREEN TEXT FILE */ + /* since this info is not really intended for text mode, we fudge */ + /* some portions of the info, but we try to be faithful as possible*/ + + int i; + unsigned char notzsoft=0,version=3,codetype=1,pixbits=16; + unsigned int xmin=0, ymin=0, xmax=79, ymax=24; + unsigned int hres=80, vres=25; + unsigned char no_planes=1; + unsigned int bytesperline=160; + + for(i=0;i!=128;i++)ptxheader[i]=0;/* pad the header with nulls */ + + ptxheader[0]=notzsoft; + ptxheader[1]=version; + ptxheader[2]=codetype; + ptxheader[3]=pixbits; + ptxheader[4] =lsb(xmin); + ptxheader[5] =msb(xmin); + ptxheader[6] =lsb(ymin); + ptxheader[7] =msb(ymin); + ptxheader[8] =lsb(xmax); + ptxheader[9] =msb(xmax); + ptxheader[10]=lsb(ymax); + ptxheader[11]=msb(ymax); + ptxheader[12]=lsb(hres); + ptxheader[13]=msb(hres); + ptxheader[14]=lsb(vres); + ptxheader[15]=msb(vres); + ptxheader[65]=no_planes; + ptxheader[66]=lsb(bytesperline); + ptxheader[67]=msb(bytesperline); + return 0; + +} + +int BSV2PTX(name1, name2) +char *name1, *name2; +{ + unsigned char *scratchbuffer; + unsigned char *buf; + char *malloc(); + + unsigned char header[7]; + int i,j,k; + + int fh; + + if((fh = open(name1,O_RDONLY)) == -1)return -1; + read(fh,header,7); + + /* make sure that we have a valid BSAVED file format */ + /* we can only check the first 2-bytes since it may */ + /* have been made on the HERCULES */ + + if(header[0]!=BSV_header[0] || header[1]!=BSV_header[1]) + { + close(fh); + return -2; + } + + printf("BSV2PTX(C) Copyright Bill Buckels 1990-2008. All rights reserved.\n\n"); + printf("Input File: %s\n",name1); + printf("Output File: %s\n",name2); + + scratchbuffer= (unsigned char *)malloc(SCREENSIZE); + buf=(unsigned char *)malloc(SCREENSIZE/2); + + read(fh,scratchbuffer,SCREENSIZE); + close(fh); + + /* seperate the attribute bytes */ + /* use the two-tank system. */ + + makeheader(); + ptxfile=fopen(name2,"w"); + for(i=0;i!=128;i++)fputc(ptxheader[i],ptxfile);/* write the header */ + + for(k=0;k!=2;k++) + { + j=0; + for(i=k;i +/* one of my headers */ +#include + +#define SCREENSIZE 4000 +unsigned int SCREENSEG=0xb000; + +/* read buffers */ +char packbuf[SCREENSIZE]; +char databuf[SCREENSIZE]; + +/* a microsoft compatible bsaved image format descriptor */ +char bsave_header[7]={'\xfd','\x00','\xb8','\x00','\x00','\xA0','\x0F'}; + +/* for verification... check the first 2 bytes only! + + the marker byte 0xfd is followed by 3 intel 16 bit integers + giving originating segment, offset, and filelength of the image. + + the segment was not always b800 and on a monochrome display + including a hercules would be b000 but the offset was generally 0. + + The filelength can vary here but the first 5 bytes are + pretty much invariant. As far as length these were 4000 bytes + or up to 4096 bytes (with the last up to 96 bytes being unused) + not including the 7 byte header and BASIC's ubiquituous + [CTRL]-Z (0x1a) footer (which was reminiscent of the early x86 file systems + but wasn't always present at the end of these either depending on who and how). + + The header above is for a CGA mode text screen of 4000 bytes. + + */ + +/* the header fragment below is part of the header for + a run length encoded ptx text screen */ +char ptx_header[4]={'\x00','\x03','\x01','\x10'}; + +/* K & R style function body */ +main(argc, argv) +int argc; +char **argv; +{ + + union REGS inregs, outregs; + struct SREGS sregs; + + int fh,i; + + unsigned int byteoff=0,secondoff=1,packet; + unsigned char byte,bytecount; + int wordcount,target; + unsigned int status = 0; + + + if (argc < 2) { + printf("Usage: textvu [my.bsv]\n"); + exit(1); + } + + fh = open(argv[1],O_RDONLY); + + if (fh == -1) { + printf("Unable to open %s!\n",argv[1]); + exit(1); + } + + sysint(0x11,&inregs,&outregs); /* get equipment list from the bios */ + /* get display type (bits 4 and 5 of ax) */ + if ((outregs.x.ax & 0x30) < 0x30)SCREENSEG=0xb800; + + + /* clearscreen and turn cursor off */ + + /* + Function 06h: Scroll Text Lines Up Scrolls part or all of the + current display page up by one or more text lines. This + function can also be used to clear part or all of the screen. + + Inputs + + AH = 06h + + AL = Number of lines to be scrolled up (AL = 00h will clear + the window). + + BH = Color attribute for blank lines. In text mode, this + corresponds to the attribute byte. In VGA graphics modes, this + is the color number to which all the pixels in the blank lines + will be set. In text mode the high nibble contains the text + background and the low nibble the text color (bg << 4 | color). + Background is in the range of 0-7 and color 0-15. Background + of over 8-15 sets the blink attribute on the color display. + Colors of 7-15 is the equivalent of adding high intensity + to colors 0-7. The same holds true for determining what + background the blink will be set to. Monochrome screens behave + somewhat differently and generally the colors will be messed-up + if a monochrome text color scheme is displayed on a color display + or vice-versa, so these values were historically assigned independently + or a simple text color scheme was used which suited both. + + CH = Top row of window to be scrolled up. + CL = Leftmost column of window. + + DH = Bottom row of window. + DL = Rightmost column of window. + + */ + inregs.x.ax = 0x0600; + inregs.x.bx = 0x0f00; /* black background, bwhite text */ + inregs.x.cx = 0; + inregs.h.dh = 24; + inregs.h.dl = 79; + sysint(0x10,&inregs,&outregs); + + /* + Function 02h: Set Cursor Position Moves the cursor to the specified + position on the screen. The video hardware maintains a separate cursor for + each display page, and the cursor will move only if the page number given + in BH is the current display page. Giving a position that is off the + screen will cause the cursor to disappear from the screen. + + Inputs + + AH = 02h + + BH = Display page (valid only in text modes--use 00h for graphics modes). + + DH = Row (00h is top row). + + DL = Column (00h is leftmost column). + + */ + inregs.x.ax = 0x0200; + inregs.x.bx = 0; + inregs.x.dx = 0; + sysint(0x10,&inregs,&outregs); + + /* + Function 01h: Define Cursor Appearance Sets the starting and ending lines + of the screen cursor, and can also be used to make the cursor invisible. + In some modes, the characters are not exactly 8 lines high in these cases + the graphics hardware will adapt the input values to the current character + size. + + Inputs + + AH = 01h + + CH = Starting line of cursor (0-7). Add 20h to make the cursor invisible. + + CL = Ending line of cursor (0-7). + */ + + inregs.x.ax = 0x0100; + inregs.x.cx = 0x2000; + sysint(0x10,&inregs,&outregs); + + read(fh,databuf,7); + + /* beginning of run raw */ + if(databuf[0]== bsave_header[0] && databuf[1]== bsave_header[1]) + { + read(fh,databuf,SCREENSIZE); + close(fh); + status = 1; + } + else if(databuf[0]==ptx_header[0] && databuf[1]==ptx_header[1] && + databuf[2]==ptx_header[2] && databuf[3]==ptx_header[3]) + { + /* beginning of run length encoded */ + status = 1; + read(fh,databuf,121);/* blow the rest of the header */ + target = read(fh,packbuf,SCREENSIZE); + close(fh); + + wordcount=0; + do{ bytecount=1; /* start with a seed count */ + byte=packbuf[wordcount]; + wordcount++; + /* check to see if its raw */ + if(0xC0 == (0xC0 &byte)){ /* if its not, run encoded */ + bytecount= 0x3f &byte; + byte=packbuf[wordcount]; + wordcount++; + } + for(packet=0;packetfcb); + if (fp->fcb.f_record == 0) { + fp->offset = 0; + return 0; + } + --fp->fcb.f_record; /* backup to last record */ + if (_find(fp)) + return -1; + + for (cp = Wrkbuf+128 ; cp > Wrkbuf ; ) + if (*--cp != 0x1a) { + ++cp; + break; + } + if ((fp->offset = (char)((int)(cp-Wrkbuf))) == 128) { + ++fp->fcb.f_record; + fp->offset = 0; + } + return 0; +} + close.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "errno.h" +#include "io.h" + +close(fd) +{ + register struct channel *chp; + extern int bdf_(); + + if (fd < 0 || fd > MAXCHAN) { + errno = EBADF; + return -1; + } + chp = &chantab[fd]; + fd = (*chp->c_close)(chp->c_arg); + chp->c_read = chp->c_write = chp->c_ioctl = chp->c_seek = 0; + chp->c_close = bdf_; + return fd; +} + croot.c +/* Copyright (C) 1981,1982,1984 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" +#include "io.h" + +int bdf_(), ret_(); + +/* + * channel table: relates fd's to devices + */ +struct channel chantab[] = { + { 2, 0, 1, 0, ret_, 2 }, + { 0, 2, 1, 0, ret_, 2 }, + { 0, 2, 1, 0, ret_, 2 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, + { 0, 0, 0, 0, bdf_, 0 }, +}; + +#define MAXARGS 30 +static char *Argv[MAXARGS]; +static char Argbuf[128]; +static int Argc; +int (*cls_)() = ret_; + +Croot() +{ + register char *cp, *fname; + register int k; + + movmem((char *)0x81, Argbuf, 127); + Argbuf[*(char *)0x80 & 0x7f] = 0; + Argv[0] = ""; + cp = Argbuf; + Argc = 1; + while (Argc < MAXARGS) { + while (*cp == ' ' || *cp == '\t') + ++cp; + if (*cp == 0) + break; +#ifndef NOREDIR + if (*cp == '>') { /* redirect output */ + k = 1; + goto redirect; + } else if (*cp == '<') { /* redirect input */ + k = 0; +redirect: + while (*++cp == ' ' || *cp == '\t') + ; + fname = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + close(k); + if (k) + k = creat(fname, 0666); + else + k = open(fname, O_RDONLY); + if (k == -1) { + strcpy(0x80, "Can't open file for redirection: "); + strcat(0x80, fname); + strcat(0x80, "$"); + bdos(9,0x80); + exit(10); + } + } else +#endif + { + Argv[Argc++] = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + } + } + main(Argc,Argv); + exit(0); +} + +exit(code) +{ + register int fd; + + (*cls_)(); + for (fd = 0 ; fd < MAXCHAN ; ) + close(fd++); + if (code && (bdos(24)&1) != 0) + unlink("A:$$$.SUB"); + _exit(); +} + +bdf_() +{ + errno = EBADF; + return -1; +} + +ret_() +{ + return 0; +} + + csread.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +extern int errno; +extern unsigned _dsval, _csval; + +_csread(fd, buffer, len) +char *buffer; +{ + register unsigned l = 0; + register struct fcbtab *fp; + register struct channel *chp; + unsigned k,j; + + chp = &chantab[fd]; + if (chp->c_read != 1) { /* only valid for disk files */ + errno = EINVAL; + return -1; + } + + fp = chp->c_arg; + setusr(fp->user); + + if (fp->offset) { + if ((l = 128 - fp->offset) > len) + l = len; + if (getsect(fp, buffer, l)) { + l = 0; + goto done; + } + } + if (k = (len-l)/128) { + bdos(51, _csval); /* set dma segment to CS */ + j = blkrd(&fp->fcb, buffer+l, k); + bdos(51, _dsval); /* set dma segment back to DS */ + if (j != 0) { + l += (k-j)*128; + goto done; + } + } + l += k*128; + if (l < len) + if (getsect(fp, buffer+l, len-l)) + goto done; + l = len; + +done: + rstusr(); + return l; +} + +static +getsect(fp, buf, len) +register struct fcbtab *fp; char *buf; unsigned len; +{ + if (_find(fp)) + return -1; + movblock(Wrkbuf+fp->offset,_dsval, buf,_csval, len); + if ((fp->offset = (fp->offset + len) & 127) == 0) + ++fp->fcb.f_record; + return 0; +} + + exec.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execlp(path, args) +char *path, *args; +{ + return execvp(path, &args); +} + +execvp(path, argv) +char *path, **argv; +{ + char buffer[130]; + register char *cp, *xp; + + cp = buffer; + for (xp = path ; *xp && cp < buffer+128 ; ) + *cp++ = *xp++; + if (*argv) { + ++argv; /* skip arg0, used for unix (tm) compatibility */ + while (*argv) { + *cp++ = ' '; + for (xp = *argv++ ; *xp && cp < buffer+128 ; ) + *cp++ = *xp++; + } + } + *cp = 0; + bdos(26, buffer); + bdos(47, 0); +} + + execl.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execl(path, args) +char *path, *args; +{ + return execvp(path, &args); +} + +execv(path, argv) +char *path, **argv; +{ + return execvp(path, argv); +} + fcbinit.asm +; :ts=8 +; Copyright (C) 1983, 1984 by Manx Software Systems +codeseg segment para public 'code' +; + include lmacros.h + public fcbinit_ +fcbinit_ proc near + mov bx,sp + push di + push si + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + mov si,word ptr 2[bx] ;si contains name + mov di,word ptr 4[bx] ;di contains fcb address +; clear name to blanks + mov dx,di ;save fcb address in dx + inc di + mov cx,11 ;clear name and ext to blanks + mov al,' ' +rep stosb + mov cx,4 + sub al,al +rep stosb + mov di,dx ;restore fcb address +; + sub dx,dx ;init user # + mov cl,10 ;multiplier inside loop +userloop: ;loop packing leading digits into DL + lodsb + cmp al,'0' + jb userdone + cmp al,'9' + ja userdone + sub al,'0' + xchg ax,dx ;get accumlated value into AL for multiply + mul cl ;value *= 10 + add al,dl ;add in new digit + xchg ax,dx ;put result back into DL + jmp userloop +; +userdone: + cmp al,'/' ;check if user # prefix + je haveuser + mov dl,255 ;set user # to default indicator + mov si,word ptr 2[bx] ;reset filename pointer +haveuser: +; + sub al,al ;default drive # + cmp byte ptr 1[si],':' + jnz setdrive +; + lodsb + inc si ;skip over colon + and al,127 + cmp al,'A' + jl badname + cmp al,'Z' + jg lowerc + sub al,'A'-1 + jmp short setdrive +; +lowerc: + cmp al,'a' + jl badname + cmp al,'z' + jg badname + sub al,'a'-1 +setdrive: + stosb +; move name in mapping to upper case + mov cx,8 +nameskp: + inc cx +namelp: + lodsb + cmp al,'.' + jz namedn + test al,al + jz alldone + loop store + jmp short nameskp +store: + call toupper + stosb + jmp short namelp +; +namedn: + dec cx + add di,cx +; move extension mapping to upper case + mov cx,3 +extlp: + lodsb + test al,al + jz alldone + call toupper + stosb + loop extlp +; +alldone: + xchg ax,dx + and ax,255 +retn: + pop si + pop di + ret +; +badname: + sub ax,ax + dec ax + jmp short retn +; +toupper: + cmp al,'*' + jne nostar + dec si ;backup so we see star again + mov al,'?' ;and map into question mark + ret +nostar: + cmp al,'a' + jl notrans + cmp al,'z' + jg notrans + sub al,'a'-'A' +notrans: + ret +fcbinit_ endp +codeseg ends + end + find.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "io.h" + +static struct fcbtab *Wfp; +static unsigned Wsct; + +_zap() /* invalidate work buffer */ +{ + Wfp = 0; +} + +_find(fp) +register struct fcbtab *fp; +{ + extern int errno; + + bdos(SETDMA, Wrkbuf); + if (Wfp != fp || fp->fcb.f_record != Wsct) { + if ((errno = bdos(READRN, &fp->fcb)) == 1 || errno == 4) { + errno = 0; + setmem(Wrkbuf, 128, 0x1a); + Wfp = 0; + return 1; + } else if (errno) + return -1; + Wfp = fp; + Wsct = fp->fcb.f_record; + } + return 0; +} + + ioctl.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" +#include "sgtty.h" + +#define TIME 10 /* number of iterations of raw_rd loop */ +#define MIN 1 /* minimum number of chars returned from read */ + +extern int (*Rd_tab[])(); +extern int (*Wrt_tab[])(); + +struct sgttyb Tty_ctl; +extern char _Eol; +extern int tty_rd(); +static int raw_rd(), raw_wr(); +static int rd_func, wrt_func; + +ioctl(fd, cmd, arg) +struct sgttyb *arg; +{ + register struct channel *chp; + + chp = &chantab[fd]; + if (chp->c_ioctl == 0) { + errno = ENOTTY; + return -1; + } + switch (cmd) { + case TIOCGETP: + *arg = Tty_ctl; + break; + case TIOCSETP: + Tty_ctl = *arg; + Wrt_tab[2] = raw_wr; + Rd_tab[2] = raw_rd; + if (Tty_ctl.sg_flags&RAW) { + rd_func = + wrt_func = 6; + _Eol = '\r'; + break; + } else if (Tty_ctl.sg_flags&CBREAK) { + rd_func = (Tty_ctl.sg_flags&ECHO) ? 1 : 6; + wrt_func = 2; + } else { + Rd_tab[2] = tty_rd; + wrt_func = 2; + } + if (Tty_ctl.sg_flags&CRMOD) + _Eol = '\n'; + else + _Eol = '\r'; + } + return 0; +} + +raw_rd(x, buff, len) +register char *buff; +{ + int c, i; + register int count; + + for (count = 0 ; count < len ; ) { + for (i = TIME ; i-- ; ) + if ((c = bdos(rd_func,0xff)) != 0) + goto have_char; + if (count < MIN) + continue; + break; +have_char: + if (c == '\r') + c = _Eol; + *buff++ = c; + ++count; + } + return count; +} + +raw_wr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) { + if (*buff == '\n' && (Tty_ctl.sg_flags&CRMOD)) + bdos(wrt_func,'\r'); + bdos(wrt_func,*buff++); + } + return len; +} + isatty.c +/* Copyright (C) 1983 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +isatty(fd) +{ + return chantab[fd].c_ioctl; +} + + lseek.c +/* Copyright (C) 1982, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +long lseek(fd, pos, how) +long pos; +{ + register struct fcbtab *fp; + + if (chantab[fd].c_seek == 0) { +Badf: + errno = EBADF; + return -1L; + } + fp = chantab[fd].c_arg; + + switch (how) { + case 2: + /* + * Close the file because CP/M doesn't know how big an open file is. + * However, the fcb is still valid. + */ + setusr(fp->user); + fp->fcb.f_name[4] |= 0x80; /* set parital close flag for MP/M */ + bdos(CLSFIL, &fp->fcb); + fp->fcb.f_name[4] &= 0x7f; /* clear parital close flag */ + _Ceof(fp); + rstusr(); + case 1: + pos += fp->offset + ((long)fp->fcb.f_record << 7); + case 0: + break; + + default: + errno = EINVAL; + return -1L; + } + + fp->fcb.f_overfl = 0; + if (pos < 0) { + fp->offset = fp->fcb.f_record = 0; + errno = EINVAL; + return -1L; + } + fp->offset = (unsigned)pos & 127; + fp->fcb.f_record = pos >> 7; + return pos; +} + + open.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" +#include "io.h" + +#define MAXFILE 8 /* maximum number of open DISK files */ +int bdf_(), ret_(), fileop(); +/* + * note: The ioctl function knows that the condev read/write numbers are + * 2. It uses this information to patch the read/write tables. + */ +static struct device condev = { 2, 2, 1, 0, ret_ }; +static struct device bdosout= { 0, 3, 0, 0, ret_ }; +static struct device bdosin = { 3, 0, 0, 0, ret_ }; +static struct device filedev= { 1, 1, 0, 1, fileop }; + +/* + * device table, contains names and pointers to device entries + */ +static struct devtabl devtabl[] = { + { "con:", &condev, 2 }, + { "CON:", &condev, 2 }, + { "lst:", &bdosout, 5 }, + { "LST:", &bdosout, 5 }, + { "prn:", &bdosout, 5 }, + { "PRN:", &bdosout, 5 }, + { "pun:", &bdosout, 4 }, + { "PUN:", &bdosout, 4 }, + { "rdr:", &bdosin, 3 }, + { "RDR:", &bdosin, 3 }, + { 0, &filedev, 0 } /* this must be the last slot in the table! */ +}; + + +creat(name, mode) +char *name; +{ + return open(name, O_WRONLY|O_TRUNC|O_CREAT, mode); +} + +open(name, flag, mode) +char *name; +{ + register struct devtabl *dp; + register struct channel *chp; + register struct device *dev; + int fd, mdmask; + + for (chp = chantab, fd = 0 ; fd < MAXCHAN ; ++chp, ++fd) + if (chp->c_close == bdf_) + goto fndchan; + errno = EMFILE; + return -1; + +fndchan: + for (dp = devtabl ; dp->d_name ; ++dp) + if (strcmp(dp->d_name, name) == 0) + break; + dev = dp->d_dev; + mdmask = (flag&3) + 1; + if (mdmask&1) { + if ((chp->c_read = dev->d_read) == 0) { + errno = EACCES; + return -1; + } + } + if (mdmask&2) { + if ((chp->c_write = dev->d_write) == 0) { + errno = EACCES; + return -1; + } + } + chp->c_arg = dp->d_arg; + chp->c_ioctl = dev->d_ioctl; + chp->c_seek = dev->d_seek; + chp->c_close = ret_; + if ((*dev->d_open)(name, flag, mode, chp, dp) < 0) { + chp->c_close = bdf_; + return -1; + } + return fd; +} + +static struct fcbtab fcbtab[MAXFILE]; + +static +fileop(name,flag,mode,chp,dp) +char *name; struct channel *chp; struct devtabl *dp; +{ + register struct fcbtab *fp; + int filecl(); + int user; + + for ( fp = fcbtab ; fp < fcbtab+MAXFILE ; ++fp ) + if ( fp->flags == 0 ) + goto havefcb; + errno = EMFILE; + return -1; + +havefcb: + if ((user = fcbinit(name,&fp->fcb)) == -1) { + errno = EINVAL; + return -1; + } + if (user == 255) + user = getusr(); + setusr(user); + if (flag & O_TRUNC) + bdos(DELFIL, &fp->fcb); + if (bdos(OPNFIL,&fp->fcb) == 0xff) { + if ((flag&(O_TRUNC|O_CREAT)) == 0 || bdos(MAKFIL,&fp->fcb) == 0xff) { + errno = ENOENT; + rstusr(); + return -1; + } + } else if ((flag&(O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) { + errno = EEXIST; + goto punt; + } else if ((flag&3) > 0 && fp->fcb.f_type[0]&0x80) { + errno = EACCES; +punt: + bdos(CLSFIL, &fp->fcb); + rstusr(); + return -1; + } + + fp->offset = fp->fcb.f_overfl = fp->fcb.f_record = 0; + fp->user = user; + chp->c_arg = (_arg)fp; + fp->flags = (flag&3)+1; + chp->c_close = filecl; + if (flag&O_APPEND) + _Ceof(fp); + rstusr(); + return 0; +} + +static +filecl(fp) +register struct fcbtab *fp; +{ + _zap(); /* zap work buffer, so data is not reused */ + setusr(fp->user); + bdos(CLSFIL,&fp->fcb); + rstusr(); + fp->flags = 0; + return 0; +} + + read.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" +#include "fcntl.h" + +int bdf_(), filerd(), tty_rd(), bdosrd(); + +int (*Rd_tab[])() = { + bdf_, filerd, tty_rd, bdosrd, +}; +extern int errno; + +read(fd, buff, len) +char *buff; +{ + register struct channel *chp; + + chp = &chantab[fd]; + return (*Rd_tab[chp->c_read])(chp->c_arg, buff, len); +} + +static +filerd(afp,buffer,len) +struct fcbtab *afp; +char *buffer; unsigned len; +{ + register unsigned l = 0; + register struct fcbtab *fp; + unsigned k,j; + + fp = afp; + setusr(fp->user); + if (fp->offset) { + if ((l = 128 - fp->offset) > len) + l = len; + if (getsect(fp, buffer, l)) { + rstusr(); + return 0; + } + } + if (k = (len-l)/128) + if ((j = blkrd(&fp->fcb, buffer+l, k)) != 0) { + rstusr(); + return (k-j)*128 + l; + } + l += k*128; + if (l < len) + if (getsect(fp, buffer+l, len-l)) { + rstusr(); + return l; + } + rstusr(); + return len; +} + +static +getsect(fp, buf, len) +register struct fcbtab *fp; char *buf; unsigned len; +{ + if (_find(fp)) + return -1; + movmem(Wrkbuf+fp->offset, buf, len); + if ((fp->offset = (fp->offset + len) & 127) == 0) + ++fp->fcb.f_record; + return 0; +} + +char _Eol = '\n'; + +tty_rd(x,buff,len) +char *buff; +{ + static char buffer[258]; + static int used; + register int l; + + if (buffer[1] == 0) { + buffer[0] = 255; + buffer[1] = buffer[2] = 0; + bdos(10,buffer); + bdos(2,'\n'); + if (buffer[2] == 0x1a) { + buffer[1] = 0; + return 0; + } + buffer[++buffer[1] + 1] = _Eol; + used = 2; + } + if ((l = buffer[1]) > len) + l = len; + movmem(buffer+used, buff, l); + used += l; + buffer[1] -= l; + return l; +} + +static +bdosrd(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = 0 ; count < len ; ++count) { + if ((*buff++ = bdos(kind)) == 0x1a) + break; + } + return count; +} + rename.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "errno.h" + +rename(old, new) +char *old, *new; +{ + auto char buff[60]; + register int user; + + user = fcbinit(old,buff); + fcbinit(new,buff+16); + setusr(user); + user = 0; + if (bdos(15,buff+16) != 0xff) { + bdos(16,buff+16); + errno = EEXIST; + user = -1; + } else if (bdos(23,buff) == 0xff) { + errno = ENOENT; + user = -1; + } + rstusr(); + return user; +} + unlink.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "errno.h" + +unlink(name) +char *name; +{ + auto char delfcb[40]; + register int user; + + user = fcbinit(name,delfcb); + setusr(user); + user = bdos(19,delfcb); + rstusr(); + if (user == 0xff) { + errno = ENOENT; + return -1; + } + return 0; +} + + user.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + +codeseg segment para public 'code' +dataseg segment para public 'data' +olduser db 0 +dataseg ends + assume cs:codeseg,ds:dataseg + public getusr_ +getusr_ proc near + push bp + push si + push di + mov cl,32 + mov dl,255 + int 224 + and ax,255 + pop di + pop si + pop bp + ret +getusr_ endp +; + public setusr_ +setusr_ proc near + push bp + mov bp,sp + push si + push di + mov cl,32 + mov dl,255 + int 224 + mov olduser,al +; + mov dl,4[bp] + cmp dl,255 + je skipset + mov cl,32 + int 224 +skipset: + pop di + pop si + pop bp + ret +setusr_ endp +; + public rstusr_ +rstusr_ proc near + push bp + push si + push di + mov cl,32 + mov dl,olduser + int 224 + pop di + pop si + pop bp + ret +rstusr_ endp +codeseg ends + end + write.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +int tty_wr(), bdoswr(), filewr(), bdf_(); + +int (*Wrt_tab[])() = { + bdf_, filewr, bdoswr, bdoswr +}; + +write(fd, buff, len) +char *buff; +{ + register struct channel *chp; + + chp = &chantab[fd]; + return (*Wrt_tab[chp->c_write])(chp->c_arg, buff, len); +} + +static +filewr(afp,buffer,len) +struct fcbtab *afp; +char *buffer; unsigned len; +{ + register unsigned l = 0; + register struct fcbtab *fp; + unsigned k,j; + + fp = afp; + setusr(fp->user); + if (fp->offset) { + if ((l = 128 - fp->offset) > len) + l = len; + if (putsect(fp, buffer, l)) { + rstusr(); + return -1; + } + } + if (k = (len-l)/128) + if ((j = blkwr(&fp->fcb, buffer+l, k)) != 0) { + rstusr(); + if ((l += (k-j)*128) == 0) + return -1; + else + return l; + } + l += k*128; + if (l < len) + if (putsect(fp, buffer+l, len-l)) { + rstusr(); + return l; + } + rstusr(); + return len; +} + +static +putsect(fp, buf, len) +register struct fcbtab *fp; char *buf; unsigned len; +{ + if (_find(fp) < 0) + return -1; + movmem(buf, Wrkbuf+fp->offset, len); + if ((errno = bdos(WRITRN, &fp->fcb)) != 0) + return -1; + if ((fp->offset = (fp->offset + len) & 127) == 0) + ++fp->fcb.f_record; + return 0; +} + +tty_wr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) { + if (*buff == '\n') + bdos(2,'\r'); + bdos(2,*buff++); + } + return len; +} + +static +bdoswr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) + bdos(kind,*buff++); + return len; +} + + sbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn errno_:word +stkred dw 512 +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + mov ax,siz + mov di,$MEMRY + add ax,di + push ax + call brk_ + pop cx + jnz brk_error + mov ax,di ;return original value of the break +ifdef LONGPTR + mov dx,ds + pop di + pret +endif +brk_error: + pop di +ifdef LONGPTR + mov dx,ax +endif + test ax,ax ;set flags for C + pret + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<> + mov ax,addr + inc ax + and al,-2 + mov bx,sp + sub bx,stkred + cmp ax,bx ;double check with sp for saftey + jae brk_ov + cmp ax,_mbot_ + jb brk_ov + mov $MEMRY,ax ;new value is good so save it away + add ax,stkred + mov _sbot_,ax + sub ax,ax + pret +; invalid request +brk_ov: + mov errno_,-4 + mov ax,-1 + test ax,ax + pret + pend brk +; +; rsvstk(size): set saftey margin for stack +; this will make sure that at least size +; bytes of stack below the current level remain. +; + procdef rsvstk,<> + mov ax,stksize + mov stkred,ax + add ax,$MEMRY + mov _sbot_,ax + pret + pend rsvstk + finish + end + stkover.c +_stkover() +{ + bdos(9, "STACK OVERFLOW, INCREASE STACK SIZE\r\n$"); + _exit(200); +} + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/CRCLIST b/Manx Aztec C86 v340a/SRC/CRCLIST new file mode 100644 index 0000000..2cd8527 --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/CRCLIST @@ -0,0 +1,90 @@ +arcv.com: crc=bf4c +as.exe: crc=620a +assert.h: crc=3798 +bln.exe: crc=0830 +c.exe: crc=50d2 +c.lib: crc=0e68 +c86.lib: crc=0c6b +cc.exe: crc=a80c +ccb.exe: crc=e8b8 +cl.lib: crc=6ec5 +clc.lib: crc=65a6 +cld.lib: crc=71aa +cnm.exe: crc=ab23 +color.h: crc=de55 +cpm86.arc: crc=eb73 +crc.exe: crc=dd5c +crt0.obj: crc=ecab +ctags.com: crc=a02e +ctype.h: crc=b0c6 +d11.lib: crc=4932 +db.exe: crc=d982 +diff.exe: crc=3d2f +dioctl.h: crc=90b8 +dos11.arc: crc=794b +dos20.arc: crc=09a8 +errno.h: crc=014d +exmpl.c: crc=cee0 +fcntl.h: crc=95b9 +g.arc: crc=decb +g.lib: crc=b86f +gl.lib: crc=68b3 +glc.lib: crc=b9ed +gld.lib: crc=45aa +grep.exe: crc=2de1 +hex86.exe: crc=37cd +io.h: crc=3b0f +lb.exe: crc=1f79 +lcrom.o: crc=619e +ldrom.o: crc=135a +libc.h: crc=012d +lmacros.h: crc=eb95 +ln.exe: crc=ed7e +lrom.o: crc=619e +ls.com: crc=762f +m.lib: crc=7776 +m87.lib: crc=45ed +m87l.lib: crc=4b7b +m87lc.lib: crc=89af +m87ld.lib: crc=6393 +m87s.lib: crc=320a +m87sl.lib: crc=8433 +m87slc.lib: crc=d248 +m87sld.lib: crc=535a +make.exe: crc=3c61 +math.arc: crc=6f48 +math.h: crc=3f06 +mch86.arc: crc=fc21 +memory.h: crc=e0dd +misc.arc: crc=7380 +ml.lib: crc=c28e +mlc.lib: crc=da51 +mld.lib: crc=fb3e +model.h: crc=9339 +obd.exe: crc=2cc0 +obj.exe: crc=bef2 +ord.exe: crc=6db3 +ovbgn.o: crc=9477 +ovld.o: crc=460e +ovldpath.o: crc=5aad +pcz.exe: crc=aaa6 +prof.exe: crc=8a51 +s.arc: crc=1afe +s.lib: crc=8b29 +sdb.exe: crc=2c7a +setjmp.h: crc=626a +sgtty.h: crc=070f +signal.h: crc=47fe +sl.lib: crc=cfd6 +slc.lib: crc=be4b +sld.lib: crc=0f96 +sqz.exe: crc=b7dd +srom.o: crc=135a +stat.h: crc=28b4 +stdio.arc: crc=64a0 +stdio.h: crc=d446 +stksiz.c: crc=026f +term.arc: crc=1e05 +term.exe: crc=7c3e +time.h: crc=9f0a +z.exe: crc=6236 diff --git a/Manx Aztec C86 v340a/SRC/DOS11.ARC b/Manx Aztec C86 v340a/SRC/DOS11.ARC new file mode 100644 index 0000000..e18e993 --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/DOS11.ARC @@ -0,0 +1,782 @@ + bdos.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems +codeseg segment para public 'code' +dataseg segment para public 'data' + extrn errno_:word + extrn _Dmaseg_:word +dataseg ends + assume cs:codeseg,ds:dataseg + public bdos_ +bdos_ proc near + mov bx,sp + push es + mov ax,2[bx] + test ah,ah + jnz valok + xchg ah,al +valok: + mov dx,4[bx] + mov cx,6[bx] + int 21H + pop es + and ax,0ffH + ret +; + public filerd_ +filerd_: ;filerd(fcb, buffer, length) + ;struct fcb *fcb; char *buffer; int length; + mov cl,27H + jmp short iocommon +; + public filewr_ +filewr_: ;filewr(fcb, buffer, length) + ;struct fcb *fcb; char *buffer; int length; + mov cl,28H +iocommon: + mov bx,sp + push ds + mov ah,1aH + mov dx,4[bx] + mov ds,_Dmaseg_ + int 21H + pop ds + mov ah,cl + mov dx,2[bx] + mov cx,6[bx] + int 21H + and ax,0ffH + mov errno_,ax + jz io_ok + cmp al,1 + je io_ok + mov ax,-1 + ret +io_ok: + mov ax,cx + ret +; + public fcbinit_ +fcbinit_: + mov bx,sp + push di + push si + mov si,2[bx] ;si contains name + mov di,4[bx] ;di contains fcb address + mov ax,2900H ; issue parse filename call + int 21H + and ax,0ffH + cmp byte ptr 1[di],' ' + jne nameok + mov ax,-1 +nameok: + test ax,ax + pop si + pop di + ret +bdos_ endp +codeseg ends + end + begin.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 +codeseg segment para public 'code' + public $MEMRY + public _mbot_, _sbot_ +dataseg segment para public 'data' +$MEMRY dw -1 + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 + public _Dmaseg_ +_Dmaseg_ dw 0 +_mbot_ dw 0 +_sbot_ dw 0 + extrn _Uorg_:byte,_Uend_:byte +dataseg ends + public exitad, exitcs +exitad dw 0 +exitcs dw 0 + + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg + extrn Croot_:near + public $begin + public _exit_ +$begin proc far + mov bp,dataseg + test bp,bp + jnz notcom + mov bp,ds +notcom: + mov exitcs,ds + mov bx,[2] ;get top segment + sub bx,bp ;compute size of Data seg + cmp bx,4096 ;check if greater than 64K + jbe smallseg + mov bx,4096 +smallseg: + mov es,bp + mov cl,4 + shl bx,cl + cli + mov ss,bp + mov sp,bx + sti + cld +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; +no_args: + mov cl,[80H] + sub ch,ch + mov si,81H + mov ax,1 + push ax ;first arg # for Croot + mov di,es:$MEMRY + push di ;argp for Croot + jcxz cpy_done +rep movsb ;copy argument string to work buffer +cpy_done: + sub al,al + stosb ;null terminate string + mov ds,bp ;set DS, now DS, SS, ES are equal + inc di + and di,0fffeH ;adjust to word boundary + mov $MEMRY,di ;save memory allocation info for sbrk() + mov _mbot_,di + add di,512 + mov _sbot_,di + mov _dsval_,ds + mov _Dmaseg_,ds + mov _csval_,cs + call Croot_ ;Croot(argp, first) + jmp short exit +_exit_: + pop ax + pop ax ;fetch return code + test ax,ax + jz exit + int 23h ;use int 23 handler for non-zero exits +exit: + jmp dword ptr exitad +$begin endp +codeseg ends + end $begin + close.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "errno.h" +#include "io.h" + +extern int badfd(); + +close(fd) +{ + register struct channel *chp; + + if (fd < 0 || fd > MAXCHAN) { + errno = EBADF; + return -1; + } + chp = &chantab[fd]; + fd = (*chp->c_close)(chp->c_arg); + chp->c_read = chp->c_write = chp->c_ioctl = chp->c_seek = 0; + chp->c_close = badfd; + return fd; +} + + croot.c +/* Copyright (C) 1981,1982, 1983 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" +#include "io.h" + +badfd() +{ + errno = EBADF; + return -1; +} + +noper() +{ + return 0; +} + +int (*cls_)() = noper; + +/* + * channel table: relates fd's to devices + */ +struct channel chantab[] = { + { 2, 0, 1, 0, noper, 2 }, + { 0, 2, 1, 0, noper, 2 }, + { 0, 2, 1, 0, noper, 2 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, + { 0, 0, 0, 0, badfd, 0 }, +}; + +#define MAXARGS 30 +static char *Argv[MAXARGS]; +static int Argc; + +Croot(cp) +register char *cp; +{ + register char *fname; + register int k; + + Argv[0] = ""; + Argc = 1; + while (Argc < MAXARGS) { + while (*cp == ' ' || *cp == '\t') + ++cp; + if (*cp == 0) + break; +#ifndef NOREDIR + if (*cp == '>') { /* redirect output */ + k = 1; + goto redirect; + } else if (*cp == '<') { /* redirect input */ + k = 0; +redirect: + while (*++cp == ' ' || *cp == '\t') + ; + fname = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + close(k); + if (k) + k = creat(fname, 0666); + else + k = open(fname, O_RDONLY); + if (k == -1) + redir_err(fname); + } else +#endif + { + Argv[Argc++] = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + } + } + main(Argc,Argv); + exit(0); +} + +#ifndef NOREDIR +static redir_err(name) +char *name; +{ + char buff[200]; + + strcpy(buff, "Can't open file for redirection: "); + strcat(buff, name); + strcat(buff, "\n"); + write(2, buff, strlen(buff)); + exit(10); +} +#endif + +exit(code) +{ + register int fd; + + (*cls_)(); + for (fd = 0 ; fd < MAXCHAN ; ) + close(fd++); + _exit(code); +} + csread.c +/* Copyright (C) 1984 by Manx Software Systems */ + +extern unsigned _csval, _dsval, _Dmaseg; + +_csread(fd, buff, len) +char *buff; +{ + register ret; + + _Dmaseg = _csval; + ret = read(fd, buff, len); + _Dmaseg = _dsval; + return ret; +} + ioctl.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" +#include "sgtty.h" + +#define TIME 10 /* number of iterations of raw_rd loop */ +#define MIN 1 /* minimum number of chars returned from read */ + +extern int (*Rd_tab[])(); +extern int (*Wrt_tab[])(); + +struct sgttyb Tty_ctl; +extern char _Eol; +extern int tty_rd(); +static int raw_rd(), raw_wr(); +static int rd_func, wrt_func; + +ioctl(fd, cmd, arg) +struct sgttyb *arg; +{ + register struct channel *chp; + + chp = &chantab[fd]; + if (chp->c_ioctl == 0) { + errno = ENOTTY; + return -1; + } + switch (cmd) { + case TIOCGETP: + *arg = Tty_ctl; + break; + case TIOCSETP: + Tty_ctl = *arg; + Wrt_tab[2] = raw_wr; + Rd_tab[2] = raw_rd; + if (Tty_ctl.sg_flags&RAW) { + rd_func = + wrt_func = 6; + _Eol = '\r'; + break; + } else if (Tty_ctl.sg_flags&CBREAK) { + rd_func = (Tty_ctl.sg_flags&ECHO) ? 1 : 6; + wrt_func = 2; + } else { + Rd_tab[2] = tty_rd; + wrt_func = 2; + } + if (Tty_ctl.sg_flags&CRMOD) + _Eol = '\n'; + else + _Eol = '\r'; + } + return 0; +} + +static +raw_rd(x, buff, len) +register char *buff; +{ + int c, i; + register int count; + + for (count = 0 ; count < len ; ) { + for (i = TIME ; i-- ; ) + if ((c = bdos(rd_func,0xff)) != 0) + goto have_char; + if (count < MIN) + continue; + break; +have_char: + if (c == '\r') + c = _Eol; + *buff++ = c; + ++count; + } + return count; +} + +static +raw_wr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) { + if (*buff == '\n' && (Tty_ctl.sg_flags&CRMOD)) + bdos(wrt_func,'\r'); + bdos(wrt_func,*buff++); + } + return len; +} + isatty.c +/* Copyright (C) 1983 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +isatty(fd) +{ + return chantab[fd].c_ioctl; +} + + lseek.c +/* Copyright (C) 1982,1983 by Manx Software Systems and Thomas Fenwick */ +#include "io.h" +#include "errno.h" + +long lseek(fd, pos, how) +long pos; +{ + register struct fcbtab *fp; + + if (fd < 0 || fd > MAXCHAN || chantab[fd].c_seek == 0) { + errno = EBADF; + return -1L; + } + fp = chantab[fd].c_arg; + + switch (how) { + case 2: + pos += fp->fcb.f_size; + break; + case 1: + pos += fp->fcb.f_record; + case 0: + break; + + default: + errno = EINVAL; + return -1L; + } + + if (pos < 0) { + fp->fcb.f_record = 0; + errno = EINVAL; + return -1L; + } + fp->fcb.f_record = pos; + return pos; +} + + open.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" +#include "io.h" + +#define MAXFILE 8 /* maximum number of open DISK files */ +int badfd(), noper(); +static int fileop(); + +static struct device condev = { 2, 2, 1, 0, noper }; +static struct device filedev= { 1, 1, 0, 1, fileop }; + +/* + * device table, contains names and pointers to device entries + */ +static struct devtabl devtabl[] = { + { "con:", &condev, 2 }, + { "CON:", &condev, 2 }, + { 0, &filedev, 0 } /* this must be the last slot in the table! */ +}; + +creat(name, mode) +char *name; +{ + return open(name, O_WRONLY|O_TRUNC|O_CREAT, mode); +} + +open(name, flag, mode) +char *name; +{ + register struct devtabl *dp; + register struct channel *chp; + register struct device *dev; + int fd, mdmask; + + for (chp = chantab, fd = 0 ; fd < MAXCHAN ; ++chp, ++fd) + if (chp->c_close == badfd) + goto fndchan; + errno = EMFILE; + return -1; + +fndchan: + for (dp = devtabl ; dp->d_name ; ++dp) + if (strcmp(dp->d_name, name) == 0) + break; + dev = dp->d_dev; + mdmask = (flag&3) + 1; + if (mdmask&1) { + if ((chp->c_read = dev->d_read) == 0) { + errno = EACCES; + return -1; + } + } + if (mdmask&2) { + if ((chp->c_write = dev->d_write) == 0) { + errno = EACCES; + return -1; + } + } + chp->c_arg = dp->d_arg; + chp->c_ioctl = dev->d_ioctl; + chp->c_seek = dev->d_seek; + chp->c_close = noper; + if ((*dev->d_open)(name, flag, mode, chp, dp) < 0) { + chp->c_close = badfd; + return -1; + } + return fd; +} + +static struct fcbtab fcbtab[MAXFILE]; + +static +fileop(name,flag,mode,chp,dp) +char *name; struct channel *chp; struct devtabl *dp; +{ + register struct fcbtab *fp; + static int filecl(); + + for ( fp = fcbtab ; fp < fcbtab+MAXFILE ; ++fp ) + if ( fp->flags == 0 ) + goto havefcb; + errno = EMFILE; + return -1; + +havefcb: + if ( fcbinit(name,&fp->fcb) ) { + errno = EINVAL; + return -1; + } + if (flag & O_TRUNC) + bdos(DELFIL, &fp->fcb); + if (bdos(OPNFIL,&fp->fcb) == 0xff) { + if ((flag&(O_TRUNC|O_CREAT)) == 0 || bdos(MAKFIL,&fp->fcb) == 0xff) { + errno = ENOENT; + return -1; + } + } else if ((flag&(O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) { + errno = EEXIST; + return -1; + } + + fp->flags = 1; + fp->fcb.f_record = (flag&O_APPEND) ? fp->fcb.f_size : 0L; + fp->fcb.f_reclen = 1; + chp->c_arg = fp; + chp->c_close = filecl; + return 0; +} + +static +filecl(fp) +register struct fcbtab *fp; +{ + bdos(CLSFIL,&fp->fcb); + fp->flags = 0; + return 0; +} + + read.c +/* Copyright (C) 1982, 1983 by Manx Software Systems */ +#include "io.h" +#include "errno.h" +#include "fcntl.h" + +int badfd(), filerd(), tty_rd(); + +int (*Rd_tab[])() = { + badfd, filerd, tty_rd, +}; +extern int errno; + +read(fd, buff, len) +char *buff; +{ + register struct channel *chp; + + if (fd < 0 || fd > MAXCHAN) { + errno = EBADF; + return -1; + } + chp = &chantab[fd]; + return (*Rd_tab[chp->c_read])(chp->c_arg, buff, len); +} + +char _Eol = '\n'; + +tty_rd(x,buff,len) +char *buff; +{ + static char buffer[258]; + static int used; + register int l; + + if (buffer[1] == 0) { + buffer[0] = 255; + buffer[1] = buffer[2] = 0; + bdos(10,buffer); + bdos(2,'\n'); + if (buffer[2] == 0x1a) { + buffer[1] = 0; + return 0; + } + buffer[++buffer[1] + 1] = _Eol; + used = 2; + } + if ((l = buffer[1]) > len) + l = len; + movmem(buffer+used, buff, l); + used += l; + buffer[1] -= l; + return l; +} + + rename.c +rename(old, new) +char *old, *new; +{ + char buff[60]; + + fcbinit(new,buff); + bdos(19,buff); + fcbinit(old,buff); + fcbinit(new,buff+16); + bdos(23,buff); +} + unlink.c +#include "io.h" + +unlink(name) +char *name; +{ + struct fcb delfcb; + + fcbinit(name,&delfcb); + return bdos(DELFIL,&delfcb); +} + + write.c +/* Copyright (C) 1982, 1983 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +int filewr(), badfd(), conwr(); + +int (*Wrt_tab[])() = { + badfd, filewr, conwr, +}; + +write(fd, buff, len) +char *buff; +{ + register struct channel *chp; + + if (fd < 0 || fd > MAXCHAN) { + errno = EBADF; + return -1; + } + chp = &chantab[fd]; + return (*Wrt_tab[chp->c_write])(chp->c_arg, buff, len); +} + +conwr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = 0 ; count < len ; ++count) + bdos(kind, *buff++); + return count; +} + + sbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn errno_:word +stkred dw 512 +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + mov ax,siz + mov di,$MEMRY + add ax,di + push ax + call brk_ + pop cx + jnz brk_error + mov ax,di ;return original value of the break +ifdef LONGPTR + mov dx,ds + pop di + pret +endif +brk_error: + pop di +ifdef LONGPTR + mov dx,ax +endif + test ax,ax ;set flags for C + pret + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<> + mov ax,addr + inc ax + and al,-2 + mov bx,sp + sub bx,stkred + cmp ax,bx ;double check with sp for saftey + jae brk_ov + cmp ax,_mbot_ + jb brk_ov + mov $MEMRY,ax ;new value is good so save it away + add ax,stkred + mov _sbot_,ax + sub ax,ax + pret +; invalid request +brk_ov: + mov errno_,-4 + mov ax,-1 + test ax,ax + pret + pend brk +; +; rsvstk(size): set saftey margin for stack +; this will make sure that at least size +; bytes of stack below the current level remain. +; + procdef rsvstk,<> + mov ax,stksize + mov stkred,ax + add ax,$MEMRY + mov _sbot_,ax + pret + pend rsvstk + finish + end + stkover.c +_stkover() +{ + bdos(9, "STACK OVERFLOW, INCREASE STACK SIZE\r\n$"); + _exit(200); +} + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/DOS20.ARC b/Manx Aztec C86 v340a/SRC/DOS20.ARC new file mode 100644 index 0000000..20c2ab1 --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/DOS20.ARC @@ -0,0 +1,3354 @@ + access.c +#include +#include + +access(path, amode) +char *path; +{ + struct { + char rsvd[21]; + char attr; + long time; + long size; + char name[13]; + } sbuf; + register char *cp; + + _sys(0x1a,&sbuf); + if (_sys(0x4e,path,~ST_VLABEL) == -1) { + if (errno == ENOMORE) + errno = ENOENT; + return -1; + } + if (amode & 02 && sbuf.attr & ST_RDONLY) { + errno = EACCES; + return -1; + } + if (amode & 01) { /* execute or search */ + if ((sbuf.attr & ST_DIRECT) == 0) { + for (cp = sbuf.name ; *cp ;) + if (*cp++ == '.') + break; + if (strcmp(cp,"EXE") != 0 && strcmp(cp,"COM") != 0 + && strcmp(cp,"BAT") != 0) { + errno = EACCES; + return -1; + } + } + } + return 0; +} + + asctime.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include + +char * +asctime(tm) +struct tm *tm; +{ + static char days[7][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static char months[12][4] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + static char buffer[26]; + + sprintf(buffer, "%s %s %2d %02d:%02d:%02d %4d\n", + days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year+1900); + return buffer; +} + bdos.asm +;Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef bdos,<,,> + push es + mov ax,func + test ah,ah + jnz valok + xchg ah,al +valok: + mov dx,dxval + mov cx,cxval + int 21H + mov dx,es + pop es + and ax,0ffH + pret + pend bdos + finish + end + sbegin.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +codeseg segment para public 'code' + public $MEMRY + public _mbot_, _sbot_, _mtop_,_lowwater_ +dataseg segment para public 'data' + extrn _Uorg_:byte,_Uend_:byte +$MEMRY dw offset _Uend_ + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 +_mbot_ dw 0 +_sbot_ dw 0 +_mtop_ dw 0 +_lowwater_ dw -1 + public _PSP_ +_PSP_ dw 0 + extrn _STKSIZ_:word,_HEAPSIZ_:word + extrn _STKLOW_:word,_STKRED_:word +dataseg ends +exitad dw 0 +exitcs dw 0 + + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg +ifdef FARPROC + extrn Croot_:far +else + extrn Croot_:near +endif + public $begin + public _exit_ +$begin proc far + mov bp,dataseg + test bp,bp + jnz notcom + mov bp,ds +notcom: + mov exitcs,ds + mov bx,[2] ;get top segment + sub bx,bp ;compute size of Data seg + cmp bx,4096 ;check if greater than 64K + jbe smallseg + lea bx,[bp+4096] ;end address of segment (paragraphs) + mov ax,es + sub bx,ax ;compute length of segment + mov ah,4aH ;SETBLOCK system call + int 21H + mov bx,4096 +smallseg: + mov es,bp + mov es:_PSP_,ds + mov cl,4 + shl bx,cl + cmp es:_STKLOW_,0 + je setstk ;stack goes above heap + mov ax,es:_STKRED_ ;stack goes below heap + shl ax,1 ;allow at least twice the RED zone size + mov bx,es:_STKSIZ_ + shl bx,cl ;compute requested stack size + cmp bx,ax ;but don't allow too little + ja sizeok + mov bx,ax +sizeok: + add bx, offset _Uend_ +setstk: + cli + mov ss,bp + mov sp,bx + sti +; + test bx,bx + jnz oksav + mov bx,0ffffh +oksav: + mov es:_mtop_,bx +; now adjust heap size if necessary + cmp es:_STKLOW_,0 ; can't do it unless heap above stack + je heapdone + mov si,es:_HEAPSIZ_ + mov ax,bx + inc ax + mov es:$MEMRY,ax ; start of heap for later + shl si,cl + add bx,si + jnc heapok + mov bx,0ffffh +heapok: + mov es:_mtop_,bx ; and save as _mtop_ + add bx,15 + shr bx,cl ; convert to paragraph form + mov ax,es + add bx,ax ; calculate paragraph address of last byte + mov ax,ds ; now take the paragrph form and + sub bx,ax ;compute length of segment + mov bp,es ;save ES + mov es,ax + mov ah,4aH ;SETBLOCK system call + int 21H + jnc heapdone + mov ax,254 + jmp badexit +heapdone: + mov es,bp ;restore ES + cld +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + mov es,[2cH] ;get enviroment segment + sub di,di + mov cx,7fffH +arglook: + mov ah,es:byte ptr [di] + cmp ah,'=' ;look for null named env. string + je found_args + test ah,ah + jz no_args +repne scasb ;look for null byte + jz arglook +no_args: + mov cl,[80H] + sub ch,ch + mov si,81H + mov ax,1 + jmp short mov_args +; +found_args: + sub ax,ax + stosb ;zap and skip over '=' + mov si,di + mov di,es + mov ds,di +mov_args: + push ax ;first arg # for Croot + mov es,bp ;reload ES with our real dataseg + mov di,es:$MEMRY + push di ;argp for Croot + jcxz cpy_done +cpy_args: ;copy argument string to work buffer + lodsb + test al,al + jz cpy_done + stosb + loop cpy_args +cpy_done: + sub al,al + stosb ;null terminate string + mov ds,bp ;set DS, now DS, SS, ES are equal + inc di + and di,0fffeH ;adjust to word boundary + mov $MEMRY,di ;save memory allocation info for sbrk() + mov _mbot_,di + mov _sbot_,offset _Uend_ + cmp _STKLOW_,0 + jnz nostk + mov _sbot_,di +nostk: + mov ax,_sbot_ + add ax,_STKRED_ + mov _sbot_,ax + mov _dsval_,ds + mov _csval_,cs + call Croot_ ;Croot(argp, first) + jmp short exits +_exit_: + pop ax + pop ax ;fetch return code +ifdef FARPROC + pop ax +exit label far +else +exit: +endif +exits: +badexit: + mov ah,4cH + int 21H + jmp dword ptr exitad +$begin endp + +retip dw 0 +retcs dw 0 + + public $dbgentry +$dbgentry proc far + pop cs:retip + pop cs:retcs ; save return address into debugger + pop ds ;set DS + call caller + jmp dword ptr cs:retip ; return to debugger +$dbgentry endp + +caller proc + push di ;CS value of local function + push si ;IP value call local function + db 0cbH ;far return instruction +caller endp + +codeseg ends + end $begin + chmod.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef chmod, <,> + pushds + mov ax,4301h + ldptr dx,filnam,ds + mov cx,attr + int 21h + popds + jnc retok + mov ds:errno_,ax + mov ax,-1 + pret +retok: + sub ax,ax + pret + pend chmod + finish + end + croot.c +/* Copyright (C) 1981,1982, 1983 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" + +static char **Argv; +static int Argc; + +noper() +{ + return 0; +} + +int (*cls_)() = noper; +extern char _ioflg[]; + +Croot(cp, first) +register char *cp; +{ + register char **cpp; + char *sbrk(); +#ifdef REDIR + register int k; + register char *fname; +#endif + + _ioflg[0] = isatty(0); /* set flag for i/o routines */ + _ioflg[1] = isatty(1); /* set flag for i/o routines */ + _ioflg[2] = isatty(2); /* set flag for i/o routines */ + + Argv = (char **)sbrk((first+1)*sizeof(char *)); + Argv[0] = ""; + cpp = &Argv[Argc = first]; + for (;;) { + while (*cp == ' ' || *cp == '\t') + ++cp; + if (*cp == 0) + break; +#ifdef REDIR + if (*cp == '>') { /* redirect output */ + k = 1; + goto redirect; + } else if (*cp == '<') { /* redirect input */ + k = 0; +redirect: + while (*++cp == ' ' || *cp == '\t') + ; + fname = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + close(k); + if (k) + k = creat(fname, 0666); + else + k = open(fname, O_RDONLY); + if (k == -1) + redir_err(fname); + } else +#endif + { + *cpp++ = cp; + Argc++; + if (sbrk(sizeof(char *)) == (char *)-1) { + write(2, "Too many args.", 14); + _exit(200); + } + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + } + } + *cpp = 0; + main(Argc,Argv); + exit(0); +} + +#ifdef REDIR +static redir_err(name) +char *name; +{ + char buff[200]; + + strcpy(buff, "Can't open file for redirection: "); + strcat(buff, name); + strcat(buff, "\n"); + write(2, buff, strlen(buff)); + exit(10); +} +#endif + +exit(code) +{ + (*cls_)(); + _exit(code); +} + + crt0.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 +PGROUP group @CODE,PROG +@CODE segment byte public 'CODE' +@CODE ends +PROG segment byte public 'CODE' +PROG ends + +DGROUP group @DATAB,DATA,@DATAC,@DATAI,@DATAT,@DATAU,@DATAV,@STACK + +@DATAB segment para public 'DATAB' +@DATAB ends + +DATA segment word public 'DATA' + db 'Aztec C86 version 3.40a',0 + even + public _Dorg +_Dorg label byte +DATA ends + +@DATAC segment word public 'DATAC' +@DATAC ends +@DATAI segment word public 'DATAI' +@DATAI ends + +@DATAT segment word public 'DATAT' + public _Dend +_Dend label byte + public _Uorg +_Uorg label byte +@DATAT ends + +@DATAU segment word public 'DATAU' +@DATAU ends + +@DATAV segment word public 'DATAV' + public _Uend +_Uend label byte +@DATAV ends + +@STACK segment para stack 'STACK' +First db 2048 dup (?) +@STACK ends + end + csread.asm +; Copyright (C) 1983, 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef _csread,<,,> +; _csread(fd, char *addr, len) +; read data into code segment + mov bx,fd + push ds +ifdef FARPROC + lds dx,addr +else + mov dx,addr +endif + mov cx,len +ifndef FARPROC + mov ax,cs + mov ds,ax +endif + mov ah,3fH + int 21H + pop ds + jnc ret_ok + mov ds:errno_,ax + mov ax,-1 +ret_ok: + pret + pend _csread + finish + end + ctime.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include + +char * +ctime(clock) +long *clock; +{ + struct tm *tm; + + tm = localtime(clock); + return asctime(tm); +} + dioctl.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef _ioctl, <,,,> +; _ioctl(fd, req, arg[, len]) + mov bx,fd + mov ah,44H + mov al,req + cmp al,0 + je getinfo + cmp al,1 + je setinfo + cmp al,6 + jge getstat + pushds + ldptr dx,arg,ds + mov cx,len + int 21H + popds + jnc xret_ok + mov ds:errno_,ax + mov ax,-1 +xret_ok: + pret +; +doint proc near + int 21H + jnc ret_ok + mov ds:errno_,ax + mov ax,-1 +ret_ok: + ret +doint endp +; +getstat: + call doint + pret +; +getinfo: + call doint + jc err + ldptr bx,arg,es +ifdef LONGPTR + mov es:[bx],dx +else + mov ds:[bx],dx +endif + sub ax,ax +err: + pret +; +setinfo: + ldptr bx,arg,es +ifdef LONGPTR + mov dl,es:[bx] +else + mov dl,ds:[bx] +endif + sub dh,dh + mov bx,fd + call doint + jc err + sub ax,ax + pret + pend _ioctl + finish + end + dos.asm +; Copyright (C) 1983, 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef dos,<,,,,,> +; dos(ax,bx,cx,dx,di,si) + push di + push si +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + mov ax,func + test ah,ah + jnz skip + xchg ah,al +skip: + mov bx,bxval + mov cx,cxval + mov dx,dxval + mov di,dival + mov si,sival + int 21H + jnc ret_ok + mov errno_,ax + mov ax,-1 +ret_ok: + pop si + pop di + pret + pend dos + finish + end + dostime.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +codeseg segment byte public "code" +days dw -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333 +codeseg ends + procdef dostime, <> + push es + push si +; + mov ah,2aH + int 21h + ldptr bx,arg,es + sub cx,1900 +ifndef LONGPTR + mov ds:word ptr 10[bx],cx ;year - 1900 +else + mov es:word ptr 10[bx],cx ;year - 1900 +endif + sub ah,ah + mov al,dh + dec al +ifndef LONGPTR + mov ds:word ptr 8[bx],ax ;month +else + mov es:word ptr 8[bx],ax ;month +endif + mov al,dl +ifndef LONGPTR + mov ds:word ptr 6[bx],ax ;day of month +else + mov es:word ptr 6[bx],ax ;day of month +endif +; + mov ah,2cH + int 21H + ldptr bx,arg,es + sub ah,ah + mov al,ch +ifndef LONGPTR + mov ds:word ptr 4[bx],ax ;hour + mov al,cl + mov ds:word ptr 2[bx],ax ;minute + mov al,dh + mov ds:word ptr [bx],ax ;seconds + mov al,dl + mov ds:word ptr 18[bx],ax ;1/100 seconds +; + sub ax,ax + mov si,ds:word ptr 8[bx] + cmp si,2 + jb noleap + test ds:byte ptr 10[bx],3 + jnz noleap + inc ax +noleap: + shl si,1 + add ax,cs:days[si] + add ax,ds:word ptr 6[bx] + mov ds:word ptr 14[bx],ax ;day of year +; + mov si,ds:word ptr 10[bx] +else + mov es:word ptr 4[bx],ax ;hour + mov al,cl + mov es:word ptr 2[bx],ax ;minute + mov al,dh + mov es:word ptr [bx],ax ;seconds + mov al,dl + mov es:word ptr 18[bx],ax ;1/100 seconds +; + sub ax,ax + mov si,es:word ptr 8[bx] + cmp si,2 + jb noleap + test es:byte ptr 10[bx],3 + jnz noleap + inc ax +noleap: + shl si,1 + add ax,cs:days[si] + add ax,es:word ptr 6[bx] + mov es:word ptr 14[bx],ax ;day of year +; + mov si,es:word ptr 10[bx] +endif + add ax,si + dec si + shr si,1 + shr si,1 + add ax,si + inc ax + sub dx,dx + mov cx,7 + div cx +ifndef LONGPTR + mov ds:word ptr 12[bx],dx ;day of week +; + mov ds:word ptr 16[bx],0 ;say no D.S.T. for now +else + mov es:word ptr 12[bx],dx ;day of week +; + mov es:word ptr 16[bx],0 ;say no D.S.T. for now +endif + pop si + pop es + pret + pend dostime + finish + end + dup.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef dup,<> +; dup(ofd) : duplicate file descriptor +; if ok, returns new fd. if error, returns -1. + mov ah,45h +dupx: + mov bx,ofd + int 21H + jnc ret_ok + mov errno_,ax + mov ax,-1 +ret_ok: + pret + pend dup +; + procdef fdup,<,> +; fdup(ofd, nfd): force dup of ofd into nfd +; If nfd is open it will be closed. +; if ok, returns nfd; if error, returns -1 + mov cx,nfd + mov ah,46h + jmp dupx + pend fdup + finish + end + exec.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + +ifdef FARPROC + extrn _sigfix_:far +else + extrn _sigfix_:near +endif +; +e_magic equ 0 +e_used equ 2 ;number of bytes used in final sector of file +e_pages equ 4 ;size of file in 512-byte pages +e_nreloc equ 6 ;number relocation table items +e_hsize equ 8 ;size of header in 16-byte paragraphs +e_min equ 10 ;minimum # of para required above program +e_max equ 12 ;maximum # of para " " " +e_ss equ 14 ;offset of stack segment in load module +e_sp equ 16 ;initial SP value +e_csum equ 18 ;negative sum of all words in the file +e_ip equ 20 ;starting IP for program +e_cs equ 22 ; " CS " +e_freloc equ 24 ;offset of first relocation item +e_ovly equ 26 ;overlay number + +; +ldrsize equ 1024 +header equ ldrsize-30 +reloc equ 26 +startad equ 0 +; +dataseg segment word public 'data' + extrn _PSP_:word +dataseg ends +; +;exec(fd,cline,fcb1,fcb2,header) +; NOTE: This function never returns, even if the exec +; fails. +; + procdef exec,<,,,,> +; +; copy cmd line and fcb's into PSP +; +load proc far ;so returns are far + push ds + call _sigfix_ ;restore int 22,23 vectors + mov es,ds:_PSP_ ;fetch segment of PSP + ldptr si,cline,ds + mov di,80h + mov cx,64 +rep movsw ;copy command line + ldptr si,fcb1,ds + mov di,5ch + mov cx,8 +rep movsw ;copy fcb1 + ldptr si,fcb2,ds + mov cx,8 +rep movsw ;copy fcb2 +; + mov bx,0ffffh ;ask for all of memory + mov ah,4ah + int 21h + mov ah,4ah ;then ask for what we can get + int 21h +; + mov dx,fd ;file handle + ldptr si,head,ds ;exe header from file + cmp ds:word ptr [si+e_magic],5a4dh ;check magic # + je exefile + + mov bp,bx ;compute new SP + cmp bp,4096 ;check size of segment + jbe smallstk + mov bp,4096 +smallstk: + mov cx,4 + shl bp,cl ;new SP +; + mov cx,es + add bx,cx ;end of our segment + sub bx,8 ;get 128 bytes for loader and stack + mov es,bx + pop si ; get old ds value back + mov ss,bx + mov sp,128 + push si ; push old ds on stack for later use +; + mov cx,cs + mov ds,cx + mov si,offset com_loader + sub di,di + mov cx,offset com_ldend + sub cx,si +rep movsb +; + mov bx,dx ;handle into bx for io calls + sub cx,cx + sub dx,dx + mov ax,4200H + int 21H ;rewind file +; + mov dx,100H ;address to read data into + lea cx,[bp-256] ;byte count to read in + pop ds + mov ax,ds:_PSP_ ;segment of PSP + mov ds,ax + mov es,ax + push ss + sub ax,ax + push ax + mov ah,3fH + ret +; +; this block of code is moved to the top of available memory +; and jumped to with the registers for a read call setup +; +com_loader: + int 21h + jnc ok + mov ax,4cfeh + int 21h +ok: + mov ah,3eH + int 21h ;close the file + mov ax,ds + mov ss,ax + mov sp,bp + push ax ;push new cs + mov ax,100h + push ax ;push new ip + ret +com_ldend: +; +; +exefile: + mov cx,es + add bx,cx ;end of our segment + sub bx,ldrsize/16 ;get mem for loader, header, and stack + mov es,bx + mov di,header + mov cx,13 +rep movsw ;copy 26 byte file header +; + pop si ; get old ds value + mov ss,bx + mov sp,header + push si ; push old ds value on new stack for later use +; + mov cx,cs + mov ds,cx + mov si,offset exe_loader + sub di,di + mov cx,offset exe_ldend + sub cx,si +rep movsb +; + pop ds + mov ax,ds:_PSP_ ;segment of PSP + push ax ;ES, DS value for program + add ax,10h + mov ds,ax ;place to load program + mov bp,ax + mov bx,dx ;get handle into bx for int 21h +; + mov di,header + mov dx,ss:e_hsize[di] ;compute offset of program + sub ax,ax + mov cl,4 +lshift: + shl dx,1 + rcl ax,1 + loop lshift + mov cx,ax + mov ax,4200H + int 21h ;lseek to load module + jc punt +; + mov si,ss:e_pages[di] + mov cl,5 + shl si,cl ;# paragraphs in file + sub si,ss:e_hsize[di] ;now, # para in program +; + push ss ;CS for loader + sub ax,ax + push ax ;IP for loader + ret ;far return to code at top of mem +; +; this code is moved to the top of our segment and jumped to +; with the following registers setup: +; bx - file handle of program +; ds, bp - where to load the program +; di - points to the exe header +; si - # para to read in +; PSP address pushed onto stack +; +exe_loader: + mov ah,3fH + mov cx,1024 + sub dx,dx + int 21h + jc punt + test ax,ax + jz load_done + mov ax,ds + add ax,64 + mov ds,ax + sub si,64 + ja exe_loader +; +load_done: + mov ax,cs + mov ds,ax + cmp word ptr e_nreloc[di],0 + jz reloc_done + mov dx,e_freloc[di] + sub cx,cx + mov ax,4200H + int 21H ;lseek to relocation info + jc punt +relocate: + lea dx,reloc[di] + mov cx,4 + mov ah,3fH + int 21H + jc punt + cmp ax,4 + jne punt + mov si,reloc[di] + mov ax,reloc+2[di] + add ax,bp + mov es,ax + add es:[si],bp + dec word ptr e_nreloc[di] + jnz relocate +reloc_done: + mov ah,3eH + int 21h ;close file + add e_ss[di],bp ;relocate stack segment + add e_cs[di],bp ;relocate starting CS + pop ax ;get PSP address before changing stack + mov ss,e_ss[di] + mov sp,e_sp[di] + mov ds,ax + mov es,ax + jmp cs:dword ptr e_ip[di] +punt: + mov ax,4cfeh + int 21h +exe_ldend: +load endp + pend exec + finish + end + execl.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execl(path, args) +char *path, *args; +{ + return execv(path, &args); +} + execlp.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execlp(name, args) +char *name, *args; +{ + return execvp(name, &args); +} + + execv.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +#define EXEMAGIC 0x5a4d + +struct exehead { /* MS-dos .exe file header */ + int e_magic; + int e_used; /* number of bytes used in final sector of file */ + int e_pages; /* size of file in 512-byte pages */ + int e_nreloc; /* number relocation table items */ + int e_hsize; /* size of header in 16-byte paragraphs */ + int e_min; /* minimum # of para required above program */ + int e_max; /* maximum # of para " " " */ + unsigned e_ss; /* offset of stack segment in load module */ + unsigned e_sp; /* initial SP value */ + unsigned e_csum; /* negative sum of all words in the file */ + unsigned e_ip; /* starting IP for program */ + unsigned e_cs; /* " CS " */ + int e_freloc; /* offset of first relocation item */ + int e_ovly; /* overlay number */ +}; + +execv(path, argv) +char *path, **argv; +{ + register char *cp, *xp; + int i, fd; + char buffer[130]; + char fcb1[16], fcb2[16]; + struct exehead header; + + if ((fd = open(path,0)) == -1) + return -1; + if (read(fd, &header, sizeof header) != sizeof header) + header.e_magic = 0; + + cp = buffer+1; + i = 1; + if (*argv) { + ++argv; /* skip arg0, used for unix (tm) compatibility */ + while (xp = *argv++) { + if (i == 1) + fcbinit(xp, fcb1); + else if (i == 2) + fcbinit(xp, fcb2); + *cp++ = ' '; + while (*xp) { + if (cp >= buffer+128) + goto done; + *cp++ = *xp++; + } + ++i; + } + } +done: + buffer[0] = cp - (buffer+1); + return exec(fd, buffer, fcb1, fcb2, &header); +} + + execvp.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execvp(name, argv) +char *name, **argv; +{ + register char *cp, *xp; + char *getenv(), path[64]; + + tryexec("", name, argv); + if ((cp = getenv("PATH")) != 0) { + while (*cp) { + xp = path; + while (*cp) { + if (*cp == ';') { + ++cp; + break; + } + *xp++ = *cp++; + } + *xp = 0; + if (path[0] != 0) + tryexec(path, name, argv); + } + } + return -1; +} + +static +tryexec(dir, name, argv) +char *dir, *name, **argv; +{ + char newname[64]; + register char *cp; + char *strchr(), *strrchr(); + + strcpy(newname, dir); + if (((cp = strchr(newname, '/')) || (cp = strchr(newname, '\\'))) + && *(cp+1) != 0) + strcat(newname, "/"); + strcat(newname, name); + if (strchr(name, '.') == 0) { + strcat(newname, ".com"); + execv(newname, argv); + strcpy(strrchr(newname,'.'), ".exe"); + } + execv(newname, argv); +} + fcbinit.asm +;Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef fcbinit, <,> + pushds + push di + push si +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,jname + ldptr di,fcb + mov ax,2900H ; issue parse filename call + int 21H + and ax,0ffH + cmp es:byte ptr 1[di],' ' + jne nameok + mov ax,-1 +nameok: + pop si + pop di + popds + pret + pend fcbinit + finish + end + fexec.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' +param equ this word +env dw ? +cline dw ?,? +fcb1 dw ?,? +fcb2 dw ?,? + extrn errno_:word +dataseg ends + assume ds:dataseg +save_ss dw 0 +save_sp dw 0 + procdef fexec,<,,,,> +; char *fexec(name,env,cline,fcb1,fcb2) +; + push si + push di + pushf + push [030H] + push [02EH] + push ds + push es + mov cs:save_ss,ss + mov cs:save_sp,sp +; +; set up parameter block for exec call +; + mov ax,enva + mov env,ax +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + ldptr ax,clinea,es + mov cline,ax + mov cline+2,es + ldptr ax,fcb1a,es + mov fcb1,ax + mov fcb1+2,es + ldptr ax,fcb2a,es + mov fcb2,ax + mov fcb2+2,es +; + mov ax,ds + mov es,ax + mov bx,offset param + ldptr dx,filname,ds ;name of file to exec + mov ax,04b00H + int 21h + mov ss,cs:save_ss + mov sp,cs:save_sp + pop es + pop ds + jnc noerror + mov errno_,ax + mov ax,-1 + jmp short done +noerror: + sub ax,ax +done: + pop [02EH] + pop [030H] + popf + pop di + pop si + pret + pend fexec + finish + end + fexecl.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +fexecl(path, args) +char *path, *args; +{ + return fexecv(path, &args); +} + fexecv.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +fexecv(path, argv) +char *path, **argv; +{ + register char *cp, *xp; + int i; + char buffer[130]; + char fcb1[16], fcb2[16]; + + cp = buffer+1; + i = 1; + fcbinit(".", fcb1); /* initialize fcb's, in case no args */ + fcbinit(".", fcb2); + if (*argv) { + ++argv; /* skip arg0, used for unix (tm) compatibility */ + while (xp = *argv++) { + if (i == 1) + fcbinit(xp, fcb1); + else if (i == 2) + fcbinit(xp, fcb2); + *cp++ = ' '; + while (*xp) { + if (cp >= buffer+127) + goto done; + *cp++ = *xp++; + } + ++i; + } + } +done: + buffer[0] = cp - (buffer+1); + *cp = '\r'; /* add CR to make some dos commands happy */ + return fexec(path, 0, buffer, fcb1, fcb2); +} + + ftime.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef ftime,<,,,> +; +;long ftime(get/set, fd, [long newtime]) +; + mov ah,57h + mov al,get + mov bx,fd + mov cx,newt1 + mov dx,newt2 + int 21h + jnc retok + mov errno_,ax + mov ax,-1 + mov dx,ax + pret +retok: + test get,1 + jz gettime + sub dx,dx + mov cx,dx +gettime: + mov ax,cx + pret + pend ftime + finish + end + getcwd.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char * +getcwd(buf, size) +char *buf; +{ + char *malloc(); + int allflag = 0; + + if (buf == 0) { + if ((buf = malloc(size)) == 0) + return 0; + allflag = 1; + } + if (_sys(0x47,buf,0) == -1) { + if (allflag) + free(buf); + return 0; + } + return buf; +} + getenv.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + ifndef LONGPTR +retbuf db 256 dup (?) + endif + extrn _PSP_:word +dataseg ends + assume ds:dataseg + procdef getenv, <> +; char *getenv(name) +; char *name; +; + push ds + push si + push di +ifndef LONGPTR + mov bx,ds + mov es,bx +endif + cld + ldptr bx,jname,es + mov ds,ds:_PSP_ ;fetch segment of PSP + mov ds,ds:[2cH] ;get environment segment + sub si,si +envloop: + lodsb + test al,al + jz nostring + sub di,di +cmploop: + cmp al,'=' + jne notaneq + sub al,al +notaneq: + cmp al,es:[bx][di] + jne next + test al,al + je foundit + inc di + lodsb + test al,al + jne cmploop + jmp envloop +next: + lodsb + test al,al + jne next + jmp envloop +; +foundit: +ifndef LONGPTR +; +; copy string to local buffer, so we can return a 16-bit pointer to it. +; + mov di,offset retbuf + mov cx,255 +cpyloop: + lodsb + stosb + test al,al + loopnz cpyloop + sub al,al + stosb ;guarantee null termination + mov ax,offset retbuf + test ax,ax + jmp short done +; +nostring: + sub ax,ax +done: +else + mov dx,ds + mov ax,si + jmp short done + +nostring: + sub ax,ax + sub dx,dx + +done: +endif + pop di + pop si + pop ds + pret + pend getenv + finish + end + io.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + +ifdef FARPROC + extrn __tty_rd_:far,__tty_wr_:far +else + extrn __tty_rd_:near,__tty_wr_:near +endif + +dataseg segment para public 'data' + extrn errno_:word + public _ioflg_ +_ioflg_ db 20 dup (0) + public _ttrd_, _ttwr_ + +ifdef FARPROC +_ttrd_ dd __tty_rd_ +else +_ttrd_ dw offset __tty_rd_ +endif + +ifdef FARPROC +_ttwr_ dd __tty_wr_ +else +_ttwr_ dw offset __tty_wr_ +endif +dataseg ends + + assume ds:dataseg +; + procdef _read, <,,> + mov ah,3fH + mov bx,rdfd + jmp short use_dos + pend _read +; + procdef _write, <,,> + mov ah,40H + mov bx,wrfd + jmp short use_dos + pend _write +; + procdef read, <,,> + ;read_(fd, buffer, length) + ;char *buffer; int length; + + mov ah,3fH + jmp short iocommon + pend read +; + procdef write, <,,> + ;write(fd, buffer, length) + ;char *buffer; int length; + mov ah,40H +iocommon: + mov bx,fd + cmp _ioflg_[bx],0 + jz use_dos + pop bp + cmp ah,03fH + je readit + jmp _ttwr_ +readit: + jmp _ttrd_ +; +use_dos: + pushds + ldptr dx,buffer,ds + mov cx,len + int 21H + popds + jnc io_ok + mov errno_,ax + mov ax,-1 +io_ok: + pret + pend write +; + procdef close, <> + ;close(fd) + mov ah,3eH + mov bx,ffd + int 21H + jnc cls_ok + mov errno_,ax + mov ax,-1 + pret +cls_ok: + sub ax,ax + pret + pend close +; + procdef lseek, <,,,> + ;long lseek(fd, pos, how) + ;long pos; + mov ah,42H + mov al,how + mov dx,pos1 + mov cx,pos2 + mov bx,fffd + int 21H + jnc lsk_ok + mov errno_,ax + mov ax,-1 + mov dx,ax +lsk_ok: + pret + pend lseek +; + procdef unlink,<> + ;unlink(name) + pushds + mov ah,41H + ldptr dx,namea,ds + int 21H + popds + jnc unl_ok + mov errno_,ax + mov ax,-1 + pret +unl_ok: + sub ax,ax + pret + pend unlink +; + procdef rename, <,> + ;rename(old, new) + push di + pushds + mov ah,56H + ldptr dx,old,ds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,new,es + int 21H + popds + pop di + jnc rnm_ok + mov errno_,ax + mov ax,-1 + pret +rnm_ok: + sub ax,ax + pret + pend rename + finish + end + ioctl.c +/* Copyright (C) 1984, 1985 by Manx Software Systems */ +#include "errno.h" +#include "sgtty.h" + +#define TIME 10 /* number of iterations of raw_rd loop */ +#define MIN 1 /* minimum number of chars returned from read */ + +extern char _ioflg[]; +extern int (*_ttrd)(); +extern int (*_ttwr)(); +extern char _Eol; +extern int _TTrem; +extern int __tty_rd(), __tty_wr(), _write(); + +static struct sgttyb Tty_ctl = { '\b', '\x18', CRMOD|ECHO }; +static int raw_rd(), cr_wr(); +static int ioflags, myflags, ttyfd; + +ioctl(fd, cmd, arg) +struct sgttyb *arg; +{ + int flags; + + if (_ioflg[fd] == 0) { + errno = ENOTTY; + return -1; + } + switch (cmd) { + case TIOCGETP: + *arg = Tty_ctl; + break; + case TIOCSETP: + if (ttyfd == 0) { + if (_ioflg[2]) + ttyfd = 2; + else if ((ttyfd = _sys(0x3d02,"/dev/con",0)) == -1) + return -1; + } + if (ioflags == 0) { + _ioctl(ttyfd, 0, &ioflags); + ioflags &= 0xff; + } + Tty_ctl = *arg; + if ((myflags = Tty_ctl.sg_flags) & RAW) + myflags = RAW; + _ttwr = _write; + _Eol = '\r'; + if (myflags&CRMOD) { + _Eol = '\n'; + _ttwr = __tty_wr; + } + if (myflags&(RAW|CBREAK)) { + _TTrem = 0; /* clear out input buffer */ + _ttrd = raw_rd; + ioflags |= 0x20; /* turn on dos's raw flag */ + _ioctl(ttyfd, 1, &ioflags); + } else { + ioflags &= ~0x20; /* turn off dos's raw flag */ + _ioctl(ttyfd, 1, &ioflags); + _ttrd = __tty_rd; + } + break; + } + return 0; +} + +raw_rd(fd, buff, len) +register char *buff; +{ + int i; + register int count; + + for (count = 0 ; count < len ; ) { + for (i = TIME ; i-- ; ) + if (_ioctl(ttyfd, 6) != 0) + goto have_char; + if (count < MIN) + continue; + break; +have_char: + _read(ttyfd, buff, 1); + if (*buff == '\r') + *buff = _Eol; + if (myflags&ECHO) + (*_ttwr)(ttyfd, buff, 1); + ++buff; + ++count; + } + return count; +} + isatty.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef isatty, <> +; isatty(fd) + mov bx,fd + mov ax,4400H + int 21H + jc not_tty ;error, then not a tty + test dl,80h ;is the channel a device? + jz not_tty ;no, ... + test dl,3 ;is it console input or output + jz not_tty ;no, ... + mov ax,1 ;yes, the channel is a tty + pret +not_tty: + sub ax,ax + pret + pend isatty + finish + end + localtim.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include + +struct tm * +gmtime(clock) +long *clock; +{ + struct tm *localtime(); + + return localtime(clock); +} + +struct tm * +localtime(clock) +long *clock; +{ + union { + long l; + unsigned u[2]; + } un; + static struct tm tm; + static int days[12] = { + -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333 + }; + + un.l = *clock; + tm.tm_sec = (un.u[0]&31) * 2; + tm.tm_min = (un.u[0]>>5) & 63; + tm.tm_hour = (un.u[0]>>11) & 31; + tm.tm_mday = un.u[1] & 31; + tm.tm_mon = ((un.u[1]>>5) & 15) - 1; + tm.tm_year = ((un.u[1]>>9) & 127) + 80; + tm.tm_yday = days[tm.tm_mon] + tm.tm_mday + + (tm.tm_mon > 1 && (tm.tm_year&3) == 0); + tm.tm_wday = (tm.tm_yday + tm.tm_year + ((tm.tm_year-1)>>2) + 1) % 7; + return &tm; +} + mkdir.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef mkdir,<> +; char *mkdir(name) +; char *name; +; + mov ah,39h +dircommon: + pushds + ldptr dx,namea,ds + int 21h + popds + mov ax,0 + jnc ok + mov errno_,ax + mov ax,-1 +ok: + pret + pend mkdir +; + procdef rmdir,<> + mov ah,3aH + jmp dircommon + pend rmdir +; + procdef chdir,<> + mov ah,3bH + jmp dircommon + pend chdir + finish + end + open.c +/* Copyright (C) 1982 1983 1984 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" + +extern int errno; +extern char _ioflg[]; + +creat(name, mode) +char *name; +{ + return open(name, O_WRONLY|O_TRUNC|O_CREAT, mode); +} + +open(name, flag, mode) +char *name; +{ + register int fd, m; + + m = 0x3d00 | (flag&0x00f3); + if ((flag&O_TRUNC) != 0) + m = 0x3c00; + + if ((fd = _sys(m,name,0)) == -1) { + if ((flag&O_CREAT) != 0) + fd = _sys(0x3c,name,0); + } else if ((flag&O_EXCL) != 0) { + close(fd); + errno = EEXIST; + return -1; + } + if (fd >= 0) { + if (flag&O_APPEND) + (void)lseek(fd, 0L, 2); + _ioflg[fd] = isatty(fd); /* set flag for i/o routines */ + } + return fd; +} + stat.c +#include + +stat(path, buf) +char *path; register struct stat *buf; +{ + struct { + char rsvd[21]; + char attr; + long time; + long size; + char name[13]; + } sbuf; + + _sys(0x1a,&sbuf); + if (_sys(0x4e,path,~ST_VLABEL) == -1) + return -1; + buf->st_attr = sbuf.attr; + buf->st_mtime = sbuf.time; + buf->st_size = sbuf.size; + return 0; +} + + system.c +/* Copyright (C) 1984 by Manx Software Systems */ + +static int swt_char; + +system(cmd) +char *cmd; +{ + register char *prog; + char *getenv(); + char buffer[130]; + +#asm + mov ax,3700h ;ask dos for current switch character + int 21h + sub dh,dh + mov swt_char_,dx +#endasm + if ((prog = getenv("COMSPEC")) == 0) + prog = "/command.com"; + sprintf(buffer+1, "%cC %.123s\r", swt_char, cmd); + buffer[0] = strlen(buffer+1) - 1; + if (fexec(prog,0,buffer,0,0) == -1) + return -1; + return wait(); +} + time.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef time,<> ;time_t time(time_t *tloc) +; if tloc!=0 then time is also stored there +; + mov ah,2aH + int 21h + sub cx,1980 + mov ax,cx + mov cl,9 + shl ax,cl + and dh,15 + and dl,31 + mov cl,3 + shl dl,cl + shr dx,cl + or ax,dx + push ax ;save across system call +; + mov ah,2cH + int 21H + mov ax,cx + and ah,31 + and al,63 + and dh,63 + shr dh,1 ;divide seconds by two + shl al,1 ;move minutes over 2 bits + shl al,1 + mov cl,3 ;now move minutes & hours over 3 bits + shl ax,cl + or al,dh ;or the seconds/2 into the bottom 5 bits +; + pop dx ;restore the date info as the high word + ldptr bx,tloc,es ;get tloc +ifdef LONGPTR + mov cx,es + or cx,bx +else + test bx,bx +endif + jz done +ifdef LONGPTR + mov es:[bx],ax + mov es:2[bx],dx +else + mov ds:[bx],ax + mov ds:2[bx],dx +endif +done: + pret + pend time + finish + end + ttyio.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "errno.h" + +extern int errno; + +char _Eol = '\n'; +int _TTrem; /* # of bytes remaining in tty buffer */ + +__tty_rd(fd,buff,len) +char *buff; +{ + static char buffer[260], *bp; + register int l; + + if ((l = _TTrem) == 0) { + if ((l = _read(fd, buffer, 260)) != 0 && buffer[l-1]=='\n') { + --l; + buffer[l-1] = _Eol; + } + bp = buffer; + _TTrem = l; + } + if (l > len) + l = len; + if (l) + movmem(bp, buff, l); + bp += l; + _TTrem -= l; + return l; +} + +__tty_wr(fd, buff, len) +char *buff; +{ + register int count; + register char *cp; + static char crbuf = '\r'; + + cp = buff; + for (count = len ; count-- ; ) { + if (*cp++ == '\n') { + _write(fd, buff, cp-buff); + _write(fd, &crbuf, 1); + buff = cp; + } + } + if (cp != buff) + _write(fd, buff, cp-buff); + return len; +} + utime.c +/* Copyright (C) 1984 by Manx Software Systems */ + +struct utimbuf { + long actime; /* access time (not used on Msdos) */ + long modtime; /* modification time */ +}; + +utime(path, times) +char *path; register struct utimbuf *times; +{ + long time(), ftime(); + register int fd, r; + + if ((fd = open(path, 0)) == -1) + return -1; + r = ftime(1, fd, times ? times->modtime : time(0)); + close(fd); + return r; +} + wait.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef wait + mov ah,4dh + int 21h + jnc noerr + neg ax +noerr: + pret + pend wait + finish + end + syserr.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char *sys_errlist[] = { + /* MsDos error codes */ + "No error", + "Invalid function number", + "File not found", + "Path not found", + "Too many open files", + "Access denied", + "Bad file handle", + "Memory control blocks destroyed", + "Insufficient memory", + "Invalid memory block address", + "Invalid environment", + "Invalid format", + "Invalid access code", + "Invalid data", + "", + "Invalid drive", + "Attempt to remove the current directory", + "Not same device", + "No more files", + + /* additional codes for Aztec C */ + "File exists", + "Not a console device", + /* math library */ + "Result too large", + "Argument out of domain" +}; + +int sys_nerr = sizeof (sys_errlist) / sizeof (char *); + lbegin.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +codeseg segment para public 'code' + public $MEMRY + public _mbot_, _sbot_, _mtop_,_lowwater_ +dataseg segment para public 'data' +$MEMRY dw -1 + dw -1 + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 +_mbot_ dw 0,0 +_sbot_ dw 0,0 +_mtop_ dw 0,0 +_lowwater_ dw -1 + public _PSP_ +_PSP_ dw 0 + extrn _HEAPSIZ_:word,_STKSIZ_:word + extrn _STKLOW_:word,_STKRED_:word + extrn _Uorg_:byte,_Uend_:byte +dataseg ends +exitad dw 0 +exitcs dw 0 + + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg +ifdef FARPROC + extrn Croot_:far +else + extrn Croot_:near +endif + public $begin + public _exit_ +$begin proc far + mov bp,dataseg + test bp,bp + jnz notcom + mov ax,253 ; This CAN'T be a com file + jmp badexit +notcom: + mov exitcs,ds + mov es,bp + mov es:_PSP_,ds + mov bp,offset _Uend_ ; stack starts at Uend + add bp,15 ; round up to next paragraph + rcr bp,1 + mov cl,3 ; and convert to paragraph form + shr bp,cl + and bp,01fffh + mov dx,es ; add in datasegment base paragraph + add bp,dx + mov bx,es:_STKRED_ + shr bx,cl ;compute (2*STKRED)/16 note: cl==3 + cmp bx,es:_STKSIZ_ ;allocate either 2*STKRED or STKSIZ + jae ok1 + mov bx,es:_STKSIZ_ ;whichever is bigger +ok1: + cmp bx,1000h ; stack can't be bigger than 64K + jb ok2 + mov bx,1000h +ok2: + mov dx,bx + mov cl,4 + shl bx,cl + cli + mov ss,bp + mov sp,bx + sti +; + add dx,bp + inc dx + mov es:$MEMRY+2,dx ; and save as bottom of heap + mov es:$MEMRY,0 + mov es:_mbot_+2,dx ; and save as bottom of heap + mov es:_mbot_,0 +; now adjust heap size if necessary + mov bx,es:_HEAPSIZ_ + add bx,es:$MEMRY+2 ; add in base paragraph of heap + mov es:_mtop_+2,bx ; and save as top of heap + mov es:_mtop_,0 + mov si,ds + sub bx,si ; get size of total program in paragraphs + mov bp,es + mov es,si ; point es at PSP + mov ah,4ah + int 21h ; SETBLOCK to raise or lower allocation + jnc didheap + mov ax,254 + jmp badexit +didheap: + mov es,bp ; restore es to point at dataseg +; + cld +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + mov es,[2cH] ;get enviroment segment + sub di,di + mov cx,7fffH +arglook: + mov ah,es:byte ptr [di] + cmp ah,'=' ;look for null named env. string + je found_args + test ah,ah + jz no_args +repne scasb ;look for null byte + jz arglook +no_args: + mov si,ds + mov es,si + mov si,081h + mov di,080h + mov cl,[80h] + sub ch,ch + jcxz nomov +rep movsb +nomov: + sub al,al + stosb + mov ax,1 + mov di,080h + jmp short mov_args +; +found_args: + sub ax,ax + stosb ;zap and skip over '=' +mov_args: + push ax ; first arg # for Croot + push es + push di ; argp argument for Croot + mov es,bp + mov ds,bp ;set DS, now DS, SS, ES are equal + mov _dsval_,ds + mov _csval_,cs + mov ax,_STKRED_ + mov _sbot_,ax + call Croot_ ;Croot(argp, first) + jmp short exits +_exit_: + pop ax + pop ax ;fetch return code +ifdef FARPROC + pop ax +exit label far +else +exit: +endif +exits: +badexit: + mov ah,4cH + int 21H + jmp dword ptr exitad +$begin endp + +retip dw 0 +retcs dw 0 + + public $dbgentry +$dbgentry proc far + pop cs:retip + pop cs:retcs ; save return address into debugger + pop ds ;set DS + call caller + jmp dword ptr cs:retip ; return to debugger +$dbgentry endp + +caller proc + push di ;CS value of local function + push si ;IP value call local function + db 0cbH ;far return instruction +caller endp + +codeseg ends + end $begin + ssbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn _mtop_:word + extrn errno_:word + extrn _STKLOW_:word + extrn _STKRED_:word + extrn _PSP_:word +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + mov ax,siz + mov di,$MEMRY + test ax,ax + jge addok + sub di,ax + jc invalid + jmp short dobrk +addok: + add ax,di + jc invalid +dobrk: + push ax + call brk_ + pop cx + test ax,ax + jnz brk_error + mov ax,di ;return original value of the break +brk_error: + pop di + test ax,ax ;set flags for C + pret +invalid: + mov errno_,-8 + mov ax,-1 + jmp brk_error + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<> + mov ax,addr + inc ax + and al,-2 + cmp ax,_mbot_ + jb brk_ov + cmp _STKLOW_,0 + jne abovestk + mov bx,sp + sub bx,_STKRED_ + cmp ax,bx + jae brk_ov + mov $MEMRY,ax ;new value is good so save it away + add ax,_STKRED_ + mov _sbot_,ax ;save as new value for safety check +brk_ok2: + sub ax,ax + pret +;heap is above stack +abovestk: + cmp ax,_mtop_ + ja getstore + cmp ax,$MEMRY + jb getstore + mov $MEMRY,ax ;new value is good so save it away + jmp brk_ok2 +; going to do a SETBLOCK call +getstore: + push ax + mov bx,ax + mov cx,4 + shr bx,cl + and bx,0fffh + add bx,65 ;bump to nearest 1k increment + and bx,0ffc0h ;and round + push bx + push es + mov cx,ds + add bx,cx ;get actual paragraph address + mov es,_PSP_ + sub bx,_PSP_ + mov ah,04ah + int 21h ;SETBLOCK + pop es + pop bx + pop ax + jc brk_ov ; couldn't do it, so punt + mov $MEMRY,ax + test bx,0e000h + jnz brk_ov + mov cx,4 + shl bx,cl + mov _mtop_,bx + sub ax,ax + pret +; invalid request +brk_ov: + mov errno_,-8 + mov ax,-1 + test ax,ax + pret + pend brk +; +; rsvstk(size): set safety margin for stack +; this will make sure that at least size +; bytes of stack below the current level remain. +; + procdef rsvstk,<> + mov ax,sp + sub ax,stksize + mov _STKRED_,ax + pret + pend rsvstk + finish + end + lsbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn _mtop_:word + extrn errno_:word + extrn _PSP_:word +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + push si + mov ax,$MEMRY ; convert $MEMRY to 20-bit physical address + mov dx,$MEMRY+2 + mov si,ax + mov di,dx + mov cx,4 + rol dx,cl + mov bx,dx + and bx,0fff0h + and dx,0fh + add ax,bx + adc dx,0 + mov bx,siz ; load and check sign of size + cmp bx,0 + jge notneg + sub ax,bx + sbb dx,0 + js brk_error ; mustn't go negative + jmp canon +notneg: + add ax,bx + adc dx,0 + test dx,0fff0h + jnz brk_error ; mustn't overflow 20-bits +canon: + ror dx,cl + mov bx,ax + and ax,0fh + shr bx,cl + and bx,0fffh + or dx,bx + push dx + push ax + call brk_ + add sp,4 + test ax,ax + jnz brk_error + mov ax,si ;return original value of the break + mov dx,di + pop si + pop di + pret +brk_error: + pop si + pop di + mov dx,ax + pret + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<,> + push di + push si + mov ax,addr + inc ax + and al,-2 + mov dx,aseg + mov bx,ax ; convert to canonical pointer + mov cx,4 + shr bx,cl + and bx,0fffh + and ax,0fh + add dx,bx + cmp dx,_mtop_+2 + ja getstore + jne brk_ok2 + cmp ax,_mtop_ + jnb getstore +brk_ok2: + cmp dx,$MEMRY+2 + ja brk_ok3 + jne chkunder + cmp ax,$MEMRY + jnb brk_ok3 +chkunder: + cmp dx,_mbot_+2 + jb brk_ov + jne getstore + cmp ax,_mbot_ + jb brk_ov +getstore: +; going to do a SETBLOCK call + push ax + mov bx,dx + test ax,ax + jz nobump + inc bx +nobump: + add bx,63 ;bump to nearest 1k increment + and bx,0ffc0h ;and round + push es + push bx + mov cx,_PSP_ + mov es,cx ;set segment for SETBLOCK call + sub bx,cx ;and adjust length appropriately + mov ah,04ah + int 21h ;SETBLOCK + pop bx + pop es + pop ax + jc brk_ov ; couldn't do it, so punt + mov _mtop_+2,bx + mov _mtop_,0 +brk_ok3: + mov $MEMRY,ax + mov $MEMRY+2,dx + sub ax,ax + pop si + pop di + pret +; invalid request +brk_ov: + mov errno_,-4 + mov ax,-1 + test ax,ax + pop si + pop di + pret + pend brk + finish + end + clock.asm +; Copyright (C) 1985, 1986 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment word public 'data' +last dw 0,0 +dataseg ends + assume ds:dataseg + + procdef clock + mov ah,2ch + int 21h ; get time + mov al,100 + mul dh ;get seconds as hundredths into ax + sub dh,dh + add ax,dx ;add in hundredths + mov bx,ax ;save total hundredths + mov al,60 + mul ch ; get hours as mins into ax + sub ch,ch + add ax,cx ; add minutes to converted hours + mov cx,6000 + mul cx ; convert to hundredths of seconds + add ax,bx ; add in seconds+hundredths + adc dx,0 ; axdx now contains value in hunredths + cmp dx,word ptr last+2 + ja valok + jne clktrn + cmp ax,word ptr last + jae valok +clktrn: ; clock turned over since last call + add ax,0d600h + adc dx,083h ; add in 24 hours +valok: + mov word ptr last+2,dx + mov word ptr last,ax + pret + pend clock + finish + end + sigfix.asm +; Copyright (C) 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' + public _brkvec_ +_brkvec_ dw 0,0 +dataseg ends + + assume ds:dataseg +; +; This routine is used by exec (used by execl, execv, etc.) +; to reset any signal handlers which have been setup. +; + procdef _sigfix + cmp _brkvec_+2,0 + je brk_ok + push ds + lds dx,dword ptr _brkvec_ + mov ax,2523H ;restore old cntl-break handler + int 21H + pop ds +brk_ok: + pret + pend _sigfix + + finish + end + sighand.asm +; Copyright (C) 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' + extrn _PSP_:word + extrn _brkvec_:word +ifdef FARPROC + bss temp:word,4 ;used for far call to handler + global _sigfuns_:word,6*4 +else + global _sigfuns_:word,6*2 +endif +saveds dw 0 +dataseg ends + +ourds dw 0 + + assume ds:dataseg +; + procdef _sig_setup + mov ourds,ds + cmp _brkvec_+2,0 + jne have_brk + push ds + mov ax,3523H ;get cntl-break (cntl-c) handler + int 21H + mov _brkvec_,bx + mov _brkvec_+2,es + mov dx,offset brk_handler + mov ax,cs + mov ds,ax + mov ax,2523H ;set new cntl-break handler + int 21H + pop ds +have_brk: + pret + pend _sig_setup + +brk_handler proc far + push ds + mov ds,ourds +ifdef FARPROC + cmp _sigfuns_+2,0 + jne chk_ignore + cmp _sigfuns_,0 + jne chk_ignore +else + cmp _sigfuns_,0 + jne chk_ignore +endif + + pop saveds ;get ds from the stack + push _brkvec_+2 + push _brkvec_ + mov ds,saveds + ret + +chk_ignore: +ifdef FARPROC + cmp _sigfuns_,1 + jne not_ignore + cmp _sigfuns_+2,0 + je ignore +not_ignore: +else + cmp _sigfuns_,1 + je ignore +endif + cld + push es + push ax + push bx + mov ax,sp + mov bx,ss + mov es,_PSP_ + mov ss,es:[30h] ;get our last ss:sp from place + mov sp,es:[2eh] ;where DOS saves it + push ax + push bx + push cx + push dx + push si + push di + mov ax,1 ;signal #1 + push ax +ifdef FARPROC + mov ax,_sigfuns_+2 + mov temp+2,ax + mov ax,_sigfuns_ + mov temp,ax + mov _sigfuns_,0 ;set SIG_DFL + mov _sigfuns_+2,0 + sti + call dword ptr temp +else + mov ax,_sigfuns_ + mov _sigfuns_,0 ;set SIG_DFL + sti + call ax +endif + pop ax ;throw away argument + pop di + pop si + pop dx + pop cx + pop bx + pop ax + mov ss,bx ;restore to system stack + mov sp,ax + pop bx + pop ax + pop es + +ignore: + pop ds + iret +brk_handler endp + finish + end + signal.c +#include +#include + +extern void (*_sigfuns[_NUMSIG])(); +static char setup; + +void (*signal(sig, func))() +register int sig; void (*func)(); +{ + register void (*retval)(); + + if (!setup) { + _sig_setup(); + setup = 1; + } + if ((sig -= _FSTSIG) < 0 || sig >= _NUMSIG) { + errno = EINVAL; + return SIG_ERR; + } + retval = _sigfuns[sig]; + _sigfuns[sig] = func; + return retval; +} + sys.asm +;Copyright (C) 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + + procdef _sys,<,,> + mov ax,func + test ah,ah + jnz valok + xchg ah,al +valok: + cmp ah,10 + jb simple +; + push si + pushds + push es + cmp ah,47H ;check for getcwd call + jne not_cwd + mov dx,arg2 ;load drive # into DX + ldptr si,arg,ds + jmp short issue +not_cwd: + mov cx,arg2 + ldptr dx,arg,ds +issue: + int 21H + mov dx,es + pop es + popds + jnc noerror + mov errno_,ax + mov ax,-1 + mov dx,ax +noerror: + pop si + pret +; +simple: + mov dx,word ptr arg + int 21H + and ax,0ffH + pret + pend _sys + finish + end + monitor.c +short monitor (lowpc, highpc, buffer, pockets, nfunc) +int (*lowpc)(), (*highpc)(); +unsigned int *buffer; +int pockets, nfunc; +{ + return _monitor(lowpc,highpc,buffer,pockets,nfunc); +} + profil.c +void profil (buff, bufsiz, offset, scale) +char *buff; +int bufsiz; +int (*offset)(); +int scale; +{ + + _profil(buff, bufsiz, offset, scale); + + return; +} + mon.c + +#include + +short _mon_off; +unsigned _speed = 0; +long _ticks=0; +extern int errno; +extern int _Corg(), _Cend(); + +#define high(x) ((unsigned long)(x)) +#define low(x) ((unsigned long)(x) & 0x0000ffffl) +#define canon(x) (int (*)())(((high(x) >> 12)&0x000fffffl) + low(x)) + +static struct { + short pockets; + short byte_pock; + long lowpc; + long highpc; + int speed; + long time; +} mon_head; + +void _profil(); + +short _monitor (lowpc, highpc, buffer, pockets, nfunc) +int (*lowpc)(), (*highpc)(); +unsigned int *buffer; +int pockets, nfunc; +{ + register int i; + static short pro_flag; + static unsigned int *buff_add, oldsig; + unsigned long tot_bytes, left_over, org; + unsigned int bytes, scale; + int exit(); + FILE *fopen(), *fp; + int (*slowpc)(); + +/* + * offset = lowpc; + * tot_bytes = highpc - lowpc + * range mod pockets = bytes left over + * if (bytes left over) + * pockets * (bytes in range +1) > range + */ + + if (pro_flag) + { + + /*check to see if profiling was turned off by overflow*/ + + if (_mon_off) { + printf ("Bucket number %d overflowed\n", _mon_off); + _mon_off = 0; + } + else + _clkrest(); + + pro_flag = 0; + mon_head.time = _ticks; + if ((fp = fopen ("mon.out", "w")) == NULL) + return (errno); + if ((fwrite (&mon_head, sizeof(mon_head), 1, fp)) != 1) { + printf("\nfunction monitor: error trying to write header data\n"); + fclose (fp); + return(errno); + } + for (i=0; i 121) { + _speed = 9861; + mon_head.speed = 121; + } else if (sp <= 0) { + _speed = 0; + mon_head.speed = 18; + } else { + _speed = DIVSOR / sp; + mon_head.speed = sp; + } +} + clk.asm + +;:ts=8 +;Copyright (C) 1985 by Manx Software Systems, Inc. +; +; IBM PC Clock Support routines +; + include lmacros.h +; +; divsor for 121 Hz clock is 9861 dec. +; hex value 0x4DE0 will give exactly 60 inters. per second + codemacro killtime + db 0EBH + db 0 + endm + +INTVEC equ 20h ;location of interrupt vector for clock +TIMER equ 40h +CNTRL equ 43h +EXITVEC equ 88h +TIME_LOW equ 61 +TIME_HIGH equ 98 +TIMES equ 6 + +dataseg segment para public 'data' + +reset_ct db TIMES +scale dw 0 +ifdef LONGPTR +buff_add dd 0 +else +buff_add dw 0 +endif +buf_size dw 0 +ifdef FARPROC +ofset dd 0 +else +ofset dw 0 +endif + extrn _mon_off_:word + extrn _speed_:word + extrn _ticks_:word + extrn _PSP_:word + +dataseg ends + +data_add dw ? ;codesegment variable for location of dataseg in 'C' +clk_ipvec dw ? ;memory location of the stored clock int vector's ip +clk_csvec dw ? ;memory location of the stored clock int vector's cs + +;memory location of all the int vectors on how to exit a program +int22_ip dw ? ;memory location of the stored int 22 vector's ip +int22_cs dw ? ;memory location of the stored int 22 vector's cs + +;memory location of all the int vectors in the PSP +PSP_ip dw ? ;memory location of the stored PSP int 22 vector's ip +PSP_cs dw ? ;memory location of the stored PSP int 22 vector's cs + + assume cs:codeseg, ds:dataseg + + procdef _clkinit,<,,,> + push es ;get args. off stack for later use + mov ax,word ptr ibufad + mov word ptr buff_add,ax +ifdef LONGPTR + mov ax,word ptr ibufad+2 + mov word ptr buff_add+2,ax +endif + mov ax,ibufsz + mov buf_size,ax +ifndef FARPROC + mov ax,word ptr iofset + mov ofset,ax +else + push cx + mov cx,4 + mov ax,word ptr iofset + mov dx,word ptr 2+iofset ;convert to physical address + rol dx,cl + mov bx,dx + and dx,0fh + and bx,0fff0h + add ax,bx + adc dx,0 + mov word ptr ofset,ax + mov word ptr ofset+2,dx + pop cx +endif + mov ax,iscl + mov scale,ax + + sub ax,ax + mov es,ax + mov ax, es:[INTVEC] ;save contents of interupt table + mov cs:clk_ipvec, ax + mov ax,es:[INTVEC+2] ;ditto + mov cs:clk_csvec,ax + mov ax, es:[EXITVEC] ;save contents of interupt table + mov cs:int22_ip, ax + mov ax,es:[EXITVEC+2] ;ditto + mov cs:int22_cs,ax + mov es,_PSP_ ;save contents of the PSP + mov ax,es:[0ah] + mov cs:PSP_ip,ax + mov ax,es:[0ch] + mov cs:PSP_cs,ax + cli + xor ax,ax + mov es,ax + mov es:[INTVEC],offset intsr ;insert the address of int. handler + mov es:[INTVEC+2],cs + mov cs:data_add,ds ;mov 'C' dataseg address to var. + mov es:[EXITVEC],offset int_22 ;insert the address of int. handler + mov es:[EXITVEC+2],cs + mov es,_PSP_ + mov es:[0ah], offset int_22 ;move handler into PSP + mov es:[0ch], cs + sti + xor ax,ax + mov al,36h ;use mode 3 for timer 0 + cli + out CNTRL,al + killtime + mov ax,word ptr _speed_ + out TIMER,al ; + killtime + mov al,ah + out TIMER,al + killtime + sti + sub ax,ax + mov _speed_,ax + pop es + pret + pend _clkinit + + + procdef _clkrest + push es + sub ax,ax + + cli + mov al,36h ;use mode 3 for timer 0 + out CNTRL,al + killtime + mov al,0h ;load low byte + out TIMER,al ;restore to 18.2 intrs. per second + killtime + out TIMER,al + + sub ax,ax + mov es,ax + mov ax, cs:clk_ipvec ;restore interupt vec. table + mov es:[INTVEC], ax + mov ax, cs:clk_csvec ;restore interupt vec. table + mov es:[INTVEC+2],ax + mov ax, cs:int22_ip ;restore interupt vec. table + mov es:[EXITVEC], ax + mov ax, cs:int22_cs ;restore interupt vec. table + mov es:[EXITVEC+2],ax + mov es,_PSP_ ;restore the PSP + mov ax,cs:PSP_ip + mov es:[0ah],ax + mov ax,cs:PSP_cs + mov es:[0ch],ax + + sti + pop es + pret + pend _clkrest + +int_22: + sti + push ax + push dx + push es + push ds + call _clkrest_ + pop ds + pop es + pop dx + mov al,020h ;send EOI to 8259 + out 020h,al + pop ax + jmp dword ptr cs:int22_ip + +intsr: + sti + push bp + mov bp,sp + push ds + push si + push ax + push bx + push dx + mov ds,cs:data_add + + add word ptr _ticks_,1 ;get total number of interupts + adc word ptr _ticks_+2,0 +ifndef FARPROC + mov ax,word ptr 4[bp] ;get cs value in interrupted code + mov dx,cs + cmp ax,dx ;compare with current cs + jne quit ;if not = punt + mov ax,word ptr 2[bp] ;get ip value in interrupted code + sub ax,ofset ;sub ofset (lowpc) from ip + jb quit ;if negative punt + cmp scale,1 + jz nodiv + xor dx,dx + div scale ;div. by scale factor done in monitor +else + mov ax,ss:word ptr 2[bp] ;get ip value in interrupted code + mov dx,ss:word ptr 4[bp] ;get cs value in interrupted code + rol dx,1 + rol dx,1 + rol dx,1 + rol dx,1 + mov bx,dx + and dx,0fh + and bx,0fff0h + add ax,bx + adc dx,0 ;convert to physical address + sub ax,word ptr ofset + sbb dx,word ptr ofset+2 + jb quit ;if beyond bottom of range,punt + cmp dx,word ptr scale + jge quit ;if divide will overflow,punt + cmp word ptr scale,1 + jz nodiv ;skip divide if index is good as is + div word ptr scale +endif +nodiv: + cmp ax,buf_size ;check to see if out of buff + ja quit ;if out of range punt + shl ax,1 ;shift to get on a word boundary + mov si,ax + ldptr bx,buff_add,ds + add ds:word ptr [bx][si],1 ;else increment word + jnc quit ;check to see if we overflowed a bucket + sub ds:word ptr 0[bx][si],1 +ifdef LONGPTR + mov ds,cs:data_add +endif + call _clkrest_ + sub ax,ax + mov ax,si + mov _mon_off_,ax +quit: +ifdef LONGPTR + mov ds,cs:data_add +endif + dec reset_ct + jz time_out + pop dx + pop bx + pop ax + pop si + pop ds + pop bp + push ax + mov al,020h ;send EOI to 8259 + out 020h,al + pop ax + iret +time_out: + mov reset_ct,TIMES + pop dx + pop bx + pop ax + pop si + pop ds + pop bp + jmp dword ptr cs:clk_ipvec + finish + end + dosdir.c +#include "model.h" + +#define SETDMA 26 +#define SRCHFIR 0x4e +#define SRCHNXT 0x4f + +char * +scdir(pat) +char *pat; +{ + register char *cp, *np; + char *index(); + static int code = SRCHFIR; + static char nambuf[64], *tail; + static struct { + char reserve[21]; + char attr; + long mtime; + long fsize; + char name[13]; + } srchbuf; + + if (code == SRCHFIR) { + if (index(pat, '*') == 0 && index(pat, '?') == 0) { + code = 0; + return pat; + } + + strncpy(nambuf, pat, 64); + for (cp = tail = nambuf ; cp < &nambuf[64] && *cp ; ++cp) + if ((tail == nambuf && *cp == ':') || *cp == '/' || *cp == '\\') + tail = cp+1; + } + +#ifdef _LARGEDATA + bdosx(SETDMA, &srchbuf); + if (code == 0 || dosx(code, 0, -1, pat) == -1) { +#else + bdos(SETDMA, &srchbuf); + if (code == 0 || dos(code, 0, -1, pat) == -1) { +#endif + code = SRCHFIR; + return (char *)0; + } + code = SRCHNXT; + + np = tail; + cp = srchbuf.name; + while (*np++ = tolower(*cp++)) + ; + return nambuf; +} + bdosx.asm +;Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef bdosx,<,,,> + push es + push ds + mov ax,func + test ah,ah + jnz valok + xchg ah,al +valok: + mov dx,dxval + mov cx,cxval + push dsval + pop ds + int 21H + mov dx,es + pop ds + pop es + and ax,0ffH + pret + pend bdosx + finish + end + dosx.asm +; Copyright (C) 1983, 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef dosx,<,,,,,,> +; dosx(ax,bx,cx,dx,es,di,si) + push di + push si +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + push ds + mov ax,func + test ah,ah + jnz skip + xchg ah,al +skip: + mov bx,bxval + mov cx,cxval + mov dx,dxval + mov di,dival + mov si,sival + push dsval + pop ds + int 21H + pop ds + jnc ret_ok + mov errno_,ax + mov ax,-1 +ret_ok: + pop si + pop di + pret + pend dosx + finish + end + stkover.c + +_stkover() +{ + write(2, "STACK OVERFLOW, INCREASE STACK SIZE\n", 36); + _exit(100); +} + filelock.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef filelock, <,,,> + push si + push di + mov ah,5ch + mov al,byte ptr flag + mov bx,fd + mov cx,word ptr pos+2 + mov dx,word ptr pos + mov si,word ptr len+2 + mov di,word ptr len + int 21h + pop di + pop si + jnc retok + mov ds:errno_,ax + mov ax,-1 + pret +retok: + sub ax,ax + pret + pend filelock + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/G.ARC b/Manx Aztec C86 v340a/SRC/G.ARC new file mode 100644 index 0000000..afc4fa7 --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/G.ARC @@ -0,0 +1,855 @@ + mode.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ + +extern int _maxx; +extern int _xaspect, _yaspect; +extern char _color; +extern int _plotf,_plottbl[]; + +mode (val) +{ + switch (val) { + case 'l': case 'L': case 3: + scr_call (3); + break; + case 'm': case 'M': case 4: + _plotf = _plottbl[0]; + _xaspect = 6; + _yaspect = 5; + _maxx = 319; + scr_call (4); + break; + case 'h': case 'H': case 6: + _plotf = _plottbl[1]; + _xaspect = 4; + _yaspect = 1; + _maxx = 639; + scr_call (6); + break; + default: + if (val < 0 || val > 6) + return; + scr_call (val); + break; + } +} + +color (c) +{ + switch (c) { + case 'w': case 'W': case 'y': case 'Y': case 3: + _color = 3; + break; + case 'm': case 'M': case 'r': case 'R': case 2: + _color = 2; + break; + case 'c': case 'C': case 'g': case 'G': case 1: + _color = 1; + break; + default: + _color = 0; + break; + } +} + +palette (c) +{ + if (c) + scr_call (11 << 8,1<<8 | 1,0,0); + else + scr_call (11 << 8,1<<8 | 0,0,0); +} + +ground (c) +{ + scr_call (11 << 8, 0 << 8 | c,0,0); +} + address.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + + public $address + +$address equ this word ;/* vertical address table */ + dw 7920+8192 + dw 7920 + dw 7840+8192 + dw 7840 + dw 7760+8192 + dw 7760 + dw 7680+8192 + dw 7680 + dw 7600+8192 + dw 7600 + dw 7520+8192 + dw 7520 + dw 7440+8192 + dw 7440 + dw 7360+8192 + dw 7360 + dw 7280+8192 + dw 7280 + dw 7200+8192 + dw 7200 + dw 7120+8192 + dw 7120 + dw 7040+8192 + dw 7040 + dw 6960+8192 + dw 6960 + dw 6880+8192 + dw 6880 + dw 6800+8192 + dw 6800 + dw 6720+8192 + dw 6720 + dw 6640+8192 + dw 6640 + dw 6560+8192 + dw 6560 + dw 6480+8192 + dw 6480 + dw 6400+8192 + dw 6400 + dw 6320+8192 + dw 6320 + dw 6240+8192 + dw 6240 + dw 6160+8192 + dw 6160 + dw 6080+8192 + dw 6080 + dw 6000+8192 + dw 6000 + dw 5920+8192 + dw 5920 + dw 5840+8192 + dw 5840 + dw 5760+8192 + dw 5760 + dw 5680+8192 + dw 5680 + dw 5600+8192 + dw 5600 + dw 5520+8192 + dw 5520 + dw 5440+8192 + dw 5440 + dw 5360+8192 + dw 5360 + dw 5280+8192 + dw 5280 + dw 5200+8192 + dw 5200 + dw 5120+8192 + dw 5120 + dw 5040+8192 + dw 5040 + dw 4960+8192 + dw 4960 + dw 4880+8192 + dw 4880 + dw 4800+8192 + dw 4800 + dw 4720+8192 + dw 4720 + dw 4640+8192 + dw 4640 + dw 4560+8192 + dw 4560 + dw 4480+8192 + dw 4480 + dw 4400+8192 + dw 4400 + dw 4320+8192 + dw 4320 + dw 4240+8192 + dw 4240 + dw 4160+8192 + dw 4160 + dw 4080+8192 + dw 4080 + dw 4000+8192 + dw 4000 + dw 3920+8192 + dw 3920 + dw 3840+8192 + dw 3840 + dw 3760+8192 + dw 3760 + dw 3680+8192 + dw 3680 + dw 3600+8192 + dw 3600 + dw 3520+8192 + dw 3520 + dw 3440+8192 + dw 3440 + dw 3360+8192 + dw 3360 + dw 3280+8192 + dw 3280 + dw 3200+8192 + dw 3200 + dw 3120+8192 + dw 3120 + dw 3040+8192 + dw 3040 + dw 2960+8192 + dw 2960 + dw 2880+8192 + dw 2880 + dw 2800+8192 + dw 2800 + dw 2720+8192 + dw 2720 + dw 2640+8192 + dw 2640 + dw 2560+8192 + dw 2560 + dw 2480+8192 + dw 2480 + dw 2400+8192 + dw 2400 + dw 2320+8192 + dw 2320 + dw 2240+8192 + dw 2240 + dw 2160+8192 + dw 2160 + dw 2080+8192 + dw 2080 + dw 2000+8192 + dw 2000 + dw 1920+8192 + dw 1920 + dw 1840+8192 + dw 1840 + dw 1760+8192 + dw 1760 + dw 1680+8192 + dw 1680 + dw 1600+8192 + dw 1600 + dw 1520+8192 + dw 1520 + dw 1440+8192 + dw 1440 + dw 1360+8192 + dw 1360 + dw 1280+8192 + dw 1280 + dw 1200+8192 + dw 1200 + dw 1120+8192 + dw 1120 + dw 1040+8192 + dw 1040 + dw 960+8192 + dw 960 + dw 880+8192 + dw 880 + dw 800+8192 + dw 800 + dw 720+8192 + dw 720 + dw 640+8192 + dw 640 + dw 560+8192 + dw 560 + dw 480+8192 + dw 480 + dw 400+8192 + dw 400 + dw 320+8192 + dw 320 + dw 240+8192 + dw 240 + dw 160+8192 + dw 160 + dw 80+8192 + dw 80 + dw 0+8192 + dw 0 + +dataseg ends + +codeseg segment para public 'code' + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg +codeseg ends + end + circ.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + +aldx dw 0 +aldy dw 0 + + public _yaspect_,_xaspect_ +_yaspect_ dw 5 +_xaspect_ dw 6 + +scale dw 1024 +scale2 dw 512 + + +aspect dw 0 ;function computed aspect (scaled) +invasp dw 0 ;reciprocal of aspect (scaled too) + +xorg dw 0 +yorg dw 0 +radius dw 0 + +dataseg ends + + assume ds:dataseg,cs:codeseg +;-------------------------------------------------------- +;procedure circle(x,y,radius) +; +;draws a circle at center (x,y) with aspect ratio +;yaspect/xaspect; radius in column units +; +;Dan Lee 7/1/1982 SourceWare +;Modified from DDJ May '83 for CI C-86 by Davin 6/22/1983 +;remodified for Aztec C86, 6/84 +; +;-------------------------------------------------------- +ifdef FARPROC + extrn $inline:far,$pnt:far +else + extrn $inline:near,$pnt:near +endif + procdef set_asp,<,> + ;set_asp (x_aspect, y_aspect); + mov ax, x_asp + mov [_xaspect_],ax + mov ax, y_asp + mov [_yaspect_],ax + pret + pend set_asp + + procdef circle,<<_xorg,word>,<_yorg,word>,> + + mov cx,_xorg + mov [xorg],cx + mov dx,_yorg + mov [yorg],dx + mov ax,irad + pop bp + push es + push si + push di ;save register variables + or ax,ax + jnz okrad + jmp single +okrad: mov [radius],ax + mov ax,_yaspect_ ;get yaspect + mul [scale] ;ax=yaspect*scale + shl ax,1 + div _xaspect_ ;ax=(yaspect*scale)/xaspect + inc ax + shr ax,1 + mov [aspect],ax ;store aspect*scale + mov ax,_xaspect_ ;get xaspect in ax + mul [scale] ;ax=xaspect*scale + shl ax,1 + div _yaspect_ ;ax=(xaspect*scale)/yaspect + inc ax + shr ax,1 + mov [invasp],ax ;store inv aspect*scale +; +; Plot 0 to 45 degrees. +; Increase y by one unit and +; decrease x by TAN units*inv aspect ratio. +; + mov ax,[radius] ;get radius for initial x + mul [scale] ;ax=radius*scale + xor di,di ;zero initial y value + +nlp1: push ax ;save lo word x*scale + push dx ;save hi word x*scale + add ax,[scale2] + adc dx,0 + div [scale] + mov [aldx],ax ; aldx,aldy are old relative coord's + mov [aldy],di + pop dx + pop ax + +lp1: push ax ;save lo word x*scale + push dx ;save hi word x*scale + add ax,[scale2] + adc dx,0 + div [scale] + mov bx,ax ;bx=1st quad x + add ax,[xorg] ;add x origin + + push bp + push di ;relative y-coord + push bx ;relative x-coord + mov bp,sp + mov bx,[yorg] ;get y origin + sub bx,di ;and sub y to plot + call near ptr pnt1 + pop cx ;1st quad x val + pop di + mov [aldx],cx + mov [aldy],di + pop bp + +;cx = 1st quad x, di = 1st quad y + inc di ;get new y + mov ax,di ;ax=y + mul [invasp] ;ax=y*inv aspect*scale + div cx ;ax=TAN*inv aspect*scale + xor dx,dx ;zero remainder + mov si,ax ;si=TAN*inv aspect*scale + div [invasp] ;ax=TAN + cmp ax,1 ;TAN=1? + pop dx ;dx=hi word x*scale + pop ax ;ax=lo word x*scale + jae part2 ;yes, go to next sector + neg si ;to decrement x + add ax,si ;new x value + adc dx,-1 ;hi word carry + jmp short lp1 ;plot new point +; +; Plot 45 to 90 degrees. +; Decrease x by one unit and +; increase y by COT units*aspect ratio. +; +part2: mov ax,di ;get next y to plot + mul [scale] ;dx:ax=y*scale + mov di,cx ;di=last x value + dec di ;next x to plot +lp2: push ax ;save lo word y*scale + push dx ;save hi word y*scale + add ax,[scale2] ;'one-half' + adc dx,0 + div [scale] ;ax=y + mov bx,ax ;bx=1st quad y co-ord + + add ax,[yorg] ;add y origin + mov cx,[xorg] ;cx=x origin + add cx,di ;x to plot + + push bp + push bx + push di + mov bp,sp + mov bx,ax + mov ax,cx + call near ptr pnt2 + pop di + pop bx + mov [aldx],di + mov [aldy],bx + pop bp + + or di,di ;90 degrees? + js exit ;yes, exit + dec di ;get new x + mov ax,di ;ax=x + imul [aspect] ;ax=x*aspect*scale + idiv bx ;ax=COT*aspect*scale + mov si,ax ;si=change in y + pop dx ;dx=hi word y*scale + pop ax ;ax=lo word y*scale + xor bx,bx + or si,si ;for sign check + jns skp ;positive + mov bx,-1 ;negative carry +skp: add ax,si ;ax=new x value + adc dx,bx + jmp short lp2 ;plot next point + +exit: add sp,4 ;release parms + jmp alldone + +pnt1 proc near +;bp points to rel x coord and bp+2 points to rel y coord +;abs coords of point are in ax,bx + + mov si,[aldx] + add si,[xorg] ;si is old abs x + mov di,[yorg] + mov cx,[aldy] + sub di,cx ;di is old abs y + + call near ptr $goinline ;write 1st quad point + sub ax,word ptr [bp] ;get 2nd quad x+origin + sub ax,word ptr [bp] + sub si,[aldx] + sub si,[aldx] + call near ptr $goinline ;write 2nd quad point + add bx,word ptr 2[bp] ;get 3rd quad y+origin + add bx,word ptr 2[bp] + add di,[aldy] + add di,[aldy] + call near ptr $goinline ;write 3rd quad point + add ax,word ptr [bp] + add ax,word ptr [bp] ;get 4th quad x+origin + add si,[aldx] + add si,[aldx] + call near ptr $goinline ;plot 4th quad point + ret +pnt1 endp + +pnt2 proc near + mov si,[aldx] + add si,[xorg] + mov di,[yorg] + add di,[aldy] + + call near ptr $goinline ;write 1st quad point + sub ax,word ptr [bp] ;get 2nd quad x+origin + sub ax,word ptr [bp] + sub si,[aldx] + sub si,[aldx] + call near ptr $goinline ;write 2nd quad point + sub bx,word ptr 2[bp] ;get 3rd quad y+origin + sub bx,word ptr 2[bp] + sub di,[aldy] + sub di,[aldy] + call near ptr $goinline ;write 3rd quad point + add ax,word ptr [bp] + add ax,word ptr [bp] ;get 4th quad x+origin + add si,[aldx] + add si,[aldx] + call near ptr $goinline ;plot 4th quad point + ret +pnt2 endp + +single: + mov si,cx + mov di,dx + call $pnt +alldone: + pop di + pop si + pop es + push bp + pret circle + +$goinline proc near + push ax + push bx + push si + push di + call $inline ;pops es,di,si + pop di + pop si + pop bx + pop ax + ret +$goinline endp + + pend circle + finish + end + lin.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + + extrn _oldx_:word, _oldy_:word + +deltax dw 0 +deltay dw 0 +yincr dw 0 + +dataseg ends + assume ds:dataseg,cs:codeseg +ifdef FARPROC + extrn $pnt:far +else + extrn $pnt:near +endif + + public $inline +$inline proc + cmp si,ax + jbe noxchg + xchg si,ax + xchg di,bx +noxchg: + jne novert + jmp vertical +novert: + sub ax,si + mov [deltax],ax + sub bx,di + jnz nohoriz + jmp horizontal +nohoriz: + mov cx,1 + jns notneg + neg cx + neg bx +notneg: mov [yincr],cx + mov [deltay],bx + cmp ax,bx + jg case2 + + mov dx,[deltax] + shl dx,1 + mov bx,dx + mov ax,[deltay] + shl ax,1 + sub bx,ax + mov ax,dx + sub ax,[deltax] + + mov cx,[deltay] +lp1: dec cx + js done + call $pnt + add di,[yincr] + cmp ax,0 + jl incr1 + inc si + add ax,bx + jmp short lp1 +incr1: + add ax,dx + jmp short lp1 + +case2: + + mov dx,[deltay] + shl dx,1 ;dx <- 2 * deltay + mov bx,dx + mov ax,[deltax] + shl ax,1 + sub bx,ax ;bx <- 2*deltay - 2 * deltax + mov ax,dx + sub ax,[deltax] ;ax <- 2*deltay - deltax + + mov cx,[deltax] +lp2: dec cx + js done + call $pnt + inc si + cmp ax,0 + jl incr2 + add di,[yincr] + add ax,bx + jmp short lp2 +incr2: + add ax,dx + jmp short lp2 + +vertical: ;si = xval, di,bx = yvals + cmp di,bx + jle yorder + xchg bx,di +yorder: + sub bx,di +vplot: + call $pnt + inc di + dec bx + jns vplot + jmp short done + +horizontal: ;ax=deltax, si,di = start point + call $pnt + inc si + dec ax + jns horizontal + ;jmp short done + +done: + ret + + procdef lineto,<,> + + ; lineto (dest_x, dest_y); + push si + push di + push es + mov si,[_oldx_] + mov di,[_oldy_] + mov ax,xdest + mov bx,ydest + mov [_oldx_],ax + mov [_oldy_],bx + call $inline ;pops si,di,es before returning + pop es + pop di + pop si + pret + pend lineto + + procdef line,<,,,> + ; line (src_x, src_y, dest_x, dest_y); + push si + push di + push es + mov si,srcx + mov di,srcy + mov ax,ddstx + mov bx,ddsty + mov [_oldx_],ax + mov [_oldy_],bx + call $inline + pop es + pop di + pop si + pret + pend line + finish + end + + point.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + + extrn $address:word + public _oldx_,_oldy_,_color_,_maxx_ + _oldx_ dw 0 + _oldy_ dw 0 + _color_ db 1 + _maxx_ dw 320 + public _plotf_, _plottbl_ + public mid,ultra + public clrmsk,colmsk + +clrmsk db 00111111b,11001111b,11110011b,11111100b + ;/* clrmsk for point mode 0 */ + +onmask db 10000000b,1000000b,100000b,10000b,1000b,100b,10b,1b +offmask db 01111111b,10111111b,11011111b,11101111b + db 11110111b,11111011b,11111101b,11111110b + +colmsk db 0,0,0,0 ;/* color_ masks */ + db 1000000b,10000b,100b,1 + db 10000000b,100000b,1000b,10b + db 11000000b,110000b,1100b,11b + +_plottbl_ dw offset mid ;medium res + dw offset ultra ;high res + +_plotf_ dw offset ptquit + +dataseg ends + assume ds:dataseg,cs:codeseg + + public $pnt +$pnt proc + cmp si,[_maxx_] ;si=x,di=y does not set oldx & oldy + ja quit + cmp si,0 + jb quit + cmp di,199 + ja quit + cmp di,0 + jnb $pnt3 + jmp quit +$pnt3: + push ax + push bx + mov bl,[_color_] ;entry #3 si=x,di=y no clipping ! +$pnt4: + mov bh,0 +;entry #5 si=x,di=y,bx=color_ +; +$pnt5: mov ax,0b800h ; set es to point to hires segment + mov es,ax + push di + shl di,1 ;mult y*2 (addr table is 2 bytes wide) + jmp [_plotf_] ;jmp to ptquit, mid or ultra + +mid: push si + + mov di,$address[di] ;get vert address from table + + mov ax,si ;save x in si + + and si,3 + shr ax,1 ;divide by 4 (4 dots per byte) + shr ax,1 + + add di,ax ;get addr of byte on screen + + sal bl,1 ; color_ table is 4 by 4 so mult color_ * 4 + sal bl,1 + mov bl,colmsk[si+bx] + mov al,clrmsk[si] + and es:[di],al + or es:[di],bl + pop si +ptquit: pop di + pop bx + pop ax +quit: + ret + +ultra: mov di,$address[di] + mov ax,si + push si + and si,7 + shr ax,1 + shr ax,1 + shr ax,1 + add di,ax + or bl,bl + jz black + mov al,onmask[si] + or es:[di],al + pop si + jmp short ptquit +black: mov al,offmask[si] + and es:[di],al + pop si + jmp short ptquit + + + procdef point,<,> + + push si + push di + push es + mov si,4[bp] + mov di,6[bp] + + mov [_oldx_],si ;si=x,di=y sets oldx and oldy + mov [_oldy_],di + call $pnt + + pop es + pop di + pop si + pret + pend point + finish + end + + scr_call.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef scr_call,<,,,> + ; scr_call (ax,bx,cx,dx) + push si + push di + mov ax, aax + mov bx, bbx + mov cx, ccx + mov dx, ddx + int 16 + pop di + pop si + xor ax,ax + pret + pend scr_call + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/MATH.ARC b/Manx Aztec C86 v340a/SRC/MATH.ARC new file mode 100644 index 0000000..0e9dc1f --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/MATH.ARC @@ -0,0 +1,4546 @@ + asin.c +#include "math.h" +#include "errno.h" + +double arcsine(); + +double asin(x) +double x; +{ + return arcsine(x,0); +} + +double acos(x) +double x; +{ + return arcsine(x,1); +} + +#define P1 -0.27368494524164255994e+2 +#define P2 +0.57208227877891731407e+2 +#define P3 -0.39688862997504877339e+2 +#define P4 +0.10152522233806463645e+2 +#define P5 -0.69674573447350646411 +#define Q0 -0.16421096714498560795e+3 +#define Q1 +0.41714430248260412556e+3 +#define Q2 -0.38186303361750149284e+3 +#define Q3 +0.15095270841030604719e+3 +#define Q4 -0.23823859153670238830e+2 + +#define P(g) ((((P5*g P4)*g P3)*g P2)*g P1) +#define Q(g) (((((g Q4)*g Q3)*g Q2)*g Q1)*g Q0) + +double arcsine(x,flg) +double x; +{ + double y, g, r; + register int i; + extern int errno; + static double a[2] = { 0.0, 0.78539816339744830962 }; + static double b[2] = { 1.57079632679489661923, 0.78539816339744830962 }; + + y = fabs(x); + i = flg; + if (y < 2.3e-10) + r = y; + else { + if (y > 0.5) { + i = 1-i; + if (y > 1.0) { + errno = EDOM; + return 0.0; + } + g = (0.5-y)+0.5; + g = ldexp(g,-1); + y = sqrt(g); + y = -(y+y); + } else + g = y*y; + r = y + y* + ((P(g)*g) + /Q(g)); + } + if (flg) { + if (x < 0.0) + r = (b[i] + r) + b[i]; + else + r = (a[i] - r) + a[i]; + } else { + r = (a[i] + r) + a[i]; + if (x < 0.0) + r = -r; + } + return r; +} + atan.c +#include "math.h" +#include "errno.h" + +#ifdef MPU8086 +#define MAXEXP 1024 +#define MINEXP -1023 +#else +#define MAXEXP 504 +#define MINEXP -512 +#endif + +#define PI 3.14159265358979323846 +#define PIov2 1.57079632679489661923 + +double atan2(v,u) +double u,v; +{ + double f, frexp(); + int vexp, uexp; + extern int flterr; + extern int errno; + + if (u == 0.0) { + if (v == 0.0) { + errno = EDOM; + return 0.0; + } else if (v > 0.0 ) + return PIov2; + return -PIov2; + } + + frexp(v, &vexp); + frexp(u, &uexp); + if (vexp-uexp > MAXEXP-3) /* overflow */ + f = PIov2; + else { + if (vexp-uexp < MINEXP+3) /* underflow */ + f = 0.0; + else + f = atan(fabs(v/u)); + if (u < 0.0) + f = PI - f; + } + if (v < 0.0) + f = -f; + return f; +} + +#define P0 -0.13688768894191926929e+2 +#define P1 -0.20505855195861651981e+2 +#define P2 -0.84946240351320683534e+1 +#define P3 -0.83758299368150059274e+0 +#define Q0 +0.41066306682575781263e+2 +#define Q1 +0.86157349597130242515e+2 +#define Q2 +0.59578436142597344465e+2 +#define Q3 +0.15024001160028576121e+2 + +#define P(g) (((P3*g P2)*g P1)*g P0) +#define Q(g) ((((g Q3)*g Q2)*g Q1)*g Q0) + +double atan(x) +double x; +{ + double f, r, g; + int n; + static double Avals[4] = { + 0.0, + 0.52359877559829887308, + 1.57079632679489661923, + 1.04719755119659774615 + }; + + n = 0; + f = fabs(x); + if (f > 1.0) { + f = 1.0/f; + n = 2; + } + if (f > 0.26794919243112270647) { + f = (((0.73205080756887729353*f - 0.5) - 0.5) + f) / + (1.73205080756887729353 + f); + ++n; + } + if (fabs(f) < 2.3e-10) + r = f; + else { + g = f*f; + r = f + f * + ((P(g)*g) + /Q(g)); + } + if (n > 1) + r = -r; + r += Avals[n]; + if (x < 0.0) + r = -r; + return r; +} + exp.c +#include "math.h" +#include "errno.h" + +#define P0 0.25000000000000000000e+0 +#define P1 0.75753180159422776666e-2 +#define P2 0.31555192765684646356e-4 +#define Q0 0.50000000000000000000e+0 +#define Q1 0.56817302698551221787e-1 +#define Q2 0.63121894374398503557e-3 +#define Q3 0.75104028399870046114e-6 + +#define P(z) ((P2*z + P1)*z + P0) +#define Q(z) (((Q3*z + Q2)*z + Q1)*z + Q0) + +#define EPS 2.710505e-20 + +double +exp(x) +double x; +{ + int n; + double xn, g, r, z; + extern int errno; + + if (x > LOGHUGE) { + errno = ERANGE; + return HUGE_VAL; + } + if (x < LOGTINY) { + errno = ERANGE; + return 0.0; + } + if (fabs(x) < EPS) + return 1.0; + n = z = x * 1.4426950408889634074; + if (n < 0) + --n; + if (z-n >= 0.5) + ++n; + xn = n; + g = ((x - xn*0.693359375)) + xn*2.1219444005469058277e-4; + z = g*g; + r = P(z)*g; + r = 0.5 + r/(Q(z)-r); + return ldexp(r,n+1); +} + floor.c +#include "math.h" + +double floor(d) +double d; +{ + if (d < 0.0) + return -ceil(-d); + modf(d, &d); + return d; +} + +double ceil(d) +double d; +{ + if (d < 0.0) + return -floor(-d); + if (modf(d, &d) > 0.0) + ++d; + return d; +} + log.c +#include "math.h" +#include "errno.h" + +double log10(x) +double x; +{ + return log(x)*0.43429448190325182765; +} + +#define A0 -0.64124943423745581147e+2 +#define A1 +0.16383943563021534222e+2 +#define A2 -0.78956112887491257267e+0 +#define A(w) ((A2*w A1)*w A0) + +#define B0 -0.76949932108494879777e+3 +#define B1 +0.31203222091924532844e+3 +#define B2 -0.35667977739034646171e+2 +#define B(w) (((w B2)*w B1)*w B0) + +#define C0 0.70710678118654752440 +#define C1 0.693359375 +#define C2 -2.121944400546905827679e-4 + +double log(x) +double x; +{ + double Rz, f, z, w, znum, zden, xn; + int n; + extern int errno; + + if (x <= 0.0) { + errno = EDOM; + return -HUGE_VAL; + } + f = frexp(x, &n); + if (f > C0) { + znum = (znum = f-0.5) - 0.5; /* the assignment prevents const. eval */ + zden = f*0.5 + 0.5; + } else { + --n; + znum = f - 0.5; + zden = znum*0.5 + 0.5; + } + z = znum/zden; + w = z*z; +/* the lines below are split up to allow expansion of A(w) and B(w) */ + Rz = z + z * (w * + A(w) + /B(w)); + xn = n; + return (xn*C2 + Rz) + xn*C1; +} + pow.c +#include "math.h" +#include "errno.h" + +double pow(a,b) +double a,b; +{ + double answer; + extern int errno; + register long count; + char sign, inverse; + + if (a == 0) { + if (b <= 0) +domain: errno = EDOM; + return 0.0; + } + if (b == 0) + return 1.0; /* anything raised to 0 is 1 */ + inverse = sign = 0; + if (modf(b,&answer) == 0) { + if (answer < 0) + inverse = 1, answer = -answer; + if ((count = answer) == answer) { + for (answer = 1.0 ; count ; count >>= 1, a *= a) + if ((int)count & 1) + answer *= a; + if (inverse) + answer = 1.0/answer; + return answer; + } + if (a < 0) + sign = 1, a = -a; + if ((count&1) == 0) + sign = 0; /* number is even so sign is positive */ + + } else if (a < 0) + goto domain; + + answer = exp(log(a)*b); + return sign ? -answer : answer; +} + random.c +/* + * Random number generator - + * adapted from the FORTRAN version + * in "Software Manual for the Elementary Functions" + * by W.J. Cody, Jr and William Waite. + */ +double ran() +{ + static long int iy = 100001; + + iy *= 125; + iy -= (iy/2796203) * 2796203; + return (double) iy/ 2796203.0; +} + +double randl(x) +double x; +{ + double exp(); + + return exp(x*ran()); +} + sin.c +#include "math.h" +#include "errno.h" + +double cos(x) +double x; +{ + double sincos(); + + return sincos(x, fabs(x) + 1.57079632679489661923, 0); +} + +double sin(x) +double x; +{ + double sincos(); + + if (x < 0.0) + return sincos(x,-x,1); + else + return sincos(x,x,0); +} + +#define R1 -0.16666666666666665052e+00 +#define R2 +0.83333333333331650314e-02 +#define R3 -0.19841269841201840457e-03 +#define R4 +0.27557319210152756119e-05 +#define R5 -0.25052106798274584544e-07 +#define R6 +0.16058936490371589114e-09 +#define R7 -0.76429178068910467734e-12 +#define R8 +0.27204790957888846175e-14 + +#define YMAX 6.7465e09 + +static double sincos(x,y,sgn) +double x,y; +{ + double f, xn, g; + extern int errno; + + if (y >= YMAX) { + errno = ERANGE; + return 0.0; + } + if (modf(y * 0.31830988618379067154, &xn) >= 0.5) + ++xn; + if ((int)xn & 1) + sgn = !sgn; + if (fabs(x) != y) + xn -= 0.5; + g = modf(fabs(x), &x); /* break into fraction and integer parts */ + f = ((x - xn*(3217.0/1024)) + g) - xn*-8.9089102067615373566e-6; + if (fabs(f) > 2.3283e-10) { + g = f*f; + f = (((((((R8*g R7)*g R6)*g R5)*g + R4)*g R3)*g R2)*g R1)*g*f+f; + } + if (sgn) + f = -f; + return f; +} + sinh.c +#include "math.h" +#include "errno.h" + +extern int errno; + +#define P0 -0.35181283430177117881e+6 +#define P1 -0.11563521196851768270e+5 +#define P2 -0.16375798202630751372e+3 +#define P3 -0.78966127417357099479e+0 +#define Q0 -0.21108770058106271242e+7 +#define Q1 +0.36162723109421836460e+5 +#define Q2 -0.27773523119650701667e+3 + +#define PS(x) (((P3*x P2)*x P1)*x P0) +#define QS(x) (((x Q2)*x Q1)*x Q0) + +double sinh(x) +double x; +{ + double y, w, z; + int sign; + + y = x; + sign = 0; + if (x < 0.0) { + y = -x; + sign = 1; + } + if (y > 1.0) { + w = y - 0.6931610107421875000; + if (w > LOGHUGE) { + errno = ERANGE; + z = HUGE_VAL; + } else { + z = exp(w); + if (w < 19.95) + z -= 0.24999308500451499336 / z; + z += 0.13830277879601902638e-4 * z; + } + if (sign) + z = -z; + } else if (y < 2.3e-10) + z = x; + else { + z = x*x; + z = x + x * + (z*(PS(z) + /QS(z))); + } + return z; +} + +double cosh(x) +double x; +{ + double y, w, z; + + y = fabs(x); + if (y > 1.0) { + w = y - 0.6931610107421875000; + if (w > LOGHUGE) { + errno = ERANGE; + return HUGE_VAL; + } + z = exp(w); + if (w < 19.95) + z += 0.24999308500451499336 / z; + z += 0.13830277879601902638e-4 * z; + } else { + z = exp(y); + z = z*0.5 + 0.5/z; + } + return z; +} + sqrt.c +#include "math.h" +#include "errno.h" + +double sqrt(x) +double x; +{ + double f, y; + int n; + extern int errno; + + if (x == 0.0) + return x; + if (x < 0.0) { + errno = EDOM; + return 0.0; + } + f = frexp(x, &n); + y = 0.41731 + 0.59016 * f; + y = (y + f/y); + y = ldexp(y,-2) + f/y; /* fast calculation of y2 */ + y = ldexp(y + f/y, -1); + y = ldexp(y + f/y, -1); + + if (n&1) { + y *= 0.70710678118654752440; + ++n; + } + return ldexp(y,n/2); +} + tan.c +#include "math.h" +#include "errno.h" + +extern int errno; + +static double tansub(); + +#if MPU8080 || MPUZ80 || MPU6502 +#define TOOSMALL (1.0/HUGE_VAL) +#else +#define TOOSMALL TINY_VAL +#endif + +double cotan(x) +double x; +{ + double y; + + y = fabs(x); + if (y < TOOSMALL) { + errno = ERANGE; + if (x < 0.0) + return -HUGE_VAL; + else + return HUGE_VAL; + } + return tansub(x,y,2); +} + +double tan(x) +double x; +{ + return tansub(x, fabs(x), 0); +} + +#define P1 -0.13338350006421960681e+0 +#define P2 +0.34248878235890589960e-2 +#define P3 -0.17861707342254426711e-4 +#define Q0 +1.0 +#define Q1 -0.46671683339755294240e+0 +#define Q2 +0.25663832289440112864e-1 +#define Q3 -0.31181531907010027307e-3 +#define Q4 +0.49819433993786512270e-6 + +#define P(f,g) (((P3*g P2)*g P1)*g*f + f) +#define Q(g) ((((Q4*g Q3)*g Q2)*g Q1)*g Q0) + +#define YMAX 6.74652e09 + +static double tansub(x, y, flag) +double x,y; +{ + double f, g, xn; + double xnum, xden; + + if (y > YMAX) { + errno = ERANGE; + return 0.0; + } + if (fabs(modf(x*0.63661977236758134308, &xn)) >= 0.5) + xn += (x < 0.0) ? -1.0 : 1.0; + f = modf(x, &g); + f = ((g - xn*(3217.0/2048)) + f) - xn*-4.454455103380768678308e-6; + if (fabs(f) < 2.33e-10) { + xnum = f; + xden = 1.0; + } else { + g = f*f; + xnum = P(f,g); + xden = Q(g); + } + flag |= ((int)xn & 1); + switch (flag) { + case 1: /* A: tan, xn odd */ + xnum = -xnum; + case 2: /* B: cotan, xn even */ + return xden/xnum; + + case 3: /* C: cotan, xn odd */ + xnum = -xnum; + case 0: /* D: tan, xn even */ + return xnum/xden; + } + return 0.0; +} + tanh.c +#include "math.h" + +#define P0 -0.16134119023996228053e+4 +#define P1 -0.99225929672236083313e+2 +#define P2 -0.96437492777225469787e+0 +#define Q0 +0.48402357071988688686e+4 +#define Q1 +0.22337720718962312926e+4 +#define Q2 +0.11274474380534949335e+3 + +#define gP(g) (((P2*g P1)*g P0)*g) +#define Q(g) (((g Q2)*g Q1)*g Q0) + +double tanh(x) +double x; +{ + double f,g,r; + + f = fabs(x); + if (f > 25.3) + r = 1.0; + else if (f > 0.54930614433405484570) { + r = 0.5 - 1.0/(exp(f+f)+1.0); + r += r; + } else if (f < 2.3e-10) + r = f; + else { + g = f*f; + r = f + f* + (gP(g) + /Q(g)); + } + if (x < 0.0) + r = -r; + return r; +} + atof.asm +; Copyright (C) 1983 by Manx Software Systems +; +;double +;atof(cp) +;register char *cp; + include lmacros.h + +IFDEF LONGPTR +cp equ es:byte ptr [di] +getes macro + mov es,ss:word ptr acp[2] + endm + +ELSE + +cp equ byte ptr [di] +getes macro +; + endm +ENDIF + + procdef atof,<> + sub sp,2 + push di + push si +;{ +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,acp,es +; double acc; +; int msign, esign, dpflg; +; int i, dexp; +msign equ byte ptr -1[bp] +esign equ byte ptr -2[bp] ;these two aren't active at the same time +dpflg equ byte ptr -2[bp] + +; while (*cp == ' ' || *cp == '\t') +; ++cp; +skiploop: + mov al,cp + cmp al,' ' + je skipbl + cmp al,9 + jne skipdone +skipbl: + inc di + jmp skiploop +skipdone: +; if (*cp == '-') { + cmp al,45 + jne $3 +; ++cp; + inc di +; msign = 1; + mov msign,1 + jmp short $4 +; } else { +$3: +; msign = 0; + mov msign,0 +; if (*cp == '+') +; ++cp; + cmp al,43 + jne $4 + inc di +; } +$4: +; dpflg = dexp = 0; + mov si,0 + mov dpflg,0 +; for (acc = zero ; ; ++cp) { + call $dlip + dw 0,0,0,0 +$6: +; if (isdigit(*cp)) { + getes + mov al,cp + cmp al,'0' + jb $9 + cmp al,'9' + ja $9 +; acc *= ten; + call $dlis + dw 0,0,0,4024H + call $dml +; acc += *cp - '0'; + call $dswap + getes + mov al,cp + cbw + add ax,-48 + call $itod + call $dad +; if (dpflg) +; --dexp; + cmp dpflg,0 + je $11 + dec si + jmp short $11 +; } else if (*cp == '.') { +$9: + cmp al,'.' + jne $8 +; if (dpflg) +; break; + cmp dpflg,0 + jne $8 +; dpflg = 1; + mov dpflg,1 +; } else +; break; +$11: +; } + inc di + jmp $6 +$8: +; if (*cp == 'e' || *cp == 'E') { + cmp al,101 + je $15 + cmp al,69 + jne $14 +$15: +; ++cp; + inc di +; if (*cp == '-') { + cmp cp,45 + jne $16 +; ++cp; + inc di +; esign = 1; + mov esign,1 + jmp short $17 +; } else { +$16: +; esign = 0; + mov esign,0 +; if (*cp == '+') +; ++cp; + cmp cp,43 + jne $17 + inc di +; } +$17: +; for ( i = 0 ; isdigit(*cp) ; i = i*10 + *cp++ - '0' ) + sub ax,ax + mov cx,10 + jmp short $20 +$19: + mul cx + mov dx,ax + mov al,cp + inc di + cbw + add ax,dx + add ax,-48 +$20: + mov bl,cp + cmp bl,'0' + jb $21 + cmp bl,'9' + jbe $19 +; ; +$21: +; if (esign) +; i = -i; + cmp esign,0 + je $22 + neg ax +$22: +; dexp += i; + add si,ax +; } +; if (dexp < 0) { +$14: + call $dlis + dw 0,0,0,4024H + test si,si + jns $23 +; while (dexp++) +$24: +; acc /= ten; + call $ddv + inc si + jnz $24 + jmp short $26 +; } else if (dexp > 0) { +$23: + jz $26 +; while (dexp--) +$28: +; acc *= ten; + call $dml + dec si + jnz $28 +; } +$26: +; if (msign) +; acc = -acc; + cmp msign,0 + je $30 + call $dng +; return acc; +$30: + pop si + pop di + mov sp,bp + pret +;} + pend atof +ifdef FARPROC + extrn $dad:far,$dml:far,$ddv:far,$dlip:far,$dlis:far + extrn $dng:far,$dswap:far,$itod:far +else + extrn $dad:near,$dml:near,$ddv:near,$dlip:near,$dlis:near + extrn $dng:near,$dswap:near,$itod:near +endif + finish + end + ftoa.asm +; Copyright (C) 1984 by Manx Software Systems +; + include lmacros.h +; +;static double round[] = { +dataseg segment word public 'data' +round_ equ this word +; 5.0e+0, + db 00H,00H,00H,00H,00H,00H,014H,040H +; 0.5e+0, + db 00H,00H,00H,00H,00H,00H,0e0H,03fH +; 0.5e-1, + db 09aH,099H,099H,099H,099H,099H,0a9H,03fH +; 0.5e-2, + db 07bH,014H,0aeH,047H,0e1H,07aH,074H,03fH +; 0.5e-3, + db 0fcH,0a9H,0f1H,0d2H,04dH,062H,040H,03fH +; 0.5e-4, + db 02dH,043H,01cH,0ebH,0e2H,036H,0aH,03fH +; 0.5e-5, + db 0f1H,068H,0e3H,088H,0b5H,0f8H,0d4H,03eH +; 0.5e-6, + db 08dH,0edH,0b5H,0a0H,0f7H,0c6H,0a0H,03eH +; 0.5e-7, + db 048H,0afH,0bcH,09aH,0f2H,0d7H,06aH,03eH +; 0.5e-8, + db 03aH,08cH,030H,0e2H,08eH,079H,035H,03eH +; 0.5e-9, + db 095H,0d6H,026H,0e8H,0bH,02eH,01H,03eH +; 0.5e-10, + db 0bbH,0bdH,0d7H,0d9H,0dfH,07cH,0cbH,03dH +; 0.5e-11, + db 095H,064H,079H,0e1H,07fH,0fdH,095H,03dH +; 0.5e-12, + db 011H,0eaH,02dH,081H,099H,097H,061H,03dH +; 0.5e-13, + db 082H,076H,049H,068H,0c2H,025H,02cH,03dH +; 0.5e-14, + db 09bH,02bH,0a1H,086H,09bH,084H,0f6H,03cH +; 0.5e-15, + db 016H,056H,0e7H,09eH,0afH,03H,0c2H,03cH +; 0.5e-16, +; db 0bcH,089H,0d8H,097H,0b2H,0d2H,08cH,03cH +; 0.5e-17, +; db 097H,0d4H,046H,046H,0f5H,0eH,057H,03cH +; 0.5e-18, +; db 0acH,043H,0d2H,0d1H,05dH,072H,022H,03cH +;}; +dataseg ends + assume ds:dataseg +IFDEF LONGPTR +buffer equ es:byte ptr [di] +getes macro + mov es,word ptr abuf[2] + endm +ELSE + +buffer equ byte ptr [di] +getes macro +; + endm +ENDIF +; +;ftoa(number, abuf, maxwidth, flag) +;double number; register char *abuf; + procdef ftoa, <,,,> + add sp,-8 + push di + push si + mov di,word ptr abuf ;load offset word of buffer +;{ +; register int i; +; int exp, digit, decpos, ndig; +; +; ndig = maxwidth+1; + mov ax,maxwidth + inc ax + mov word ptr -8[bp],ax +; exp = 0; + mov word ptr -2[bp],0 +; if (number < 0.0) { +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,number + call $dldp + call $dlis + db 00H,00H,00H,00H,00H,00H,00H,00H + call $dcmp + je $4 ;skip scaling if zero + jge $3 +; number = -number; + call $dng +; *buffer++ = '-'; + getes + mov buffer,'-' + inc di +; } +$3: + call $isnan + je notnan + mov cx,ax + mov al,'?' + cmp cx,1 + beq outrange + mov al,'*' + jmp outrange +notnan: +; if (number > 0.0) { +; while (number < 1.0) { +$5: + call $dlis + db 00H,00H,00H,00H,00H,00H,0f0H,03fH + call $dcmp + jge $6 +; number *= 10.0; + call $dlis + db 00H,00H,00H,00H,00H,00H,024H,040H + call $dml +; --exp; + dec word ptr -2[bp] +; } + jmp $5 +$6: +; while (number >= 10.0) { + call $dlis + db 00H,00H,00H,00H,00H,00H,024H,040H +$7: + call $dcmp + jl $8 +; number /= 10.0; + call $ddv +; ++exp; + inc word ptr -2[bp] +; } + jmp $7 +$8: +; } +; +; if (flag == 2) { /* 'g' format */ +$4: + mov ax,flag + cmp ax,2 + jne $9 +; ndig = maxwidth; + mov ax,maxwidth + mov word ptr -8[bp],ax +; if (exp < -4 || exp >= maxwidth) +; flag = 0; /* switch to 'e' format */ + mov ax,word ptr -2[bp] + cmp ax,-4 + jl $11 + cmp ax,maxwidth + jl $10 +$11: + mov flag,0 +$10: + jmp $12 +; } else if (flag == 1) /* 'f' format */ +; ndig += exp; +$9: + cmp al,1 + jne $13 + mov ax,word ptr -2[bp] + add word ptr -8[bp],ax +; +; if (ndig >= 0) { +$13: +$12: + mov bx,word ptr -8[bp] + test bx,bx + jl $14 +; if ((number += round[ndig>16?16:ndig]) >= 10.0) { + cmp bx,16 + jle $16 + mov bx,16 +$16: + mov cx,3 + shl bx,cl + add bx,offset round_ +ifdef LONGPTR + mov dx,ds + mov es,dx +endif + call $dlds + call $dad + call $dlis + db 00H,00H,00H,00H,00H,00H,024H,040H + call $dcmp + jl $15 +; number = 1.0; + call $dlip + db 00H,00H,00H,00H,00H,00H,0f0H,03fH +; ++exp; + inc word ptr -2[bp] +; if (flag) +; ++ndig; + cmp flag,0 + je $18 + inc word ptr -8[bp] +; } +$18: +; } +$15: +; +; if (flag) { +$14: + cmp flag,0 + je $19 +; if (exp < 0) { + mov ax,word ptr -2[bp] + test ax,ax + jge $20 +; *buffer++ = '0'; + getes + mov buffer,'0' + inc di +; *buffer++ = '.'; + mov buffer,'.' + inc di +; i = -exp - 1; + not ax + mov cx,ax +; if (ndig <= 0) +; i = maxwidth; + cmp word ptr -8[bp],0 + jg $21 + mov cx,maxwidth +$21: +; while (i--) +; *buffer++ = '0'; + jcxz $23 + mov al,'0' +rep stosb +$23: +; decpos = 0; + sub ax,ax +; } else { + jmp short $25 +$20: +; decpos = exp+1; +; } + mov ax,word ptr -2[bp] + inc ax + jmp short $25 +; } else { +$19: +; decpos = 1; + mov ax,1 +; } +$25: + mov word ptr -6[bp],ax +; +; if (ndig > 0) { + cmp word ptr -8[bp],0 + jle $28 +; for (i = 0 ; ; ++i) { + mov si,0 + jmp short $27 +$26: + inc si +$27: +; if (i < 16) { + cmp si,16 + jge $29 +; digit = (int)number; + call $dtoi + push ax +; *buffer++ = digit+'0'; + getes + add al,'0' + stosb +; number = (number - digit) * 10.0; + call $dswap ;preserve number + pop ax + call $utod + call $dswap ;number back into primary, digit into secondary + call $dsb + call $dlis + db 00H,00H,00H,00H,00H,00H,024H,040H + call $dml + jmp short $30 +; } else +$29: +; *buffer++ = '0'; + getes + mov buffer,'0' + inc di +$30: +; if (--ndig == 0) +; break; + dec word ptr -8[bp] + jz $28 +; if (decpos && --decpos == 0) +; *buffer++ = '.'; + mov ax,word ptr -6[bp] + test ax,ax + jz $26 + dec ax + mov word ptr -6[bp],ax + jnz $26 + getes + mov buffer,'.' + inc di +; } + jmp $26 +; } +$28: + getes +; +; if (!flag) { + cmp flag,0 + jne $32 +; *buffer++ = 'e'; + mov buffer,'e' + inc di +; if (exp < 0) { +; exp = -exp; +; *buffer++ = '-'; + mov al,'+' + cmp word ptr -2[bp],0 + jge $33 + neg word ptr -2[bp] + mov al,'-' +; } else +; *buffer++ = '+'; +$33: + stosb +; if (exp >= 100) { + mov ax,word ptr -2[bp] + cmp ax,100 + jl $35 +; *buffer++ = exp/100 + '0'; + mov cx,100 + cwd + idiv cx + add al,'0' + stosb +; exp %= 100; + mov ax,dx +; } +; *buffer++ = exp/10 + '0'; +$35: + mov cx,10 + cwd + idiv cx + add al,'0' + stosb +; *buffer++ = exp%10 + '0'; + mov ax,dx + add al,'0' + stosb +; } +; *buffer = 0; +$32: + mov buffer,0 +;} + pop si + pop di + mov sp,bp + pret + +outrange: + mov cx,maxwidth + jcxz $32 +rep stosb + jmp $32 +; +ifdef FARPROC + extrn $dad:far,$dsb:far,$dml:far,$ddv:far + extrn $dldp:far,$dlds:far,$dlip:far,$dlis:far + extrn $dcmp:far,$dng:far,$dswap:far,$utod:far,$dtoi:far + extrn $isnan:far +else + extrn $dad:near,$dsb:near,$dml:near,$ddv:near + extrn $dldp:near,$dlds:near,$dlip:near,$dlis:near + extrn $dcmp:near,$dng:near,$dswap:near,$utod:near,$dtoi:near + extrn $isnan:near +endif + pend ftoa + finish + end + frexp.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -10 -8 -6 -4 -2 0 +; |grd + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + include lmacros.h +dataseg segment word public 'data' + dw 5 dup (?) +temp dw ? + extrn flprm:word,flsec:word + extrn flterr_:word +dataseg ends + assume ds:dataseg + +ifdef FARPROC + extrn $dldp:far, $dst:far, $itod:far + extrn $dad:far, $dsb:far, $isnan:far +else + extrn $dldp:near, $dst:near, $itod:near + extrn $dad:near, $dsb:near, $isnan:near +endif + procdef isnan + sub ax,ax + pret + pend isnan + + procdef frexp, <,> +; +; frexp(d, &i) +; returns 0 <= x < 1 +; such that: d = x * 2^i +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,d ;compute address of first argument + call $dldp ;load it into the float primary + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz fr_nzero + ldptr bx,i,es ;get pointer +ifndef LONGPTR + mov ds:word ptr [bx],0 +else + mov es:word ptr [bx],0 +endif + pret +fr_nzero: + sub ax,1022 + mov word ptr -2[bx],1022 + ldptr bx,i,es ;get pointer +ifndef LONGPTR + mov ds:word ptr [bx],ax +else + mov es:word ptr [bx],ax +endif + pret + pend frexp +; +; ldexp(d, i) +; returns x = d * 2^i + procdef ldexp, <,> +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,dou ;compute address of first argument + call $dldp ;load it into the float primary + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jz ld_zero + add ax,ii ;add i to exponent + js ld_underflow + cmp ax,2048 + jl ld_ret + mov flterr_,UNDER_FLOW + mov ax,2047 +ld_ret: + mov word ptr -2[bx],ax +ld_zero: + pret +; +ld_underflow: + mov flterr_,UNDER_FLOW + sub ax,ax + jmp ld_ret + pend ldexp +; +; modf(d, dptr) +; returns fractional part of d, and +; stores integral part into *dptr + procdef modf,<,> + push di + push si + pushds +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,doubl ;compute address of first argument + call $dldp ;load it into the float primary + std + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz mf_nzero + ldptr bx,dptr,es ;get pointer + call $dst +mf_return: + cld + popds + pop si + pop di + pret +mf_nzero: + mov di,ds + mov es,di + mov si,bx + mov di,offset temp + mov cx,6 ;save value for fraction part later +rep movsw + sub ax,1023 + jns int_notzero + mov ax,0 + call $itod + jmp get_fraction +int_notzero: + cmp ax,52 + jna mf_frac + ;fraction is zero + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + sub ax,ax + call $itod + jmp mf_return +mf_frac: + sub di,di + mov cx,ax + mov ax,4 +mf_count: + sub cx,ax + jbe mf_cdone + dec di + mov ax,8 + jmp mf_count +mf_cdone: + jcxz no_shift + neg cx + mov al,byte ptr -3[bx][di] + shr al,cl + shl al,cl + mov byte ptr -3[bx][di],al +no_shift: + dec di +zap_loop: + cmp di,-8 + jle get_fraction + mov byte ptr -3[bx][di],0 + dec di + jmp zap_loop +get_fraction: + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + std + popds + pushds + mov di,flprm + xchg di,flsec + mov flprm,di + mov si,ds + mov es,si + mov si,offset temp + mov cx,6 ;restore original value +rep movsw + call $dsb ;compute fractional part + jmp mf_return + pend modf + finish + end + fsubs.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -12 -10 -8 -6 -4 -2 0 +; |guard digits + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: + +ifndef INTERNAL + include lmacros.h +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 + endif +; +dataseg segment word public 'data' + public flprm,flsec +ifndef INTERNAL + public flterr_ +flterr_ dw 0 +endif + +flprm dw acc1 +flsec dw acc2 +YU dw ? +VEE dw ? + dw 5 dup (?) +acc1 dw 7 dup (?) +acc2 dw ? +; +;work area for divide and multiply routines +; + dw 4 dup (?) +temp dw 4 dup (?) +loop_count db 0 ;iterations left (for divide) +lcnt1 db 0 ;# iter. for this word of quotient +dataseg ends +ifdef LONGPTR + assume ds:dataseg +else + assume ds:dataseg,ss:dataseg +endif + +ifndef INTERNAL + internal $floats +endif + + intrdef $isnan + sub ax,ax + ret + + intrdef $flds ;load single float into secondary accum + push di + mov di,flsec + jmp short fload + +ifdef LONGPTR + intrdef $fldsss ;load single float into secondary accum + push di + mov di,ss + mov es,di + mov di,flsec + jmp short fload + + intrdef $fldsds ;load single float into secondary accum + push di + mov di,ds + mov es,di + mov di,flsec + jmp short fload + + intrdef $fldpss ;load single float into primary accum + push di + mov di,ss + mov es,di + mov di,flprm + jmp short fload + + intrdef $fldpds ;load single float into primary accum + push di + mov di,ds + mov es,di + mov di,flprm + jmp short fload + +endif +; + intrdef $fldp ;load single float into primary accum + push di + mov di,flprm +fload: + push si +ifndef LONGPTR + mov si,ds + mov es,si +endif + mov ax,es:2[bx] ;get exponent/sign word of number + mov byte ptr [di],ah ;save sign + mov dh,al ;save fraction bits + shl ax,1 ;get LS bit of exponent + xchg ah,al + and ax,0ffH + jnz fld_nz + pushds +ifdef LONGPTR + mov ax,ds + mov es,ax +endif + jmp loadzero +fld_nz: + sub ax,127 ;adjust from excess 127 notation + add ax,1023 ;put into excess 1023 notation + mov word ptr -2[di],ax ;and save + or dh,80H ;turn "hidden" bit back on + mov dl,es:byte ptr 1[bx] + mov ah,es:byte ptr [bx] + sub al,al + shr dx,1 ;shift fraction into same position as a double + rcr ax,1 + shr dx,1 + rcr ax,1 + shr dx,1 + rcr ax,1 + mov word ptr -4[di],dx + mov word ptr -6[di],ax + sub ax,ax + mov word ptr -8[di],ax + mov word ptr -10[di],ax + mov word ptr -12[di],ax + pop si + pop di + ret +; + +ifdef LONGPTR + intrdef $fstss + mov cx,ss + mov es,cx + jmp short dofst + + intrdef $fstds + mov cx,ds + mov es,cx + jmp short dofst + + intrdef $fstsss + mov cx,ss + mov es,cx + jmp short dofsts + + intrdef $fstsds + mov cx,ds + mov es,cx + jmp short dofsts +endif + + intrdef $fsts ; store single from secondary +dofsts: + mov ax,flprm + xchg ax,flsec + mov flprm,ax +ifdef FARPROC + call far ptr $fst +else + call $fst +endif + mov ax,flprm + xchg ax,flsec + mov flprm,ax + ret + + intrdef $fst ;store single at addr in BX +ifndef LONGPTR + mov ax,ds + mov es,ax +endif +dofst: + push di + push si + push bx + call dornd + pop di + mov si,flprm + mov ax,-2[si] ;get exponent + test ax,ax + jnz fst_nzero + mov es:word ptr [di],0 + mov es:word ptr 2[di],0 + pop si + pop di + ret +fst_nzero: + sub ax,1023 ;switch from excess 1023 notation + add ax,127 ;into excess 127 notation + mov dx,-4[si] + mov bx,-6[si] + add bx,10H ;round number + adc dx,0 + shl bx,1 ;move number back into proper position + rcl dx,1 + shl bx,1 + rcl dx,1 + test dx,dx + js fix_exp + shl bx,1 + rcl dx,1 + jmp short fst_merge +fix_exp: + inc ax ;adjust exponent +fst_merge: + mov cl,7 + shl ax,cl + mov cl,[si] ;get sign + and cl,80H + or ah,cl ;merge sign and exponent + and dh,7fH ;clear "hidden" bit + or al,dh ;merge with sign/exponent + mov es:word ptr 2[di],ax + mov es:byte ptr 1[di],dl + mov es:byte ptr [di],bh + pop si + pop di + ret +; + intrdef $dlis ;load double immediate secondary +ifdef LONGPTR + push bp + mov bp,sp + ifdef FARPROC + les bx,2[bp] + else + mov bx,cs + mov es,bx + mov bx,2[bp] + endif + add 2[bp],8 ;skip over double constant in code + pop bp + jmp dolds + +else + mov bx,sp + push di + push si + mov cx,ds + mov es,cx + ifdef FARPROC + lds si,[bx] ;get return addr + else + mov si,[bx] ;get return addr + mov di,cs + mov ds,di + endif + cld + mov di,offset temp + movsw + movsw + movsw + movsw + mov ds,cx + mov [bx],si ;put back correct return addr + lea si,-2[di] + mov di,flsec + jmp dload2 +endif +; +ifdef LONGPTR + intrdef $dldsds + mov cx,ds + mov es,cx + jmp dolds + + intrdef $dldsss + mov cx,ss + mov es,cx + jmp dolds +endif + + intrdef $dlds ;load double float into secondary accum +ifndef LONGPTR + mov ax,ds + mov es,ax +endif +dolds: + push di + mov di,flsec + jmp short dload +; + intrdef $dlip ;load double immediate primary +ifdef LONGPTR + push bp + mov bp,sp + ifdef FARPROC + les bx,2[bp] + else + mov bx,cs + mov es,bx + mov bx,2[bp] + endif + add 2[bp],8 ;skip over double constant in code + pop bp + jmp short dodldp + +else + mov bx,sp + push di + push si + mov cx,ds + mov es,cx + ifdef FARPROC + lds si,[bx] ;get return addr + else + mov si,[bx] ;get return addr + mov di,cs + mov ds,di + endif + cld + mov di,offset temp + movsw + movsw + movsw + movsw + mov ds,cx + mov [bx],si ;put back correct return addr + lea si,-2[di] + mov di,flprm + jmp dload2 +endif +; +ifdef LONGPTR + intrdef $dldpss + mov cx,ss + mov es,cx + jmp short dodldp + + intrdef $dldpds + mov cx,ds + mov es,cx + jmp short dodldp +endif + + intrdef $dldp ;load double float into primary accum +ifndef LONGPTR + mov ax,ds + mov es,ax +endif +dodldp: + push di + mov di,flprm +dload: + push si + lea si,6[bx] +dload2: +ifdef LONGPTR + push ds + mov cx,es ;swap the segment registers + mov dx,ds + mov es,dx + mov ds,cx +endif + std + lods word ptr [si];get first two bytes of number + mov es:byte ptr [di],ah ;save sign + mov dh,al ;save top nibble of fraction + mov cl,4 + shr ax,cl + and ax,7ffH ;isolate exponent + jz loadzero + sub di,2 + stos word ptr [di] + and dh,15 ;isolate fraction + or dh,10H ;put back "hidden" bit + mov es:byte ptr 1[di],dh + mov cx,6 + inc si +rep movs byte ptr [di], byte ptr [si] + mov al,0 + stosb ;clear guard bytes + stosb + stosb + cld + popds + pop si + pop di + ret +loadzero: + std + sub ax,ax + mov cx,7 +rep stos word ptr [di] + cld + popds + pop si + pop di + ret +; +ifdef LONGPTR + intrdef $dstss + mov cx,ss + mov es,cx + jmp short dodst + + intrdef $dstds + mov cx,ds + mov es,cx + jmp short dodst + + intrdef $dstsss + mov cx,ss + mov es,cx + jmp short dodsts + + intrdef $dstsds + mov cx,ds + mov es,cx + jmp short dodsts +endif + intrdef $dsts +dodsts: + mov ax,flprm + xchg ax,flsec + mov flprm,ax +ifdef FARPROC + call far ptr $dst +else + call $dst +endif + mov ax,flprm + xchg ax,flsec + mov flprm,ax + ret + + + intrdef $dst ;store double at addr in ES:BX +dodst: + std +ifndef LONGPTR + mov dx,ds + mov es,dx +endif + push di + push si + push bx ;save address + call dornd ;round fraction to 7 bytes + pop di ;restore address + add di,6 + mov si,flprm + mov dl,[si] ;get sign + and dl,80H + sub si,2 + lods word ptr [si];get exponent + mov cl,4 + shl ax,cl + or ah,dl ;merge sign and exponent + mov dl,1[si] + and dl,15 ;clear "hidden" bit + or al,dl ;merge with sign/exponent + stos word ptr [di] + mov cx,6 + inc di +rep movs byte ptr [di], byte ptr [si] + cld + pop si + pop di + ret +; + intrdef $dpshs ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back + jmp near ptr dodsts +; + intrdef $dpsh ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back + jmp near ptr dodst +; + intrdef $dpopp ;pop double float into secondary accum + push bx + push es +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + mov bx,sp + add bx,FPTRSIZE+4 ;address of data to load +ifdef FARPROC + call far ptr $dldp +else + call $dldp +endif + + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dpop ;pop double float into secondary accum + push bx + push es +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + mov bx,sp + add bx,FPTRSIZE+4 ;address of data to load +ifdef FARPROC + call far ptr $dlds +else + call $dlds +endif + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dswap ;exchange primary and secondary + mov ax,flsec + xchg ax,flprm + mov flsec,ax + ret +; + intrdef $dng ;negate primary + mov bx,flprm + xor byte ptr [bx],80H ;flip sign + ret +; + intrdef $dtst ;test if primary is zero + mov bx,flprm + cmp word ptr -2[bx],0 + jne true + sub ax,ax + ret +true: + sub ax,ax + inc ax + ret +; + intrdef $dcmp ;compare primary and secondary + push di + push si + std + mov si,flprm + mov di,ds + mov es,di + mov di,flsec + mov al,byte ptr [si] + test al,al ;is primary negative + js dcneg +; primary is positive + xor al,byte ptr [di] ;check if signs the same + js p_gt_s ;differ then p > s + jmp short docomp +dcneg: + ;primary is negative + xor al,byte ptr [di] ;check if signs the same + js p_lt_s ;differ the p < s + xchg di,si ;both negative reverse sense of test +docomp: + sub di,2 ;back up to exponent + sub si,2 + mov cx,5 ;test exponent + 4 words of fraction +repe cmps acc1, es:acc2 + jb p_lt_s + ja p_gt_s + ;return 0 if p == s + xor ax,ax + jmp short cmp_return + ;return 0 if p == s +p_lt_s: ;return < 0 if p < s + xor ax,ax + dec ax + jmp short cmp_return +; +p_gt_s: ; > 0 if p > s + xor ax,ax + inc ax +cmp_return: + pop si + pop di + cld + ret +; + intrdef $dsb ;subtract secondary from primary + mov bx,flsec + xor byte ptr [bx],80H ;flip sign of secondary + ;and fall thru into add routine +; + intrdef $dad ;add secondary to primary + pushf + push bp + push si + push di + std + mov si,flprm + mov di,ds + mov es,di + mov di,flsec + mov cx,word ptr -2[si] ;get exponent of primary + sub cx,word ptr -2[di] ;compute magnitude difference + jae order_ok + xchg si,di ;make largest number primary + mov flprm,si + mov flsec,di + neg cx ;fix exponent difference +order_ok: + cmp cx,64 ;see if numbers overlap + jna add_ok ;no overlap just return largest number + pop di + pop si + pop bp + popf + ret +add_ok: + lea si,-3[di] + mov di,offset temp+7 + sub al,al +cx_check: + cmp cx,8 ;more than a byte to shift ? + jb shift_it ;no, then shift remaining part over + stos byte ptr [di] + sub cx,8 + jmp cx_check +shift_it: + sub dl,dl +shift_loop: + mov ah,dl + lods byte ptr [si] + mov dl,al + shr ax,cl + stos byte ptr [di] + cmp di,offset temp-2 + jae shift_loop +; + mov si,flprm + mov di,flsec + mov cx,5 ;load up for loops below + mov al,byte ptr [di] + xor al,byte ptr [si] + jns signs_same + test byte ptr [di],80H ;check which is negative + jnz sub_s_from_p +; +; subtract primary from secondary +; + clc + mov bx,0 +sub_loop_1: + mov ax,temp-2[bx] + sbb ax,word ptr -12[bx][si] + mov word ptr -12[bx][si],ax + inc bx + inc bx + loop sub_loop_1 + jmp short check_sign +; +; subtract secondary from primary +; +sub_s_from_p: + clc + mov bx,0 +sub_loop_2: + mov ax,temp-2[bx] + sbb word ptr -12[bx][si],ax + inc bx + inc bx + loop sub_loop_2 +check_sign: + mov byte ptr [si],0 ;mark result as positive + jnb do_normalize + mov byte ptr [si],0FFH ;mark result as negative + clc + mov bx,0 + mov cx,5 +neg_loop: + mov ax,0 + sbb ax,word ptr -12[bx][si] + mov word ptr -12[bx][si],ax + inc bx + inc bx + loop neg_loop + jmp short do_normalize +; +; signs of numbers are the same just add them together +; +signs_same: + clc + mov bx,0 +add_loop: + mov ax,temp-2[bx] + adc word ptr -12[bx][si],ax + inc bx + inc bx + loop add_loop +;;; jmp short do_normalize ;fall through +; +; normalize number such that first byte of number is >= 0x10 +; and < 0x20 +; +do_normalize: + mov si,flprm + lea bp,-12[si] +norm: + lea bx,-3[si] + mov dx,word ptr -2[si] ;get exponent +byte_loop: + cmp byte ptr [bx],0 + jne bskip_done + dec bx + sub dx,8 + cmp bx,bp + jae byte_loop +; +; number is zero +; +zero_result: + mov di,ds + mov es,di + mov di,flprm + sub ax,ax + mov cx,7 +rep stos word ptr [di] + pop di + pop si + pop bp + popf + ret + +bskip_done: + sub cx,cx + lea di,-3[si] + mov ah,byte ptr [bx] + dec bx + cmp ah,20H + jnb too_big +; + mov al,byte ptr [bx] + mov ch,al +left_count: + cmp ah,10H + jae move_left + shl ax,1 + inc cl + dec dx + jmp left_count +move_left: + mov [di],ah + dec di + dec bx + cmp bx,bp + jb clear_tail + mov ah,ch + mov al,byte ptr [bx] + mov ch,al + shl ax,cl + jmp move_left +; +; +too_big: + mov al,ah + sub ah,ah + mov ch,al +right_count: + inc cl + inc dx + shr ax,1 + cmp al,20H + jnb right_count +move_right: + stos byte ptr [di] + cmp bx,bp + jb clear_tail + mov ah,ch + mov al,byte ptr [bx] + dec bx + mov ch,al + shr ax,cl + jmp move_right +; +clear_tail: + mov cx,di + sub cx,bp + inc cx + jcxz norm_done + sub al,al +rep stos byte ptr [di] +; +norm_done: +; +; overflow/underflow checking needs to be done here +; + cmp dx,0 + jg no_under + mov flterr_,UNDER_FLOW + mov word ptr -2[si],1 + jmp short clr_fraction +no_under: + cmp dx,2048 + jl no_over + mov flterr_,OVER_FLOW + mov word ptr -2[si],2047 +clr_fraction: + mov word ptr -4[si],1000H + lea di,-6[si] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp fault_handler +no_over: + mov word ptr -2[si],dx ;save new value of exponent + pop di + pop si + pop bp + popf + ret +; + intrdef $ddv + ;double floating divide (primary = primary/secondary) + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov bp,flprm + mov bx,flsec + mov ax,ds:-2[bp] + test ax,ax + jnz not_zero + jmp zero_result +not_zero: + mov dx,-2[bx] + test dx,dx + jnz div_ok + mov flterr_,DIV_BY_ZERO + jmp fault_handler +div_ok: + sub ax,dx + add ax,1019 ;exp = Ep - Es + mov ds:-2[bp],ax + mov al,byte ptr [bx] + xor ds:byte ptr [bp],al +; + mov ax,-6[bx] ;check if easy divide case + or ax,-8[bx] + or ax,-10[bx] + jnz hard_div +; + mov si,-4[bx] + lea di,ds:-4[bp] + mov cx,4 + mov dx,[di] + cmp dx,si + jb ediv_loop + shl si,1 + inc ds:word ptr -2[bp] ;adjust exponent +ediv_loop: + mov ax,-2[di] + div si + stos word ptr [di] + loop ediv_loop + sub ax,ax ;this IS the correct way + div si + stos word ptr [di] + jmp do_normalize +; +hard_div: + lea si,ds:-4[bp] + lea di,-4[bx] + mov cx,4 +repe cmps acc1, es:acc2 + jne do_div +; numbers are the same so answer is 1 + add ds:word ptr -2[bp],4 ;adjust exponent + lea di,ds:-4[bp] + mov ax,1000H + stos es:acc1 + sub ax,ax + stos es:acc1 + stos es:acc1 + stos es:acc1 + mov si,bp + mov dx,word ptr -2[si] + jmp norm_done +; +do_div: + mov ds:word ptr -12[bp],0 + mov ax,ds:-10[bp] + mov dx,ds:-8[bp] + mov si,ds:-6[bp] + mov di,ds:-4[bp] + jb dont_shift + inc ds:word ptr -2[bp] ;fix exponent + shr di,1 + rcr si,1 + rcr dx,1 + rcr ax,1 +dont_shift: + sub cx,cx + sub bp,4 + mov loop_count,4 +bdiv_loop: + mov lcnt1,16 +div_loop: + shl cx,1 + shl ax,1 + rcl dx,1 + rcl si,1 + rcl di,1 + sub ax,word ptr -10[bx] + sbb dx,word ptr -8[bx] + sbb si,word ptr -6[bx] + sbb di,word ptr -4[bx] + js zero_bit +one_bit: + inc cx ;set bit in quotient + dec lcnt1 + jnz div_loop + mov ds:word ptr [bp],cx + sub bp,2 + sub cx,cx + dec loop_count + jnz bdiv_loop + jmp do_normalize +; +bzero_loop: + mov lcnt1,16 +zero_loop: + shl cx,1 + shl ax,1 + rcl dx,1 + rcl si,1 + rcl di,1 + add ax,word ptr -10[bx] + adc dx,word ptr -8[bx] + adc si,word ptr -6[bx] + adc di,word ptr -4[bx] + jns one_bit +zero_bit: + dec lcnt1 + jnz zero_loop + mov ds:word ptr [bp],cx + sub bp,2 + sub cx,cx + dec loop_count + jnz bzero_loop + jmp do_normalize +; +; + intrdef $dml + ;double floating multiply (primary = primary * secondary) + pushf + push bp + push si + push di + std + mov si,flprm + mov bx,flsec + mov ax,-2[si] + test ax,ax + jnz prm_not_zero + jmp zero_result +prm_not_zero: + mov dx,-2[bx] + test dx,dx + jnz alt_not_zero + jmp zero_result +alt_not_zero: + add ax,dx + sub ax,1019 + mov -2[si],ax + mov al,byte ptr [bx] + xor byte ptr [si],al + sub ax,ax + mov cx,8 + mov di,ds + mov es,di + mov di,offset temp+6 +rep stos word ptr [di] ;clear result +; + mov cx,-10[bx] + jcxz skip1 + mov ax,-6[si] + test ax,ax + jz skip13 + mul cx + mov temp-2,dx +skip13: + mov ax,-4[si] + test ax,ax + jz skip1 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 +skip1: + mov cx,-8[bx] + jcxz skip2 + mov ax,-8[si] + test ax,ax + jz skip22 + mul cx + add temp-2,dx + adc temp,0 + adc temp+2,0 +skip22: + mov ax,-6[si] + test ax,ax + jz skip23 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 +skip23: + mov ax,-4[si] + test ax,ax + jz skip2 + mul cx + add temp,ax + adc temp+2,dx + adc temp+4,0 +skip2: + mov cx,-6[bx] + jcxz skip3 + mov ax,-10[si] + test ax,ax + jz skip3x + mul cx + add temp-2,dx + adc temp,0 + adc temp+2,0 + adc temp+4,0 +skip3x: + mov ax,-8[si] + test ax,ax + jz skip31 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 + adc temp+4,0 +skip31: + mov ax,-6[si] + test ax,ax + jz skip32 + mul cx + add temp,ax + adc temp+2,dx + adc temp+4,0 +skip32: + mov ax,-4[si] + test ax,ax + jz skip3 + mul cx + add temp+2,ax + adc temp+4,dx + adc temp+6,0 +skip3: + mov cx,-4[bx] + jcxz skip4 + mov ax,-10[si] + test ax,ax + jz skip41 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 + adc temp+4,0 + adc temp+6,0 +skip41: + mov ax,-8[si] + test ax,ax + jz skip42 + mul cx + add temp,ax + adc temp+2,dx + adc temp+4,0 + adc temp+6,0 +skip42: + mov ax,-6[si] + test ax,ax + jz skip43 + mul cx + add temp+2,ax + adc temp+4,dx + adc temp+6,0 +skip43: + mov ax,-4[si] + test ax,ax + jz skip4 + mul cx + add temp+4,ax + adc temp+6,dx +skip4: + lea di,-4[si] + mov si,offset temp+6 + mov cx,5 +rep movs word ptr [di], word ptr [si] + jmp do_normalize +; + intrdef $utod + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov di,flprm + mov byte ptr [di],0 ;make sign positive + mov word ptr -2[di],1023+12 ;set exponent + sub di,4 + stos word ptr [di] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp do_normalize +; + intrdef $itod + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov di,flprm + mov byte ptr [di],0 ;make sign positive + mov word ptr -2[di],1023+12 ;set exponent + test ax,ax + jns pos_int + neg ax + mov byte ptr [di],80H ;make sign negative +pos_int: + sub di,4 + stos word ptr [di] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp do_normalize +; +dornd proc near + ; round the number in the primary accumulator + mov di,flprm + mov ax,word ptr -12[di] + mov word ptr -12[di],0 + cmp byte ptr -10[di],80H + mov byte ptr -10[di],0 + jb rndexit + jne round_up + test ax,ax + jnz round_up + or byte ptr -9[di],1 ;round up on even, down on odd + ret +round_up: + add byte ptr -9[di],1 + adc word ptr -8[di],0 + adc word ptr -6[di],0 + adc word ptr -4[di],0 + cmp byte ptr -3[di],20h + jb rndexit + inc word ptr -2[di] ;bump exponent + shr word ptr -4[di],1 ;and re-normalize number + rcr word ptr -6[di],1 + rcr word ptr -8[di],1 + rcr word ptr -10[di],1 +rndexit: + ret +dornd endp +; + intrdef $xtod + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov di,flprm + mov byte ptr [di],0 ;make sign positive + mov word ptr -2[di],1023+28 ;set exponent + test dx,dx + jns pos_long + neg dx + neg ax + sbb dx,0 + mov byte ptr [di],80H ;make sign negative +pos_long: + sub di,4 + xchg ax,dx + stos word ptr [di] + xchg ax,dx + stos word ptr [di] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp do_normalize +; + intrdef $dtou + intrdef $dtoi + intrdef $dtox + push si + push di + mov si,flprm + sub ax,ax + mov temp,ax + mov temp+2,ax + mov temp+4,ax + mov temp+6,ax + mov ax,word ptr -2[si] + sub ax,1023 + js d2x_zero + cmp ax,54 + jae d2x_zero + mov di,ds + mov es,di + mov di,offset temp + sub bx,bx + mov cx,ax + mov ax,4 +d2x_count: + sub cx,ax + jbe d2x_cdone + dec bx + mov ax,8 + jmp d2x_count +d2x_cdone: + mov dl,byte ptr -3[si][bx] + mov byte ptr [di],dl + inc di + inc bx + jle d2x_cdone + neg cx + mov ax,temp + mov dx,temp+2 + mov bx,temp+4 ;added 9/22/86 TTF to fix >29 bit converts + jcxz d2x_nshift +d2x_shift: + shr bx,1 ;added 9/22/86 TTF to fix >29 bit converts + rcr dx,1 ;chgd as above + rcr ax,1 + loop d2x_shift +d2x_nshift: + test byte ptr [si],80H + jz d2x_ret + neg dx + neg ax + sbb dx,0 +d2x_ret: + pop di + pop si + ret + +d2x_zero: + sub ax,ax + sub dx,dx + pop di + pop si + ret + + intrdef $dstat ; save floating state in buf es:bx + push si + push di + mov di,bx + mov si, offset flterr_ ; get start of data area + mov cx, offset lcnt1+1 ; get end of data area + sub cx, si ; get size +rep movs byte ptr [di], byte ptr [si] ; save floating state + pop di + pop si + ret + + intrdef $drest ; restore floating state from buf es:bx + push si + push di + push ds + mov dx,ds ; swap segment registers + mov cx,es + mov ds,cx + mov es,dx + mov si,bx + mov di, offset flterr_ ; get start of data area + mov cx, offset lcnt1+1 ; get end of data area + sub cx, di ; get size +rep movs byte ptr [di], byte ptr [si] ; restore floating state + pop ds + pop di + pop si + ret + +; +; +fault_handler: + pop di + pop si + pop bp + popf + ret +; +ifndef INTERNAL +$floats endp + finish + end +endif + sqrt87.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' +status dw ? + extrn chop_ctl:word, round_ctl:word + extrn errno_:word +dataseg ends + assume ds:dataseg + +ERANGE equ -20 +EDOM equ -21 + + procdef sqrt, <> +; +; double sqrt(d) +; + wait + db 0dbh,0e3h ;finit + wait + esc 40,doub ;fld qword ptr doub + wait + db 0d9h,0e4h ;ftst + wait + esc 47,status ;fstsw exponent + mov ah,byte ptr status+1 + sahf + jnb sqrt_ok + wait + db 0d9h,0e0h ;fchs + mov errno_,EDOM + wait +sqrt_ok: + db 0d9h,0fah ;fsqrt + pret + pend sqrt + finish + end + frexp87.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -10 -8 -6 -4 -2 0 +; |grd + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + include lmacros.h +ifndef FARPROC + extrn $isnan:near +else + extrn $isnan:far +endif + +dataseg segment word public 'data' +status dw ? + extrn chop_ctl:word, round_ctl:word +dataseg ends + assume ds:dataseg + + procdef isnan,<> + wait + db 0dbh,0e3h ;finit + wait + esc 40,ddd ;fld qword ptr 4[bp] + wait + call $isnan + pret + pend isnan + + procdef frexp,<,> +; +; frexp(d, &i) +; returns 0 <= x < 1 +; such that: d = x * 2^i + wait + db 0dbh,0e3h ;finit + wait + db 0d9h,0e8h ;fld1 + wait + db 0d9h,0e0h ;fchs + wait + esc 40,d ;fld qword ptr 4[bp] + wait + db 0d9h,0e4h ;ftst + wait + esc 47,status ;fstsw exponent + mov ah,byte ptr status+1 + sahf + je zero + wait + db 0d9h,0f4h ;fxtract + wait + db 0d9h,0c9h ;fxch + wait + db 0d8h,0e2h ;fsub st,st(2) + ldptr bx,i,es + wait +ifdef LONGPTR + esc 59,es:[bx] ;fistp word ptr [bx] +else + esc 59,ds:[bx] ;fistp word ptr [bx] +endif + wait + db 0d9h,0fdh ;fscale + pret +zero: + ldptr bx,i,es +ifdef LONGPTR + mov es:word ptr [bx],0 +else + mov ds:word ptr [bx],0 +endif + pret + pend frexp +; +; ldexp(d, i) +; returns x = d * 2^i + procdef ldexp, <,> + wait + db 0dbh,0e3h ;finit + wait + esc 56,ii ;fild word ptr 12[bp] + wait + esc 40,dou ;fld qword ptr 4[bp] + wait + db 0d9h,0fdh ;fscale + pret + pend ldexp +; +; modf(d, dptr) +; returns fractional part of d, and +; stores integral part into *dptr + procdef modf, <,> + wait + db 0dbh,0e3h ;finit + wait + esc 40,doub ;fld qword ptr 4[bp] + wait + db 0d9h,0c0h ;fld st(0) + wait + esc 13,chop_ctl ;fldcw chop_ctl + wait + db 0d9h,0fch ;frndint + ldptr bx,dptr,es + wait + esc 13,round_ctl ;fldcw round_ctl + wait +ifdef LONGPTR + esc 42,es:[bx] ;fst qword ptr [bx] +else + esc 42,ds:[bx] ;fst qword ptr [bx] +endif + wait + db 0deh,0e9h ;fsub + pret + pend modf + finish + end + fsubs87.asm +; Copyright (C) 1983 by Manx Software Systems +; page 54,130 +; :ts=8 +; floating point system error codes: + +ifndef INTERNAL + include lmacros.h +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + internal $floats +endif + +dataseg segment word public 'data' +ifndef INTERNAL + public flterr_ +flterr_ dw 0 +endif + +second db 8 dup (?) +work dw 4 dup (?) +status dw 0 + public chop_ctl, round_ctl, rdown_ctl +chop_ctl dw 0fbfH ;control word for Chop mode +round_ctl dw 03bfH ;control word for Round nearest mode +rdown_ctl dw 07bfh ;control word for Round Down mode +dataseg ends +ifdef LONGPTR + assume ds:dataseg +else + assume ds:dataseg,es:dataseg,ss:dataseg +endif +ifdef FARPROC +frame equ 4 +else +frame equ 2 +endif + + intrdef $isnan + wait + db 0d9h,0e5h ;fxam + wait + esc 47,status ;fstsw status + wait + mov ah,byte ptr status+1 + and ah,047h + cmp ah,1 + jz lnan + cmp ah,2 + jz lnan + cmp ah,5 + jz linf + cmp ah,7 + jz linf + sub ax,ax + ret +lnan: + sub ax,ax + inc ax + ret +linf: + sub ax,ax + inc ax + inc ax + ret + + intrdef $flds ;load single float into secondary accum +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + wait + esc 8,es:[bx] ;fld dword ptr [bx] + wait + esc 43,second ;fstp qword ptr second + ret + +ifdef LONGPTR + intrdef $fldsss ;load single float into secondary accum + wait + esc 8,ss:[bx] ;fld dword ptr [bx] + wait + esc 43,second ;fstp qword ptr second + ret + + intrdef $fldsds ;load single float into secondary accum + wait + esc 8,ds:[bx] ;fld dword ptr [bx] + wait + esc 43,second ;fstp qword ptr second + ret +endif +; + intrdef $fldp ;load single float into primary accum +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + wait + db 0dbh,0e3h ;finit + wait + esc 8,es:[bx] ;fld dword ptr [bx] + ret +; +ifdef LONGPTR + intrdef $fldpss ;load single float into primary accum + wait + db 0dbh,0e3h ;finit + wait + esc 8,ss:[bx] ;fld dword ptr [bx] + ret +; + intrdef $fldpds ;load single float into primary accum + wait + db 0dbh,0e3h ;finit + wait + esc 8,ds:[bx] ;fld dword ptr [bx] + ret +endif +; + intrdef $fst ;store single at addr in BX +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + wait + esc 10,es:[bx] ;fst dword ptr [bx] + wait + ret +; + intrdef $fsts ;store single at addr in BX +ifndef LONGPTR + mov ax,ds + mov es,ax +endif +; wait +; esc 40,second ;fld qword ptr second +;; wait +; db 0d9h,0c9h ;fxch +; wait +; esc 43,second ;fstp qword ptr second +; wait +; esc 10,es:[bx] ;fst dword ptr [bx] +; wait +; esc 40,second ;fld qword ptr second +; wait +; db 0d9h,0c9h ;fxch +; wait +; esc 43,second ;fstp qword ptr second + wait + esc 40,second ;fld qword ptr second + wait + esc 43,es:[bx] ;fstp dword ptr [bx] + ret +; +ifdef LONGPTR + intrdef $fstss ;store single at addr in BX + wait + esc 10,ss:[bx] ;fst dword ptr [bx] + wait + ret +; + intrdef $fstsds ;store single at addr in BX +; wait +; esc 40,second ;fld qword ptr second +; wait +; db 0d9h,0c9h ;fxch +; wait +; esc 43,second ;fstp qword ptr second +; wait +; esc 10,ds:[bx] ;fst dword ptr [bx] +; wait +; esc 40,second ;fld qword ptr second +; wait +; db 0d9h,0c9h ;fxch +; wait +; esc 43,second ;fstp qword ptr second + wait + esc 40,second ;fld qword ptr second + wait + esc 43,ds:[bx] ;fstp dword ptr [bx] + ret + + intrdef $fstsss ;store single at addr in BX +; wait +; esc 40,second ;fld qword ptr second +; wait +; db 0d9h,0c9h ;fxch +; wait +; esc 43,second ;fstp qword ptr second +; wait +; esc 10,ss:[bx] ;fst dword ptr [bx] +; wait +; esc 40,second ;fld qword ptr second +; wait +; db 0d9h,0c9h ;fxch +; wait +; esc 43,second ;fstp qword ptr second + wait + esc 40,second ;fld qword ptr second + wait + esc 43,ds:[bx] ;fstp dword ptr [bx] + ret +; + intrdef $fstds ;store single at addr in BX + wait + esc 10,ds:[bx] ;fst dword ptr [bx] + wait + ret +endif +; + intrdef $dlis ;load double immediate secondary + pop bx +ifdef FARPROC + pop dx +endif + push di + push si + mov di,ds + mov es,di + mov di,offset second + mov si,bx ;get return addr + mov cx,4 +ifdef FARPROC + push ds + mov ds,dx +lis_lp: ;8086 doesn't handle double prefixes + movs word ptr [di], word ptr [si] +else +lis_lp: ;8086 doesn't handle double prefixes + movs word ptr [di], cs:word ptr [si] +endif + loop lis_lp + mov bx,si +ifdef FARPROC + pop ds +endif + pop si + pop di +ifdef FARPROC + push dx + push bx + ret +else + jmp bx +endif + +; +ifdef LONGPTR + intrdef $dldsss + mov cx,ss + mov es,cx + jmp dodlds + + intrdef $dldsds + push di + push si + push ds + mov cx,ds + mov es,cx + jmp dodldsx +endif + intrdef $dlds ;load double float into secondary accum +dodlds: + push di + push si +ifdef LONGPTR + push ds + mov di,ds + mov si,es + mov ds,si + mov es,di +else + mov di,ds + mov es,di +endif +dodldsx: + mov di,offset second + mov si,bx + mov cx,4 +rep movsw + popds + pop si + pop di + ret +; + intrdef $dlip ;load double immediate primary + wait + db 0dbh,0e3h ;finit + pop bx +ifdef FARPROC +ifndef LONGPTR + mov cx,es +endif + pop es + wait + esc 40,es:[bx] ;fld cs:qword ptr [bx] + add bx,8 + push es + push bx +ifndef LONGPTR + mov es,cx +endif + ret +else + wait + esc 40,cs:[bx] ;fld cs:qword ptr [bx] + add bx,8 + jmp bx +endif +; +ifdef LONGPTR + intrdef $dldpss ;load double float into primary accum + wait + db 0dbh,0e3h ;finit + wait + esc 40,ss:[bx] ;fld qword ptr [bx] + ret + + intrdef $dldpds ;load double float into primary accum + wait + db 0dbh,0e3h ;finit + wait + esc 40,ds:[bx] ;fld qword ptr [bx] + ret +endif + intrdef $dldp ;load double float into primary accum +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + wait + db 0dbh,0e3h ;finit + wait + esc 40,es:[bx] ;fld qword ptr [bx] + ret +; + intrdef $dsts + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + call $dst + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + wait + ret + + intrdef $dst ;store double at addr in BX +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + wait + esc 42,es:[bx] ;fst qword ptr [bx] + wait + ret +ifdef LONGPTR + intrdef $dstss ;store double at addr in BX + wait + esc 42,ss:[bx] ;fst qword ptr [bx] + wait + ret + + intrdef $dstds ;store double at addr in BX + wait + esc 42,ds:[bx] ;fst qword ptr [bx] + wait + ret + + intrdef $dstsss ;store double at addr in BX + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + wait + esc 42,ss:[bx] ;fst qword ptr [bx] + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + ret + + intrdef $dstsds ;store double at addr in BX + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + wait + esc 42,ds:[bx] ;fst qword ptr [bx] + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + ret +endif +; + intrdef $dpsh ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back +ifdef LONGPTR + jmp $dstss +else + jmp $dst +endif +; + intrdef $dpshs ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back +ifdef LONGPTR + jmp $dstsss +else + jmp $dsts +endif + intrdef $dpopp ;pop double float into secondary accum + push bx + push es + mov bx,sp + add bx,frame+4 ;address of data to load +ifdef LONGPTR + call $dldpss +else + call $dldp +endif + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dpop ;pop double float into secondary accum + push bx + push es + mov bx,sp + add bx,frame+4 ;address of data to load +ifdef LONGPTR + call $dldsss +else + call $dlds +endif + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dswap ;exchange primary and secondary + wait + esc 40,second ;fld qword ptr second + wait + db 0d9h,0c9h ;fxch + wait + esc 43,second ;fstp qword ptr second + ret +; + intrdef $dng ;negate primary + wait + db 0d9h,0e0h ;fchs + ret +; + intrdef $dtst ;test if primary is zero + wait + db 0d9h,0e4h ;ftst + wait + esc 47,status ;fstsw status + wait + mov ah,byte ptr status+1 + sahf + jne ltrue + sub ax,ax + ret +ltrue: + sub ax,ax + inc ax + ret +; + intrdef $dcmp ;compare primary and secondary + wait + esc 34,second ;fcom qword ptr second + wait + esc 47,status ;fstsw status + wait + mov ah,byte ptr status+1 + sahf + jb lp_lt_s + ja lp_gt_s + ;return 0 if p == s + xor ax,ax + ret + ;return 0 if p == s +lp_lt_s: ;return < 0 if p < s + xor ax,ax + dec ax + ret +; +lp_gt_s: ; > 0 if p > s + xor ax,ax + inc ax + ret +; + intrdef $dsb ;subtract secondary from primary + wait + esc 36,second ;fsub qword ptr second + ret +; + intrdef $dad ;add secondary to primary + wait + esc 32,second ;fadd qword ptr second + ret +; + intrdef $ddv + ;double floating divide (primary = primary/secondary) + wait + esc 38,second ;fdiv qword ptr second + ret +; + intrdef $dml + ;double floating multiply (primary = primary * secondary) + wait + esc 33,second ;fmul qword ptr second + ret +; + intrdef $utod + wait + db 0dbh,0e3h ;finit + mov work,ax + mov work+2,0 + wait + esc 24,work ;fild dword ptr work + ret +; + intrdef $itod + wait + db 0dbh,0e3h ;finit + mov work,ax + wait + esc 56,work ;fild word ptr work + ret +; + intrdef $xtod + wait + db 0dbh,0e3h ;finit + mov work,ax + mov work+2,dx + wait + esc 24,work ;fild dword ptr work + ret +; + intrdef $dtou + intrdef $dtoi + intrdef $dtox + wait + esc 13,chop_ctl ;fldcw chop_ctl + wait + esc 26,work ;fist dword ptr work + wait + esc 13,round_ctl ;fldcw round_ctl + mov ax,work + mov dx,work+2 + ret + + intrdef $dstat ; save floating state in buf es:bx + push si + push di + push ds + mov di,bx + mov si,offset flterr_ ;get start of data + mov cx,offset status+2 ;get end of data + sub cx,si ;get size + add bx,cx ;save end +rep movs byte ptr [di], byte ptr [si] ; save data + mov cx,es + mov ds,cx + esc 101110b,[bx] ; save floating state (acts like finit) + wait + esc 101100b,[bx] ; restore floating state + pop ds + pop di + pop si + ret + + intrdef $drest ; restore floating state from buf es:bx + push si + push di + push ds + mov si,bx + mov cx,es ; swap segment registers + mov dx,ds + mov es,dx + mov ds,cx + mov di,offset flterr_ ;get start of data + mov cx,offset status+2 ;get end of data + sub cx,di ;get size + add bx,cx ;save end +rep movs byte ptr [di], byte ptr [si] ; save data + esc 101100b,[bx] ; restore floating state + wait + pop ds + pop di + pop si + ret + +ifndef INTERNAL +$floats endp + finish + end +endif + frexp87s.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -10 -8 -6 -4 -2 0 +; |grd + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + include lmacros.h +dataseg segment word public 'data' + dw 5 dup (?) +temp dw ? + extrn flprm:word,flsec:word + extrn flterr_:word +status dw ? + extrn $flt_inx:word,chop_ctl:word, round_ctl:word +dataseg ends + assume ds:dataseg + +ifdef FARPROC + extrn $dldp:far, $dst:far, $itod:far + extrn $dad:far, $dsb:far, $isnan:far +else + extrn $dldp:near, $dst:near, $itod:near + extrn $dad:near, $dsb:near, $isnan:near +endif + procdef isnan,<> +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,ddd ;compute address of first argument + call $dldp ;load it into the float primary + call $isnan + pret + pend isnan + + procdef frexp, <,> +; +; frexp(d, &i) +; returns 0 <= x < 1 +; such that: d = x * 2^i +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,d ;compute address of first argument + call $dldp ;load it into the float primary + mov cx,$flt_inx + or cx,cx + jnz $frexp87 + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz fr_nzero + ldptr bx,i,es ;get pointer +ifdef LONGPTR + mov es:word ptr [bx],0 +else + mov ds:word ptr [bx],0 +endif + pret +fr_nzero: + sub ax,1022 + mov word ptr -2[bx],1022 + ldptr bx,i,es ;get pointer +ifdef LONGPTR + mov es:word ptr [bx],ax +else + mov ds:word ptr [bx],ax +endif + pret +$frexp87: + wait + db 0dbh,0e3h ;finit + wait + db 0d9h,0e8h ;fld1 + wait + db 0d9h,0e0h ;fchs + wait + esc 40,d ;fld qword ptr 4[bp] + wait + db 0d9h,0e4h ;ftst + wait + esc 47,status ;fstsw exponent + mov ah,byte ptr status+1 + sahf + je zero + wait + db 0d9h,0f4h ;fxtract + wait + db 0d9h,0c9h ;fxch + wait + db 0d8h,0e2h ;fsub st,st(2) + ldptr bx,i,es + wait +ifdef LONGPTR + esc 59,es:[bx] ;fistp word ptr [bx] +else + esc 59,ds:[bx] ;fistp word ptr [bx] +endif + wait + db 0d9h,0fdh ;fscale + pret +zero: + ldptr bx,i,es +ifdef LONGPTR + mov es:word ptr [bx],0 +else + mov ds:word ptr [bx],0 +endif + pret + pend frexp +; +; ldexp(d, i) +; returns x = d * 2^i + procdef ldexp, <,> +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,dou ;compute address of first argument + call $dldp ;load it into the float primary + mov cx,$flt_inx + or cx,cx + jnz $ldexp87 + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jz ld_zero + add ax,ii ;add i to exponent + js ld_underflow + cmp ax,2048 + jl ld_ret + mov flterr_,UNDER_FLOW + mov ax,2047 +ld_ret: + mov word ptr -2[bx],ax +ld_zero: + pret +; +ld_underflow: + mov flterr_,UNDER_FLOW + sub ax,ax + jmp ld_ret +$ldexp87: + wait + db 0dbh,0e3h ;finit + wait + esc 56,ii ;fild word ptr 12[bp] + wait + esc 40,dou ;fld qword ptr 4[bp] + wait + db 0d9h,0fdh ;fscale + pret + pend ldexp +; +; modf(d, dptr) +; returns fractional part of d, and +; stores integral part into *dptr + procdef modf,<,> + push di + push si + pushds +ifdef LONGPTR + mov bx,ss + mov es,bx +endif + lea bx,doubl ;compute address of first argument + call $dldp ;load it into the float primary + mov cx,$flt_inx + or cx,cx + jz around + jmp $modf87 +around: + std + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz mf_nzero + ldptr bx,dptr,es ;get pointer + call $dst +mf_return: + cld + popds + pop si + pop di + pret +mf_nzero: + mov di,ds + mov es,di + mov si,bx + mov di,offset temp + mov cx,6 ;save value for fraction part later +rep movsw + sub ax,1023 + jns int_notzero + mov ax,0 + call $itod + jmp get_fraction +int_notzero: + cmp ax,52 + jna mf_frac + ;fraction is zero + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + sub ax,ax + call $itod + jmp mf_return +mf_frac: + sub di,di + mov cx,ax + mov ax,4 +mf_count: + sub cx,ax + jbe mf_cdone + dec di + mov ax,8 + jmp mf_count +mf_cdone: + jcxz no_shift + neg cx + mov al,byte ptr -3[bx][di] + shr al,cl + shl al,cl + mov byte ptr -3[bx][di],al +no_shift: + dec di +zap_loop: + cmp di,-8 + jle get_fraction + mov byte ptr -3[bx][di],0 + dec di + jmp zap_loop +get_fraction: + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + std + popds + pushds + mov di,flprm + xchg di,flsec + mov flprm,di + mov si,ds + mov es,si + mov si,offset temp + mov cx,6 ;restore original value +rep movsw + call $dsb ;compute fractional part + jmp mf_return +$modf87: + wait + db 0dbh,0e3h ;finit + wait + esc 40,doubl ;fld qword ptr 4[bp] + wait + db 0d9h,0c0h ;fld st(0) + wait + esc 13,chop_ctl ;fldcw chop_ctl + wait + db 0d9h,0fch ;frndint + ldptr bx,dptr,es + wait + esc 13,round_ctl ;fldcw round_ctl + wait +ifdef LONGPTR + esc 42,es:[bx] ;fst qword ptr [bx] +else + esc 42,ds:[bx] ;fst qword ptr [bx] +endif + wait + db 0deh,0e9h ;fsub + popds + pop si + pop di + pret + pend modf + finish + end + sqrt87s.asm + include lmacros.h +dataseg segment para public 'data' +status dw ? + extrn chop_ctl:word, round_ctl:word + extrn errno_:word + extrn $flt_inx:word +dataseg ends + assume ds:dataseg +;#include "math.h" +;#include "errno.h" +ifdef FARPROC +OFFS equ 2 +else +OFFS equ 0 +endif +; +ifndef LONGPTR +$dldsss equ $dlds +$dldpss equ $dldp +$dstss equ $dst +$dldsds equ $dlds +$dldpds equ $dldp +$dstds equ $dst +$fldsss equ $flds +$fldpss equ $fldp +$fstss equ $fst +$fldsds equ $flds +$fldpds equ $fldp +$fstds equ $fst +endif +;double sqrt(x) +;double x; + procdef sqrt, <> + lea bx,doub + call $dldpss + mov cx,$flt_inx + or cx,cx + jz $sqrt86 +; +; + +ERANGE equ -20 +EDOM equ -21 + +$sqrt87: + wait + db 0dbh,0e3h ;finit + wait + esc 40,ss:4+OFFS[bp] ;fld qword ptr 4+OFFS[bp] + wait + db 0d9h,0e4h ;ftst + wait + esc 47,status ;fstsw exponent + mov ah,byte ptr status+1 + sahf + jnb sqrt_ok + wait + db 0d9h,0e0h ;fchs + mov errno_,EDOM + wait +sqrt_ok: + db 0d9h,0fah ;fsqrt + pret sqrt +; +$sqrt86: +; +;{ +; double f, y; +; int n; +; extern int errno; + add sp,$2 + push di + push si +; +; if (x == 0.0) +; return x; + call $dlis + db 00H,00H,00H,00H,00H,00H,00H,00H + call $dcmp + jne $3 + lea bx,doub + call $dldpss + jmp $cret +; if (x < 0.0) { +$3: + lea bx,doub + call $dldpss + call $dlis + db 00H,00H,00H,00H,00H,00H,00H,00H + call $dcmp + jge $4 +; errno = EDOM; + mov word ptr errno_,22 +; return 0.0; + call $dlip + db 00H,00H,00H,00H,00H,00H,00H,00H + + jmp $cret +; } +; f = frexp(x, &n); +$4: + lea ax,word ptr -18[bp] +ifdef LONGPTR + push ss +endif + push ax + lea bx,doub + call $dldpss + call $dpsh + call frexp_ +ifdef LONGPTR + add sp,12 +else + add sp,10 +endif + lea bx,word ptr -8[bp] + call $dstss +; y = 0.41731 + 0.59016 * f; + lea bx,word ptr -8[bp] + call $dldpss + call $dlis + db 018H,09H,06dH,039H,097H,0e2H,0e2H,03fH + call $dml + call $dlis + db 0f7H,0ccH,092H,00H,035H,0b5H,0daH,03fH + call $dad + lea bx,word ptr -16[bp] + call $dstss +; y = (y + f/y); + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + lea bx,word ptr -16[bp] + call $dldsss + call $dad + lea bx,word ptr -16[bp] + call $dstss +; y = ldexp(y,-2) + f/y; /* fast calculation of y2 */ + mov ax,-2 + push ax + lea bx,word ptr -16[bp] + call $dldpss + call $dpsh + call ldexp_ + add sp,10 + call $dpsh + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + call $dpop + call $dad + lea bx,word ptr -16[bp] + call $dstss +; y = ldexp(y + f/y, -1); + mov ax,-1 + push ax + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + lea bx,word ptr -16[bp] + call $dldsss + call $dad + call $dpsh + call ldexp_ + add sp,10 + lea bx,word ptr -16[bp] + call $dstss +; y = ldexp(y + f/y, -1); + mov ax,-1 + push ax + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + lea bx,word ptr -16[bp] + call $dldsss + call $dad + call $dpsh + call ldexp_ + add sp,10 + lea bx,word ptr -16[bp] + call $dstss +; +; if (n&1) { + mov ax,word ptr -18[bp] + test ax,1 + jeq $5 +; y *= 0.70710678118654752440; + lea bx,word ptr -16[bp] + call $dldpss + call $dlis + db 0cdH,03bH,07fH,066H,09eH,0a0H,0e6H,03fH + call $dml + lea bx,word ptr -16[bp] + call $dstss +; ++n; + inc word ptr -18[bp] +; } +; return ldexp(y,n/2); +$5: + mov ax,word ptr -18[bp] + mov cx,2 + cwd + idiv cx + push ax + lea bx,word ptr -16[bp] + call $dldpss + call $dpsh + call ldexp_ + add sp,10 + jmp $cret + +$cret: + pop si + pop di + mov sp,bp + pop bp + ret +;} +$2 = -18 +; +ifdef FARPROC + extrn frexp_:far + extrn ldexp_:far + extrn $dad:far,$dsb:far,$dml:far,$ddv:far + extrn $dldp:far,$dlds:far,$dlip:far,$dlis:far,$dst:far + extrn $fldp:far,$flds:far,$fst:far,$dcmp:far,$dtst:far + extrn $dpsh:far,$dpopp:far,$dpop:far,$dng:far,$dswap:far + extrn $itod:far,$utod:far,$xtod:far + extrn $dtoi:far,$dtou:far,$dtox:far +else + extrn frexp_:near + extrn ldexp_:near + extrn $dad:near,$dsb:near,$dml:near,$ddv:near + extrn $dldp:near,$dlds:near,$dlip:near,$dlis:near,$dst:near + extrn $fldp:near,$flds:near,$fst:near,$dcmp:near,$dtst:near + extrn $dpsh:near,$dpopp:near,$dpop:near,$dng:near,$dswap:near + extrn $itod:near,$utod:near,$xtod:near + extrn $dtoi:near,$dtou:near,$dtox:near +endif +ifdef LONGPTR +ifdef FARPROC + extrn $dldpss:far,$dldsss:far,$dstss:far + extrn $dldpds:far,$dldsds:far,$dstds:far + extrn $fldpss:far,$fldsss:far,$fstss:far + extrn $fldpds:far,$fldsds:far,$fstds:far +else + extrn $dldpss:near,$dldsss:near,$dstss:near + extrn $dldpds:near,$dldsds:near,$dstds:near + extrn $fldpss:near,$fldsss:near,$fstss:near + extrn $fldpds:near,$fldsds:near,$fstds:near +endif +endif + pend sqrt +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + end + fsubs87s.asm +; Copyright (C) 1983 by Manx Software Systems +; page 54,130 +; :ts=8 +; floating point system error codes: + include lmacros.h + + internal $floats + +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + public flterr_ +dataseg segment para public 'data' + public $flt_inx +$flt_inx dw 0 ; 8087/software emulation switch index +flterr_ dw 0 +dataseg ends + +ifdef LONGPTR + assume ds:dataseg +else + assume ds:dataseg,es:dataseg,ss:dataseg +endif + +ifdef FARPROC +CALLSZ equ 5 +else +CALLSZ equ 3 +endif + +dataseg segment para public 'data' +$flttb86: ; 8086 software indirection table + dw $isnan86 + dw $flds86 + dw $fldp86 + dw $fst86 + dw $fsts86 + dw $dlis86 + dw $dlds86 + dw $dlip86 + dw $dldp86 + dw $dst86 + dw $dsts86 + dw $dpsh86 + dw $dpshs86 + dw $dpop86 + dw $dpopp86 + dw $dswap86 + dw $dng86 + dw $dtst86 + dw $dcmp86 + dw $dsb86 + dw $dad86 + dw $ddv86 + dw $dml86 + dw $utod86 + dw $itod86 + dw $xtod86 + dw $dtoi86 + dw $dstat86 + dw $drest86 +ifdef LONGPTR + dw $fldsss86 + dw $fldsds86 + dw $fldpss86 + dw $fldpds86 + dw $fstss86 + dw $fstds86 + dw $fstsss86 + dw $fstsds86 + dw $dldsss86 + dw $dldsds86 + dw $dldpss86 + dw $dldpds86 + dw $dstss86 + dw $dstds86 + dw $dstsss86 + dw $dstsds86 +endif + +$flttb87: ; 8087 hardware indirection table + dw $isnan87 + dw $flds87 + dw $fldp87 + dw $fst87 + dw $fsts87 + dw $dlis87 + dw $dlds87 + dw $dlip87 + dw $dldp87 + dw $dst87 + dw $dsts87 + dw $dpsh87 + dw $dpshs87 + dw $dpop87 + dw $dpopp87 + dw $dswap87 + dw $dng87 + dw $dtst87 + dw $dcmp87 + dw $dsb87 + dw $dad87 + dw $ddv87 + dw $dml87 + dw $utod87 + dw $itod87 + dw $xtod87 + dw $dtoi87 + dw $dstat87 + dw $drest87 +ifdef LONGPTR + dw $fldsss87 + dw $fldsds87 + dw $fldpss87 + dw $fldpds87 + dw $fstss87 + dw $fstds87 + dw $fstsss87 + dw $fstsds87 + dw $dldsss87 + dw $dldsds87 + dw $dldpss87 + dw $dldpds87 + dw $dstss87 + dw $dstds87 + dw $dstsss87 + dw $dstsds87 +endif +dataseg ends + + +$flttb: ; initial indirection table +$isnantb dw $flt_tst +$fldstb dw $flt_tst +$fldptb dw $flt_tst +$fsttb dw $flt_tst +$fststb dw $flt_tst +$dlistb dw $flt_tst +$dldstb dw $flt_tst +$dliptb dw $flt_tst +$dldptb dw $flt_tst +$dsttb dw $flt_tst +$dststb dw $flt_tst +$dpshtb dw $flt_tst +$dpshstb dw $flt_tst +$dpoptb dw $flt_tst +$dpopptb dw $flt_tst +$dswaptb dw $flt_tst +$dngtb dw $flt_tst +$dtsttb dw $flt_tst +$dcmptb dw $flt_tst +$dsbtb dw $flt_tst +$dadtb dw $flt_tst +$ddvtb dw $flt_tst +$dmltb dw $flt_tst +$utodtb dw $flt_tst +$itodtb dw $flt_tst +$xtodtb dw $flt_tst +$dtoitb dw $flt_tst +$dstattb dw $flt_tst +$dresttb dw $flt_tst +ifdef LONGPTR +$fldssstb dw $flt_tst +$fldsdstb dw $flt_tst +$fldpsstb dw $flt_tst +$fldpdstb dw $flt_tst +$fstsstb dw $flt_tst +$fstdstb dw $flt_tst +$fstssstb dw $flt_tst +$fstsdstb dw $flt_tst +$dldssstb dw $flt_tst +$dldsdstb dw $flt_tst +$dldpsstb dw $flt_tst +$dldpdstb dw $flt_tst +$dstsstb dw $flt_tst +$dstdstb dw $flt_tst +$dstssstb dw $flt_tst +$dstsdstb dw $flt_tst +endif + + +ifdef LONGPTR +SIZFLTTB equ 45 +else +SIZFLTTB equ 29 +endif + +$flt_tst: +; test for 8087 goes here + push si + push di + push es + mov ds:status,0 + esc 28,bx ; finit (initialize 8087) + xor cx,cx + esc 15,ds:status ; fstcw + mov cx,50 +w1loop: loop w1loop ; wait for a while + and status,01f3fh ; clear unused bits + cmp status,0033fh ; is 8087 there? + mov si,offset $flttb86 ; assume not + mov cx,0 + jnz $fltnxt ; no, use software emulation + wait + esc 47,status ; fstsw status + mov cx,50 +w2loop: loop w2loop ; wait for a while + test ds:status,0b8bfh ; all status bits should be off + mov si,offset $flttb86 ; assume not + mov cx,0 + jnz $fltnxt ; bad status, assume not there + mov si,offset $flttb87 ; 8087 is there! + mov cx,2 +$fltnxt: + mov $flt_inx,cx ; set index for outside routines + mov di,cs + mov es,di + mov di,cs:offset $flttb ; get pointer to indirection table + mov cx,SIZFLTTB + cld +rep movsw ; and overwrite it with new table + pop es + pop di + pop si + pop cx ; get return address offset part + sub cx,CALLSZ ; back up return over call + push cx ; put back on stack + ret ; and return to reissue call + + intrdef $isnan + jmp cs:word ptr $isnantb + + intrdef $flds ;load single float into secondary accum + jmp cs:word ptr $fldstb + +ifdef LONGPTR + intrdef $fldsss ;load single float into secondary accum + jmp cs:word ptr $fldssstb + + intrdef $fldsds ;load single float into secondary accum + jmp cs:word ptr $fldsdstb +endif +; + intrdef $fldp ;load single float into primary accum + jmp cs:word ptr $fldptb +; +ifdef LONGPTR + intrdef $fldpss ;load single float into primary accum + jmp cs:word ptr $fldpsstb +; + intrdef $fldpds ;load single float into primary accum + jmp cs:word ptr $fldpdstb +endif +; + intrdef $fst ;store single at addr in BX + jmp cs:word ptr $fsttb +; + intrdef $fsts ;store single at addr in BX + jmp cs:word ptr $fststb +; +ifdef LONGPTR + intrdef $fstss ;store single at addr in BX + jmp cs:word ptr $fstsstb +; + intrdef $fstds ;store single at addr in BX + jmp cs:word ptr $fstdstb + + intrdef $fstsss ;store single at addr in BX + jmp cs:word ptr $fstssstb +; + intrdef $fstsds ;store single at addr in BX + jmp cs:word ptr $fstsdstb +endif +; + intrdef $dlis ;load double immediate secondary + jmp cs:word ptr $dlistb +; +ifdef LONGPTR + intrdef $dldsss + jmp cs:word ptr $dldssstb + + intrdef $dldsds + jmp cs:word ptr $dldsdstb +endif + intrdef $dlds ;load double float into secondary accum + jmp cs:word ptr $dldstb +; + intrdef $dlip ;load double immediate primary + jmp cs:word ptr $dliptb +; +ifdef LONGPTR + intrdef $dldpss ;load double float into primary accum + jmp cs:word ptr $dldpsstb + + intrdef $dldpds ;load double float into primary accum + jmp cs:word ptr $dldpdstb +endif + intrdef $dldp ;load double float into primary accum + jmp cs:word ptr $dldptb +; + intrdef $dsts + jmp cs:word ptr $dststb + + intrdef $dst ;store double at addr in BX + jmp cs:word ptr $dsttb +ifdef LONGPTR + intrdef $dstss ;store double at addr in BX + jmp cs:word ptr $dstsstb + + intrdef $dstds ;store double at addr in BX + jmp cs:word ptr $dstdstb + + intrdef $dstsss ;store double at addr in BX + jmp cs:word ptr $dstssstb + + intrdef $dstsds ;store double at addr in BX + jmp cs:word ptr $dstsdstb +endif +; + intrdef $dpsh ;push double float onto the stack + ;from the primary accumulator + jmp cs:word ptr $dpshtb +; + intrdef $dpshs ;push double float onto the stack + ;from the secondary accumulator + jmp cs:word ptr $dpshstb + + intrdef $dpopp ;pop double float into primary accum + jmp cs:word ptr $dpopptb +; + intrdef $dpop ;pop double float into secondary accum + jmp cs:word ptr $dpoptb +; + intrdef $dswap ;exchange primary and secondary + jmp cs:word ptr $dswaptb +; + intrdef $dng ;negate primary + jmp cs:word ptr $dngtb +; + intrdef $dtst ;test if primary is zero + jmp cs:word ptr $dtsttb +; + intrdef $dcmp ;compare primary and secondary + jmp cs:word ptr $dcmptb +; + intrdef $dsb ;subtract secondary from primary + jmp cs:word ptr $dsbtb +; + intrdef $dad ;add secondary to primary + jmp cs:word ptr $dadtb +; + intrdef $ddv + ;double floating divide (primary = primary/secondary) + jmp cs:word ptr $ddvtb +; + intrdef $dml + ;double floating multiply (primary = primary * secondary) + jmp cs:word ptr $dmltb +; + intrdef $utod + jmp cs:word ptr $utodtb +; + intrdef $itod + jmp cs:word ptr $itodtb +; + intrdef $xtod + jmp cs:word ptr $xtodtb +; + intrdef $dtou + intrdef $dtoi + intrdef $dtox + jmp cs:word ptr $dtoitb + + intrdef $dstat + jmp cs:word ptr $dstattb + + intrdef $drest + jmp cs:word ptr $dresttb + +INTERNAL equ 1 + purge intrdef +intrdef macro pname +pname&86 label near + endm + include fsubs.asm + purge intrdef +intrdef macro pname +pname&87 label near + endm + include fsubs87.asm + purge intrdef +intrdef macro pname + public pname +ifdef FARPROC + pname label far +else + pname label near +endif + endm +$floats endp + finish + end + fabs.c +#ifdef MPU68K +#define SIGN 0 +#else +#define SIGN 7 +#endif + +double +fabs(dou) +double dou; +{ + register char *cp; + + cp = (char *)&dou; + cp[SIGN] &= 0x7f; + return dou; +} + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/MCH86.ARC b/Manx Aztec C86 v340a/SRC/MCH86.ARC new file mode 100644 index 0000000..a3fe2ee --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/MCH86.ARC @@ -0,0 +1,1666 @@ + csav.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn _sbot_:word + extrn _lowwater_:word +dataseg ends + assume ds:dataseg,cs:codeseg +ifdef FARPROC + extrn _stkover_:far +else + extrn _stkover_:near +endif + extrn $begin:far + dw near ptr $begin + public $csav, $cret +$csav proc + pop bx +ifdef FARPROC + pop dx +endif + push bp + mov bp,sp + add sp,ax + cmp sp,bp ;check for wrap around + ja stackfault + cmp sp,word ptr _sbot_ ;or moving into the RED zone + jb stackfault + cmp sp,word ptr _lowwater_ + ja nodeeper + mov word ptr _lowwater_,sp +nodeeper: + push di + push si +ifdef FARPROC + push cs + mov ax,offset $cret + push ax + push dx + push bx + ret +else + call bx +endif +$csav endp + +$cret proc + pop si + pop di + mov sp,bp + pop bp + ret +$cret endp + +stackfault: + mov sp,bp ;put stack back the way it was + jmp _stkover_ + finish + end + cswt.asm +; Copyright (C) 1983, 85 by Manx Software Systems +; :ts=8 + include lmacros.h + ifdef FARPROC +data equ word ptr es:[bx] +addr equ word ptr es:2[bx] +dflt equ word ptr es:[bx] + else +data equ word ptr cs:[bx] +addr equ word ptr cs:2[bx] +dflt equ word ptr cs:[bx] + endif +slot equ 4 + public $swt + +$swt proc + pop bx +ifdef FARPROC +ifndef LONGPTR + mov dx,es +endif + pop es + push es +endif + mov cx,data + add bx,2 + jcxz eswt +swtloop: + cmp ax,data + je found + add bx,slot + loop swtloop +eswt: + push dflt +ifdef FARPROC +ifndef LONGPTR + mov es,dx +endif +endif + ret +found: + push addr +ifdef FARPROC +ifndef LONGPTR + mov es,dx +endif +endif + ret +$swt endp + finish + end + farcall.asm +; :ts=8 +;Copyright (C) 1983, 85 by Manx Software Systems + include lmacros.h + procdef farcall, <, , > + push si + push di + push ds + push es +; + ldptr bx,srcregs,ds + mov ax,[bx] + push 2[bx] ;save BX value for later + mov cx,4[bx] + mov dx,6[bx] + mov si,8[bx] + mov di,10[bx] + mov es,14[bx] + mov ds,12[bx] ;trash DS last + pop bx ;now get value for BX + push bp + call where + pop bp + push ds ;save returned DS + push bx ;save returned BX + mov ds,-6[bp] ;fetch C's data seg, for small model + ldptr bx,dstregs,ds + mov [bx],ax + pop 2[bx] ;value returned in BX + mov 4[bx],cx + mov 6[bx],dx + mov 8[bx],si + mov 10[bx],di + pop 12[bx] ;value returned in DS + mov 14[bx],es + pop es + pop ds + pop di + pop si + pop bp + pushf + pop ax + ret + pend farcall + finish + end + index.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef index, <,> + cld + push si + pushds + ldptr si,arg,ds + mov bl,val +lookloop: + lodsb + test al,al + jz notfound + cmp al,bl + jne lookloop + retptrr si,ds + dec ax + popds + pop si + pret +notfound: + retnull + popds + pop si + pret + pend index + finish + end + lsubs.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + internal $longs +; + intrdef $ldv +;long divide (primary = primary/secondary) + push di + sub di,di ;mark result as positive + test dx,dx + jns prim_ok + neg dx + neg ax + sbb dx,0 + inc di ;mark as negative +prim_ok: + test bx,bx + jns sec_ok + neg bx + neg cx + sbb bx,0 + xor di,1 ;flip sign of result +sec_ok: + call comdivide +chksign: + test di,di + jz posres + neg dx + neg ax + sbb dx,0 +posres: + pop di + ret +; + intrdef $lrm +;long remainder (primary = primary%secondary) + push di + mov di,0 ;mark result as positive + test dx,dx + jns rprim_ok + neg dx + neg ax + sbb dx,0 + inc di ;mark as negative +rprim_ok: + test bx,bx + jns rsec_ok + neg bx + neg cx + sbb bx,0 +rsec_ok: + call comdivide + mov ax,cx + mov dx,bx + jmp chksign +; + intrdef $lum +;unsigned long remainder (primary = primary%secondary) + call comdivide + mov ax,cx + mov dx,bx + ret +; + intrdef $lud +;unsigned long divide (primary = primary/secondary) + ifdef FARPROC + call comdivide + ret + endif + +; fall thru into common divide routine if not large code model +; +comdivide proc near ; divide (dx,ax) by (bx,cx): +; returns quotient in (dx,ax) +; remainder in (bx,cx) +; + test bx,bx ;check for easy case + jnz hardldv + cmp cx,dx + ja veryeasy + push ax + mov ax,dx + sub dx,dx + div cx + mov bx,ax ;save high word of quotient + pop ax + div cx + mov cx,dx ;save remainder + mov dx,bx + sub bx,bx + ret +veryeasy: + div cx + mov cx,dx ;save remainder + mov dx,bx ;bx is already zero if we are here + ret +hardldv: + push di + push si + mov si,cx ;copy divisor (bx,cx) into (di,si) + mov di,bx + push dx ;save dividend for remainder calculation + push ax + + test bh,bh + jz shiftit + mov cl,ch ;shift bx,cx right 8 bits + mov ch,bl + mov bl,bh + mov al,ah ;shift dx,ax right 8 bits + mov ah,dl + mov dl,dh + sub dh,dh +shiftit: + shr dx,1 + rcr ax,1 + shr bl,1 + rcr cx,1 + test bl,bl + jnz shiftit + + div cx ;guess at quotient (may off by 1) + mov cx,ax + ; compute remainder = dividend - divisor*quotient + mul si + mov bx,dx + push ax ;save low half + mov ax,cx + mul di + add bx,ax + mov dx,bx ;high half + mov ax,cx ;restore quotient to ax for return + + pop bx ;low half of divisor*quotient + pop cx ;low half of dividend + sub cx,bx + pop bx ;high half of dividend + sbb bx,dx + jnc answer_ok ;if we get a borrow, answer was too big + add cx,si ;so adjust the remainder + adc bx,di + dec ax ;and the quotient +answer_ok: + sub dx,dx + pop si + pop di + ret +comdivide endp +$longs endp + finish + end + movblock.asm +;Copyright (C) 1983, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef movblock,<,,> + push di + push si + push ds + push es + pushf + cld + mov cx,len + les di,dest + lds si,src + cmp cx,4 + jne not_int + cli +not_int: + test cx,cx + jnz not_mov_all + mov cx,8000H + jmp short movwords +not_mov_all: + mov dx,cx + shr cx,1 + jz mv_skip +movwords: +rep movsw +mv_skip: + test dl,1 + jz done + movsb +done: + popf + pop es + pop ds + pop si + pop di + pret + pend movblock + finish + end + movmem.asm +;Copyright (C) 1984, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef movmem,<,,> + pushf + cld + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,arg1 + ldptr di,arg2 + mov cx,len + mov ax,es + mov dx,ds + cmp ax,dx + jne move_forward + cmp di,si + je done + jb move_forward + std + add di,cx + add si,cx + dec di + dec si + test cl,1 + jz nobyte + movsb +nobyte: + dec di + dec si + jmp short domove +; +move_forward: + test cl,1 + jz domove + movsb +domove: + shr cx,1 + jz done +rep movsw +done: + cld + popds + pop di + pop si + popf + pret + pend movmem + finish + end + peek.asm +;Copyright (C) 1983, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef peekw,<> + push ds + lds bx,addr + mov ax,ds:[bx] + pop ds + pret + pend peekw +; + entrdef peekb + procdef peek,<> + push ds + lds bx,addr1 + mov al,ds:[bx] + and ax,0ffH + pop ds + pret + pend peek +; + procdef pokew,<,> + push ds + mov ax,val + lds bx,addr2 + mov ds:[bx],ax + pop ds + pret + pend pokew +; + entrdef poke + procdef pokeb,<,> + push ds + mov al,val1 + lds bx,addr3 + mov ds:[bx],al + pop ds + pret + pend pokeb + finish + end + port.asm +;Copyright (C) 1983, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + entrdef inport + procdef inportb,<> + mov dx,port + in al,dx + and ax,0ffH + pret + pend inportb +; + procdef inportw,<> + mov dx,port1 + in ax,dx + pret + pend inportw +; + entrdef outport + procdef outportb,<,> + mov dx,port2 + mov al,val + out dx,al + pret + pend outportb +; + procdef outportw,<,> + mov dx,port3 + mov ax,val1 + out dx,ax + pret + pend outportw + finish + end + rindex.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef rindex, <,> + pushf + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,string,es + mov dx,di ;save for later + sub ax,ax + mov cx,7fffH +repne scasb + mov cx,di + sub cx,dx ;compute length of string + dec di ;backup to null byte + mov al,chr ;get byte to look for + std ;now go backwards +repne scasb + je found + retnull + pop di + popf + pret +found: + retptrr di,es + inc ax + pop di + popf + pret + pend rindex + finish + end + cswit.asm +; Copyright (C) 1983, 85 by Manx Software Systems +; :ts=8 + include lmacros.h + public $cswt + +$cswt proc +ifndef FARPROC + pop bx ; get address of table + push di +ifndef LONGPTR + push es +endif + mov di,cs + mov es,di + mov di,bx ; make di to point to table of values + mov bx,cx ; save number of entries in bx + shl bx,1 ; adjusted for size of an entry + cld +repne scasw ; find the right entry + mov cx,es:word ptr -4[di][bx] ; pick up target address +ifndef LONGPTR + pop es +endif + pop di + jmp cx ; jump there +endif +$cswt endp + finish + end + segread.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef segread,<> +ifndef LONGPTR + mov bx,ds + mov es,bx +endif + ldptr bx,segs,es +ifdef FARPROC + mov ax,4[bp] + mov es:[bx],ax +else + mov es:[bx],cs +endif + mov es:2[bx],ss + mov es:4[bx],ds + mov es:6[bx],es + pret + pend segread + finish + end + setjmp.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef setjmp,<> + pushds + ldptr bx,jmpbuf,ds + lea ax,jmpbuf + mov [bx],ax + mov ax,0[bp] ;get caller's BP + mov 2[bx],ax + mov 4[bx],si + mov 6[bx],di + mov ax,2[bp] ;caller's IP + mov 8[bx],ax +ifdef FARPROC + mov ax,4[bp] ;caller's CS + mov 10[bx],ax +endif + sub ax,ax + popds + pret + pend setjmp +; + procdef longjmp,<,> + mov ax,retval +ifndef LONGPTR + mov bx,ds + mov es,bx +endif + ldptr bx,jbuf,es + mov sp,es:[bx] + mov bp,es:2[bx] + mov si,es:4[bx] + mov di,es:6[bx] + test ax,ax + jnz ax_ok + inc ax +ax_ok: +ifdef FARPROC + jmp es:dword ptr 8[bx] +else + jmp es:word ptr 8[bx] +endif + pend longjmp + finish + end + setmem.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef setmem,<,,> + pushf + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,src,es + mov cx,len + mov al,val + mov ah,al + mov dx,cx + shr cx,1 + jz skip +rep stosw +skip: + test dl,1 + jz done + stosb +done: + pop di + popf + pret + pend setmem + finish + end + strcat.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef strcat,<,> + mov dx,7fffH + jmp short catcommon + pend strcat + + procdef strncat,<,,> + mov dx,len +catcommon: + cld + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + sub ax,ax + mov cx,7fffH +repne scasb ;find end of destination string + dec di ;backup to null byte + ldptr si,str2 + mov cx,dx +cpyloop: + lodsb + stosb + test al,al + loopnz cpyloop + jz nul_ok + sub al,al ;guarantee that string is nul terminated + stosb +nul_ok: + popds + pop di + pop si + retptrm str1 + pret + pend strncat + finish + end + strcmp.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef strcmp,<,> + mov cx,7fffh + jmp short cmpcommon + pend strcmp + + procdef strncmp,<,,> + mov cx,len +cmpcommon: + cld + push si + push di + pushds + ldptr si,str1 +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str2 +cmploop: + lodsb + scasb + jne notequal + test al,al + loopnz cmploop + sub ax,ax +done: + popds + pop di + pop si + pret +notequal: + mov ax,0 + jb less + inc ax + jmp done +less: + dec ax + jmp done + + pend strncmp + finish + end + strcpy.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef strcpy,<,> + cld + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + ldptr si,str2 +cpyloop: + lodsb + stosb + test al,al + jnz cpyloop + popds + pop di + pop si + retptrm str1 + pret + pend strcpy + finish + end + strlen.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef strlen,<> + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + mov bx,di ;save for later + sub ax,ax + mov cx,7fffH +repne scasb + mov ax,di + sub ax,bx ;compute length of string + dec ax + pop di + pret + pend strlen + finish + end + strncpy.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef strncpy,<,,> + cld + push si + push di + pushds + mov cx,len +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + ldptr si,str2 + jcxz cpydone +cpyloop: + lodsb + test al,al + jz zerofill + stosb + loop cpyloop + jmp short cpydone +zerofill: +rep stosb +cpydone: + popds + pop di + pop si + retptrm str1 + pret + pend strncpy + finish + end + swapmem.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h + procdef swapmem,<,,> + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,str1 + ldptr di,str2 + mov cx,len + jcxz done +ifdef LONGPTR + mov ax,ds + mov dx,es + cmp ax,dx + jne swaploop +endif + cmp di,si + je done +swaploop: + mov al,es:[di] + xchg al,ds:[si] + stosb + inc si + loop swaploop +done: + popds + pop di + pop si + pret + pend swapmem + finish + end + sysint.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef sysint,<,,> + sub sp,14 + push si + push di + push es + push ds +; +; build instruction sequence on the stack to issue int +; and restore ss:sp to value before int. +; Note: All this is because some handlers don't restore ss and sp. +; + mov byte ptr -10[bp],0cdH ;int xx + mov al,num + mov byte ptr -9[bp],al + mov word ptr -8[bp],0cd8cH ;mov bp,cs + mov word ptr -6[bp],0d58eH ;mov ss,bp + mov byte ptr -4[bp],0bcH ;mov sp,xx + mov ax,sp + sub ax,6 + mov word ptr -3[bp],ax + mov byte ptr -1[bp],0cbH ;retf + mov word ptr -12[bp],ss ;set up pointer to above code + lea ax,-10[bp] + mov word ptr -14[bp],ax +; + ldptr bx,sregs,ds + mov ax,[bx] + push 2[bx] ;value to go into BX + mov cx,4[bx] + mov dx,6[bx] + mov si,8[bx] + mov di,10[bx] + mov es,14[bx] + mov ds,12[bx] + pop bx + push bp + call ss:dword ptr -14[bp] + pop bp + push ds ;save values so we have working registers + push bx + ldptr bx,dregs,ds +ifdef LONGPTR + mov [bx],ax + pop 2[bx] ;value returned in BX + mov 4[bx],cx + mov 6[bx],dx + mov 8[bx],si + mov 10[bx],di + pop 12[bx] ;value returned in DS + mov 14[bx],es + pop ds +else + mov ss:14[bx],es + pop ss:2[bx] ;value returned in BX + pop ss:12[bx] ;value returned in DS + pop ds + mov [bx],ax + mov 4[bx],cx + mov 6[bx],dx + mov 8[bx],si + mov 10[bx],di +endif + pop es + pop di + pop si + pushf + pop ax + add sp,14 + pret + pend sysint + finish + end + toupper.asm +; Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef toupper,<> +; + mov al,val1 + sub ah,ah + cmp al,'a' + jl tu_done + cmp al,'z' + jg tu_done + sub al,'a'-'A' +tu_done: + pret + pend toupper +; +; + procdef tolower,<> +; + mov al,val2 + sub ah,ah + cmp al,'A' + jl skip + cmp al,'Z' + jg skip + add al,'a'-'A' +skip: + pret + pend tolower + finish + end + memccpy.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memccpy,<,,,> + push si + push di + pushds + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,s1 + ldptr si,s2 + mov bl,char + mov cx,lim + jcxz cpydone +cpyloop: + lodsb + stosb + cmp al,bl + jz cpyfnd + loop cpyloop + jmp short cpydone +cpyfnd: + retptrr di,es + popds + pop di + pop si + pret +cpydone: + retnull + popds + pop di + pop si + pret + pend memccpy + finish + end + memchr.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef memchr,<,,> + push di +ifdef LONGPTR + mov ax,ds + mov es,ax +endif + cld + ldptr di,area + mov al,char + mov cx,lim + jcxz notfound +repne scasb + jne notfound + dec di + retptrr di,es + pop di + pret +notfound: + retnull + pop di + pret + pend memchr + finish + end + memcmp.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memcmp,<,,> + push si + push di + pushds + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,dest + ldptr di,src + mov cx,lim + jcxz done +repe cmpsb + mov ax,0 + ja greater + je done + dec ax +done: + popds + pop di + pop si + pret +greater: + inc ax + jmp done + pend memcmp + finish + end + memcpy.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memcpy,<,,> + push si + push di + pushds + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,s1 + ldptr si,s2 + mov cx,lim + mov dx,cx + shr cx,1 + jcxz chk_odd +rep movsw +chk_odd: + test dl,1 + jz done + movsb +done: + retptrm s1 + popds + pop di + pop si + pret + pend memcpy + finish + end + memset.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memset,<,,> + push di + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,area + mov al,char + mov ah,al + mov cx,lim + mov dx,cx + shr cx,1 + jcxz nowords +rep stosw +nowords: + test dl,1 + jz done + stosb +done: + retptrm area + pop di + pret + pend memset + finish + end + strchr.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h + procdef strchr, <,> + cld + push si + pushds + ldptr si,arg,ds + mov bl,val +lookloop: + lodsb + cmp al,bl + je found + test al,al + jnz lookloop + retnull + popds + pop si + pret +found: + retptrr si,ds + dec ax + popds + pop si + pret + pend strchr + finish + end + strrchr.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef strrchr, <,> + pushf + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,string,es + mov dx,di ;save for later + sub ax,ax + mov cx,7fffH +repne scasb + mov cx,di + sub cx,dx ;compute length of string + dec di ;backup to null byte + mov al,chr ;get byte to look for + std ;now go backwards +repne scasb + je found + retnull + pop di + popf + pret +found: + retptrr di,es + inc ax + pop di + popf + pret + pend strrchr + finish + end + pointers.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h + assume ds:dataseg +; +; ptrtoabs(lptr): convert pointer to 20-bit physical address +; + procdef ptrtoabs,<,> + mov ax,lptr + mov dx,llptr + mov cx,4 + rol dx,cl + mov bx,dx + and bx,0fff0h + and dx,0fh + add ax,bx + adc dx,0 + pret + pend ptrtoabs +; +; abstoptr(laddr): convert 20-bit physical address to pointer +; + procdef abstoptr,<,> + mov ax,laddr + mov dx,lladdr + and dx,0fh + mov bx,ax + mov cx,4 + ror dx,cl + shr bx,cl + and bx,0fffh + or dx,bx + and ax,0fh + pret + pend abstoptr + finish + end + ptrdiff.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h +; +; long _ptrdiff(lptr1, lptr2): return long pointer difference +; + procdef _ptrdiff,<,,,> + mov ax,seg1 + sub ax,seg2 + sbb dx,dx + mov cx,4 +sloop: shl ax,1 + rcl dx,1 + loop sloop + add ax,off1 + adc dx,0 + sub ax,off2 + sbb dx,0 + mov bx,dx + pret + pend _ptrdiff + finish + end + ptradd.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h +; +;char *_ptradd(lptr, long): return lptr+long +; + procdef _ptradd,<,,,> + mov ax,segm + sub dx,dx + mov cx,4 +sloop: shl ax,1 + rcl dx,1 + loop sloop + add ax,offs + adc dx,0 + add ax,incrl + adc dx,incrh + mov bx,ax + mov cx,4 +sloop2: shr dx,1 + rcr ax,1 + loop sloop2 + mov dx,ax + mov ax,bx + and ax,15 + mov bx,dx + pret + pend _ptradd + finish + end + inthand.asm +;Copyright (C) 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' +; +; this is the code for the initial handlers +; +template label byte + push si + push es + call common_handler +tIP dw 0 ;original vector IP +tCS dw 0 ;original vector CS +tDS dw 0 ;current data segment +tSP dw 0 ;offset of handler's stack +ifdef FARPROC +tCfunc dd 0 ;C function address +else +tCfunc dw 0 ;C function address +endif +tmpl_end label byte +tmpl_len equ offset tmpl_end - offset template + +origIP equ es:0[si] ;original vector IP +origCS equ es:2[si] ;original vector CS +saveSS equ es:4[si] ;save area for interupted SS +saveSP equ es:6[si] ;ditto for SP +ourDS equ es:8[si] ;current data segment +newSP equ es:10[si] ;offset of handler's stack +ifdef FARPROC +Cfunc equ es:dword ptr 12[si] ;C function address +else +Cfunc equ es:dword ptr 12[si] ;C function address +endif + +dataseg ends + + assume ds:dataseg + +common_handler label far + pop si ;get address of table stuff + pop es ;following code block + push ax + push bx + push cx + mov bx,ss ;save stack info + mov cx,sp + mov ax,es + mov ss,ax ;switch to private stack + mov sp,newSP + push bx ;save old stack stuff on new stack + push cx + push dx + push ds + mov ds,ourDS + push es ;save across call + cld + call Cfunc + pop es + pop ds + pop dx + pop cx + pop bx + cli ;just in case + mov ss,bx + mov sp,cx + pop cx + pop bx + pop ax + pop es + pop si + iret + + finish + end + fcall.asm +; Copyright (C) 1985 by Manx Software Systems +; :ts=8 + largecode +codeseg segment byte public 'code' + assume cs:codeseg + public $fcall +$fcall proc far + push dx + push ax + ret +$fcall endp +codeseg ends + end + ovbgn.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems +codeseg segment para public 'code' +dataseg segment para public 'data' +save_si dw 0 +save_di dw 0 +save_sp dw 0 +save_bp dw 0 +save_ret dw 0 + extrn _Uorg_:word, _Uend_:word +dataseg ends + assume cs:codeseg,ds:dataseg + extrn ovmain_:near + public $ovbgn +$ovbgn proc near + pop save_ret + pop cx ;throw away overlay name + mov save_sp,sp + mov save_bp,bp + mov save_si,si + mov save_di,di + cld + mov di,offset _Uorg_ ;clear uninitialized data + mov cx,offset _Uend_ + sub cx,di + shr cx,1 + jz nobss + sub ax,ax +rep stosw +nobss: + call ovmain_ +; +; fall through into ovexit code +; + public ovexit_ +ovexit_: + mov bp,save_bp + mov sp,save_sp + mov si,save_si + mov di,save_di + push cx ;fake argument to replace overlay name + jmp save_ret +$ovbgn endp +codeseg ends + end $ovbgn + ovloader.c +/* Copyright (C) 1984 by Manx Software Systems */ + +#define OV_MAGIC 0xf2 + +struct ovrheader { /* overlay header header */ + short o_magic; + unsigned short o_corg; + unsigned short o_csize; + unsigned short o_dorg; + unsigned short o_dsize; + unsigned short o_bss; + unsigned short o_entry; +}; + +static char *ovname; + +#asm + public ovloader_ +ovloader_ proc near + mov bx,sp + mov ax,word ptr 2[bx] + mov ovname_,ax + call _ovld_ + jmp ax +ovloader_ endp +#endasm + +static +_ovld() +{ + int fd, flag; + register char *cp, *xp; + auto struct ovrheader hdr; + char *getenv(), path[64]; + extern char *_mbot, _Cend[], _Uend[]; + +#ifdef DOS20 + if ((cp = getenv("PATH")) == 0) + cp = ""; + xp = path; + for (;;) { + strcpy(xp, ovname); + strcat(path, ".ovr"); + if ((fd = open(path, 0)) != -1) + break; + do { + if (*cp == 0) + loadabort(10); + xp = path; + while (*cp) { + if (*cp == ';') { + ++cp; + break; + } + *xp++ = *cp++; + } + *xp = 0; + } while (path[0] == 0); + } + +#else + strcpy(path, ovname); + strcat(path, ".ovr"); + if ((fd = open(path, 0)) == -1) + loadabort(10); +#endif + + if (read(fd, &hdr, sizeof hdr) != sizeof hdr) + loadabort(20); + + /* safety check overlay header */ + if (hdr.o_magic != OV_MAGIC) + loadabort(30); + if (_mbot < hdr.o_dorg+hdr.o_dsize+hdr.o_bss) + loadabort(40); + if (_Cend > hdr.o_corg || _Uend > hdr.o_dorg) + loadabort(60); + + if (_csread(fd, hdr.o_corg, hdr.o_csize) < hdr.o_csize + || read(fd, hdr.o_dorg, hdr.o_dsize) < hdr.o_dsize) + loadabort(50); + close(fd); + return hdr.o_entry; +} + +static +loadabort(code) +{ + char buffer[80]; + + sprintf(buffer, "Error %d loading overlay: %s$", code, ovname); + bdos(9, buffer); + exit(100); +} + lrom.asm +; Copyright (C) 1984, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h +; +; If you want your stack at a fixed place, you may remove the +; "bss cstack..." statement below and change the "mov sp,cstack..." +; to load SP with the value you desire. Note that the setup of +; SS may need to be changed also. If the program is small data +; model, then SS must be equal to DS or pointers to automatic +; variables won't work. +; +; Otherwise, stacksize should be set according to your program's +; requirements. +stacksize equ 2048 +; +; dataseg is the data segment address (as a paragraph #) +; this is picked from the -D option of the linker +; +;Dseg equ 040H ;physical addr 0x400, just above the int vectors + +dataseg segment word public 'data' + bss cstack:byte,stacksize + public $MEMRY +$MEMRY dw -1 + dw -1 + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 + public _mbot_, sbot +_mbot_ dw 0 + dw 0 +sbot dw 0 + dw 0 + extrn _Dorg_:byte,_Dend_:byte + extrn _Uorg_:byte,_Uend_:byte +dataseg ends + extrn _Corg_:byte,_Cend_:byte + +ifdef FARPROC + extrn main_:far +else + extrn main_:near +endif + + public $begin +$begin proc far + cli + cld +; +; Compute where initialzed data starts (@ next para after code) +; + mov ax,offset _Cend_+15 + mov cl,4 + shr ax,cl + add ax,seg _Cend_ + mov ds,ax ;place where data is in rom + mov bx,dataseg ;place where data is to go in ram + mov es,bx +; +; Note: For hardware reasons the instruction which loads SS should +; be immediatly followed by the load of SP. +; + mov ss,bx + mov sp,offset cstack+stacksize +; +; copy Init data from rom to ram + mov di,0 + mov cx,offset _Dend_ + inc cx + shr cx,1 + jcxz nocopy + mov si,0 +rep movsw +nocopy: +; +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + assume ds:dataseg,es:dataseg + + mov ds,bx ;set DS, now DS, SS, ES are equal + mov di,$MEMRY + inc di + and di,0fffeH ;adjust to word boundary + mov $MEMRY,di ;save memory allocation info for sbrk() + mov $MEMRY+2,ds + mov _mbot_,di + mov _mbot_,ds + mov sbot,0ffffH ;this is the heap limit for sbrk() + mov sbot+2,0fff0h + mov _dsval_,ds + mov _csval_,cs ;this is of dubious value in large code + sti + jmp main_ ;main shouldn't return in ROM based system +$begin endp +codeseg ends + end $begin + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/MISC.ARC b/Manx Aztec C86 v340a/SRC/MISC.ARC new file mode 100644 index 0000000..598a87f --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/MISC.ARC @@ -0,0 +1,757 @@ + atoi.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include + +atoi(cp) +register char *cp; +{ + register unsigned i; + register sign; + + while (*cp == ' ' || *cp == '\t') + ++cp; + sign = 0; + if ( *cp == '-' ) { + sign = 1; + ++cp; + } else if ( *cp == '+' ) + ++cp; + + for ( i = 0 ; isdigit(*cp) ; ) + i = i*10 + *cp++ - '0'; + return sign ? -i : i; +} + atol.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include + +long +atol(cp) +register char *cp; +{ + long n; + register sign; + + while (*cp == ' ' || *cp == '\t') + ++cp; + sign = 0; + if ( *cp == '-' ) { + sign = 1; + ++cp; + } else if ( *cp == '+' ) + ++cp; + + for ( n = 0 ; isdigit(*cp) ; ) + n = n*10 + *cp++ - '0'; + return sign ? -n : n; +} + calloc.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char *calloc(nelem, size) +unsigned nelem, size; +{ + register unsigned i = nelem*size; + register char *cp, *malloc(); + + if ((cp = malloc(i)) != (char *)0) + setmem(cp, i, 0); + return cp; +} + ctype.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char ctp_[129] = { + 0, /* EOF */ + 0x20, 0x20, 0x20, 0x20, /* nul soh stx etx */ + 0x20, 0x20, 0x20, 0x20, /* eot enq ack bel */ + 0x20, 0x30, 0x30, 0x30, /* bs ht nl vt */ + 0x30, 0x30, 0x20, 0x20, /* ff cr so si */ + 0x20, 0x20, 0x20, 0x20, /* dle dc1 dc2 dc3 */ + 0x20, 0x20, 0x20, 0x20, /* dc4 nak syn etb */ + 0x20, 0x20, 0x20, 0x20, /* can em sub esc */ + 0x20, 0x20, 0x20, 0x20, /* fs gs rs us */ + 0x90, 0x40, 0x40, 0x40, /* sp ! " # */ + 0x40, 0x40, 0x40, 0x40, /* $ % & ' */ + 0x40, 0x40, 0x40, 0x40, /* ( ) * + */ + 0x40, 0x40, 0x40, 0x40, /* , - . / */ + 0x0C, 0x0C, 0x0C, 0x0C, /* 0 1 2 3 */ + 0x0C, 0x0C, 0x0C, 0x0C, /* 4 5 6 7 */ + 0x0C, 0x0C, 0x40, 0x40, /* 8 9 : ; */ + 0x40, 0x40, 0x40, 0x40, /* < = > ? */ + 0x40, 0x09, 0x09, 0x09, /* @ A B C */ + 0x09, 0x09, 0x09, 0x01, /* D E F G */ + 0x01, 0x01, 0x01, 0x01, /* H I J K */ + 0x01, 0x01, 0x01, 0x01, /* L M N O */ + 0x01, 0x01, 0x01, 0x01, /* P Q R S */ + 0x01, 0x01, 0x01, 0x01, /* T U V W */ + 0x01, 0x01, 0x01, 0x40, /* X Y Z [ */ + 0x40, 0x40, 0x40, 0x40, /* \ ] ^ _ */ + 0x40, 0x0A, 0x0A, 0x0A, /* ` a b c */ + 0x0A, 0x0A, 0x0A, 0x02, /* d e f g */ + 0x02, 0x02, 0x02, 0x02, /* h i j k */ + 0x02, 0x02, 0x02, 0x02, /* l m n o */ + 0x02, 0x02, 0x02, 0x02, /* p q r s */ + 0x02, 0x02, 0x02, 0x02, /* t u v w */ + 0x02, 0x02, 0x02, 0x40, /* x y z { */ + 0x40, 0x40, 0x40, 0x20, /* | } ~ del */ +} ; + format.c +/* Copyright (C) 1981,1982,1983 by Manx Software Systems */ +#include + +#if MPU8080 || MPUZ80 +char *_fmtcvt(); +#else + +static char * +_fmtcvt(ap, base, cp, len) +int *ap; register char *cp; +{ + register unsigned long val; + static char digits[]="0123456789abcdef"; + + if (len == sizeof(long)) + val = *(long *)ap; + else if (base > 0) + val = *(unsigned *)ap; + else + val = *ap; + + len = 0; + if (base < 0) { + base = -base; + if ((long)val < 0) { + val = -val; + len = 1; + } + } + + do { + *--cp = digits[(int)(val%base)]; + } while ((val /= base) != 0); + if (len) + *--cp = '-'; + return cp; +} +#endif + +format(putsub, fmt, argp) +register int (*putsub)(); register char *fmt; char *argp; +{ + register int c; + union { + int *ip; + char *cp; + char **cpp; +#ifdef FLOAT + double *dp; +#endif + } args; + int charcount; + int rj, fillc; + int maxwidth, width; + int i, k; + char *cp; + auto char s[200]; + + charcount = 0; + args.cp = argp; + while ( c = *fmt++ ) { + if ( c == '%' ) { + s[14] = 0; + rj = 1; + fillc = ' '; + maxwidth = 10000; + if ((c = *fmt++) == '-') { + rj = 0; + c = *fmt++; + } + if (c == '0') { + fillc = '0'; + c = *fmt++; + } + if (c == '*') { + width = *args.ip++; + c = *fmt++; + } else { + for (width = 0 ; isdigit(c) ; c = *fmt++) + width = width*10 + c - '0'; + } + if ( c == '.' ) { + if ((c = *fmt++) == '*') { + maxwidth = *args.ip++; + c = *fmt++; + } else { + for (maxwidth = 0 ; isdigit(c) ; c = *fmt++) + maxwidth = maxwidth*10 + c - '0'; + } + } + i = sizeof(int); + if (c == 'l') { + c = *fmt++; + i = sizeof(long); + } else if (c == 'h') + c = *fmt++; + + switch ( c ) { + case 'o': + k = 8; + goto do_conversion; + case 'u': + k = 10; + goto do_conversion; + case 'x': + k = 16; + goto do_conversion; + + case 'd': + k = -10; + do_conversion: + cp = _fmtcvt(args.cp, k, s+14, i); + args.cp += i; + break; + + case 's': + i = strlen(cp = *args.cpp++); + goto havelen; +#ifdef FLOAT + case 'e': + case 'f': + case 'g': + ftoa(*args.dp++, s, maxwidth==10000?6:maxwidth, c-'e'); + i = strlen(cp = s); + maxwidth = 200; + goto havelen; +#endif + + case 'c': + c = *args.ip++; + default: + *(cp = s+13) = c; + break; + } + + i = (s+14) - cp; + havelen: + if ( i > maxwidth ) + i = maxwidth; + + if ( rj ) { + if ((*cp == '-' || *cp == '+') && fillc == '0') { + --width; + if ((*putsub)(*cp++) == -1) + return -1; + } + for (; width-- > i ; ++charcount) + if ((*putsub)(fillc) == -1) + return -1; + } + for ( k = 0 ; *cp && k < maxwidth ; ++k ) + if ((*putsub)(*cp++) == -1) + return -1; + charcount += k; + + if ( !rj ) { + for (; width-- > i ; ++charcount) + if ((*putsub)(' ') == -1) + return -1; + } + } else { + if ((*putsub)(c) == -1) + return -1; + ++charcount; + } + } + return charcount; +} + + malloc.c +/* Copyright (C) 1985 by Manx Software Systems, Inc. */ + +#ifdef __LDATA +typedef long size_t; +char *_ptradd(); +long _ptrdiff(); +#define bump(p,i) ((l_t *)_ptradd((p),(long)(i))) +#define ptrdiff(p1,p2) _ptrdiff(p1,p2) +#else +typedef unsigned size_t; +#define bump(p,i) ((l_t *)((char *)(p)+(i))) +#define ptrdiff(p1,p2) (unsigned)((char *)(p1)-(char *)(p2)) +#endif + +typedef struct list { + struct list *next; +} l_t; +static l_t first, *current; +static l_t *endmarker = &first, *restart = &first; +static size_t keep; + +#define INUSE 1 +#define inuse(p) (*(size_t *)(p)&INUSE) +#define markblk(p) (*(size_t *)(p) |= INUSE) +#define unmark(p) (*(size_t *)(p) &= ~INUSE) +#define chain(p) ((l_t *)(*(size_t *)(p) & ~INUSE)) + +#define BLOCK (512*sizeof(l_t)) /* # of bytes to ask sbrk for */ + +char * +realloc(area, size) +register char *area; unsigned size; +{ + register char *cp, *end; + size_t osize; + char *malloc(); + + end = (char *)chain((l_t *)area-1); + if ((osize = ptrdiff(end, area)) > size) { + osize = size; + end = (char *)bump(area, osize); + } + free(area); + if ((cp = malloc(size)) != 0 && cp != area) { + movmem(area, cp, osize); + if ((char *)current >= area && (char *)current < end) + *(size_t *)bump(cp, ptrdiff(current,area)) = keep; + } + return cp; +} + +char * +malloc(size) +unsigned size; +{ + register l_t *ptr, *temp, *lastfree; + register size_t len; + int times; + char *sbrk(); + + size = ((size+sizeof(l_t)*2-1)/sizeof(l_t))*sizeof(l_t); + if (current == 0) { + first.next = &first; + markblk(&first); + current = &first; + } + for (times = 0, lastfree = ptr = current ; ; ptr = chain(ptr)) { + if (ptr == endmarker) { + if (++times > 1) { + len = BLOCK; + if ((temp = (l_t *)sbrk((int)len)) == (l_t *)-1) + return 0; + if (temp != bump(ptr,sizeof(l_t))) { + /* non-contiguous allocation */ + ptr->next = temp; + markblk(ptr); + len -= sizeof(l_t); + ptr = temp; + } + temp = bump(ptr, len); + ptr->next = temp; + temp->next = &first; /* new end marker */ + markblk(temp); + endmarker = temp; + if (chain(lastfree) == ptr) + ptr = lastfree; + } + } + if (inuse(ptr)) + continue; + lastfree = ptr; + while (!inuse(temp = chain(ptr))) + ptr->next = temp->next; + len = ptrdiff(temp,ptr); + if (len >= size) { + if (len > size) { + ptr->next = bump(ptr, size); + keep = *(size_t *)ptr->next; + ptr->next->next = temp; + } + current = ptr->next; + markblk(ptr); + return (char *)(ptr+1); + } + } +} + +free(p) +char *p; +{ + register l_t *ptr; + + ptr = (l_t *)p - 1; + if (!inuse(ptr)) + return -1; + unmark(ptr); + current = ptr; + return 0; +} + qsort.c +/* Copyright (C) 1984 by Manx Software Systems */ + +qsort(base, nel, size, compar) +char *base; unsigned nel, size; int (*compar)(); +{ + register char *i,*j,*x,*r; + auto struct stk { + char *l, *r; + } stack[16]; + struct stk *sp; + + sp = stack; + r = base + (nel-1)*size; + for (;;) { + do { + x = base + (r-base)/size/2 * size; + i = base; + j = r; + do { + while ((*compar)(i,x) < 0) + i += size; + while ((*compar)(x,j) < 0) + j -= size; + if (i < j) { + swapmem(i, j, size); + if (i == x) + x = j; + else if (j == x) + x = i; + } + if (i <= j) { + i += size; + j -= size; + } + } while (i <= j); + if (j-base < r-i) { + if (i < r) { /* stack request for right partition */ + sp->l = i; + sp->r = r; + ++sp; + } + r = j; /* continue sorting left partition */ + } else { + if (base < j) { /* stack request for left partition */ + sp->l = base; + sp->r = j; + ++sp; + } + base = i; /* continue sorting right partition */ + } + } while (base < r); + + if (sp <= stack) + break; + --sp; + base = sp->l; + r = sp->r; + } +} + scan.c +/* Copyright (C) 1982, 1984 by Manx Software Systems */ +#include + +#define EOF -1 + +static int maxwidth; +static int (*gsub)(); +static getnum(); +char *strchr(); + +scanfmt(getsub, fmt, args) +int (*getsub)(); register char *fmt; register int **args; +{ +#ifdef FLOAT + double atof(); +#endif + long lv; + register int c, count, base, cc; + char suppress, lflag, widflg; + char *cp; + auto char tlist[130]; + static char list[] = "ABCDEFabcdef9876543210"; + static char vals[] = { + 10,11,12,13,14,15,10,11,12,13,14,15,9,8,7,6,5,4,3,2,1,0 + }; + + count = 0; + gsub = getsub; + while (c = *fmt++) { + if (c == '%') { + widflg = lflag = suppress = 0; + maxwidth = 127; + if (*fmt == '*') { + ++fmt; + suppress = 1; + } + if (isdigit(*fmt)) { + maxwidth = 0; + do { + maxwidth = maxwidth*10 + *fmt - '0'; + } while (isdigit(*++fmt)); + widflg = 1; + } + if (*fmt == 'l') { + lflag = 1; + ++fmt; + } + + switch (cc = *fmt++) { + case '%': + c = '%'; + goto matchit; + case 'h': /* specify short (for compatibility) */ + lflag = 0; + goto decimal; + case 'D': + lflag = 1; + case 'u': + case 'd': + decimal: + c = 12; + base = 10; + goto getval; + + case 'X': + lflag = 1; + case 'x': + c = 0; + base = 16; + goto getval; + + case 'O': + lflag = 1; + case 'o': + c = 14; + base = 8; + getval: + if (skipblank()) + goto stopscan; + if (getnum(&list[c], &vals[c], base, &lv) == 0) + goto stopscan; + if (!suppress) { + if (lflag) + *(long *)(*args++) = lv; + else + **args++ = lv; + ++count; + } + break; + +#ifdef FLOAT + case 'E': + case 'F': + lflag = 1; + case 'e': + case 'f': + if (skipblank()) + goto stopscan; + if (getflt(tlist)) + goto stopscan; + if (!suppress) { + if (lflag) + *(double *)(*args++) = atof(tlist); + else + *(float *)(*args++) = atof(tlist); + ++count; + } + break; +#endif + case '[': + lflag = 0; + if (*fmt == '^' || *fmt == '~') { + ++fmt; + lflag = 1; + } + for (cp = tlist ; (c = *fmt++) != ']' ; ) + *cp++ = c; + *cp = 0; + goto string; + case 's': + lflag = 1; + tlist[0] = ' '; + tlist[1] = '\t'; + tlist[2] = '\n'; + tlist[3] = 0; + string: + if (skipblank()) + goto stopscan; + charstring: + if (!suppress) + cp = (char *)*args++; + widflg = 0; + while (maxwidth--) { + if ((c = (*gsub)(0)) == EOF) + break; + if (lflag ? (strchr(tlist,c)!=0) : (strchr(tlist,c)==0)) { + (*gsub)(1); /* unget last character */ + break; + } + if (!suppress) + *cp++ = c; + widflg = 1; + } + if (!widflg) + goto stopscan; + if (!suppress) { + if (cc != 'c') + *cp = 0; + ++count; + } + break; + + case 'c': + if (!widflg) + maxwidth = 1; + tlist[0] = 0; + lflag = 1; + goto charstring; + } + } else if (isspace(c)) { + if (skipblank()) + goto stopscan; + } else { +matchit: + if ((*gsub)(0) != c) { + (*gsub)(1); + goto stopscan; + } + } + } + +stopscan: + if (count == 0) { + if ((*gsub)(0) == EOF) + return EOF; + (*gsub)(1); + } + return count; +} + +skipblank() +{ + while (isspace((*gsub)(0))) + ; + if ((*gsub)(1) == EOF) + return EOF; + return 0; +} + +#ifdef FLOAT +getflt(buffer) +char *buffer; +{ + register char *cp; + register int c; + char decpt, sign, exp; + + sign = exp = decpt = 0; + + for (cp = buffer ; maxwidth-- ; *cp++ = c) { + c = (*gsub)(0); + if (!isdigit(c)) { + if (!decpt && c == '.') + decpt = 1; + else if (!exp && (c == 'e' || c == 'E') && cp != buffer) { + sign = 0; + exp = decpt = 1; + continue; + } else if (sign || (c != '-' && c != '+')) { + (*gsub)(1); + break; + } + } + sign = 1; + } + *cp = 0; + return cp==buffer; +} +#endif + +static +getnum(list, values, base, valp) +char *list; char *values; long *valp; +{ + register char *cp; + register int c, cnt; + long val; + int sign; + + if (maxwidth <= 0) + return 0L; + val = cnt = sign = 0; + if ((c = (*gsub)(0)) == '-') { + sign = 1; + ++cnt; + } else if (c == '+') + ++cnt; + else + (*gsub)(1); + + for ( ; cnt < maxwidth ; ++cnt) { + if ((cp = strchr(list, c = (*gsub)(0))) == 0) { + if (base == 16 && val == 0 && (c=='x' || c=='X')) + continue; + (*gsub)(1); + break; + } + val *= base; + val += values[cp-list]; + } + if (sign) + *valp = -val; + else + *valp = val; + return cnt; +} + + sprintf.c +/* Copyright (C) 1982 by Manx Software Systems */ +static char *buff; + +sprintf(str,fmt,args) +char *str, *fmt; unsigned args; +{ + int spsub(); + register int i; + + buff = str; + i = format(spsub,fmt,&args); + *buff = 0; + return i; +} + +static +spsub(c) +{ + return (*buff++ = c)&0xff; +} + + sscanf.c +/* Copyright (C) 1983 by Manx Software Systems */ +static char *scnstr; +static char quit; + +sscanf(string, fmt, arg) +char *string, *fmt; int *arg; +{ + int sgetc(); + + scnstr = string; + quit = 0; + return scanfmt(sgetc, fmt, &arg); +} + +static +sgetc(what) +{ + if (what == 0) { + if (*scnstr) + return *scnstr++ & 255; + quit = 1; + } else { + if (!quit) + return *--scnstr & 255; + } + return -1; +} + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/S.ARC b/Manx Aztec C86 v340a/SRC/S.ARC new file mode 100644 index 0000000..ad94c5d --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/S.ARC @@ -0,0 +1,392 @@ + cio.c +extern int _attrib; + +static cputc(chr) +register int chr; +{ + scr_putc(chr); + + if (chr == '\n') + scr_putc('\r'); +} + +scr_puts(str) +register char *str; +{ + while(*str) + cputc(*str++); + + cputc('\n'); +} + +scr_printf(fmt,args) +register char *fmt; +unsigned args; +{ + format(cputc,fmt,&args); +} + +scr_setatr(back,frg,intens,blink) +register int back, frg; +register int intens, blink; +{ + register char tmp; + + tmp = _attrib; + _attrib = (back << 4) | frg; + + if (blink) + _attrib |= 128; + else + _attrib &= 127; + + if (intens) + _attrib |= 8; + else + _attrib &= 247; + + _attrib &= 255; + return(tmp); +} + +scr_getatr() +{ + return(_attrib); +} + +scr_resatr(atr) +register int atr; +{ + register char tmp; + + tmp = _attrib; + _attrib = atr; + return(tmp); +} + scr_cdel.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * delete the char. at the cursor and put blank at end of line + */ + +#define max_width 80 + +extern int _attrib; + +scr_cdelete() +{ + register unsigned ch, x; + int lin, col; + + scr_loc(&lin, &col); + for (x = col ; x < max_width-1 ; ++x) { + scr_curs(lin, x+1); + ch = scr_call(0x0800,0,0,0); /* read out current char */ + scr_curs(lin, x); + scr_call(0x0900 | (ch&255), ch>>8, 1, 0); /* and shift over */ + } + scr_curs(lin, max_width-1); + scr_call(0x920, _attrib, 1, 0); /* put a blank at end of line */ + scr_curs(lin, col); + return(0); +} + scr_cins.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * insert a space at the cursor and delete the char. at end of line + */ + +#define max_width 80 +extern int _attrib; + +scr_cinsert() +{ + register unsigned ch, z; + int lin, col; + + scr_loc(&lin, &col); + for (z = max_width - 1 ; z > col ; --z) { + scr_curs(lin, z-1); + ch = scr_call(0x0800,0,0,0); /* read out current char */ + scr_curs(lin, z); + scr_call(0x0900 | (ch&255), ch>>8, 1, 0); /* and move it right */ + } + scr_curs(lin, col); + scr_call(0x920,_attrib,1,0); + return(0); +} + scr_clear.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Clears the screen and homes the cursor + */ + +#define max_width 80 +#define max_y 25 + +extern int _attrib; + +scr_clear() +{ + scr_home(); + scr_call(0x920,_attrib,(max_width * max_y),0); + return(0); +} + scr_curs.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Moves cursor to line lin, position pos + */ + +#define max_width 80 + +scr_curs(lin, col) +register int lin, col; +{ + if (col >= max_width) + col = max_width - 1; + if (lin >= 25) + lin = 24; + scr_call(0x200, 0, 0, (lin << 8) | col); + return(0); +} + scr_echo.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * if flg is zero disable echoing of characters + */ + +extern int _echo; + +scr_echo(flg) +int flg; +{ + _echo = flg; + return(0); +} + scr_eol.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Clear to the end of line + */ + +extern int _attrib; + +scr_eol() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x920, _attrib, 80-col, 0); + return(0); +} + scr_eos.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * clear to end of screen + */ + +extern int _attrib; + +scr_eos() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x920, _attrib, (80-col)+((24-lin)*80), 0); + return(0); +} + scr_home.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Homes the cursor (0, 0) + */ + +scr_home() +{ + scr_curs(0, 0); + return(0); +} + scr_inve.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * if flg is zero turn on inverse + */ + +extern int _attrib; + +scr_invers(flg) +int flg; +{ + _attrib = flg ? 0x70 : 0x07; + return(0); +} + scr_ldel.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Deletes line at lin, blank lines at bottom + */ + +extern int _attrib; + +scr_ldelete() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x600 | 1, _attrib<<8, lin<<8, (24<<8) | 79); + scr_curs(lin, 0); + return(0); +} + scr_lins.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Inserts blank lines at lin, pushing rest down + */ + +extern int _attrib; + +scr_linsert() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x700 | 1, _attrib<<8, lin<<8, (24<<8) | 79); + scr_curs(lin, 0); + return(0); +} + scr_putc.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * display the character at the cursor + */ + +int _attrib = 0x07; + +scr_putc(c) +register int c; +{ + c &= 255; + if (c >= 0x20) + scr_call(0x0900 | c, _attrib,1,0); + scr_call(0x0e00 | c, _attrib); + return c; +} + scr_getc.asm +; Copyright (C) 1985 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + public _echo_ +_echo_ db 0,0 +dataseg ends + assume ds:dataseg +ifdef FARPROC + extrn scr_putc_:far +else + extrn scr_putc_:near +endif +; +; scr_getc() - issue int 16 to get keyboard value +; returns normal ASCII chars as their value (0-127) +; special chars are in the range 128 - 255 +; cntl-break is returned as -2 +; + procdef scr_getc + mov ah,0 + int 16h + call mapchar + cmp _echo_,0 + jz no_echo + cmp ax,128 + jae no_echo + push ax + call scr_putc_ + pop ax +no_echo: + pret + pend scr_getc +; +; scr_poll() - polls keyboard for a character +; returns -1 for no character +; otherwise returns the character as above +; Note: this doesn't remove the char from the buffer +; + procdef scr_poll + mov ah,1 + int 16h + jnz mapit + mov ax,-1 + pret +mapit: + call mapchar + pret + pend scr_poll +; +mapchar proc near + test al,al + jz special + sub ah,ah + ret +special: + xchg al,ah + test al,al + jz ctl_brk + cmp al,3 + jne not_nul + sub ax,ax + ret +not_nul: + or al,80H + ret +ctl_brk: + mov ax,-2 + ret +mapchar endp +; + finish + end + scr_loc.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 +; +; scr_loc(lin, col) - place the location of the cursor in line and column +; + include lmacros.h +; + procdef scr_loc,<,> +; + pushds + mov ah,3 + mov bh,0 + int 10h ; find the location of cursor + ldptr bx,lin,ds ; move address of line into bx + mov 0[bx],dh ; move cursor location into memory + mov byte ptr 1[bx],0 + ldptr bx,col,ds ; move addres of col. into bx + mov 0[bx],dl ; move cursor location into memory + mov byte ptr 1[bx],0 + popds + pret + pend scr_loc + finish + end + scr_call.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +; +; scr_call(ax,bx,cx,dx) - issue int 10 with ax,... set to args +; +; + procdef scr_call,<,,,> + mov ax,aax + mov bx,bbx + mov cx,ccx + mov dx,ddx + int 10h + pret + pend scr_call + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/STDIO.ARC b/Manx Aztec C86 v340a/SRC/STDIO.ARC new file mode 100644 index 0000000..eddfbb1 --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/STDIO.ARC @@ -0,0 +1,702 @@ + agetc.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +agetc(ptr) +register FILE *ptr; +{ + register int c; + +top: + if ((c = getc(ptr)) != EOF) { + switch (c &= 127) { + case 0x1a: + ptr->_flags |= _EOF; + return EOF; + case '\r': + case 0: + goto top; + } + } + return c; +} + + aputc.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +aputc(c,ptr) +register int c; register FILE *ptr; +{ + if (c == '\n') + if (putc('\r',ptr) == EOF) + return EOF; + return putc(c,ptr); +} + + fdopen.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "stdio.h" + +FILE * +fdopen(fd,mode) +char *mode; +{ + register FILE *fp; + FILE *newstream(); + + if ((fp = newstream()) == NULL) + return NULL; + fp->_unit = fd; + fp->_flags = _BUSY; + return fp; +} + + fgets.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +char *fgets(s, n, fp) +char *s; FILE *fp; +{ + register c; + register char *cp; + + cp = s; + while (--n > 0 && (c = agetc(fp)) != EOF) { + *cp++ = c; + if (c == '\n') + break; + } + *cp = 0; + if (c == EOF && cp == s) + return NULL; + return(s); +} + fopen.c +/* Copyright (C) 1981,1982,1983,1984 by Manx Software Systems */ +#include "stdio.h" +#include "fcntl.h" +#include "errno.h" + +extern int errno; + +static struct modes { + char fmode[3]; + int omode; +} modes[] = { + "r", O_RDONLY, + "r+", O_RDWR, + "w", (O_WRONLY|O_CREAT|O_TRUNC), + "w+", (O_RDWR|O_CREAT|O_TRUNC), + "a", (O_WRONLY|O_CREAT|O_APPEND), + "a+", (O_RDWR|O_CREAT|O_APPEND), + "x", (O_WRONLY|O_CREAT|O_EXCL), + "x+", (O_RDWR|O_CREAT|O_EXCL), + "", 0, +}; + +FILE * +fopen(name,mode) +char *name,*mode; +{ + register FILE *fp; + FILE *newstream(), *freopen(); + + if ((fp = newstream()) == NULL) + return NULL; + return freopen(name, mode, fp); +} + +FILE * +freopen(name, mode, fp) +char *name,*mode; FILE *fp; +{ + register struct modes *mp; + register int fd; + + fclose(fp); + + for (mp = modes ; ; ++mp) { + if (*mp->fmode == 0) { + errno = EINVAL; + return NULL; + } + if (strcmp(mp->fmode, mode) == 0) + break; + } + +/* + Don't try to optimize the next 3 lines. Since _unit is a char, + assigning to it in the if statement will cause the -1 test to fail + on unsigned char machines. +*/ + if ((fd = open(name, mp->omode)) == -1) + return (NULL); + fp->_unit = fd; + fp->_flags = _BUSY; + return fp; +} + + fprintf.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +static FILE *Stream; + +fprintf(stream,fmt,args) +FILE *stream; char *fmt; unsigned args; +{ + int fpsub(); + + Stream = stream; + return format(fpsub,fmt,&args); +} + +static +fpsub(c) +{ + return aputc(c,Stream); +} + fputs.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +fputs(s,fp) +register char *s; +FILE *fp; +{ + while ( *s ) + if (aputc(*s++,fp) == EOF) + return(EOF); + return 0; +} + fread.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +fread(buffer,size,number,stream) +register char *buffer; unsigned size; int number; +FILE *stream; +{ + int total; + register int c,i; + + for ( total = 0 ; total < number ; ++total ) { + for ( i = size ; i ; --i ) { + if ( (c = getc(stream)) == EOF ) + return total; + *buffer++ = c; + } + } + return total; +} + fscanf.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +static int scnlast; +static FILE *scnfp; + +fscanf(fp, fmt, args) +FILE *fp; char *fmt; int *args; +{ + int gchar(); + + scnfp = fp; + scnlast = 0; + return scanfmt(gchar, fmt, &args); +} + +static gchar(what) +{ + if (what == 0) { + if (feof(scnfp)) + scnlast = EOF; + else + scnlast = agetc(scnfp); + } else + scnlast = ungetc(scnlast, scnfp); + return scnlast; +} + + fseek.c +/* Copyright (c) 1981, 1982 by Manx Software Systems */ +#include "stdio.h" + +fseek(fp,pos,mode) +register FILE *fp; +long pos; +{ + register int i; + long curpos, lseek(); + + fp->_flags &= ~_EOF; + if (fp->_flags & _DIRTY) { + if (flsh_(fp,-1)) + return EOF; + } else if (mode == 1 && fp->_bp) + pos -= fp->_bend - fp->_bp; + fp->_bp = fp->_bend = NULL; + if (lseek(fp->_unit, pos, mode) < 0) + return EOF; + return 0; +} + +long ftell(fp) +register FILE *fp; +{ + long pos, lseek(); + + pos = lseek(fp->_unit, 0L, 1); /* find out where we are */ + if (fp->_flags & _DIRTY) + pos += fp->_bp - fp->_buff; + else if (fp->_bp) + pos -= fp->_bend - fp->_bp; + return pos; +} + fwrite.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +fwrite(buffer,size,number,stream) +register char *buffer; unsigned size,number; +FILE *stream; +{ + register unsigned i,max; + + max = size * number; + for ( i = 0 ; i < max ; ++i ) { + if ( putc(*buffer++,stream) == EOF ) + return 0; + } + return number; +} + + getbuff.c +/* Copyright (C) 1983 by Manx Software Systems */ +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +FILE Cbuffs[MAXSTREAM] = { + { 0,0,0, _BUSY,0,0,1 }, + { 0,0,0, _BUSY,1,0,1 }, + { 0,0,0, _BUSY,2,0,1 }, +}; + +FILE * +newstream() +{ + register FILE *fp; + + fp = Cbuffs; + while (fp->_flags) + if (++fp >= &Cbuffs[MAXSTREAM]) + return NULL; + return fp; +} + +getbuff(ptr) +register FILE *ptr; +{ + char *buffer, *malloc(); + + if (isatty(ptr->_unit)) { +smlbuff: + ptr->_buflen = 1; + ptr->_buff = &ptr->_bytbuf; + return; + } + if ((buffer = malloc(BUFSIZ)) == NULL) + goto smlbuff; + ptr->_buflen = BUFSIZ; + ptr->_flags |= _ALLBUF; + ptr->_buff = buffer; + return; +} + + getc.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +getc(ptr) +register FILE *ptr; +{ + register int len; + + if (ptr->_bp >= ptr->_bend) { + if (ptr->_flags&(_EOF|_IOERR)) + return EOF; + ptr->_flags &= ~_DIRTY; + if (ptr->_buff == NULL) + getbuff(ptr); + if ((len = read(ptr->_unit,ptr->_buff,ptr->_buflen)) <= 0) { + ptr->_flags |= len==0 ? _EOF : _IOERR; + return EOF; + } + ptr->_bend = (ptr->_bp = ptr->_buff) + len; + } + return *ptr->_bp++ & 255; +} + getchar.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +#undef getchar + +getchar() +{ + return agetc(stdin); +} + gets.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +#undef getchar + +char *gets(line) +char *line; +{ + register char *cp; + register int i; + + cp = line; + while ((i = getchar()) != EOF && i != '\n') + *cp++ = i; + *cp = 0; + if (i == EOF && cp == line) + return NULL; + return line; +} + getw.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +getw(stream) +FILE *stream; +{ + register int x1,x2; + + if ((x1 = getc(stream)) == EOF || (x2 = getc(stream)) == EOF) + return EOF; + return (x2<<8) | x1; +} + printf.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ + +printf(fmt,args) +char *fmt; unsigned args; +{ + extern int putchar(); + + format(putchar,fmt,&args); +} + putc.c +/* Copyright (C) 1981,1982,1983,1984 by Manx Software Systems */ +#include "stdio.h" + +putc(c,ptr) +int c; register FILE *ptr; +{ + if (ptr->_bp >= ptr->_bend) + return flsh_(ptr,c&0xff); + return (*ptr->_bp++ = c) & 0xff; +} + +static closall() /* called by exit to close any open files */ +{ + register FILE *fp; + + for ( fp = Cbuffs ; fp < Cbuffs+MAXSTREAM ; ) + fclose(fp++); +} + +fclose(ptr) +register FILE *ptr; +{ + register int err; + + err = 0; + if (!ptr) + return -1; + if ( ptr->_flags ) { + if (ptr->_flags&_DIRTY) /* if modifed flush buffer */ + err = flsh_(ptr,-1); + err |= close(ptr->_unit); + if (ptr->_flags&_ALLBUF) + free(ptr->_buff); + if (ptr->_flags&_TEMP) { /* temp file, delete it */ + unlink(ptr->_tmpname); + free(ptr->_tmpname); + } + } + + ptr->_buff = + ptr->_bend = /* nothing in buffer */ + ptr->_bp = 0; + ptr->_flags = 0; + return err; +} + +flsh_(ptr,data) +register FILE *ptr; +{ + register int size; + extern int (*cls_)(); + + cls_ = closall; + if (ptr->_flags & _IOERR) + return EOF; + if (ptr->_flags & _DIRTY) { + size = ptr->_bp - ptr->_buff; + if (write(ptr->_unit, ptr->_buff, size) != size) { +ioerr: + ptr->_flags |= _IOERR; + ptr->_bend = ptr->_bp = NULL; + return EOF; + } + } + if (data == -1) { + ptr->_flags &= ~_DIRTY; + ptr->_bend = ptr->_bp = NULL; + return 0; + } + if (ptr->_buff == NULL) + getbuff(ptr); + if (ptr->_buflen == 1) { /* unbuffered I/O */ + if (write(ptr->_unit, &data, 1) != 1) + goto ioerr; + return data; + } + ptr->_bp = ptr->_buff; + ptr->_bend = ptr->_buff + ptr->_buflen; + ptr->_flags |= _DIRTY; + return (*ptr->_bp++ = data) & 0xff; +} + putchar.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +#undef putchar + +putchar(c) +{ + return aputc(c,stdout); +} + puterr.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +puterr(c) +{ + return aputc(c, stderr); +} + puts.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ + +puts(str) +register char *str; +{ + while (*str) + if (putchar(*str++) == -1) + return -1; + return putchar('\n'); +} + putw.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +putw(w,stream) +register unsigned w; +FILE *stream; +{ + if ( putc(w,stream) < 0 ) + return EOF; + else if ( putc((w>>8),stream) < 0 ) + return EOF; + return w; +} + scanf.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +static int scnlast; + +scanf(fmt, args) +char *fmt; int *args; +{ + int gchar(); + + scnlast = 0; + return scanfmt(gchar, fmt, &args); +} + +static gchar(what) +{ + if (what == 0) { + if (feof(stdin)) + scnlast = EOF; + else + scnlast = agetc(stdin); + } else + scnlast = ungetc(scnlast, stdin); + return scnlast; +} + + setbuf.c +/* Copyright (C) 1981,1982 by Manx Software Systems and Thomas Fenwick */ +#include "stdio.h" + +setbuf(stream, buffer) +register FILE *stream; char *buffer; +{ + if (stream->_buff) + return; + if (buffer) { + stream->_buff = buffer; + stream->_buflen = BUFSIZ; + } else { + stream->_buff = &stream->_bytbuf; + stream->_buflen = 1; + } +} + + tmpfile.c +#include + +/* returns a pointer for a temp file which is automatically deleted + when the program exits; the file is opened for update */ + +FILE * +tmpfile () +{ + register char *cp; + register FILE *fp; + char *tmpnam(), *malloc(); + + cp = tmpnam (NULL); + if ( (fp = fopen (cp, "w+")) == NULL ) + perror (cp); + else { + if ((fp->_tmpname = malloc(strlen(cp)+1)) == NULL) { + fclose(fp); + unlink(cp); + return NULL; + } + strcpy(fp->_tmpname,cp); + fp->_flags |= _TEMP; + } + return fp; +} + + tmpnam.c +#include + +static char work[] = "AAAAA"; + +char * +tmpnam(s) +char *s; +{ + static char tmpbuf[L_tmpnam]; + register char *cp; + + if (s == NULL) + s = tmpbuf; + for (;;) { + strcpy(s,P_tmpdir); + strcat(s,work); + strcat(s,"XXX.XXX"); + for (cp = work ; *cp ; ++cp) + if (*cp == 'Z') + *cp = 'A'; + else { + ++*cp; + break; + } + if (mktemp(s)) + break; + } + return s; +} + mktemp.c +#ifdef DOS11 +#include +#endif + +char * +mktemp(template) +char *template; +{ + register char *cp; + register unsigned val; + extern unsigned _dsval; +#ifdef DOS11 + int file; +#endif + + cp = template; + cp += strlen(cp); + for (val = _dsval ; ; ) + if (*--cp == 'X') { + *cp = val%10 + '0'; + val /= 10; + } else if (*cp != '.') + break; + + if (*++cp == '.') /* allow for "abcd.XXX" type file names */ + ++cp; + if (*cp != 0) { + *cp = 'A'; +#ifdef DOS11 + while ((file = open(template, O_RDONLY)) >= 0) { + close(file); +#else + while (access(template, 0) == 0) { +#endif + if (*cp == 'Z') { + *template = 0; + break; + } + ++*cp; + } + } else { +#ifdef DOS11 + if ((file = open(template, O_RDONLY)) >= 0) { + close(file); +#else + if (access(template, 0) == 0) { +#endif + *template = 0; + } + } + return template; +} + ungetc.c +/* Copyright (c) 1981, 1982 by Manx Software Systems */ +#include "stdio.h" + +ungetc(c,ptr) +int c; register FILE *ptr; +{ + if (c == EOF || ptr->_bp <= ptr->_buff) + return EOF; + *--ptr->_bp = c; + return c; +} + + perror.c +#include +#include + +perror (s) +char *s; +{ + if (errno < 0 || errno > sys_nerr) + return -1; + if (s) + fprintf (stderr, "%s: ", s); + fprintf (stderr, "%s\n", sys_errlist[errno]); + return 0; +} + \ No newline at end of file diff --git a/Manx Aztec C86 v340a/SRC/STKSIZ.C b/Manx Aztec C86 v340a/SRC/STKSIZ.C new file mode 100644 index 0000000..e03f327 --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/STKSIZ.C @@ -0,0 +1,21 @@ +#if sizeof(char *) == 4 +int _STKSIZ = 8192/16; /* (in paragraphs) (large data model) */ +int _STKRED = 1024; /* size of RED zone (in bytes) */ +#else +int _STKSIZ = 4096/16; /* (in paragraphs) */ +int _STKRED = 2048; /* size of RED zone (in bytes) */ +#endif + +int _HEAPSIZ = 4096/16; /* (in paragraphs) */ +int _STKLOW = 0; /* default is stack above heap (small only) */ + +/* +NOTE: The RED zone is used for stack saftey checking. With stack above heap, +the heap will not be allowed to get within STKRED bytes of the current value +of the SP, if limit checking is enabled (see the cc +b option), SP isn't +allowed any closer than STKRED bytes to the top of the heap. If stack below +heap and limit checking is enabled, SP isn't allowed any closer than STKRED +bytes to _Utop. Minimum stack size = 2*_STKRED. Minimum value for STKRED +should be about 256 bytes. This allows some margin to issue DOS calls and +allow interrupt handlers to execute. (Some people think that this should +be > 1k.) */ diff --git a/Manx Aztec C86 v340a/SRC/TERM.ARC b/Manx Aztec C86 v340a/SRC/TERM.ARC new file mode 100644 index 0000000..f6101fe --- /dev/null +++ b/Manx Aztec C86 v340a/SRC/TERM.ARC @@ -0,0 +1,282 @@ + term.c +#define XOFF 0x13 +#define XON 0x11 + +main(argc, argv) +char **argv; +{ + register int speed; + + speed = 9600; + if (argc > 1) + speed = atoi(argv[1]); + term(speed); + comrest(); +} + +#undef putchar + +putchar(c) +{ + scr_putc(c); + if (c == '\n') + scr_putc('\r'); + return c; +} + +#define INQSIZ 256 /* these sizes must be powers of two */ +#define OUTQSIZ 16 + +unsigned char inqh, inqt, outqh, outqt; +unsigned char inpq[INQSIZ], outq[OUTQSIZ]; +int inqcnt; +char mode, stopped, xoffsent; + +term(speed) +{ + /* + * Inpq is the queue of characters from the com line, waiting to go to + * the console. Outq is from the console, waiting to go to the com line + */ + register int c, row; + + printf("Manx term 3.20A (Use F1 to exit)\n"); + cominit(speed); + for (;;) { + if (scr_poll() != -1) { + c = scr_getc(); + if (c == (59|0x80)) /* check for F1 to exit */ + return c; + if (c == (83|0x80)) + c = 0x7f; /* map DEL key to ascii DEL */ + outq[outqh] = c; + outqh = outqh+1 & OUTQSIZ-1; + } + + if (inqh != inqt) { + c = inpq[inqt] & 0x7f; /* strip parity */ + ++inqt; + --inqcnt; + switch (mode) { + case 1: + mode = 0; + switch (c) { +#ifdef DOWNLOAD + case 02: case 03: /* initiate upload/download sequence */ + download(); + continue; +#endif + case 'Q': /* insert a blank @ cursor pos */ + scr_cinsert(); + continue; + case 'W': /* delete the char @ cursor pos */ + scr_cdelete(); + continue; + case 'E': /* insert a blank line @ cursor pos */ + scr_linsert(); + continue; + case 'R': /* delete the line @ cursor pos */ + scr_ldelete(); + continue; + case 'T': /* clear to end of line */ + scr_eol(); + continue; + case '*': /* home cursor & clear screen */ + scr_clear(); + continue; + case '=': /* cursor move sequence */ + mode = 2; + continue; + } + /* fall thru into normal character processing */ + + case 0: + if (c == 0x1b) + mode = 1; + else if (c == 032) + scr_clear(); + else + scr_putc(c); + break; + + case 2: /* row character for cursor move */ + row = c - 32; + mode = 3; + continue; + + case 3: /* column character for cursor move */ + c -= 32; + scr_curs(row, c); + mode = 0; + continue; + } + } + + if (inqcnt > 200 && !stopped) { + if (comput(XOFF) == 0) + stopped = xoffsent = 1; + } else if (xoffsent && inqcnt < 30) { + if (comput(XON) == 0) + stopped = xoffsent = 0; + } else if (outqt != outqh && comput(outq[outqt]) == 0) { + stopped = 0; + outqt = outqt+1 & OUTQSIZ-1; + } + } +} + pcio.asm +;:ts=8 +; +; IBM PC Support routines +; + +BASE equ 3f8H +DATA equ BASE+0 ;data register +INTENAB equ BASE+1 ;interrupt enable +DIVLAT0 equ BASE+0 ;divisor latch (least sig. byte) +DIVLAT1 equ BASE+1 ;divisor latch (most sig. byte) +INTID equ BASE+2 ;interrupt identification +LINECTL equ BASE+3 ;line control +MODCTL equ BASE+4 ;modem control +LINSTAT equ BASE+5 ;line status +MODSTAT equ BASE+6 ;modem status +INTVEC equ 30H ;location of interrupt vector +INTCTL equ 20h ;8259 control register +INTCHIP equ 21h ;8259 mask register + + +codeseg segment para public 'code' + assume cs:codeseg, ds:dataseg +dataseg segment para public 'data' +extrn inqh_:byte, inqt_:byte, inqcnt_:word +extrn inpq_:byte + +port dw 0200H +vec_low dw ? +vec_high dw ? +intr_reg db ? +intr_chp db ? +dataseg ends + +data_add dw ? ;codesegment variable for location of dataseg in 'C' + + public comput_ +comput_ proc near + mov dx,LINSTAT + in al,dx + and ax,20H ;is the transmitter ready? + jz notready ;not yet + mov bx,sp + mov al,2[bx] + mov dx,DATA + out dx,al ;output the data + sub ax,ax + ret +notready: + mov ax,-1 + ret +comput_ endp + + public cominit_ +cominit_ proc near + mov bx,sp + push es + sub ax,ax + mov es,ax + mov ax, es:[INTVEC] ;save contents of interupt table + mov vec_low, ax + mov ax,es:[INTVEC+2] ;ditto + mov vec_high,ax + cli + mov es:[INTVEC],offset intsr ;insert the address of int. handler + mov es:[INTVEC+2],cs + mov data_add,ds ;mov 'C' dataseg address to var. + sti + mov dx,INTENAB ;get contents of interupt enable reg. + in al,dx + mov intr_reg,al ;sav contents of interupt enable reg. + mov al,01H ;enable data ready intr. + out dx,al + mov dx,INTCHIP ;get contents of interupt chip + in al,dx + mov intr_chp,al ;sav contents of interupt chip + and al,0efH + out dx,al ;turn on interupt chip + mov al,80H + mov dx,LINECTL + out dx,al + mov ax,0c200H + mov dx,1 ;dividend = 0x1c200 + div word ptr 2[bx] ;compute baud rate divisor + mov dx,DIVLAT0 + out dx,al ;setup com port to given baud rate + mov al,ah + inc dx ;second byte of divisor latch + out dx,al + mov al,03H ;set 8 data, 1 stop, no parity + mov dx,LINECTL + out dx,al + inc dx + mov al,0bh ;turn on DTR, RTS and enable ints + out dx,al + mov al,020h ;send EOI to 8259 + out INTCTL,al + pop es + ret +cominit_ endp + + public comrest_ +comrest_ proc near + push es + mov al,intr_reg + mov dx,INTENAB + out dx,al + mov al,intr_chp + mov dx,INTCHIP + out dx,al +; + sub ax,ax + mov es,ax + mov ax, vec_low ;restore interupt vec. table + cli + mov es:[INTVEC], ax + mov ax, vec_high ;restore interupt vec. table + mov es:[INTVEC+2],ax + sti + pop es + ret +comrest_ endp + + public intsr +intsr proc far + push ds + push ax + push dx + push bx + mov ds,data_add + mov dx,DATA + in al,dx ;yes, get the byte + and ax,255 + sub bx,bx + mov bl,inqh_ + mov byte ptr inpq_[bx],al ;mov char. into cue +; inc inqh_ ;increment cue head will wrap at 255 + inc bl + cmp bl,inqt_ + je no_overflow + mov inqh_,bl + inc inqcnt_ +no_overflow: +; + mov al,020h ;send EOI to 8259 + out INTCTL,al + pop bx + pop dx + pop ax + pop ds + iret +intsr endp + +codeseg ends + end + \ No newline at end of file