├── GPL.TXT ├── README.md ├── bin └── distros │ ├── odc88.0.1.bin.tar.bz2 │ └── odc88.0.1.src.tar.bz2 ├── doc └── c88_310.pdf └── src ├── ASM ├── ASM2.C ├── ASM3.C ├── ASM4.C ├── ASM5.C ├── ASM88.C ├── ASM88.H ├── CHAIN.A ├── MAKE_ASM.BAT └── OBJ.H ├── BIND ├── BIND.C ├── MAKEBIND.BAT └── OBJ.H ├── C ├── C2.C ├── C3.C ├── C4.C ├── C5.C ├── C6.C ├── C7.C ├── C88.C ├── CHAIN.A ├── MAKE_C88.BAT ├── NODES.H ├── OBJ.H └── PASS1.H ├── D ├── D88.C ├── D88A.A ├── DC.C ├── DEBUG.H ├── DIS.A ├── FLIP.A ├── GLINE.C ├── GO.C ├── MAKE_D88.BAT ├── PCFAST.A └── TOKIT.C ├── GEN ├── CHAIN.A ├── GEN.C ├── GEN2.C ├── GEN3.C ├── GEN4.C ├── GEN5.C ├── GEN6.C ├── INST86.H ├── MAKE_GEN.BAT ├── NODES.H ├── OBJ.H └── PASS2.H ├── INCLUDE ├── ASSERT.H ├── CTYPE.H ├── DOS.H ├── FLOAT.H ├── LIMITS.H ├── MATH.H ├── SETJMP.H ├── STDARG.H ├── STDIO.H ├── STDLIB.H └── STRING.H ├── LIB88 ├── LIB88.C ├── MAKE_L88.BAT ├── OBJ.H └── SQUISH.C ├── LIB_31 ├── ABORT.C ├── ACCESS.A ├── ASIN.C ├── ATAN.C ├── ATAN2.C ├── ATAN7.C ├── ATOL.A ├── BC887LIB.BAT ├── BC88LIB.BAT ├── BSEARCH.C ├── BUILTIN.A ├── C887LIB.BAT ├── C88LIB.BAT ├── CHDIR.A ├── CHSIZE.C ├── CONFIG.H ├── CREAT3.C ├── CTYPE.C ├── CTYPE.H ├── DATES.A ├── ECVT.C ├── ERRNO.H ├── EXP.C ├── EXP10.C ├── EXPA.A ├── FABS.A ├── FINPUT.A ├── FLOAT.A ├── FLOAT.H ├── FLOAT7.A ├── FLOOR.A ├── FLOOR7.A ├── FOUTPUT.A ├── FPRINTF.C ├── FREXP.C ├── FSCANF.C ├── FSTUFF.C ├── GETENV.C ├── ISETUP.A ├── ITOA.C ├── LDEXP.C ├── LGPL.TXT ├── LMOVE.A ├── LOG.C ├── LOG10.C ├── LOGA.A ├── LTOA.A ├── MACHAR.H ├── MAKBLIB7.LST ├── MAKEBLIB.BAT ├── MAKEBLIB.LST ├── MAKELIB.LST ├── MAKELIB7.LST ├── MAKE_BMS.BAT ├── MAKE_LIB.BAT ├── MAKE_MS.BAT ├── MALLOC.A ├── MATH.H ├── MEMCHR.A ├── MEMCMP.A ├── MEMCPY.A ├── MEMICMP.A ├── MEMMOVE.A ├── MEMSET.A ├── MODF.C ├── MOVERLAY.C ├── MSVER2.A ├── MTAN.C ├── MTANA.A ├── MULDIV.A ├── NEWLIB.C ├── OVERLAY.C ├── PEEKPOKE.A ├── POW.C ├── PRINTF.C ├── PUTENV.C ├── QSORT.C ├── RAND.C ├── READ.ME ├── RERRNO.C ├── SCANF.C ├── SETJMP.A ├── SIN.C ├── SPRINTF.C ├── SQRT.A ├── STDIO.H ├── STRCAT.A ├── STRCHR.A ├── STRCMP.A ├── STRCPY.A ├── STRDUP.C ├── STRINGI.A ├── STRLEN.A ├── STRLWR.C ├── STRRCHR.A ├── STRREV.C ├── STRSET.C ├── STRSTR.C ├── STRTOD.C ├── STRTOK.C ├── STRTOL.C ├── STRUPR.C ├── SYSTEM.C ├── TAN.C ├── UMULDIV.A ├── UPPER.A ├── VALUES.H ├── _ADX.A ├── _AINTRND.C ├── _DOPRINT.C ├── _DOSCAN.C ├── _INTRND.C ├── _PI.C └── _PI_2.C ├── MAKEODC.BAT ├── NBIND ├── MAKE_NB.BAT ├── NBIND.C ├── OBJ.H ├── _LCMP.A ├── _LCPY.A └── _LMOV.A ├── OTHER ├── DUMPO.C ├── LLINK.BAT ├── OBJ.H ├── OTHER.BAT └── TOOBJ.C ├── SEE ├── BLOCK.C ├── BUFFER.C ├── DOSINT.C ├── EXEC.O ├── EXTERN.H ├── EXTMEM.C ├── GPL.TXT ├── MACRO.C ├── MAKE.BAT ├── MAKEFILE ├── MORE.C ├── MOVE.A ├── PCFAST.A ├── SCREEN.C ├── SEE.C ├── VIEW.C ├── WORLD.H └── WRAP.C ├── SRC ├── BUF128.A ├── C.ASM ├── CB.C ├── CLOCK.C ├── CONFIG.C ├── DUMP.C ├── FLIP.A ├── ISETUP.A ├── LATER.C ├── LIFE.C ├── PCIO.A ├── RUBRBAND.C ├── STUB.ASM ├── TDRAW.C ├── TGETPUT.C └── TXDRAW.C └── TOOLS ├── ENVIRON.C ├── FASTSCR.A ├── FASTSCR.DOC ├── FINDFILE.C ├── FREE.C ├── FREE.DOC ├── GREP.C ├── GREP.DOC ├── LINE2.C ├── LINEIN.C ├── LS.C ├── LS.DOC ├── MAIN.C ├── MAKEFILE ├── MAKEIT.BAT ├── MERGE.C ├── MERGE.DOC ├── MORE.C ├── MORE.DOC ├── PCFAST.A ├── PCMAKE.C ├── PCMAKE.DOC ├── READ.ME ├── RM.C ├── RM.DOC ├── STDIO.H └── TOOLBOX.DOC /README.md: -------------------------------------------------------------------------------- 1 | # OpenDC 2 | An attempt to breathe some life back in to this compiler and associated tools. 3 | 4 | Original code located at www.desmet-c.com 5 | -------------------------------------------------------------------------------- /bin/distros/odc88.0.1.bin.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-grue/OpenDC/88499f82a54969df344fbd53bf7857c01f8f5f1c/bin/distros/odc88.0.1.bin.tar.bz2 -------------------------------------------------------------------------------- /bin/distros/odc88.0.1.src.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-grue/OpenDC/88499f82a54969df344fbd53bf7857c01f8f5f1c/bin/distros/odc88.0.1.src.tar.bz2 -------------------------------------------------------------------------------- /doc/c88_310.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-grue/OpenDC/88499f82a54969df344fbd53bf7857c01f8f5f1c/doc/c88_310.pdf -------------------------------------------------------------------------------- /src/ASM/MAKE_ASM.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | del my_asm88.exe >nul 3 | del chain.o >nul 4 | asm88 chain 5 | if errorlevel 1 goto stop 6 | if not exist chain.o goto stop 7 | 8 | del asm88.o >nul 9 | c88 asm88 %1 10 | if errorlevel 1 goto stop 11 | if not exist asm88.o goto stop 12 | 13 | del asm2.o >nul 14 | c88 asm2 %1 15 | if errorlevel 1 goto stop 16 | if not exist asm2.o goto stop 17 | 18 | del asm3.o >nul 19 | c88 asm3 %1 20 | if errorlevel 2 goto stop 21 | if not exist asm3.o goto stop 22 | 23 | del asm4.o >nul 24 | c88 asm4 %1 25 | if errorlevel 1 goto stop 26 | if not exist asm4.o goto stop 27 | 28 | del asm5.o >nul 29 | c88 asm5 %1 30 | if errorlevel 1 goto stop 31 | if not exist asm5.o goto stop 32 | 33 | if .%1.==.c. goto generate_chk 34 | 35 | bind chain asm88 asm2 asm3 asm4 asm5 -omy_asm88 36 | goto stop 37 | 38 | :generate_chk 39 | bind chain asm88 asm2 asm3 asm4 asm5 -omy_asm88 -c 40 | 41 | :stop 42 | -------------------------------------------------------------------------------- /src/ASM/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/BIND/MAKEBIND.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | c88 bind %1 px 3 | if errorlevel 1 goto stop 4 | 5 | if .%1.==.c. goto generate_chk 6 | 7 | bind bind -omy_bind 8 | goto stop 9 | 10 | bind bind -omy_bind -c 11 | 12 | :stop 13 | -------------------------------------------------------------------------------- /src/BIND/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/C/MAKE_C88.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | asm88 chain 4 | if errorlevel 1 goto stop 5 | 6 | c88 c88 %1 7 | if errorlevel 1 goto stop 8 | 9 | rem 10 | rem ANSI compiler, need to add "#pragma extended" via command line (px) 11 | rem to turn on inline assembly 12 | rem 13 | c88 c2 %1 px 14 | if errorlevel 1 goto stop 15 | 16 | c88 c3 %1 17 | if errorlevel 1 goto stop 18 | 19 | c88 c4 %1 20 | if errorlevel 1 goto stop 21 | 22 | c88 c5 %1 23 | if errorlevel 1 goto stop 24 | 25 | c88 c6 %1 26 | if errorlevel 1 goto stop 27 | 28 | rem 29 | rem ANSI compiler, need to add "#pragma extended" via command line (px) 30 | rem to turn on inline assembly 31 | rem 32 | c88 c7 %1 px 33 | if errorlevel 1 goto stop 34 | 35 | if .%1.==.c. goto generate_chk 36 | 37 | bind chain c88 c2 c3 c4 c5 c6 c7 -omy_c88 38 | goto stop 39 | 40 | :generate_chk 41 | bind chain c88 c2 c3 c4 c5 c6 c7 -omy_c88 -c 42 | 43 | :stop 44 | -------------------------------------------------------------------------------- /src/C/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/D/MAKE_D88.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | c88 d88 -px %1 4 | if errorlevel 1 goto stop 5 | 6 | c88 tokit %1 7 | if errorlevel 1 goto stop 8 | 9 | c88 gline %1 10 | if errorlevel 1 goto stop 11 | 12 | c88 go %1 13 | if errorlevel 1 goto stop 14 | 15 | asm88 d88a 16 | if errorlevel 1 goto stop 17 | 18 | asm88 dis 19 | if errorlevel 1 goto stop 20 | 21 | asm88 pcfast 22 | if errorlevel 1 goto stop 23 | 24 | asm88 flip 25 | if errorlevel 1 goto stop 26 | 27 | if .%1.==.c. goto generate_chk 28 | 29 | bind d88 tokit gline go d88a dis pcfast flip -omy_d88 30 | goto stop 31 | 32 | :generate_chk 33 | bind d88 tokit gline go d88a dis pcfast flip -omy_d88 -c 34 | 35 | :stop 36 | -------------------------------------------------------------------------------- /src/GEN/INST86.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | #define ADD86 0 17 | #define OR86 1 18 | #define ADC86 2 19 | #define SBB86 3 20 | #define AND86 4 21 | #define SUB86 5 22 | #define XOR86 6 23 | #define CMP86 7 24 | 25 | #define PUSH86 0 26 | #define POP86 1 27 | 28 | #define INC86 0 29 | #define DEC86 1 30 | 31 | #define TEST86 0 32 | #define NOT86 2 33 | #define NEG86 3 34 | #define MUL86 4 35 | #define IMUL86 5 36 | #define DIV86 6 37 | #define IDIV86 7 38 | 39 | #define JZ86 4 40 | #define JNZ86 5 41 | #define JL86 12 42 | #define JG86 15 43 | #define JMP86 20 44 | #define CALL86 21 45 | 46 | #define SHL86 4 47 | #define SHR86 5 48 | #define SAR86 7 49 | 50 | #define INC86 0 51 | #define DEC86 1 52 | 53 | #define PUSH86 0 54 | #define POP86 1 55 | -------------------------------------------------------------------------------- /src/GEN/MAKE_GEN.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | asm88 chain 4 | if errorlevel 1 goto stop 5 | 6 | rem 7 | rem ANSI compiler, need to add "#pragma extended" via command line (px) 8 | rem to turn on inline assembly 9 | rem 10 | c88 gen %1 px 11 | if errorlevel 1 goto stop 12 | 13 | c88 gen2 %1 14 | if errorlevel 1 goto stop 15 | 16 | c88 gen3 %1 17 | if errorlevel 1 goto stop 18 | 19 | c88 gen4 %1 20 | if errorlevel 1 goto stop 21 | 22 | c88 gen5 %1 23 | if errorlevel 1 goto stop 24 | 25 | c88 gen6 %1 26 | if errorlevel 1 goto stop 27 | 28 | if .%1.==.c. goto generate_chk 29 | 30 | bind chain gen gen2 gen3 gen4 gen5 gen6 -omy_gen 31 | goto stop 32 | 33 | :generate_chk 34 | bind chain gen gen2 gen3 gen4 gen5 gen6 -omy_gen -c 35 | 36 | :stop 37 | -------------------------------------------------------------------------------- /src/GEN/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/INCLUDE/ASSERT.H: -------------------------------------------------------------------------------- 1 | # ifdef NDEBUG 2 | 3 | # define assert(e) 4 | 5 | # else 6 | 7 | # define assert(e) if(!(e)) {\ 8 | printf("Assertion (" # e ") failed: file %s, line %d\n", __FILE__, __LINE__);\ 9 | abort();\ 10 | } 11 | 12 | # endif -------------------------------------------------------------------------------- /src/INCLUDE/CTYPE.H: -------------------------------------------------------------------------------- 1 | #define _U 0x01 /* Upper case */ 2 | #define _L 0x02 /* Lower case */ 3 | #define _N 0x04 /* Numeral (digit) */ 4 | #define _S 0x08 /* Spacing character */ 5 | #define _P 0x10 /* Punctuation */ 6 | #define _C 0x20 /* Control character */ 7 | #define _B 0x40 /* Blank */ 8 | #define _X 0x80 /* heXadecimal digit */ 9 | 10 | extern char _ctype[]; 11 | 12 | #define isalpha(c) ((_ctype + 1)[c] & (_U | _L)) 13 | #define isupper(c) ((_ctype + 1)[c] & _U) 14 | #define islower(c) ((_ctype + 1)[c] & _L) 15 | #define isdigit(c) ((_ctype + 1)[c] & _N) 16 | #define isxdigit(c) ((_ctype + 1)[c] & _X) 17 | #define isalnum(c) ((_ctype + 1)[c] & (_U | _L | _N)) 18 | #define isspace(c) ((_ctype + 1)[c] & _S) 19 | #define ispunct(c) ((_ctype + 1)[c] & _P) 20 | #define isprint(c) ((_ctype + 1)[c] & (_P | _U | _L | _N | _B)) 21 | #define isgraph(c) ((_ctype + 1)[c] & (_P | _U | _L | _N)) 22 | #define iscntrl(c) ((_ctype + 1)[c] & _C) 23 | #define isascii(c) (!((c) & ~0177)) 24 | #define _toupper(c) ((c) - 'a' + 'A') 25 | #define _tolower(c) ((c) - 'A' + 'a') 26 | #define toascii(c) ((c) & 0177) 27 | -------------------------------------------------------------------------------- /src/INCLUDE/DOS.H: -------------------------------------------------------------------------------- 1 | /* 2 | ; note: FP_OFF and FP_SEG only work in large case 3 | */ 4 | 5 | /* Mode bits for chdir(). Or the bits desired. */ 6 | 7 | #define CHDIR_READONLY 1 8 | #define CHDIR_HIDDEN 2 9 | 10 | /* #defines for extraction offset and segment from a pointer. */ 11 | 12 | struct {unsigned _offset,_segment;}; 13 | #define FP_OFF(ptr) ((((char *)&ptr))->_offset) 14 | #define FP_SEG(ptr) ((((char *)&ptr))->_segment) 15 | 16 | /* Codes for locking and unlocking. Used by locking(). */ 17 | 18 | #define LOCK 0 19 | #define UNLCK 1 20 | 21 | /* Open modes. */ 22 | 23 | #define READ 0 24 | #define WRITE 1 25 | #define READWRITE 2 26 | 27 | /* Open sharing modes. Add to above open modes. */ 28 | 29 | #define COMPAT 0x00 /* compatibility mode */ 30 | #define DENYRW 0x10 /* deny read/write mode */ 31 | #define DENYWR 0x20 /* deny write mode */ 32 | #define DENYRD 0x30 /* deny read mode */ 33 | #define DENYNO 0x40 /* deny none mode */ 34 | 35 | -------------------------------------------------------------------------------- /src/INCLUDE/FLOAT.H: -------------------------------------------------------------------------------- 1 | #define FLT_RADIX 2 2 | 3 | #define FLT_MANT_DIG 24 4 | #define FLT_EPSILON 1.19209290E-07 5 | #define FLT_DIG 6 6 | #define FLT_MIN_EXP -125 7 | #define FLT_MIN 1.17549435E-38 8 | #define FLT_MIN_10_EXP -37 9 | #define FLT_MAX_EXP 128 10 | #define FLT_MAX 3.40282347E+38 11 | #define FLT_MAX_10_EXP 38 12 | 13 | #define DBL_MANT_DIG 53 14 | #define DBL_EPSILON 2.2204460492503131E-16 15 | #define DBL_DIG 15 16 | #define DBL_MIN_EXP -1021 17 | #define DBL_MIN 2.225073858507201E-308 18 | #define DBL_MIN_10_EXP -307 19 | #define DBL_MAX_EXP +1024 20 | #define DBL_MAX 1.797693134862316E+308 21 | #define DBL_MAX_10_EXP +308 22 | -------------------------------------------------------------------------------- /src/INCLUDE/LIMITS.H: -------------------------------------------------------------------------------- 1 | #define CHAR_BIT 8 2 | 3 | #define SCHAR_MIN -127 4 | #define SCHAR_MAX 127 5 | 6 | #define UCHAR_MAX 255 7 | 8 | #define CHAR_MIN 0 9 | #define CHAR_MAX 255 10 | 11 | #define SHRT_MIN -32767 12 | #define SHRT_MAX 32767 13 | 14 | #define USHRT_MAX 65535 15 | 16 | #define INT_MIN -32767 17 | #define INT_MAX 32767 18 | 19 | #define UINT_MAX 65535 20 | 21 | #define LONG_MIN -2147483647 22 | #define LONG_MAX 2147483647 23 | 24 | #define ULONG_MAX 4294967295 25 | -------------------------------------------------------------------------------- /src/INCLUDE/MATH.H: -------------------------------------------------------------------------------- 1 | struct exception { 2 | int type; 3 | char *name; 4 | double arg1; 5 | double arg2; 6 | double retval; 7 | } ; 8 | 9 | struct complex { 10 | double x,y; 11 | } ; 12 | 13 | #define DOMAIN 1 14 | #define SING 2 15 | #define OVERFLOW 3 16 | #define UNDERFLOW 4 17 | #define TLOSS 5 18 | #define PLOSS 6 19 | 20 | #define EDOM 33 21 | #define ERANGE 34 22 | 23 | extern int errno; 24 | 25 | #define HUGE_VAL 1.797693134862316E+308 26 | 27 | double acos(double); 28 | double asin(double); 29 | double atan(double); 30 | double atan2(double, double); 31 | double ceil(double); 32 | double cos(double); 33 | double exp(double); 34 | double fabs(double); 35 | double floor(double); 36 | double frexp(double, int *); 37 | double ldexp(double, double); 38 | double log(double); 39 | double log10(double); 40 | double modf(double, double *); 41 | double pow(double, double); 42 | double sin(double); 43 | double sqrt(double); 44 | double tan(double); 45 | 46 | #ifndef atof 47 | double strtod(const char *, char **); 48 | #define atof(c) strtod((c), (char**)0); 49 | #endif 50 | 51 | double _pi(void); 52 | double _pi_2(void); 53 | -------------------------------------------------------------------------------- /src/INCLUDE/SETJMP.H: -------------------------------------------------------------------------------- 1 | /* setjmp.h -- setjmp(), longjmp() environment */ 2 | 3 | typedef char jmp_buf[10]; 4 | -------------------------------------------------------------------------------- /src/INCLUDE/STDARG.H: -------------------------------------------------------------------------------- 1 | typedef char *va_list; 2 | 3 | #define va_start(ap,v) ap = (va_list)&v + sizeof(v) 4 | #define va_arg(ap,t) ((t*)(ap += sizeof(t)))[-1] 5 | #define va_end(ap) ap = NULL 6 | -------------------------------------------------------------------------------- /src/INCLUDE/STDIO.H: -------------------------------------------------------------------------------- 1 | /* STDIO.H Include file for C88 input/output. */ 2 | 3 | /* a 'FILE' is simply an integer is this implimentation */ 4 | 5 | #define FILE int 6 | 7 | /* Standard input, standard output and standard error. */ 8 | 9 | #define stdin (FILE *)0 10 | #define stdout (FILE *)1 11 | #define stderr (FILE *)2 12 | #define stdaux (FILE *)3 13 | #define stdprn (FILE *)4 14 | 15 | #ifdef LARGE_CASE 16 | 17 | /* With LARGE case (-B option), */ 18 | /* Use lower case stdin, stdout etc with fopen(), fread(), getc() etc. */ 19 | /* Use upper case STDIN, STDOUT etc with open(), read() etc. */ 20 | 21 | #define STDIN 0 22 | #define STDOUT 1 23 | #define STDERR 2 24 | #define STDAUX 3 25 | #define STDPRN 4 26 | 27 | #endif 28 | 29 | #define NULL (void *)0 30 | #define TRUE 1 31 | #define FALSE 0 32 | #define EOF (-1) 33 | #define ERR (-1) 34 | 35 | #define SEEK_SET 0 36 | #define SEEK_CUR 1 37 | #define SEEK_END 2 38 | 39 | #define F_ERR 1 40 | #define F_EOF 2 41 | 42 | extern char _flag[]; 43 | 44 | #define feof(f) (_flag[(int)f] & F_EOF) 45 | #define ferror(f) (_flag[(int)f] & F_ERR) 46 | #define clrerror(f) (_flag[(int)f] & ~(F_ERR | F_EOF)) 47 | 48 | int closeall(void); 49 | int fclose(FILE *); 50 | int fflush(FILE *); 51 | int fgetc(FILE *); 52 | int fgetchar(void); 53 | char *fgets(char *, int, FILE *); 54 | long filelength(int); 55 | int fileno(FILE *); 56 | FILE *fopen(char *, char *); 57 | int fprintf(FILE *, char *, ... ); 58 | int fputc(int, FILE *); 59 | int fputchar(int); 60 | int fputs(char *, FILE *); 61 | int fread(char *, int, int, FILE *); 62 | FILE *freopen(char *, char *, FILE *); 63 | int fscanf(FILE *, char *, ... ); 64 | long fseek(FILE *, long, int); 65 | long ftell(FILE *); 66 | int fwrite(char *, int, int, FILE *); 67 | int getc(FILE *); 68 | int getchar(void); 69 | char *gets(char *); 70 | int getw(FILE *); 71 | int printf(char *, ... ); 72 | int puts(char *); 73 | int putw(int, FILE *); 74 | int rewind(FILE *); 75 | int scanf(char *, ... ); 76 | int sprintf(char *, char *, ... ); 77 | int sscanf(char *, char *, ... ); 78 | int ungetc(int, FILE *); 79 | 80 | -------------------------------------------------------------------------------- /src/INCLUDE/STDLIB.H: -------------------------------------------------------------------------------- 1 | extern int errno; 2 | 3 | #define ERANGE 34 4 | 5 | #define HUGE_VAL 1.797693134862316E+308 6 | 7 | #define RAND_MAX 32767 8 | 9 | extern unsigned environ; 10 | 11 | extern unsigned _psp; 12 | 13 | extern char _osmajor, _osminor; 14 | 15 | int abs(int); 16 | char *getenv(char *, char *, ...); 17 | char *itoa(int, char *, int); 18 | long labs(long); 19 | char *ltoa(long, char *, int); 20 | int putenv(char *, char *); 21 | int rand(void); 22 | void srand(int); 23 | double strtod(const char *, char **); 24 | long strtol(const char *, char **, int); 25 | 26 | #ifndef tolower 27 | int tolower(int); 28 | #endif 29 | 30 | #ifndef toupper 31 | int toupper(int); 32 | #endif 33 | 34 | #define atoi(c) (int)strtol((c), (char**)0, 0) 35 | #define atol(c) strtol((c), (char**)0, 0) 36 | #define atof(c) strtod((c), (char**)0); 37 | -------------------------------------------------------------------------------- /src/INCLUDE/STRING.H: -------------------------------------------------------------------------------- 1 | typedef unsigned size_t; 2 | 3 | void *memccpy( void *, void *, char, size_t ); 4 | void *memchr( void *, int, size_t ); 5 | int memcmp( void *, void *, size_t ); 6 | void *memcpy( void *, void *, size_t ); 7 | int memicmp( void *, void *, size_t ); 8 | void *memmove( void *, void *, size_t ); 9 | void *memset( void *, char, size_t ); 10 | 11 | char *strcat(char *, char *); 12 | char *strchr(char *, char); 13 | int strcmp(char *, char *); 14 | int strcmpi(char *, char *); 15 | char *strcpy(char *, char *); 16 | unsigned strcspn(char *, char *); 17 | char *strdup(char *); 18 | int stricmp(char *, char *); 19 | unsigned strlen(char *); 20 | char *strlwr(char *); 21 | char *strncat(char *, char *, unsigned int); 22 | int strncmp(char *, char *, unsigned int); 23 | char *strncpy(char *, char *, unsigned int); 24 | char *strrchr(char *, int); 25 | char *strrev(char *); 26 | char *strset(char *, int); 27 | unsigned strspn(char *, char *); 28 | char *strstr(char *, char *); 29 | char *strtok(char *, char *); 30 | char *strupr(char *); 31 | -------------------------------------------------------------------------------- /src/LIB88/MAKE_L88.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | c88 lib88 %1 4 | if errorlevel 1 goto stop 5 | 6 | c88 squish %1 7 | if errorlevel 1 goto stop 8 | 9 | if .%1.==.c. goto generate_chk 10 | 11 | bind lib88 -omy_lib88 12 | 13 | bind squish -omysquish 14 | goto stop 15 | 16 | :generate_chk 17 | bind lib88 -omy_lib88 -c 18 | 19 | bind squish -omysquish -c 20 | 21 | :stop 22 | -------------------------------------------------------------------------------- /src/LIB88/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/LIB_31/ABORT.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | 18 | abort(){ 19 | fputs("Abnormal program termination", stderr); 20 | _exit(3); 21 | } 22 | -------------------------------------------------------------------------------- /src/LIB_31/ACCESS.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | INCLUDE "CONFIG.H" 17 | ; access(char * filename, int mode) 18 | ; 19 | ; return 0 if OK, -1 on err (errno = AX) 20 | 21 | cseg 22 | public access_ 23 | access_:push bp 24 | mov bp,sp 25 | 26 | if model 27 | push ds 28 | endif 29 | 30 | sub sp,128 ; space for FIND FIRST 31 | 32 | if model 33 | mov dx,ss 34 | mov ds,dx 35 | endif 36 | 37 | mov dx,sp 38 | mov ah,1AH ; set DTA 39 | int 21H 40 | mov dx,[bp+pbase] ; name 41 | 42 | if model 43 | mov ds,[bp+pbase+2] 44 | endif 45 | 46 | xor cx,cx ; no attributes 47 | mov ah,4EH ; FIND FIRST 48 | int 21H 49 | jc err 50 | 51 | if model 52 | test byte [bp+10],4 53 | else 54 | test byte [bp+6],4 55 | endif 56 | 57 | jnz ok 58 | mov bx,sp 59 | test byte ss:[bx+21],1 60 | jnz err 61 | ok: xor ax,ax 62 | 63 | if model 64 | add sp,128 65 | pop ds 66 | else 67 | mov sp,bp 68 | endif 69 | 70 | pop bp 71 | ret 72 | 73 | dseg 74 | public errno_:word 75 | cseg 76 | err: mov errno_,ax 77 | mov ax,-1 78 | if model 79 | add sp,128 80 | pop ds 81 | else 82 | mov sp,bp 83 | endif 84 | 85 | pop bp 86 | ret 87 | -------------------------------------------------------------------------------- /src/LIB_31/ATAN.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | extern double fabs(); 17 | 18 | static double a[4] = {0x0000000000000000,/* 0.0 */ 19 | 0x3FE0C152382D7365, /* 0.52359877559829887308 */ 20 | 0x3FF921FB54442D18, /* 1.57079632679489661923 */ 21 | 0x3FF0C152382D7365}; /* 1.04719755119659774615 */ 22 | static double one = 0x3FF0000000000000; /* 1.0 */ 23 | static double twoMinusSqrt3 = 0x3FD126145E9ECD56; /* 0.26794919243112270647 */ 24 | static double sqrt3Minus1 = 0x3FE76CF5D0B09955; /* 0.73205080756887729353 */ 25 | static double sqrt3 = 0x3FFBB67AE8584CAA; /* 1.73205080756887729353 */ 26 | static double dot5 = 0x3FE0000000000000; /* 0.5 */ 27 | static double eps = 0x3E4E1094D643F785; /* 1.4e-8 */ 28 | static double p0 = 0xC02B60A651061CE1; /* -0.13688768894191926929e+2 */ 29 | static double p1 = 0xC034817FB9E2BCCA; /* -0.20505855195861651981e+2 */ 30 | static double p2 = 0xC020FD3F5C8D6A63; /* -0.84946240351320683534e+1 */ 31 | static double p3 = 0xBFEACD7AD9B187BD; /* -0.83758299368150059274 */ 32 | static double q0 = 0x4044887CBCC495A9; /* 0.41066306682575781263e+2 */ 33 | static double q1 = 0x40558A12040B6DA4; /* 0.86157349597130242515e+2 */ 34 | static double q2 = 0x404DCA0A320DA3D5; /* 0.59578436142597344465e+2 */ 35 | static double q3 = 0x402E0C49E14AC70F; /* 0.15024001160028576121e+2 */ 36 | static double zero = 0x0000000000000000; /* 0.0 */ 37 | static double pi = 0x400921FB54442D19; /* 3.14159265358979323846264 */ 38 | static double _atan(f) 39 | double f; 40 | { 41 | int n; 42 | double g, gpg, qg; 43 | 44 | if(f > one) 45 | { 46 | f = one / f; 47 | n = 2; 48 | } 49 | else 50 | n = 0; 51 | if(f > twoMinusSqrt3) 52 | { 53 | f = (((sqrt3Minus1 * f - dot5) - dot5) + f) / (sqrt3 + f); 54 | ++n; 55 | } 56 | if(fabs(f) > eps) 57 | { 58 | g = f * f; 59 | gpg = (((p3 * g + p2) * g +p1) * g +p0) * g; 60 | qg = (((g + q3) * g + q2) * g + q1) * g + q0; 61 | f += f * (gpg / qg); 62 | } 63 | if(n > 1) 64 | f = -f; 65 | f += a[n]; 66 | return f; 67 | } 68 | 69 | double atan(x) 70 | double x; 71 | { 72 | double r; 73 | 74 | r = _atan(fabs(x)); 75 | return x < zero ? -r : r; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/LIB_31/ATAN2.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | #include 18 | #include 19 | 20 | double atan2(double y, double x) { 21 | int neg_y = 0; 22 | double arctan; 23 | 24 | if (!(y || x)) { 25 | errno = EDOM; 26 | return y; 27 | } 28 | if (y < 0) { 29 | y = -y; 30 | neg_y++; 31 | } 32 | if (y - fabs(x) == y) 33 | return (neg_y ? -_pi_2() : _pi_2()); 34 | arctan = x >= DBL_MIN ? atan(y/x) : atan(DBL_MAX); 35 | if (x > 0) return (arctan); 36 | if (neg_y) return arctan - _pi(); 37 | return arctan + _pi(); 38 | } 39 | -------------------------------------------------------------------------------- /src/LIB_31/ATAN7.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #define SQRT3 1.732050807568877293 17 | #define EPS 2.328306436e-10 18 | 19 | static double A[] = { 20 | 0.0, 21 | 0.52359877559829887308, 22 | 1.57079632679489661923, 23 | 1.04719755119659774615 24 | }; 25 | 26 | static double f, result; 27 | 28 | double fabs(); 29 | 30 | double atan(X) 31 | double X; 32 | { 33 | int N; 34 | 35 | f = fabs( X ); 36 | 37 | if ( f > 1.0 ) 38 | { 39 | f = 1.0 / f; 40 | N = 2; 41 | } 42 | else 43 | N = 0; 44 | 45 | if ( f > ( 2.0 - SQRT3 )) 46 | { 47 | f = (((( SQRT3 - 1.0 ) * f - 0.5 ) - 0.5 ) + f ) / ( SQRT3 + f ); 48 | N++; 49 | } 50 | 51 | if ( fabs( f ) < EPS ) 52 | result = f; 53 | else { 54 | #asm 55 | FLD QWORD f_ 56 | FLD1 57 | FPATAN 58 | FST QWORD result_ 59 | # 60 | } 61 | if ( N > 1 ) 62 | result = -result; 63 | result += A[N]; 64 | 65 | if ( X < 0.0 ) 66 | result = -result; 67 | 68 | return ( result ); 69 | } 70 | -------------------------------------------------------------------------------- /src/LIB_31/ATOL.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | ; ATOI_ -- convert a string with an integer to an integer 21 | ; ATOL_ -- convert a string with an integer to a long 22 | 23 | public ATOL_,ATOI_ 24 | ATOL_: 25 | ATOI_: push bp 26 | mov bp,sp 27 | if model 28 | mov bx,[bp+6] 29 | mov es,[bp+8] 30 | else 31 | mov bx,[bp+4] 32 | endif 33 | xor ax,ax 34 | xor bp,bp ;high 2 bytes 35 | mov si,0 36 | if model 37 | skipbl: mov cl,es:[bx] 38 | else 39 | skipbl: mov cl,[bx] 40 | endif 41 | inc bx 42 | cmp cl,' ' 43 | jz skipbl 44 | cmp cl,9 45 | jz skipbl 46 | cmp cl,'+' 47 | jz skipbl 48 | cmp cl,'-' ;is it minus ? 49 | jnz no_sign 50 | mov si,1 ;flag for sign 51 | if model 52 | mov cl,es:[bx] 53 | else 54 | mov cl,[bx] 55 | endif 56 | inc bx 57 | no_sign:cmp cl,'0' ;is it a digit? 58 | jc endatoi 59 | cmp cl,'9' 60 | ja endatoi 61 | push ax ;calc hi word times 10 62 | mov ax,10 63 | mul bp 64 | mov bp,ax ;old hi word times 10 65 | pop ax 66 | sub cl,'0' 67 | mov ch,0 68 | mov di,10 69 | mul di 70 | add ax,cx 71 | adc dx,0 72 | add bp,dx ;add to hi word 73 | if model 74 | mov cl,es:[bx] 75 | else 76 | mov cl,[bx] 77 | endif 78 | inc bx 79 | jmp no_sign 80 | endatoi: 81 | mov dx,bp 82 | cmp si,0 83 | jz quita 84 | not dx 85 | neg ax 86 | sbb dx,-1 87 | quita: pop bp 88 | _ret 89 | -------------------------------------------------------------------------------- /src/LIB_31/BC887LIB.BAT: -------------------------------------------------------------------------------- 1 | lib bc887; 2 | del bc887.lib 3 | lib bc887; 4 | lib bc887 + ABORT.OBJ; 5 | lib bc887 + ACCESS.OBJ; 6 | lib bc887 + _ADX.OBJ; 7 | lib bc887 + _AINTRND.OBJ; 8 | lib bc887 + ASIN.OBJ; 9 | lib bc887 + ATAN2.OBJ; 10 | lib bc887 + ATAN7.OBJ; 11 | lib bc887 + ATOL.OBJ; 12 | lib bc887 + BSEARCH.OBJ; 13 | lib bc887 + BUILTIN.OBJ; 14 | lib bc887 + CHDIR.OBJ; 15 | lib bc887 + CHSIZE.OBJ; 16 | lib bc887 + CREAT3.OBJ; 17 | lib bc887 + CTYPE.OBJ; 18 | lib bc887 + DATES.OBJ; 19 | lib bc887 + _DOPRINT.OBJ; 20 | lib bc887 + _DOSCAN.OBJ; 21 | lib bc887 + ECVT.OBJ; 22 | lib bc887 + EXP10.OBJ; 23 | lib bc887 + EXPA.OBJ; 24 | lib bc887 + FABS.OBJ; 25 | lib bc887 + FINPUT.OBJ; 26 | lib bc887 + FLOAT7.OBJ; 27 | lib bc887 + FLOOR7.OBJ; 28 | lib bc887 + FOUTPUT.OBJ; 29 | lib bc887 + FPRINTF.OBJ; 30 | lib bc887 + FREXP.OBJ; 31 | lib bc887 + FSCANF.OBJ; 32 | lib bc887 + FSTUFF.OBJ; 33 | lib bc887 + GETENV.OBJ; 34 | lib bc887 + _INTRND.OBJ; 35 | lib bc887 + ISETUP.OBJ; 36 | lib bc887 + ITOA.OBJ; 37 | lib bc887 + LDEXP.OBJ; 38 | lib bc887 + LMOVE.OBJ; 39 | lib bc887 + LOG10.OBJ; 40 | lib bc887 + LOGA.OBJ; 41 | lib bc887 + LTOA.OBJ; 42 | lib bc887 + MALLOC.OBJ; 43 | lib bc887 + MEMCHR.OBJ; 44 | lib bc887 + MEMCMP.OBJ; 45 | lib bc887 + MEMCPY.OBJ; 46 | lib bc887 + MEMICMP.OBJ; 47 | lib bc887 + MEMMOVE.OBJ; 48 | lib bc887 + MEMSET.OBJ; 49 | lib bc887 + MODF.OBJ; 50 | lib bc887 + MSVER2.OBJ; 51 | lib bc887 + MTANA.OBJ; 52 | lib bc887 + MULDIV.OBJ; 53 | lib bc887 + NEWLIB.OBJ; 54 | lib bc887 + PEEKPOKE.OBJ; 55 | lib bc887 + _PI_2.OBJ; 56 | lib bc887 + _PI.OBJ; 57 | lib bc887 + POW.OBJ; 58 | lib bc887 + PRINTF.OBJ; 59 | lib bc887 + PUTENV.OBJ; 60 | lib bc887 + QSORT.OBJ; 61 | lib bc887 + RAND.OBJ; 62 | lib bc887 + SCANF.OBJ; 63 | lib bc887 + SETJMP.OBJ; 64 | lib bc887 + SIN.OBJ; 65 | lib bc887 + SPRINTF.OBJ; 66 | lib bc887 + STRCAT.OBJ; 67 | lib bc887 + STRCHR.OBJ; 68 | lib bc887 + STRCMP.OBJ; 69 | lib bc887 + STRCPY.OBJ; 70 | lib bc887 + STRDUP.OBJ; 71 | lib bc887 + STRINGI.OBJ; 72 | lib bc887 + STRLEN.OBJ; 73 | lib bc887 + STRLWR.OBJ; 74 | lib bc887 + STRRCHR.OBJ; 75 | lib bc887 + STRREV.OBJ; 76 | lib bc887 + STRSET.OBJ; 77 | lib bc887 + STRSTR.OBJ; 78 | lib bc887 + STRTOD.OBJ; 79 | lib bc887 + STRTOK.OBJ; 80 | lib bc887 + STRTOL.OBJ; 81 | lib bc887 + STRUPR.OBJ; 82 | lib bc887 + SYSTEM.OBJ; 83 | lib bc887 + TAN.OBJ; 84 | lib bc887 + UMULDIV.OBJ; 85 | lib bc887 + UPPER.OBJ; 86 | del bc887.bak 87 | -------------------------------------------------------------------------------- /src/LIB_31/BC88LIB.BAT: -------------------------------------------------------------------------------- 1 | lib bc88; 2 | del bc88.lib 3 | lib bc88; 4 | lib bc88 + ABORT.OBJ; 5 | lib bc88 + ACCESS.OBJ; 6 | lib bc88 + _ADX.OBJ; 7 | lib bc88 + _AINTRND.OBJ; 8 | lib bc88 + ASIN.OBJ; 9 | lib bc88 + ATAN2.OBJ; 10 | lib bc88 + ATAN.OBJ; 11 | lib bc88 + ATOL.OBJ; 12 | lib bc88 + BSEARCH.OBJ; 13 | lib bc88 + BUILTIN.OBJ; 14 | lib bc88 + CHDIR.OBJ; 15 | lib bc88 + CHSIZE.OBJ; 16 | lib bc88 + CREAT3.OBJ; 17 | lib bc88 + CTYPE.OBJ; 18 | lib bc88 + DATES.OBJ; 19 | lib bc88 + _DOPRINT.OBJ; 20 | lib bc88 + _DOSCAN.OBJ; 21 | lib bc88 + ECVT.OBJ; 22 | lib bc88 + EXP10.OBJ; 23 | lib bc88 + EXP.OBJ; 24 | lib bc88 + FABS.OBJ; 25 | lib bc88 + FINPUT.OBJ; 26 | lib bc88 + FLOAT.OBJ; 27 | lib bc88 + FLOOR.OBJ; 28 | lib bc88 + FOUTPUT.OBJ; 29 | lib bc88 + FPRINTF.OBJ; 30 | lib bc88 + FREXP.OBJ; 31 | lib bc88 + FSCANF.OBJ; 32 | lib bc88 + FSTUFF.OBJ; 33 | lib bc88 + GETENV.OBJ; 34 | lib bc88 + _INTRND.OBJ; 35 | lib bc88 + ISETUP.OBJ; 36 | lib bc88 + ITOA.OBJ; 37 | lib bc88 + LDEXP.OBJ; 38 | lib bc88 + LMOVE.OBJ; 39 | lib bc88 + LOG10.OBJ; 40 | lib bc88 + LOG.OBJ; 41 | lib bc88 + LTOA.OBJ; 42 | lib bc88 + MALLOC.OBJ; 43 | lib bc88 + MEMCHR.OBJ; 44 | lib bc88 + MEMCMP.OBJ; 45 | lib bc88 + MEMCPY.OBJ; 46 | lib bc88 + MEMICMP.OBJ; 47 | lib bc88 + MEMMOVE.OBJ; 48 | lib bc88 + MEMSET.OBJ; 49 | lib bc88 + MODF.OBJ; 50 | lib bc88 + MSVER2.OBJ; 51 | lib bc88 + MTAN.OBJ; 52 | lib bc88 + MULDIV.OBJ; 53 | lib bc88 + NEWLIB.OBJ; 54 | lib bc88 + PEEKPOKE.OBJ; 55 | lib bc88 + _PI_2.OBJ; 56 | lib bc88 + _PI.OBJ; 57 | lib bc88 + POW.OBJ; 58 | lib bc88 + PRINTF.OBJ; 59 | lib bc88 + PUTENV.OBJ; 60 | lib bc88 + QSORT.OBJ; 61 | lib bc88 + RAND.OBJ; 62 | lib bc88 + RERRNO.OBJ; 63 | lib bc88 + SCANF.OBJ; 64 | lib bc88 + SETJMP.OBJ; 65 | lib bc88 + SIN.OBJ; 66 | lib bc88 + SPRINTF.OBJ; 67 | lib bc88 + SQRT.OBJ; 68 | lib bc88 + STRCAT.OBJ; 69 | lib bc88 + STRCHR.OBJ; 70 | lib bc88 + STRCMP.OBJ; 71 | lib bc88 + STRCPY.OBJ; 72 | lib bc88 + STRDUP.OBJ; 73 | lib bc88 + STRINGI.OBJ; 74 | lib bc88 + STRLEN.OBJ; 75 | lib bc88 + STRLWR.OBJ; 76 | lib bc88 + STRRCHR.OBJ; 77 | lib bc88 + STRREV.OBJ; 78 | lib bc88 + STRSET.OBJ; 79 | lib bc88 + STRSTR.OBJ; 80 | lib bc88 + STRTOD.OBJ; 81 | lib bc88 + STRTOK.OBJ; 82 | lib bc88 + STRTOL.OBJ; 83 | lib bc88 + STRUPR.OBJ; 84 | lib bc88 + SYSTEM.OBJ; 85 | lib bc88 + TAN.OBJ; 86 | lib bc88 + UMULDIV.OBJ; 87 | lib bc88 + UPPER.OBJ; 88 | del bc88.bak 89 | -------------------------------------------------------------------------------- /src/LIB_31/BSEARCH.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * Binary search algorithm, generalized from Knuth (6.2.1) Algorithm B. 18 | * 19 | */ 20 | 21 | typedef char *POINTER; 22 | 23 | POINTER 24 | bsearch(key, base, nel, width, compar) 25 | POINTER key; /* Key to be located */ 26 | POINTER base; /* Beginning of table */ 27 | unsigned nel; /* Number of elements in the table */ 28 | unsigned width; /* Width of an element (bytes) */ 29 | int (*compar)(); /* Comparison function */ 30 | { 31 | int two_width = width + width; 32 | POINTER last = base + width * (nel - 1); /* Last element in table */ 33 | 34 | while (last >= base) { 35 | 36 | register POINTER p = base + width * ((last - base)/two_width); 37 | register int res = (*compar)(key, p); 38 | 39 | if (res == 0) 40 | return (p); /* Key found */ 41 | if (res < 0) 42 | last = p - width; 43 | else 44 | base = p + width; 45 | } 46 | return ((POINTER) 0); /* Key not found */ 47 | } 48 | -------------------------------------------------------------------------------- /src/LIB_31/C887LIB.BAT: -------------------------------------------------------------------------------- 1 | lib c887; 2 | del c887.lib 3 | lib c887; 4 | lib c887 + ABORT.OBJ; 5 | lib c887 + ACCESS.OBJ; 6 | lib c887 + _ADX.OBJ; 7 | lib c887 + _AINTRND.OBJ; 8 | lib c887 + ASIN.OBJ; 9 | lib c887 + ATAN2.OBJ; 10 | lib c887 + ATAN7.OBJ; 11 | lib c887 + ATOL.OBJ; 12 | lib c887 + BSEARCH.OBJ; 13 | lib c887 + BUILTIN.OBJ; 14 | lib c887 + CHDIR.OBJ; 15 | lib c887 + CHSIZE.OBJ; 16 | lib c887 + CREAT3.OBJ; 17 | lib c887 + CTYPE.OBJ; 18 | lib c887 + DATES.OBJ; 19 | lib c887 + _DOPRINT.OBJ; 20 | lib c887 + _DOSCAN.OBJ; 21 | lib c887 + ECVT.OBJ; 22 | lib c887 + EXP10.OBJ; 23 | lib c887 + EXPA.OBJ; 24 | lib c887 + FABS.OBJ; 25 | lib c887 + FINPUT.OBJ; 26 | lib c887 + FLOAT7.OBJ; 27 | lib c887 + FLOOR7.OBJ; 28 | lib c887 + FOUTPUT.OBJ; 29 | lib c887 + FPRINTF.OBJ; 30 | lib c887 + FREXP.OBJ; 31 | lib c887 + FSCANF.OBJ; 32 | lib c887 + FSTUFF.OBJ; 33 | lib c887 + GETENV.OBJ; 34 | lib c887 + _INTRND.OBJ; 35 | lib c887 + ISETUP.OBJ; 36 | lib c887 + ITOA.OBJ; 37 | lib c887 + LDEXP.OBJ; 38 | lib c887 + LMOVE.OBJ; 39 | lib c887 + LOG10.OBJ; 40 | lib c887 + LOGA.OBJ; 41 | lib c887 + LTOA.OBJ; 42 | lib c887 + MALLOC.OBJ; 43 | lib c887 + MEMCHR.OBJ; 44 | lib c887 + MEMCMP.OBJ; 45 | lib c887 + MEMCPY.OBJ; 46 | lib c887 + MEMICMP.OBJ; 47 | lib c887 + MEMMOVE.OBJ; 48 | lib c887 + MEMSET.OBJ; 49 | lib c887 + MODF.OBJ; 50 | lib c887 + MOVERLAY.OBJ; 51 | lib c887 + MSVER2.OBJ; 52 | lib c887 + MTANA.OBJ; 53 | lib c887 + MULDIV.OBJ; 54 | lib c887 + NEWLIB.OBJ; 55 | lib c887 + OVERLAY.OBJ; 56 | lib c887 + PEEKPOKE.OBJ; 57 | lib c887 + _PI_2.OBJ; 58 | lib c887 + _PI.OBJ; 59 | lib c887 + POW.OBJ; 60 | lib c887 + PRINTF.OBJ; 61 | lib c887 + PUTENV.OBJ; 62 | lib c887 + QSORT.OBJ; 63 | lib c887 + RAND.OBJ; 64 | lib c887 + SCANF.OBJ; 65 | lib c887 + SETJMP.OBJ; 66 | lib c887 + SIN.OBJ; 67 | lib c887 + SPRINTF.OBJ; 68 | lib c887 + STRCAT.OBJ; 69 | lib c887 + STRCHR.OBJ; 70 | lib c887 + STRCMP.OBJ; 71 | lib c887 + STRCPY.OBJ; 72 | lib c887 + STRDUP.OBJ; 73 | lib c887 + STRINGI.OBJ; 74 | lib c887 + STRLEN.OBJ; 75 | lib c887 + STRLWR.OBJ; 76 | lib c887 + STRRCHR.OBJ; 77 | lib c887 + STRREV.OBJ; 78 | lib c887 + STRSET.OBJ; 79 | lib c887 + STRSTR.OBJ; 80 | lib c887 + STRTOD.OBJ; 81 | lib c887 + STRTOK.OBJ; 82 | lib c887 + STRTOL.OBJ; 83 | lib c887 + STRUPR.OBJ; 84 | lib c887 + SYSTEM.OBJ; 85 | lib c887 + TAN.OBJ; 86 | lib c887 + UMULDIV.OBJ; 87 | lib c887 + UPPER.OBJ; 88 | del c887.bak 89 | -------------------------------------------------------------------------------- /src/LIB_31/C88LIB.BAT: -------------------------------------------------------------------------------- 1 | lib c88; 2 | del c88.lib 3 | lib c88; 4 | lib c88 + ABORT.OBJ; 5 | lib c88 + ACCESS.OBJ; 6 | lib c88 + _ADX.OBJ; 7 | lib c88 + _AINTRND.OBJ; 8 | lib c88 + ASIN.OBJ; 9 | lib c88 + ATAN2.OBJ; 10 | lib c88 + ATAN.OBJ; 11 | lib c88 + ATOL.OBJ; 12 | lib c88 + BSEARCH.OBJ; 13 | lib c88 + BUILTIN.OBJ; 14 | lib c88 + CHDIR.OBJ; 15 | lib c88 + CHSIZE.OBJ; 16 | lib c88 + CREAT3.OBJ; 17 | lib c88 + CTYPE.OBJ; 18 | lib c88 + DATES.OBJ; 19 | lib c88 + _DOPRINT.OBJ; 20 | lib c88 + _DOSCAN.OBJ; 21 | lib c88 + ECVT.OBJ; 22 | lib c88 + EXP10.OBJ; 23 | lib c88 + EXP.OBJ; 24 | lib c88 + FABS.OBJ; 25 | lib c88 + FINPUT.OBJ; 26 | lib c88 + FLOAT.OBJ; 27 | lib c88 + FLOOR.OBJ; 28 | lib c88 + FOUTPUT.OBJ; 29 | lib c88 + FPRINTF.OBJ; 30 | lib c88 + FREXP.OBJ; 31 | lib c88 + FSCANF.OBJ; 32 | lib c88 + FSTUFF.OBJ; 33 | lib c88 + GETENV.OBJ; 34 | lib c88 + _INTRND.OBJ; 35 | lib c88 + ISETUP.OBJ; 36 | lib c88 + ITOA.OBJ; 37 | lib c88 + LDEXP.OBJ; 38 | lib c88 + LMOVE.OBJ; 39 | lib c88 + LOG10.OBJ; 40 | lib c88 + LOG.OBJ; 41 | lib c88 + LTOA.OBJ; 42 | lib c88 + MALLOC.OBJ; 43 | lib c88 + MEMCHR.OBJ; 44 | lib c88 + MEMCMP.OBJ; 45 | lib c88 + MEMCPY.OBJ; 46 | lib c88 + MEMICMP.OBJ; 47 | lib c88 + MEMMOVE.OBJ; 48 | lib c88 + MEMSET.OBJ; 49 | lib c88 + MODF.OBJ; 50 | lib c88 + MOVERLAY.OBJ; 51 | lib c88 + MSVER2.OBJ; 52 | lib c88 + MTAN.OBJ; 53 | lib c88 + MULDIV.OBJ; 54 | lib c88 + NEWLIB.OBJ; 55 | lib c88 + OVERLAY.OBJ; 56 | lib c88 + PEEKPOKE.OBJ; 57 | lib c88 + _PI_2.OBJ; 58 | lib c88 + _PI.OBJ; 59 | lib c88 + POW.OBJ; 60 | lib c88 + PRINTF.OBJ; 61 | lib c88 + PUTENV.OBJ; 62 | lib c88 + QSORT.OBJ; 63 | lib c88 + RAND.OBJ; 64 | lib c88 + RERRNO.OBJ; 65 | lib c88 + SCANF.OBJ; 66 | lib c88 + SETJMP.OBJ; 67 | lib c88 + SIN.OBJ; 68 | lib c88 + SPRINTF.OBJ; 69 | lib c88 + SQRT.OBJ; 70 | lib c88 + STRCAT.OBJ; 71 | lib c88 + STRCHR.OBJ; 72 | lib c88 + STRCMP.OBJ; 73 | lib c88 + STRCPY.OBJ; 74 | lib c88 + STRDUP.OBJ; 75 | lib c88 + STRINGI.OBJ; 76 | lib c88 + STRLEN.OBJ; 77 | lib c88 + STRLWR.OBJ; 78 | lib c88 + STRRCHR.OBJ; 79 | lib c88 + STRREV.OBJ; 80 | lib c88 + STRSET.OBJ; 81 | lib c88 + STRSTR.OBJ; 82 | lib c88 + STRTOD.OBJ; 83 | lib c88 + STRTOK.OBJ; 84 | lib c88 + STRTOL.OBJ; 85 | lib c88 + STRUPR.OBJ; 86 | lib c88 + SYSTEM.OBJ; 87 | lib c88 + TAN.OBJ; 88 | lib c88 + UMULDIV.OBJ; 89 | lib c88 + UPPER.OBJ; 90 | del c88.bak 91 | -------------------------------------------------------------------------------- /src/LIB_31/CHSIZE.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* CHSIZE.C -- change the size of a file */ 17 | 18 | chsize(file,size) 19 | char *file; 20 | long size; { 21 | int fil,i,err; 22 | char zero[128]; 23 | long location; 24 | 25 | fil=_open("X",2); 26 | if (fil == -1) return -1; 27 | location=_lseek(fil,0l,2); 28 | if (location < size) { 29 | for (i=0; i < 128; i++) 30 | zero[i]=0; 31 | while (location < size) { 32 | if (size-location > 128) i=128; 33 | else i=size-location; 34 | err=_write(fil,zero,i); 35 | location+=i; 36 | } 37 | } 38 | else { 39 | _lseek(fil,location,0); 40 | err=_write(fil,0,0); 41 | } 42 | return err; 43 | } 44 | 45 | main() { 46 | int fil; 47 | 48 | fil=open("x"); 49 | chsize(fil,100l); 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/LIB_31/CONFIG.H: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | model equ LARGE_CASE 17 | if model 18 | pbase equ 6 ; first parameter offset 19 | _call equ lcall 20 | _ret equ lret 21 | else 22 | pbase equ 4 23 | _call equ call 24 | _ret equ ret 25 | endif 26 | -------------------------------------------------------------------------------- /src/LIB_31/CTYPE.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | 18 | char _ctype[] = { 0, 19 | 20 | /* 0 1 2 3 4 5 6 7 */ 21 | 22 | /* 0*/ _C, _C, _C, _C, _C, _C, _C, _C, 23 | /* 10*/ _C, _S|_C, _S|_C, _S|_C, _S|_C, _S|_C, _C, _C, 24 | /* 20*/ _C, _C, _C, _C, _C, _C, _C, _C, 25 | /* 30*/ _C, _C, _C, _C, _C, _C, _C, _C, 26 | /* 40*/ _S|_B, _P, _P, _P, _P, _P, _P, _P, 27 | /* 50*/ _P, _P, _P, _P, _P, _P, _P, _P, 28 | /* 60*/ _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, 29 | /* 70*/ _N|_X, _N|_X, _P, _P, _P, _P, _P, _P, 30 | /*100*/ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, 31 | /*110*/ _U, _U, _U, _U, _U, _U, _U, _U, 32 | /*120*/ _U, _U, _U, _U, _U, _U, _U, _U, 33 | /*130*/ _U, _U, _U, _P, _P, _P, _P, _P, 34 | /*140*/ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, 35 | /*150*/ _L, _L, _L, _L, _L, _L, _L, _L, 36 | /*160*/ _L, _L, _L, _L, _L, _L, _L, _L, 37 | /*170*/ _L, _L, _L, _P, _P, _P, _P, _C, 38 | /*200*/ 0, 0, 0, 0, 0, 0, 0, 0, 39 | 0, 0, 0, 0, 0, 0, 0, 0, 40 | 0, 0, 0, 0, 0, 0, 0, 0, 41 | 0, 0, 0, 0, 0, 0, 0, 0, 42 | 0, 0, 0, 0, 0, 0, 0, 0, 43 | 0, 0, 0, 0, 0, 0, 0, 0, 44 | 0, 0, 0, 0, 0, 0, 0, 0, 45 | 0, 0, 0, 0, 0, 0, 0, 0, 46 | 0, 0, 0, 0, 0, 0, 0, 0, 47 | 0, 0, 0, 0, 0, 0, 0, 0, 48 | 0, 0, 0, 0, 0, 0, 0, 0, 49 | 0, 0, 0, 0, 0, 0, 0, 0, 50 | 0, 0, 0, 0, 0, 0, 0, 0, 51 | 0, 0, 0, 0, 0, 0, 0, 0, 52 | 0, 0, 0, 0, 0, 0, 0, 0, 53 | 0, 0, 0, 0, 0, 0, 0, 0 54 | }; 55 | -------------------------------------------------------------------------------- /src/LIB_31/CTYPE.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #define _U 0x01 /* Upper case */ 17 | #define _L 0x02 /* Lower case */ 18 | #define _N 0x04 /* Numeral (digit) */ 19 | #define _S 0x08 /* Spacing character */ 20 | #define _P 0x10 /* Punctuation */ 21 | #define _C 0x20 /* Control character */ 22 | #define _B 0x40 /* Blank */ 23 | #define _X 0x80 /* heXadecimal digit */ 24 | 25 | extern char _ctype[]; 26 | 27 | #define isalpha(c) ((_ctype + 1)[c] & (_U | _L)) 28 | #define isupper(c) ((_ctype + 1)[c] & _U) 29 | #define islower(c) ((_ctype + 1)[c] & _L) 30 | #define isdigit(c) ((_ctype + 1)[c] & _N) 31 | #define isxdigit(c) ((_ctype + 1)[c] & _X) 32 | #define isalnum(c) ((_ctype + 1)[c] & (_U | _L | _N)) 33 | #define isspace(c) ((_ctype + 1)[c] & _S) 34 | #define ispunct(c) ((_ctype + 1)[c] & _P) 35 | #define isprint(c) ((_ctype + 1)[c] & (_P | _U | _L | _N | _B)) 36 | #define isgraph(c) ((_ctype + 1)[c] & (_P | _U | _L | _N)) 37 | #define iscntrl(c) ((_ctype + 1)[c] & _C) 38 | #define isascii(c) (!((c) & ~0177)) 39 | #define _toupper(c) ((c) - 'a' + 'A') 40 | #define _tolower(c) ((c) - 'A' + 'a') 41 | #define toascii(c) ((c) & 0177) 42 | -------------------------------------------------------------------------------- /src/LIB_31/ERRNO.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #define EFLOAT 30 17 | #define EOVERFLOW 31 18 | #define EDIV0 32 19 | #define EDOM 33 20 | #define ERANGE 34 21 | 22 | extern int errno; -------------------------------------------------------------------------------- /src/LIB_31/EXP.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * exp returns the exponential function of "x" 18 | */ 19 | 20 | #include "machar.h" 21 | #include "errno.h" 22 | 23 | extern double fabs(), ldexp(); 24 | extern int _intrnd(); 25 | 26 | static double oneOverLn2 = 0x3FF71547652B82FE; /* 1.4426950408889634074 */ 27 | static double ln2 = 0x3FE62E42FEFA39EE; /* 0.6931471805599453094172321 */ 28 | static double p0 = 0x3FCFFFFFFFFFFFFF; /* 0.249999999999999993 */ 29 | static double p1 = 0x3F7C70E46FB3F6DF; /* 0.694360001511792852e-2 */ 30 | static double p2 = 0x3EF152A46F58DC1D; /* 0.165203300268279130e-4 */ 31 | static double q0 = 0x3FE0000000000000; /* 0.5 */ 32 | static double q1 = 0x3FAC718E714251B2; /* 0.555538666969001188e-1 */ 33 | static double q2 = 0x3F403F996FDE3809; /* 0.495862884905441294e-3 */ 34 | static double dot5 = 0x3FE0000000000000; /* 0.5 */ 35 | 36 | double exp(x) 37 | double x; 38 | { 39 | int n; 40 | double xn, g, z, pz, qz; 41 | 42 | if(x > BIGX || x < SMALLX) 43 | { 44 | errno = ERANGE; 45 | return -XMAX; 46 | } 47 | if(fabs(x) < EPS) 48 | return 1.0; 49 | 50 | xn = n = _intrnd(x * oneOverLn2); 51 | g = x - xn * ln2; 52 | z = g * g; 53 | pz = ((p2 * z + p1) * z + p0) * g; 54 | qz = (q2 * z + q1) * z + q0; 55 | return ldexp((dot5 + pz / (qz - pz)), n+1); 56 | } 57 | -------------------------------------------------------------------------------- /src/LIB_31/EXP10.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * exp10(x) 10 to the x power 18 | * 19 | * Abramowitz & Stegun 4.2.4 20 | * 10**x = exp( x * log(10) ) 21 | */ 22 | 23 | double exp(); 24 | 25 | double exp10(x) 26 | double x; 27 | { 28 | return( exp( x * 2.302585092994 ) ); 29 | } 30 | -------------------------------------------------------------------------------- /src/LIB_31/EXPA.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; 8087 version of double exp(x) 18 | 19 | dseg 20 | treal db 0,0,0,0,0,0,0,0,0,0 21 | cseg 22 | 23 | public exp_ 24 | 25 | exp_: 26 | push bp ; standard 27 | mov bp,sp ; prolog 28 | 29 | public _testinit 30 | _call _testinit 31 | FLDL2E ; log2(e) 32 | FLD qword [bp+pbase] ; x 33 | FMULP ST(1),ST ; x * log2(e) 34 | FWAIT 35 | 36 | FSTP tbyte treal ; store the number 37 | FWAIT 38 | mov ax,word treal+8 ; get the exponent 39 | mov cx,0 ; assume less than .5 40 | mov bl,ah ; remember if negative 41 | and ah,7fh ; remove the sign if any 42 | mov dx,3ffdh ; exponent if number from .25 to .5 43 | cmp ax,dx ; is number < .5 ? 44 | jbe numok 45 | sub ax,dx ; power of 2 too big 46 | mov cx,ax 47 | mov ax,dx 48 | numok: mov word treal+8,ax ; reduce the number 49 | FLD tbyte treal ; re-load patched number 50 | FWAIT 51 | 52 | F2XM1 ; 2**(x * log2(e))-1 53 | FWAIT 54 | 55 | FLD1 ; 1.0 56 | FADDP ST(1),ST ; e**x = 2**(x * log2(e)) 57 | FWAIT 58 | 59 | jcxz adjusted ; must double number cx times 60 | dbl: FMUL ST,ST(0) ; double the number 61 | FWAIT 62 | loop dbl 63 | adjusted: 64 | 65 | test bl,80h ; was sign on originally ? 66 | jz alldone 67 | FLD1 ; take reciprocal 68 | FWAIT 69 | FDIVR 70 | FWAIT 71 | alldone: 72 | pop bp ; standard 73 | _ret ; epilog 74 | -------------------------------------------------------------------------------- /src/LIB_31/FABS.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; double fabs(x) 18 | ; double x 19 | ; 20 | ; returns x with sign=0 21 | 22 | cseg 23 | 24 | public fabs_,_floadd 25 | 26 | fabs_: 27 | push bp ; standard 28 | mov bp,sp ; prolog 29 | 30 | and byte [bp+pbase+7],7FH ; sign=0 31 | lea si,[bp+pbase] ; x 32 | if model 33 | push ss 34 | pop es 35 | endif 36 | _call _floadd ; put in fpac 37 | 38 | pop bp ; standard 39 | _ret ; epilog 40 | 41 | 42 | ; abs(a); 43 | 44 | ; returns absolute value of a 45 | 46 | public abs_ 47 | 48 | abs_: pop dx 49 | if model 50 | pop bx 51 | endif 52 | pop ax 53 | push ax 54 | cmp ax,0 ;see if equal to or over zero 55 | jge absret 56 | neg ax 57 | absret: 58 | if model 59 | push bx 60 | push dx 61 | _ret 62 | else 63 | jmp dx 64 | endif 65 | -------------------------------------------------------------------------------- /src/LIB_31/FLOAT.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #define FLT_RADIX 2 17 | 18 | #define FLT_MANT_DIG 24 19 | #define FLT_EPSILON 1.19209290E-07 20 | #define FLT_DIG 6 21 | #define FLT_MIN_EXP -125 22 | #define FLT_MIN 1.17549435E-38 23 | #define FLT_MIN_10_EXP -37 24 | #define FLT_MAX_EXP 128 25 | #define FLT_MAX 3.40282347E+38 26 | #define FLT_MAX_10_EXP 38 27 | 28 | #define DBL_MANT_DIG 53 29 | #define DBL_EPSILON 2.2204460492503131E-16 30 | #define DBL_DIG 15 31 | #define DBL_MIN_EXP -1021 32 | #define DBL_MIN 2.225073858507201E-308 33 | #define DBL_MIN_10_EXP -307 34 | #define DBL_MAX_EXP +1024 35 | #define DBL_MAX 1.797693134862316E+308 36 | #define DBL_MAX_10_EXP +308 37 | -------------------------------------------------------------------------------- /src/LIB_31/FLOOR7.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; FLOOR7.A -- Hardware floating point floor function. 18 | 19 | dseg 20 | cw dw 0 ;control word 21 | cseg 22 | public _floadd 23 | public floor_,ceil_ 24 | ceil_: mov cx,100000000000b ;set round to up 25 | jmp floor_cont 26 | 27 | floor_: mov cx,010000000000b ;set round to down 28 | floor_cont: 29 | 30 | push bp 31 | mov bp,sp 32 | lea si,[bp+pbase] ;argument is here 33 | if model 34 | push ss 35 | pop es 36 | endif 37 | _call _floadd 38 | fstcw cw 39 | or cw,cx ;set rounding mode 40 | fldcw cw 41 | frndint 42 | wait 43 | and cw,1111001111111111b ;back to round to even 44 | fldcw cw 45 | wait 46 | pop bp 47 | _ret 48 | -------------------------------------------------------------------------------- /src/LIB_31/FPRINTF.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | fprintf: 18 | Like printf, except that the first argument is 19 | a pointer to a stream, and the text 20 | is written to the file described by the buffer: 21 | ERROR (-1) returned on error. 22 | 23 | usage: 24 | fprintf(iobuf, format, arg1, arg2, ...); 25 | */ 26 | 27 | int fprintf(int * file, char * format) { 28 | int fputc(); 29 | 30 | return _doprint(fputc, file, &format); 31 | } 32 | -------------------------------------------------------------------------------- /src/LIB_31/FREXP.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * frexp returns the mantissa of a double "value" as a double 18 | * quantity, "x", of magnitude less than 1.0 and stores an integer 19 | * "n" (such that "value" = "x" * 2 ** "n") indirectly through "eptr" 20 | */ 21 | 22 | double frexp(value, eptr) 23 | double value; 24 | int *eptr; 25 | { 26 | int *ip; 27 | 28 | if(value == 0.0) 29 | *eptr = 0; 30 | else 31 | { 32 | ip = &value; 33 | *eptr = ((ip[3] >> 4) & 0x7FF) - 0x3FE; 34 | ip[3] = (ip[3] & 0x800F) + 0x3FE0; 35 | } 36 | return value; 37 | } 38 | -------------------------------------------------------------------------------- /src/LIB_31/FSCANF.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* FSCANF.C -- FORMATTED FILE INPUT */ 17 | 18 | /* 19 | fscanf: 20 | Like scanf, except that the first argument is 21 | a pointer to a buffered input file buffer, and 22 | the text is taken from the file instead of from 23 | the console. 24 | Usage: 25 | fscanf(iobuf, format, ptr1, ptr2, ...); 26 | Returns number of items matched (zero on EOF.) 27 | Note that any unprocessed text is lost forever. Each 28 | time scanf is called, a new line of input is gotten 29 | from the file, and any information left over from 30 | the last call is wiped out. Thus, the text in the 31 | file must be arranged such that a single call to 32 | fscanf will always get all the required data on a 33 | line. This is not compatible with the way UNIX does 34 | things, but it eliminates the need for separate 35 | scanning functions for files, strings, and console 36 | input; it is more economical to let both "fscanf" and 37 | "scanf" use "sscanf". If you want to be able to scan 38 | a partial line with fscanf and have the rest still be 39 | there on the next fscanf call, you'll have to rewrite 40 | fscanf to be self contained (not use sscanf) and use 41 | "ungetc" to push back characters. 42 | 43 | Returns number of items succesfully matched. 44 | */ 45 | 46 | char *fgetc(); 47 | 48 | int fscanf(int *file, char *format) { return _doscan(fgetc, file, 1, &format); } 49 | -------------------------------------------------------------------------------- /src/LIB_31/GETENV.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* getenv.C */ 17 | 18 | /* 19 | This file contains the routine for searching the environment 20 | area for a given string. 21 | 22 | Interface: 23 | 24 | getenv(search_str, buffer) 25 | 26 | where search_str is the actual string being searched for, 27 | buffer is the location to store the string if found, 28 | NULL is returned if the environment variable isn't found, 29 | otherwise the address of the buffer is returned. 30 | */ 31 | 32 | extern unsigned environ; /* c88 variable with the environment segment */ 33 | 34 | char * getenv(char *search_str, char buffer[]) { 35 | int envoff,searchoff; 36 | char ch, *beg=buffer; 37 | 38 | envoff=0; 39 | buffer[0]=0; 40 | while (ch=_peek(envoff++,environ)) { 41 | searchoff=0; 42 | while (ch == search_str[searchoff++]) ch=_peek(envoff++,environ); 43 | if (ch == '=' && search_str[searchoff-1] == 0) { 44 | do { 45 | *buffer++=ch=_peek(envoff++,environ); 46 | } 47 | while (ch); 48 | return beg; 49 | } 50 | while (ch=_peek(envoff++,environ)); 51 | } 52 | return (char *)0; 53 | } 54 | -------------------------------------------------------------------------------- /src/LIB_31/ITOA.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | char *itoa(v, s, r) /* convert n to characters in s using base b */ 17 | int v; 18 | char *s; 19 | int r; 20 | { 21 | char c; 22 | char *b=s, *p=s; 23 | int i, sign=0; 24 | 25 | if(r < 2 || r > 36) { 26 | *s=0; 27 | return s; 28 | } 29 | if(r==10 && v < 0) { 30 | sign++; 31 | v = -v; 32 | } 33 | do { /* generate digits in reverse order */ 34 | i = (unsigned)v % r; /* get next digit */ 35 | *p++ = (i >= 10) ? i + ('A' - 10) : i + '0'; 36 | } 37 | while (((unsigned)v /= r) > 0); /* delete it */ 38 | if(sign) 39 | *p++='-'; 40 | *p = '\0'; 41 | while (p > s) { /* reverse string */ 42 | c = *s; 43 | *s++ = *--p; 44 | *p = c; 45 | } 46 | return b; 47 | } 48 | -------------------------------------------------------------------------------- /src/LIB_31/LDEXP.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | #include 18 | /* Largest signed long int power of 2 */ 19 | #define MAXSHIFT 30 20 | 21 | extern double frexp(); 22 | 23 | double 24 | ldexp(value, exp) 25 | register double value; 26 | register int exp; 27 | { 28 | int old_exp; 29 | 30 | if (exp == 0 || value == 0.0) /* nothing to do for zero */ 31 | return (value); 32 | frexp(value, &old_exp); 33 | if (exp > 0) { 34 | if (exp + old_exp > DBL_MAX_EXP) { /* overflow */ 35 | errno = ERANGE; 36 | return (value < 0 ? -DBL_MAX : DBL_MAX); 37 | } 38 | for ( ; exp > MAXSHIFT; exp -= MAXSHIFT) 39 | value *= (1L << MAXSHIFT); 40 | return (value * (1L << exp)); 41 | } 42 | if (exp + old_exp < DBL_MIN_EXP) { /* underflow */ 43 | errno = ERANGE; 44 | return (0.0); 45 | } 46 | for ( ; exp < -MAXSHIFT; exp += MAXSHIFT) 47 | value *= 1.0/(1L << MAXSHIFT); /* mult faster than div */ 48 | return (value / (1L << -exp)); 49 | } 50 | -------------------------------------------------------------------------------- /src/LIB_31/LMOVE.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; lmove.a -- long move routine 18 | 19 | ; _lmove(count, from_offset, from_segment, to_offset, to_segment); 20 | 21 | cseg 22 | public _lmove_ 23 | 24 | _lmove_: push bp 25 | mov bp,sp 26 | mov si,[bp+pbase+2] ;from offset 27 | mov di,[bp+pbase+6] ;to offset 28 | mov es,[bp+pbase+8] ;destination segment 29 | push ds ;save ds 30 | mov ds,[bp+pbase+4] ;source segment 31 | cld 32 | mov ax,ds 33 | mov cl,4 34 | mov bx,si 35 | shr bx,cl 36 | add ax,bx 37 | jc err 38 | mov ds,ax 39 | and si,15 40 | mov dx,es 41 | mov bx,di 42 | shr bx,cl 43 | add dx,bx 44 | jc err 45 | mov es,dx 46 | and di,15 47 | mov cx,[bp+pbase] ;count 48 | mov bx,di 49 | add bx,cx ; test for room 50 | jc err 51 | cmp ax,dx ;moving up ? 52 | ja domov 53 | jb movdn 54 | cmp si,di 55 | jae domov 56 | movdn: 57 | add si,cx ;change to move down 58 | jc err 59 | sub si,2 60 | mov di,bx 61 | sub di,2 62 | std 63 | shr cx,1 ;do a word move 64 | rep movsw ;move the bytes 65 | jnc end_moved 66 | inc si 67 | inc di 68 | movsb 69 | end_moved: 70 | cld 71 | xor ax,ax 72 | pop ds ;restore ds 73 | pop bp 74 | _ret 75 | domov: 76 | shr cx,1 ;do a word move 77 | rep movsw ;move the bytes 78 | jnc end_move 79 | movsb 80 | end_move: 81 | xor ax,ax 82 | pop ds ;restore ds 83 | pop bp 84 | _ret 85 | err: 86 | mov ax,1 87 | pop ds 88 | pop bp 89 | _ret 90 | -------------------------------------------------------------------------------- /src/LIB_31/LOG.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * log returns the natural logarithm of "x". 18 | */ 19 | 20 | #include "machar.h" 21 | #include "errno.h" 22 | 23 | extern double frexp(); 24 | 25 | static double a0 = 0xC05007FF12B3B59A; /* -0.64124943423745581147e2 */ 26 | static double a1 = 0x4030624A2016AFEC; /* 0.16383943563021534222e2 */ 27 | static double a2 = 0xBFE94415B356BD29; /* -0.78956112887491257267 */ 28 | static double b0 = 0xC0880BFE9C0D9079; /* -0.76949932108494879777e3 */ 29 | static double b1 = 0x40738083FA15267F; /* 0.31203222091924532844e3 */ 30 | static double b2 = 0xC041D5804B67CE0E; /* -0.35667977739034646171e2 */ 31 | static double c0 = 0x3FE6A09E667F3BCC; /* 0.70710678118654752440 */ 32 | static double c1 = 0x3FE6300000000000; /* 355.0 / 512.0 */ 33 | static double c2 = 0xBF2BD0105C610CA7; /* -2.121944400546905827679e-4 */ 34 | static double dot5 =0x3FE0000000000000; /* 0.5 */ 35 | 36 | double log(x) 37 | double x; 38 | { 39 | int n; 40 | double f, znum, zden, z, w, aw, bw, rz; 41 | 42 | if(x <= 0.0) 43 | { 44 | errno = EDOM; 45 | return -XMAX; 46 | } 47 | 48 | f = frexp(x, &n); 49 | znum = f - dot5; 50 | if(f > c0) 51 | { 52 | znum -= dot5; 53 | zden = f * dot5 + dot5; 54 | } 55 | else 56 | { 57 | n--; 58 | zden = znum * dot5 + dot5; 59 | } 60 | z = znum / zden; 61 | w = z * z; 62 | bw = ((w + b2) * w + b1) * w + b0; 63 | aw = (a2 * w + a1) * w + a0; 64 | rz = z + z * (w * aw / bw); 65 | return (c2 * n + rz) + c1 * n; 66 | } 67 | -------------------------------------------------------------------------------- /src/LIB_31/LOG10.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * log10 returns the base 10 logarithm. 18 | */ 19 | 20 | extern double log(); 21 | 22 | static double c3 = 0x3FDBCB7B1526E50E; /* 0.43429448190325182765 */ 23 | 24 | double log10(x) 25 | double x; 26 | { 27 | return log(x) * c3; 28 | } 29 | -------------------------------------------------------------------------------- /src/LIB_31/LOGA.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; 8087 version of double log(x) 18 | 19 | cseg 20 | 21 | public log_ 22 | 23 | log_: 24 | push bp ; standard 25 | mov bp,sp ; prolog 26 | 27 | public _testinit 28 | _call _testinit 29 | FLDLN2 ; log(2) 30 | FLD qword [bp+pbase] ; x 31 | 32 | FYL2X ; log(x) = log(2) * log2(x) 33 | FWAIT 34 | 35 | pop bp ; standard 36 | _ret ; epilog 37 | -------------------------------------------------------------------------------- /src/LIB_31/LTOA.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | CSEG 17 | PUBLIC ltoa_ 18 | 19 | ltoa_: PUSH BP 20 | MOV BP,SP 21 | SUB SP,10 22 | MOV AX,WORD [BP+8] 23 | MOV WORD [BP-4],AX 24 | MOV WORD [BP-6],AX 25 | MOV WORD [BP-10],0 26 | CMP WORD [BP+10],2 27 | JL _L2 28 | CMP WORD [BP+10],36 29 | JLE _L1 30 | _L2: 31 | MOV SI,WORD [BP+8] 32 | MOV AX,SI 33 | MOV BYTE [SI],0 34 | MOV SP,BP 35 | POP BP 36 | RET 37 | _L1: 38 | CMP WORD [BP+10],10 39 | JNZ _L3 40 | TEST BYTE [BP+7],80H 41 | JZ _L3 42 | INC WORD [BP-10] 43 | NOT WORD [BP+6] 44 | NEG WORD [BP+4] 45 | SBB WORD [BP+6],-1 46 | _L3: 47 | MOV AX,WORD [BP+8] 48 | MOV WORD [BP-6],AX 49 | _L4: 50 | MOV CX,WORD [BP+10] 51 | XOR BX,BX 52 | MOV DX,WORD [BP+6] 53 | MOV AX,WORD [BP+4] 54 | PUBLIC _UMOD4 55 | CALL _UMOD4 56 | MOV WORD [BP-8],AX 57 | CMP WORD [BP-8],10 58 | JL _L7 59 | ADD AX,55 60 | JMP _L8 61 | _L7: 62 | ADD AX,48 63 | _L8: 64 | MOV SI,WORD [BP-6] 65 | INC WORD [BP-6] 66 | MOV BYTE [SI],AL 67 | _L5: 68 | MOV CX,WORD [BP+10] 69 | XOR BX,BX 70 | MOV DX,WORD [BP+6] 71 | MOV AX,WORD [BP+4] 72 | PUBLIC _UDIV4 73 | CALL _UDIV4 74 | MOV WORD [BP+4],AX 75 | MOV WORD [BP+6],DX 76 | OR AX,DX 77 | JNZ _L4 78 | _L6: 79 | MOV SI,WORD [BP-6] 80 | CMP WORD [BP-10],0 81 | JZ _L9 82 | MOV BYTE [SI],45 83 | INC SI 84 | INC WORD [BP-6] 85 | _L9: 86 | MOV BYTE [SI],0 87 | _L10: 88 | MOV AX,WORD [BP-6] 89 | CMP AX,WORD [BP+8] 90 | JBE _L11 91 | MOV SI,WORD [BP+8] 92 | MOV AL,BYTE [SI] 93 | MOV BYTE [BP-1],AL 94 | DEC WORD [BP-6] 95 | MOV SI,WORD [BP-6] 96 | MOV DI,WORD [BP+8] 97 | INC WORD [BP+8] 98 | MOV AL,BYTE [SI] 99 | MOV BYTE [DI],AL 100 | MOV SI,WORD [BP-6] 101 | MOV AL,BYTE [BP-1] 102 | MOV BYTE [SI],AL 103 | JMP _L10 104 | _L11: 105 | MOV AX,WORD [BP-4] 106 | MOV SP,BP 107 | POP BP 108 | RET 109 | END 110 | -------------------------------------------------------------------------------- /src/LIB_31/MACHAR.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #define IBETA 2 17 | #define IT 52 18 | #define IRND 0 19 | #define NGRD 1 20 | #define MACHEP -51 21 | #define NEGEPS -51 22 | #define IEXP 11 23 | #define MINEXP -1022 24 | #define MAXEXP 1026 25 | #define EPS 4.4408920985006E-16 26 | #define EPSNEG 4.4408920985006E-16 27 | #define XMIN 2.2250738585071E-300 28 | #define XMAX 3.5953862697245E+300 29 | #define SMALLX -6.899757E2 30 | #define BIGX 6.920551E2 31 | -------------------------------------------------------------------------------- /src/LIB_31/MAKBLIB7.LST: -------------------------------------------------------------------------------- 1 | isetup 2 | dates 3 | msver2 4 | creat3 5 | peekpoke 6 | upper 7 | strlen 8 | memcpy 9 | memchr 10 | builtin 11 | memcmp 12 | _pi 13 | stringi 14 | _pi_2 15 | strrchr 16 | _adx 17 | printf 18 | fprintf 19 | fabs 20 | strchr 21 | memset 22 | strupr 23 | strlwr 24 | lmove 25 | strcpy 26 | strset 27 | sprintf 28 | strcat 29 | strcmp 30 | memicmp 31 | access 32 | strdup 33 | memmove 34 | log10 35 | exp10 36 | strrev 37 | setjmp 38 | atol 39 | bsearch 40 | frexp 41 | system 42 | umuldiv 43 | strtok 44 | chdir 45 | itoa 46 | ctype 47 | strstr 48 | ltoa 49 | modf 50 | getenv 51 | muldiv 52 | newlib 53 | malloc 54 | chsize 55 | mtana 56 | floor7 57 | qsort 58 | rand 59 | atan2 60 | foutput 61 | strtod 62 | float7 63 | putenv 64 | atan7 65 | abort 66 | strtol 67 | asin 68 | finput 69 | _doprint 70 | fstuff 71 | fscanf 72 | sin 73 | pow 74 | tan 75 | _aintrnd 76 | scanf 77 | loga 78 | expa 79 | _intrnd 80 | ldexp 81 | ecvt 82 | _doscan 83 | -------------------------------------------------------------------------------- /src/LIB_31/MAKEBLIB.LST: -------------------------------------------------------------------------------- 1 | isetup 2 | dates 3 | msver2 4 | creat3 5 | peekpoke 6 | upper 7 | strlen 8 | memcpy 9 | memchr 10 | builtin 11 | memcmp 12 | _pi 13 | stringi 14 | _pi_2 15 | strrchr 16 | _adx 17 | printf 18 | fprintf 19 | fabs 20 | strchr 21 | memset 22 | strupr 23 | strlwr 24 | lmove 25 | strcpy 26 | strset 27 | sprintf 28 | strcat 29 | strcmp 30 | memicmp 31 | access 32 | strdup 33 | memmove 34 | log10 35 | exp10 36 | strrev 37 | setjmp 38 | atol 39 | bsearch 40 | frexp 41 | system 42 | umuldiv 43 | strtok 44 | chdir 45 | itoa 46 | ctype 47 | strstr 48 | ltoa 49 | modf 50 | getenv 51 | muldiv 52 | newlib 53 | malloc 54 | chsize 55 | rerrno 56 | mtan 57 | floor 58 | qsort 59 | rand 60 | atan2 61 | foutput 62 | strtod 63 | float 64 | putenv 65 | atan 66 | abort 67 | strtol 68 | asin 69 | finput 70 | _doprint 71 | fstuff 72 | fscanf 73 | sin 74 | pow 75 | tan 76 | _aintrnd 77 | scanf 78 | log 79 | exp 80 | sqrt 81 | _intrnd 82 | ldexp 83 | ecvt 84 | _doscan 85 | -------------------------------------------------------------------------------- /src/LIB_31/MAKELIB.LST: -------------------------------------------------------------------------------- 1 | isetup 2 | dates 3 | msver2 4 | creat3 5 | peekpoke 6 | upper 7 | strlen 8 | memcpy 9 | memchr 10 | builtin 11 | memcmp 12 | _pi 13 | stringi 14 | _pi_2 15 | strrchr 16 | _adx 17 | printf 18 | fprintf 19 | fabs 20 | strchr 21 | memset 22 | strupr 23 | strlwr 24 | lmove 25 | strcpy 26 | strset 27 | sprintf 28 | strcat 29 | strcmp 30 | memicmp 31 | access 32 | strdup 33 | memmove 34 | log10 35 | exp10 36 | strrev 37 | setjmp 38 | atol 39 | bsearch 40 | frexp 41 | system 42 | umuldiv 43 | strtok 44 | chdir 45 | itoa 46 | ctype 47 | strstr 48 | ltoa 49 | modf 50 | getenv 51 | muldiv 52 | newlib 53 | malloc 54 | chsize 55 | rerrno 56 | mtan 57 | floor 58 | qsort 59 | moverlay 60 | rand 61 | atan2 62 | foutput 63 | strtod 64 | float 65 | putenv 66 | atan 67 | abort 68 | strtol 69 | overlay 70 | asin 71 | finput 72 | _doprint 73 | fstuff 74 | fscanf 75 | sin 76 | pow 77 | tan 78 | _aintrnd 79 | scanf 80 | log 81 | exp 82 | sqrt 83 | _intrnd 84 | ldexp 85 | ecvt 86 | _doscan 87 | -------------------------------------------------------------------------------- /src/LIB_31/MAKELIB7.LST: -------------------------------------------------------------------------------- 1 | isetup 2 | dates 3 | msver2 4 | creat3 5 | peekpoke 6 | upper 7 | strlen 8 | memcpy 9 | memchr 10 | builtin 11 | memcmp 12 | _pi 13 | stringi 14 | _pi_2 15 | strrchr 16 | _adx 17 | printf 18 | fprintf 19 | fabs 20 | strchr 21 | memset 22 | strupr 23 | strlwr 24 | lmove 25 | strcpy 26 | strset 27 | sprintf 28 | strcat 29 | strcmp 30 | memicmp 31 | access 32 | strdup 33 | memmove 34 | log10 35 | exp10 36 | strrev 37 | setjmp 38 | atol 39 | bsearch 40 | frexp 41 | system 42 | umuldiv 43 | strtok 44 | chdir 45 | itoa 46 | ctype 47 | strstr 48 | ltoa 49 | modf 50 | getenv 51 | muldiv 52 | newlib 53 | malloc 54 | chsize 55 | mtana 56 | floor7 57 | qsort 58 | moverlay 59 | rand 60 | atan2 61 | foutput 62 | strtod 63 | float7 64 | putenv 65 | atan7 66 | abort 67 | strtol 68 | overlay 69 | asin 70 | finput 71 | _doprint 72 | fstuff 73 | fscanf 74 | sin 75 | pow 76 | tan 77 | _aintrnd 78 | scanf 79 | loga 80 | expa 81 | _intrnd 82 | ldexp 83 | ecvt 84 | _doscan 85 | -------------------------------------------------------------------------------- /src/LIB_31/MATH.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | struct exception { 17 | int type; 18 | char *name; 19 | double arg1; 20 | double arg2; 21 | double retval; 22 | } ; 23 | 24 | struct complex { 25 | double x,y; 26 | } ; 27 | 28 | #define DOMAIN 1 29 | #define SING 2 30 | #define OVERFLOW 3 31 | #define UNDERFLOW 4 32 | #define TLOSS 5 33 | #define PLOSS 6 34 | 35 | #define EDOM 33 36 | #define ERANGE 34 37 | 38 | extern int errno; 39 | 40 | #define HUGE_VAL 1.797693134862316E+308 41 | 42 | double acos(double); 43 | double asin(double); 44 | double atan(double); 45 | double atan2(double, double); 46 | double ceil(double); 47 | double cos(double); 48 | double exp(double); 49 | double fabs(double); 50 | double floor(double); 51 | double frexp(double, int *); 52 | double ldexp(double, double); 53 | double log(double); 54 | double log10(double); 55 | double modf(double, double *); 56 | double pow(double, double); 57 | double sin(double); 58 | double sqrt(double); 59 | double tan(double); 60 | 61 | #ifndef atof 62 | double strtod(const char *, char **); 63 | #define atof(c) strtod((c), (char**)0); 64 | #endif 65 | 66 | double _pi(void); 67 | double _pi_2(void); 68 | -------------------------------------------------------------------------------- /src/LIB_31/MEMCHR.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | ; void *memchr(const void *s, int c, size_t n); 17 | 18 | cseg 19 | public memchr_ 20 | memchr_:push bp 21 | mov bp,sp 22 | 23 | if LARGE_CASE 24 | 25 | les di,[bp+6] 26 | mov al,[bp+10] 27 | mov cx,[bp+12] 28 | 29 | else 30 | 31 | mov ax,ds 32 | mov es,ax 33 | mov di,[bp+4] 34 | mov al,[bp+6] 35 | mov cx,[bp+8] 36 | 37 | endif 38 | 39 | jcxz notfnd 40 | cld 41 | repne scasb 42 | jne notfnd 43 | 44 | if LARGE_CASE 45 | 46 | mov si,di 47 | dec si 48 | pop bp 49 | lret 50 | notfnd: xor si,si 51 | mov es,si 52 | pop bp 53 | lret 54 | 55 | else 56 | 57 | mov ax,di 58 | dec ax 59 | pop bp 60 | ret 61 | notfnd: xor ax,ax 62 | pop bp 63 | ret 64 | 65 | endif 66 | -------------------------------------------------------------------------------- /src/LIB_31/MEMCMP.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | ; void *memcmp(const void *s1, const void *s2, size_t n); 17 | 18 | cseg 19 | public memcmp_ 20 | memcmp_:push bp 21 | mov bp,sp 22 | 23 | if LARGE_CASE 24 | 25 | push ds 26 | lds si,[bp+6] 27 | les di,[bp+10] 28 | mov cx,[bp+14] 29 | 30 | else 31 | 32 | mov ax,ds 33 | mov es,ax 34 | mov si,[bp+4] 35 | mov di,[bp+6] 36 | mov cx,[bp+8] 37 | 38 | endif 39 | 40 | xor ax,ax 41 | jcxz eq 42 | cld 43 | rep cmpsb 44 | je eq 45 | ja gt 46 | 47 | dec ax 48 | 49 | if LARGE_CASE 50 | 51 | pop ds 52 | pop bp 53 | lret 54 | gt: inc ax 55 | eq: pop ds 56 | pop bp 57 | lret 58 | 59 | else 60 | 61 | pop bp 62 | ret 63 | gt: inc ax 64 | eq: pop bp 65 | ret 66 | 67 | endif 68 | -------------------------------------------------------------------------------- /src/LIB_31/MEMCPY.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | ; void *memcpy(void *s1, const void *s2, size_t n); 17 | 18 | cseg 19 | public memcpy_ 20 | memcpy_:push bp 21 | mov bp,sp 22 | 23 | if LARGE_CASE 24 | 25 | push ds 26 | les di,[bp+6] 27 | lds si,[bp+10] 28 | mov cx,[bp+14] 29 | 30 | else 31 | 32 | mov ax,ds 33 | mov es,ax 34 | mov di,[bp+4] 35 | mov si,[bp+6] 36 | mov cx,[bp+8] 37 | 38 | endif 39 | 40 | jcxz done 41 | cld 42 | rep movsb 43 | 44 | if LARGE_CASE 45 | 46 | done: pop ds 47 | les si,[bp+6] 48 | pop bp 49 | lret 50 | 51 | else 52 | 53 | done: mov ax,[bp+4] 54 | pop bp 55 | ret 56 | 57 | endif 58 | -------------------------------------------------------------------------------- /src/LIB_31/MEMICMP.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | ; void *memicmp(const void *s1, const void *s2, size_t n); 17 | 18 | cseg 19 | public memicmp_ 20 | memicmp_: 21 | push bp 22 | mov bp,sp 23 | 24 | if LARGE_CASE 25 | 26 | push ds 27 | lds si,[bp+6] 28 | les di,[bp+10] 29 | mov cx,[bp+14] 30 | 31 | else 32 | 33 | mov ax,ds 34 | mov es,ax 35 | mov si,[bp+4] 36 | mov di,[bp+6] 37 | mov cx,[bp+8] 38 | 39 | endif 40 | 41 | xor dx,dx 42 | jcxz eq 43 | cld 44 | dec di 45 | c: lodsb 46 | cmp al, 'a' 47 | jb l 48 | cmp al, 'z' 49 | ja l 50 | and al, 0DFH 51 | l: inc di 52 | mov ah,es:[di] 53 | cmp ah, 'a' 54 | jb r 55 | cmp ah, 'z' 56 | ja r 57 | and ah, 0DFH 58 | r: cmp al,ah 59 | ja gt 60 | jb lt 61 | loop c 62 | 63 | eq: mov ax,dx 64 | 65 | if LARGE_CASE 66 | 67 | pop ds 68 | pop bp 69 | lret 70 | 71 | else 72 | 73 | pop bp 74 | ret 75 | 76 | endif 77 | 78 | gt: inc dx 79 | jmp eq 80 | lt: dec dx 81 | jmp eq 82 | -------------------------------------------------------------------------------- /src/LIB_31/MEMMOVE.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; move.a -- move some data 18 | 19 | ; _move(num,from,to); 20 | 21 | cseg 22 | public _MOVE_ 23 | _MOVE_: push bp 24 | mov bp,sp 25 | if model 26 | push ds 27 | endif 28 | mov cx,[bp+pbase] ;number of bytes 29 | mov si,[bp+pbase+2] ;source 30 | if model 31 | mov ds,[bp+pbase+4] ;source segment 32 | les di,[bp+pbase+6] ;destination 33 | else 34 | mov di,[bp+pbase+4] ;destination 35 | mov ax,ds ;set es=ds 36 | mov es,ax 37 | endif 38 | 39 | jmp moveit 40 | 41 | ; void *memmove(void * dst, void * src, size_t n) 42 | 43 | public memmove_ 44 | memmove_: 45 | 46 | push bp 47 | mov bp,sp 48 | 49 | if model 50 | 51 | push ds 52 | les di,[bp+pbase] ;destination 53 | lds si,[bp+pbase+4] ;source 54 | mov cx,[bp+pbase+8] ;number of bytes 55 | 56 | else 57 | 58 | mov di,[bp+pbase] ;destination 59 | mov ax,ds ;set es=ds 60 | mov es,ax 61 | mov si,[bp+pbase+2] ;source 62 | mov cx,[bp+pbase+4] ;number of bytes 63 | 64 | endif 65 | 66 | moveit: 67 | 68 | cld 69 | cmp si,di ;moving up ? 70 | jae domov 71 | add si,cx ;change to move down 72 | sub si,2 73 | add di,cx 74 | sub di,2 75 | std 76 | shr cx,1 ;do a word move 77 | rep movsw 78 | jnc move_end 79 | inc si 80 | inc di 81 | movsb ;move the odd byte 82 | jmp move_end 83 | 84 | domov: 85 | shr cx,1 ;do a word move 86 | rep movsw 87 | jnc move_end 88 | movsb ;move the odd byte 89 | move_end: 90 | cld 91 | if model 92 | pop ds 93 | les si,[bp+pbase] ;destination 94 | else 95 | mov ax,[bp+pbase] ;destination 96 | endif 97 | pop bp 98 | _ret 99 | -------------------------------------------------------------------------------- /src/LIB_31/MEMSET.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | ; _setmem(addr,count,byte); from bds c. 21 | 22 | public _SETMEM_ 23 | _SETMEM_: 24 | push bp 25 | mov bp,sp 26 | if model 27 | mov di,[bp+6] 28 | mov es,[bp+8] 29 | mov cx,[bp+10] 30 | mov ax,[bp+12] 31 | else 32 | mov di,[bp+4] 33 | mov cx,[bp+6] 34 | mov ax,[bp+8] 35 | mov bx,ds ;set es to ds 36 | mov es,bx 37 | endif 38 | 39 | jmp setit 40 | 41 | ; void *memset(void *dst, char c, size_t n); 42 | 43 | public memset_ 44 | memset_: 45 | push bp 46 | mov bp,sp 47 | if model 48 | les di,[bp+6] 49 | mov ax,[bp+10] 50 | mov cx,[bp+12] 51 | else 52 | mov di,[bp+4] 53 | mov ax,[bp+6] 54 | mov cx,[bp+8] 55 | mov bx,ds ;set es to ds 56 | mov es,bx 57 | endif 58 | 59 | setit: 60 | 61 | cld ;clear up 62 | rep stosb ;set the area to al 63 | 64 | if model 65 | les si,[bp+6] 66 | else 67 | mov ax,[bp+4] 68 | endif 69 | pop bp 70 | _ret 71 | -------------------------------------------------------------------------------- /src/LIB_31/MODF.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * modf returns the positive fractional part of "value" and 18 | * stores the integer part indirectly through "iptr" 19 | */ 20 | 21 | double modf(value,iptr) 22 | double value, *iptr; 23 | { 24 | int exp, *ip; 25 | 26 | ip = &value; 27 | exp = ((ip[3] >> 4) & 0x7FF) - 0x3FF; 28 | if(exp < 0) 29 | *iptr=0.0; 30 | else 31 | { 32 | *iptr = value; 33 | if(exp < 52) 34 | { 35 | exp = 52 - exp; 36 | for(ip = iptr; exp > 0; exp -= 16) 37 | { 38 | if(exp >= 16) 39 | *ip++ = 0; 40 | else 41 | *ip++ &= (-1) << exp; 42 | } 43 | } 44 | } 45 | return value - *iptr; 46 | } 47 | -------------------------------------------------------------------------------- /src/LIB_31/MOVERLAY.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* MOVERLAY.C -- Load an Overlay from Memory. */ 17 | 18 | /* header for overlays. at start of .OV file. followed by code,data 19 | for each overlay except 0 (root). */ 20 | /* ovlen is length of data, code and reserved for each overlay. */ 21 | 22 | #define MAXOVER 40 23 | static unsigned ovlen[MAXOVER][3]; 24 | static char num_overlay; 25 | 26 | /* MOVERLAY -- load in the overlay */ 27 | 28 | static get_mem(); 29 | moverlay(ov) 30 | int ov; { 31 | int i; 32 | unsigned dataat,codeat,buflen,need,nread,*ptr,bufferat; 33 | long seekto; 34 | 35 | if (ov == num_overlay) return 1; 36 | get_mem(sizeof(ovlen),0l,ovlen,_showds()); 37 | 38 | if (ov <= 0 || ov >= MAXOVER || 39 | ovlen[ov][0]+ovlen[ov][1]+ovlen[ov][2] == 0) return -1; 40 | 41 | /* get code and data base addresses */ 42 | 43 | dataat=ovlen[0][0]+ovlen[0][2]; /* base of overlay daya */ 44 | codeat=ovlen[0][1]; /* base of overlay code */ 45 | seekto=sizeof(ovlen); 46 | for (i=1; i < ov; i++) { 47 | seekto+=ovlen[i][0]; 48 | seekto+=ovlen[i][1]; 49 | } 50 | if (ovlen[ov][1]) { /* read in the code */ 51 | get_mem(ovlen[ov][1],seekto,codeat,_showcs()); 52 | } 53 | 54 | if (ovlen[ov][0]) { /* read in the data */ 55 | get_mem(ovlen[ov][0],seekto+ovlen[ov][1],dataat,_showds()); 56 | } 57 | 58 | if (ovlen[ov][2]) { /* clear reserved */ 59 | ptr=dataat+ovlen[ov][0]; 60 | i=(ovlen[ov][2]+1)>>1; 61 | while (i--) *ptr=0; 62 | } 63 | num_overlay=ov; 64 | return 1; 65 | /* need a int 3 for d88 */ 66 | #asm 67 | public _movint3_ 68 | _movint3_: int 3 69 | # 70 | } 71 | 72 | 73 | /* GET_MEM -- Copy memory down for MEMOVERLAY */ 74 | 75 | static get_mem(size,into_mem,to_off,to_seg) 76 | int size; 77 | long into_mem; 78 | unsigned to_off,to_seg; { 79 | unsigned *wp,from_seg,from_off; 80 | 81 | wp=4; /* start of overlay stuff is at ds:[4] */ 82 | into_mem+=*wp; 83 | from_seg=_showcs(); 84 | from_seg+=into_mem>>4; 85 | from_off=into_mem & 15; 86 | _lmove(size,from_off,from_seg,to_off,to_seg); 87 | } 88 | 89 | -------------------------------------------------------------------------------- /src/LIB_31/MTAN.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #define RANGE 7.853981634e-2 /* PI/2 * 0.05 */ 17 | 18 | /* 19 | Series Expansion of tan(x) |x| < PI/2 20 | 21 | Abramowitz and Stegun 4.3.67 22 | */ 23 | 24 | static double tantab[] = 25 | { 26 | 1.0, 27 | 0.333333333, 28 | 0.133333333, 29 | 5.230769231e-2, 30 | 2.186948854e-2, 31 | 8.863235529e-3, 32 | 5.131611482e-3, 33 | 1.455834387e-3, 34 | 5.900274409e-4, 35 | 2.391291142e-4 36 | }; 37 | 38 | static double itab[] = 39 | { 40 | 0.0, 41 | 7.87017068e-2, 42 | 1.58384440e-1, 43 | 2.40078759e-1, 44 | 3.24919696e-1, 45 | 4.14213562e-1, 46 | 5.09525449e-1, 47 | 6.12800788e-1, 48 | 7.26542528e-1, 49 | 8.54080685e-1 50 | }; 51 | 52 | double _tan(z) 53 | double z; 54 | { 55 | double m,n,r,x; 56 | int i,j; 57 | 58 | j = 0; 59 | while ( z > RANGE) 60 | { 61 | j++; 62 | z -= RANGE; 63 | } 64 | m = z; 65 | n = m * m; 66 | r = 0; 67 | for ( i=0; i < 10; i++) 68 | { 69 | x = tantab[i] * m; 70 | r += x; 71 | m *= n; 72 | if ( x < 1.0e-12 ) break; 73 | } 74 | return( ( r + itab[j] ) / ( 1.0 - r * itab[j] ) ); 75 | } 76 |  -------------------------------------------------------------------------------- /src/LIB_31/MTANA.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; 8087 Version of double _tan(x) 18 | 19 | cseg 20 | 21 | public _tan_ 22 | public _testinit 23 | 24 | _tan_: 25 | push bp ; standard 26 | mov bp,sp ; prolog 27 | 28 | _call _testinit 29 | FLD qword [bp+pbase] ; get x 30 | 31 | FPTAN ; get partial tan 32 | FWAIT 33 | 34 | FDIVP ST(1),ST ; convert to tangent 35 | FWAIT 36 | 37 | pop bp ; standard 38 | _ret ; epilog -------------------------------------------------------------------------------- /src/LIB_31/POW.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | * pow returns "x" to the "y" power 18 | */ 19 | 20 | #include 21 | 22 | extern double log(), exp(); 23 | static double zero = 0.0; 24 | 25 | double pow(x, y) 26 | double x, y; 27 | { 28 | long l; 29 | double temp; 30 | 31 | if(x <= zero) 32 | { 33 | if(x == zero) 34 | { 35 | if(y <= zero) 36 | errno = EDOM; 37 | return zero; 38 | } 39 | l = y; 40 | if(l != y) 41 | { 42 | errno = EDOM; 43 | return zero; 44 | } 45 | temp = exp(y * log(-x)); 46 | if(l & 1) 47 | temp = -temp; 48 | } 49 | else 50 | temp = exp(y * log(x)); 51 | return temp; 52 | } 53 | -------------------------------------------------------------------------------- /src/LIB_31/PRINTF.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | printf fprintf to stdout 18 | ERROR (-1) returned on error. 19 | 20 | usage: 21 | printf(format, arg1, arg2, ...); 22 | */ 23 | 24 | int printf(char * format) { 25 | int fputc(); 26 | 27 | return _doprint(fputc, (int *) 1, &format); 28 | } 29 | -------------------------------------------------------------------------------- /src/LIB_31/PUTENV.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* putenv.C */ 17 | 18 | /* 19 | This file contains the routine for searching the environment 20 | area for a given string and replacing it. 21 | 22 | Interface: 23 | 24 | putenv(search_str, buffer) 25 | 26 | where search_str is the actual string being searched for, 27 | buffer is the location of new string. 28 | -1 is returned if the environment variable isn't found, 29 | otherwise 0 is returned. 30 | */ 31 | 32 | extern unsigned environ; 33 | 34 | int putenv(search_str, buffer) 35 | char *search_str, *buffer; { 36 | int envoff,searchoff,len,oldlen,newlen,envrep; 37 | char ch,count,first; 38 | 39 | envoff=0; 40 | while (ch=_peek(envoff++,environ)) { 41 | searchoff=0; 42 | while (ch == search_str[searchoff++]) ch=_peek(envoff++,environ); 43 | if (ch == '=' && search_str[searchoff-1] == 0) { 44 | count=0; 45 | first=1; 46 | len=2; 47 | oldlen=0; 48 | envrep=envoff; 49 | while (count < 2) { 50 | while (_peek(envoff++,environ)) { 51 | len++; 52 | if (first) oldlen++; 53 | } 54 | first=0; 55 | if (_peek(envoff++,environ) == 0) count++; 56 | else len++; 57 | } 58 | newlen=strlen(buffer); 59 | # if defined LARGE_CASE 60 | _move(len,envrep-newlen+oldlen,environ,envrep,environ); 61 | _move(newlen,buffer,envrep,environ); 62 | # else 63 | _lmove(len,envrep-newlen+oldlen,environ,envrep,environ); 64 | _lmove(newlen,buffer,_showds(),envrep,environ); 65 | # endif 66 | return 0; 67 | } 68 | while (ch=_peek(envoff++,environ)); 69 | } 70 | return -1; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/LIB_31/RAND.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* random number generator */ 17 | 18 | static long _seed=7613941; 19 | static long xalo,leftlo, fhi, xhi, k, p=2147483647; 20 | 21 | 22 | 23 | /* frand returns a random floating point number in the range of 0 to 1. */ 24 | 25 | double frand() { 26 | return rand()/32767.; 27 | } 28 | 29 | 30 | 31 | /* rand returns an integer in the ranf 0 to 32767 */ 32 | 33 | rand() { 34 | int ans; 35 | 36 | xhi=_seed>>16; 37 | xalo=(_seed-(xhi<<16))*16807; 38 | leftlo=xalo>>16; 39 | fhi=xhi*16807+leftlo; 40 | k=fhi>>15; 41 | _seed=(((xalo-(leftlo<<16))-p)+((fhi-(k<<15))<<16))+k; 42 | if (_seed > p) _seed+=p; 43 | ans=_seed; 44 | return ans >= 0 ? ans: -ans; 45 | } 46 | 47 | /* set a random number _seed */ 48 | 49 | srand(news) 50 | int news; { 51 | 52 | _seed=news; 53 | } 54 | -------------------------------------------------------------------------------- /src/LIB_31/RERRNO.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* RERRNO.C -- default routine to report on float errors. */ 17 | 18 | #include 19 | 20 | static onum(); 21 | rerrno() { 22 | 23 | puts("errno="); 24 | onum(errno); 25 | switch (errno) { 26 | case EFLOAT: puts(" *Error in Floating Point*"); 27 | break; 28 | case EOVERFLOW: puts(" *Overflow*"); 29 | return; 30 | case EDIV0: puts(" *Divide by Zero*"); 31 | break; 32 | case EDOM: puts(" *Domain Error*"); 33 | break; 34 | case ERANGE: puts(" *Out of Range*"); 35 | break; 36 | } 37 | putchar('\n'); 38 | exit(2); 39 | } 40 | 41 | static onum(num) 42 | int num; { 43 | if (num > 9) { 44 | onum(num/10); 45 | num=num%10; 46 | } 47 | putchar(num+'0'); 48 | } 49 | -------------------------------------------------------------------------------- /src/LIB_31/SCANF.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* SCANF.C -- FORMATTED FILE INPUT */ 17 | 18 | /* 19 | like fscanf() but from stdin 20 | 21 | Returns number of items succesfully matched. 22 | */ 23 | 24 | static cgetc(){ 25 | int ch; 26 | 27 | ch=getchar(); 28 | if(ch == '\r') co('\n'); 29 | return ch; 30 | } 31 | 32 | int scanf(char *format) { return _doscan(cgetc, (int*)0, 1, &format); } 33 | -------------------------------------------------------------------------------- /src/LIB_31/SIN.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | 18 | extern double modf(), fabs(); 19 | 20 | static double ymax = 0x41A908B100000000; /* 2.1e8 */ 21 | static double zero = 0x0000000000000000; /* 0.0 */ 22 | static double dot5 = 0x3FE0000000000000; /* 0.5 */ 23 | static double one = 0x3FF0000000000000; /* 1.0 */ 24 | static double oneOverPi = 0x3FD45F306DC9C883; /* 0.31830988618379067154 */ 25 | static double pi = 0x400921FB54442D18; /* 3.14159265358979323846 */ 26 | static double eps = 0x3E45798EE2308C3B; /* 1.0e-8 */ 27 | static double piOver2 = 0x3FF921FB54442D18; /* 1.57079632679489661923 */ 28 | static double r1 = 0xBFC5555555555555; /* -0.16666666666666665052 */ 29 | static double r2 = 0x3F811111111110B0; /* 0.83333333333331650314e-2 */ 30 | static double r3 = 0xBF2A01A01A013E1B; /* -0.19841269841201840457e-3 */ 31 | static double r4 = 0x3EC71DE3A524F062; /* 0.27557319210152756119e-5 */ 32 | static double r5 = 0xBE5AE6454B5DC0AB; /* -0.25052106798274584544e-7 */ 33 | static double r6 = 0x3DE6123C686AD431; /* 0.16058936490371589114e-9 */ 34 | static double r7 = 0xBD6AE420DC08499B; /* -0.76429178068910467734e-12 */ 35 | static double r8 = 0x3CE880FF6993DF95; /* 0.27204790957888846175e-14 */ 36 | 37 | static double _sc(x, y, sgn, flag) 38 | double x, y; 39 | { 40 | int j, n; 41 | double xn, f, g, R; 42 | 43 | if(y >= ymax) 44 | { 45 | errno = EDOM; 46 | return zero; 47 | } 48 | if(modf(y * oneOverPi, &xn) >= dot5) 49 | xn += one; 50 | n = xn; 51 | if(n & 1) 52 | sgn = !sgn; 53 | if(flag) 54 | xn -= dot5; 55 | f = fabs(x) - xn * pi; 56 | if(fabs(f) >= eps) 57 | { 58 | g = f * f; 59 | R = (((((((r8 * g + r7) * g + r6) * g + r5) * g + r4) * g + r3) * g + r2) * g + r1) * g; 60 | f = f + f * R; 61 | } 62 | f=sgn ? -f: f; 63 | return (f > 1. ? 1.: f); 64 | } 65 | 66 | 67 | double sin(X) 68 | double X; 69 | { 70 | return _sc(X, fabs(X), X < 0.0 ? 1 : 0, 0); 71 | } 72 | 73 | double cos(X) 74 | double X; 75 | { 76 | return _sc(X, fabs(X) + piOver2, 0, 1); 77 | } 78 | -------------------------------------------------------------------------------- /src/LIB_31/SPRINTF.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | sprintf: 18 | Like fprintf, except a string pointer is specified 19 | instead of a buffer pointer. The text is written 20 | directly into memory where the string pointer points. 21 | 22 | Usage: 23 | sprintf(string,format,arg1, arg2, ...); 24 | */ 25 | 26 | static sputc(char ch, char **ptr) { return *(*ptr)++ = ch; } 27 | 28 | sprintf(char * buf, char * fmt) { 29 | int n; 30 | 31 | n = _doprint(sputc, &buf, &fmt); 32 | *buf = 0; 33 | return n; 34 | } 35 | -------------------------------------------------------------------------------- /src/LIB_31/STDIO.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STDIO.H Include file for C88 input/output. */ 17 | 18 | /* a 'FILE' is simply an integer is this implimentation */ 19 | 20 | #define FILE int 21 | 22 | /* Standard input, standard output and standard error. */ 23 | 24 | #define stdin (FILE *)0 25 | #define stdout (FILE *)1 26 | #define stderr (FILE *)2 27 | #define stdaux (FILE *)3 28 | #define stdprn (FILE *)4 29 | 30 | #ifdef LARGE_CASE 31 | 32 | /* With LARGE case (-B option), */ 33 | /* Use lower case stdin, stdout etc with fopen(), fread(), getc() etc. */ 34 | /* Use upper case STDIN, STDOUT etc with open(), read() etc. */ 35 | 36 | #define STDIN 0 37 | #define STDOUT 1 38 | #define STDERR 2 39 | #define STDAUX 3 40 | #define STDPRN 4 41 | 42 | #endif 43 | 44 | #define NULL (void *)0 45 | #define TRUE 1 46 | #define FALSE 0 47 | #define EOF (-1) 48 | #define ERR (-1) 49 | 50 | #define SEEK_SET 0 51 | #define SEEK_CUR 1 52 | #define SEEK_END 2 53 | 54 | #define F_ERR 1 55 | #define F_EOF 2 56 | 57 | extern char _flag[]; 58 | 59 | #define feof(f) (_flag[(int)f] & F_EOF) 60 | #define ferror(f) (_flag[(int)f] & F_ERR) 61 | #define clrerror(f) (_flag[(int)f] & ~(F_ERR | F_EOF)) 62 | 63 | int closeall(void); 64 | int fclose(FILE *); 65 | int fflush(FILE *); 66 | int fgetc(FILE *); 67 | int fgetchar(void); 68 | char *fgets(char *, int, FILE *); 69 | long filelength(int); 70 | int fileno(FILE *); 71 | FILE *fopen(char *, char *); 72 | int fprintf(FILE *, char *, ... ); 73 | int fputc(int, FILE *); 74 | int fputchar(int); 75 | int fputs(char *, FILE *); 76 | int fread(char *, int, int, FILE *); 77 | FILE *freopen(char *, char *, FILE *); 78 | int fscanf(FILE *, char *, ... ); 79 | long fseek(FILE *, long, int); 80 | long ftell(FILE *); 81 | int fwrite(char *, int, int, FILE *); 82 | int getc(FILE *); 83 | int getchar(void); 84 | char *gets(char *); 85 | int getw(FILE *); 86 | int printf(char *, ... ); 87 | int puts(char *); 88 | int putw(int, FILE *); 89 | int rewind(FILE *); 90 | int scanf(char *, ... ); 91 | int sprintf(char *, char *, ... ); 92 | int sscanf(char *, char *, ... ); 93 | int ungetc(int, FILE *); 94 | 95 | -------------------------------------------------------------------------------- /src/LIB_31/STRCAT.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | 21 | ; strcat(destination string,source string); 22 | ; strncat(destination string,source string, maximum); 23 | 24 | public STRNCAT_,STRCAT_ 25 | STRNCAT_: 26 | push bp 27 | mov bp,sp 28 | if model 29 | push ds 30 | les di,[bp+pbase] 31 | lds si,[bp+pbase+4] 32 | mov cx,[bp+pbase+8] 33 | else 34 | mov di,[bp+pbase] 35 | mov si,[bp+pbase+2] 36 | mov cx,[bp+pbase+4] 37 | endif 38 | jcxz cc_quit 39 | jmp catcont 40 | 41 | 42 | STRCAT_: 43 | push bp 44 | mov bp,sp 45 | if model 46 | push ds 47 | les di,[bp+pbase] 48 | lds si,[bp+pbase+4] 49 | else 50 | mov di,[bp+pbase] 51 | mov si,[bp+pbase+2] 52 | endif 53 | mov cx,65535 ;big number 54 | catcont:mov ax,di ;return pointer to result 55 | if model 56 | skiplp: mov dl,es:[di] ;skip source 57 | else 58 | skiplp: mov dl,[di] ;skip source 59 | endif 60 | or dl,dl 61 | jz cc_loop 62 | inc di 63 | jmp skiplp 64 | cc_loop:mov dl,[si] ;from source 65 | if model 66 | mov es:[di],dl ;to destination 67 | else 68 | mov [di],dl ;to destination 69 | endif 70 | inc si 71 | inc di 72 | or dl,dl ;till zero copied 73 | jz cc_quit 74 | loop cc_loop 75 | mov byte [di],0 76 | cc_quit: 77 | if model 78 | pop ds 79 | mov si,ax ; pointer return 80 | endif 81 | pop bp 82 | _ret 83 | -------------------------------------------------------------------------------- /src/LIB_31/STRCHR.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | ; location = INDEX(string, character); 21 | ; location = strchr(string, character); 22 | 23 | public INDEX_,STRCHR_ 24 | INDEX_: 25 | STRCHR_: 26 | push bp 27 | mov bp,sp 28 | if model 29 | push ds 30 | lds si,[bp+pbase] 31 | mov bx,[bp+pbase+4] 32 | else 33 | mov si,[bp+pbase] 34 | mov bx,[bp+pbase+2] 35 | endif 36 | cld 37 | in_loop:lodsb 38 | or al,al ;failure ? 39 | jz in_fail 40 | cmp al,bl ;a match ? 41 | jz in_quit 42 | jmp in_loop 43 | in_fail:mov ah,0 ;not found 44 | if model 45 | mov es,ax 46 | mov si,ax 47 | pop ds 48 | endif 49 | pop bp 50 | _ret 51 | in_quit: 52 | if model 53 | dec si ;address of match 54 | mov ax,ds 55 | mov es,ax 56 | pop ds 57 | else 58 | lea ax,[si-1] ;address of match 59 | endif 60 | pop bp 61 | _ret 62 | -------------------------------------------------------------------------------- /src/LIB_31/STRCMP.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | ; return = strcmp(first string, second string); 21 | ; return = strncmp(first string,second string,maximum); 22 | 23 | ; return < 0 if f < s, 0 if f == s, >0 if f > s 24 | 25 | public STRCMP_,STRNCMP_ 26 | STRNCMP_: 27 | push bp 28 | mov bp,sp 29 | if model 30 | push ds 31 | les di,[bp+pbase] 32 | lds si,[bp+pbase+4] 33 | mov cx,[bp+pbase+8] 34 | else 35 | mov di,[bp+pbase] 36 | mov si,[bp+pbase+2] 37 | mov cx,[bp+pbase+4] 38 | endif 39 | jcxz sp_quit 40 | jmp sp_loop 41 | 42 | 43 | STRCMP_: 44 | push bp 45 | mov bp,sp 46 | if model 47 | push ds 48 | les di,[bp+pbase] 49 | lds si,[bp+pbase+4] 50 | else 51 | mov di,[bp+pbase] 52 | mov si,[bp+pbase+2] 53 | endif 54 | mov cx,65535 55 | sp_loop:mov al,[si] ;from second 56 | if model 57 | cmp es:[di],al ;to first 58 | else 59 | cmp [di],al ;to first 60 | endif 61 | jb flow 62 | ja fhigh 63 | inc si ;increment indexes 64 | inc di 65 | or al,al 66 | jz sp_quit 67 | loop sp_loop 68 | sp_quit:mov ax,0 ;return a zero as both the same 69 | if model 70 | pop ds 71 | endif 72 | pop bp 73 | _ret 74 | flow: mov ax,-1 ;return -1 as first is low 75 | if model 76 | pop ds 77 | endif 78 | pop bp 79 | _ret 80 | fhigh: mov ax,1 ;return 1 as first is high 81 | if model 82 | pop ds 83 | endif 84 | pop bp 85 | _ret 86 | -------------------------------------------------------------------------------- /src/LIB_31/STRCPY.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; string.a - strlen_, strcmp_, STRCPY_ and _setmem. 18 | 19 | cseg 20 | 21 | ; strcpy(destination string,source string); 22 | ; strncpy(destination string,source string,maximum); 23 | 24 | 25 | 26 | public STRNCPY_,STRCPY_ 27 | STRNCPY_: 28 | push bp 29 | mov bp,sp 30 | if model 31 | push ds 32 | les di,[bp+pbase] ;destination 33 | lds si,[bp+pbase+4] ;source 34 | mov cx,[bp+pbase+8] ;count 35 | else 36 | mov di,[bp+pbase] ;destination offset 37 | mov si,[bp+pbase+2] ;source offset 38 | mov cx,[bp+pbase+4] ;count 39 | endif 40 | jcxz sc_quit 41 | jmp cpycont 42 | 43 | 44 | STRCPY_: 45 | push bp 46 | mov bp,sp 47 | if model 48 | push ds 49 | les di,[bp+pbase] ;destination 50 | lds si,[bp+pbase+4] ;source 51 | else 52 | mov di,[bp+pbase] ;destination 53 | mov si,[bp+pbase+2] ;source 54 | endif 55 | mov cx,65535 ;big number 56 | cpycont: 57 | mov ax,di ;return result 58 | sc_loop:mov bl,[si] ;from source 59 | if model 60 | mov es:[di],bl ;to destination 61 | else 62 | mov [di],bl ;to destination 63 | endif 64 | inc si 65 | inc di 66 | or bl,bl ;till zero copied 67 | jz sc_quit 68 | loop sc_loop 69 | sc_quit: 70 | if model 71 | pop ds 72 | endif 73 | pop bp 74 | if model 75 | mov si,ax ; pointer return 76 | endif 77 | _ret 78 | 79 | -------------------------------------------------------------------------------- /src/LIB_31/STRDUP.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STRDUP -- use malloc to make a copy of a string. */ 17 | 18 | char *malloc(); 19 | 20 | char *strdup(str) 21 | char *str; { 22 | char *strat; 23 | 24 | strat=malloc(strlen(str)+1); 25 | if (strat) strcpy(strat,str); 26 | return strat; 27 | } 28 | -------------------------------------------------------------------------------- /src/LIB_31/STRLEN.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | 21 | public STRLEN_ 22 | STRLEN_: 23 | push bp 24 | mov bp,sp 25 | if model 26 | mov si,[bp+6] 27 | mov es,[bp+8] 28 | else 29 | mov si,[bp+4] 30 | endif 31 | xor ax,ax 32 | if model 33 | sl_loop:cmp es: byte [si],0 ;string char 34 | else 35 | sl_loop:cmp byte [si],0 ;string char 36 | endif 37 | jz slret 38 | inc ax ;length 39 | inc si 40 | jmp sl_loop 41 | slret: pop bp 42 | _ret 43 | -------------------------------------------------------------------------------- /src/LIB_31/STRLWR.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STRLWR -- make a string lower case */ 17 | 18 | char *strlwr(str) 19 | char *str; { 20 | char *strwas; 21 | 22 | strwas=str; 23 | while (*str) { 24 | if (*str >= 'A' && *str <= 'Z') *str+='a'-'A'; 25 | str++; 26 | } 27 | return strwas; 28 | } 29 | -------------------------------------------------------------------------------- /src/LIB_31/STRRCHR.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | 18 | cseg 19 | 20 | ; location = rindex(string, character); 21 | ; location = strrchr(string, character); 22 | 23 | public RINDEX_,STRRCHR_ 24 | RINDEX_: 25 | STRRCHR_: 26 | push bp 27 | mov bp,sp 28 | if model 29 | push ds 30 | lds si,[bp+pbase] 31 | mov bx,[bp+pbase+4] ;bl is character to find 32 | else 33 | mov si,[bp+pbase] 34 | mov bx,[bp+pbase+2] 35 | endif 36 | cld 37 | xor cx,cx 38 | in_rloop:lodsb 39 | cmp al,bl ;a match ? 40 | jnz in_next 41 | lea cx,[si-1] ;address of match 42 | in_next: 43 | or al,al ;failure ? 44 | jnz in_rloop 45 | if model 46 | mov si,cx ; pointer to last found 47 | mov ax,ds 48 | mov es,ax 49 | cmp cx,0 ; if zero neex zero es 50 | jnz got_i 51 | mov es,cx 52 | got_i: pop ds 53 | else 54 | mov ax,cx ;return addr of last found 55 | endif 56 | pop bp 57 | _ret 58 | -------------------------------------------------------------------------------- /src/LIB_31/STRREV.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STRREV -- reverse a string. */ 17 | 18 | char *strrev(str) 19 | char *str; { 20 | int first,last; 21 | char ch; 22 | 23 | first=0; 24 | last=strlen(str)-1; 25 | while (first < last) { 26 | ch=str[last]; 27 | str[last--]=str[first]; 28 | str[first++]=ch; 29 | } 30 | return str; 31 | } 32 | -------------------------------------------------------------------------------- /src/LIB_31/STRSET.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STRSET -- set the characters of a string */ 17 | 18 | char *strset(str,ch) 19 | char *str; 20 | char ch; { 21 | int i; 22 | 23 | i=0; 24 | i=strlen(str)-1; 25 | while (i >= 0) { 26 | str[i--]=ch; 27 | } 28 | return str; 29 | } 30 | -------------------------------------------------------------------------------- /src/LIB_31/STRSTR.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | char *strstr(char * s1, char * s2) { 17 | char * w, c = *s2, *strchr(); 18 | 19 | while(w = strchr(s1, c)) { 20 | char *t1 = w, *t2 = s2; 21 | 22 | while(*t2 && *t1++ == *t2++) ; 23 | if(*t2 == 0) 24 | return w; 25 | s1 = w + 1; 26 | } 27 | return (char *)0; 28 | } 29 | -------------------------------------------------------------------------------- /src/LIB_31/STRTOK.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STRTOK -- return tokens from a string. 17 | example: char *tptr,*strtok(); 18 | tptr=strtok(" , aaa , bbb"," ,\t"); */ 19 | 20 | static char *nxt; 21 | 22 | char *strpbrk(); 23 | 24 | #define NULL (char *)0 25 | 26 | char *strtok(char *str, char *toks) { 27 | char *beg, *end; 28 | 29 | if ((beg = (str == NULL) ? nxt : str) == NULL) 30 | return NULL; 31 | beg += strspn(beg,toks); 32 | if (*beg == '\0') 33 | return NULL; 34 | if((end = strpbrk(beg,toks)) == NULL) 35 | nxt = NULL; 36 | else { 37 | *end++ = '\0'; 38 | nxt = end; 39 | } 40 | return beg; 41 | } 42 | -------------------------------------------------------------------------------- /src/LIB_31/STRTOL.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | 18 | #define DIGIT(x) (isdigit(x) ? (x) - '0' : \ 19 | islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A') 20 | #define MBASE ('z' - 'a' + 1 + 10) 21 | 22 | long 23 | strtol(str, ptr, base) 24 | register char *str; 25 | char **ptr; 26 | register int base; 27 | { 28 | register long val; 29 | register int c; 30 | int xx, neg = 0; 31 | 32 | if (ptr != (char **)0) 33 | *ptr = str; /* in case no number is formed */ 34 | if (base < 0 || base > MBASE) 35 | return (0); /* base is invalid -- should be a fatal error */ 36 | if (!isalnum(c = *str)) { 37 | while (isspace(c)) 38 | c = *++str; 39 | switch (c) { 40 | case '-': 41 | neg++; 42 | case '+': /* fall-through */ 43 | c = *++str; 44 | } 45 | } 46 | if (base == 0) 47 | if (c != '0') 48 | base = 10; 49 | else if (str[1] == 'x' || str[1] == 'X') 50 | base = 16; 51 | else 52 | base = 8; 53 | /* 54 | * for any base > 10, the digits incrementally following 55 | * 9 are assumed to be "abc...z" or "ABC...Z" 56 | */ 57 | if (!isalnum(c) || (xx = DIGIT(c)) >= base) 58 | return (0); /* no number formed */ 59 | if (base == 16 && c == '0' && isxdigit(str[2]) && 60 | (str[1] == 'x' || str[1] == 'X')) 61 | c = *(str += 2); /* skip over leading "0x" or "0X" */ 62 | for (val = -DIGIT(c); isalnum(c = *++str) && (xx = DIGIT(c)) < base; ) 63 | /* accumulate neg avoids surprises near MAXLONG */ 64 | val = base * val - xx; 65 | if (ptr != (char **)0) 66 | *ptr = str; 67 | return (neg ? val : -val); 68 | } 69 | -------------------------------------------------------------------------------- /src/LIB_31/STRUPR.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* STRUPR -- make a string upper case */ 17 | 18 | char *strupr(str) 19 | char *str; { 20 | char *strwas; 21 | 22 | strwas=str; 23 | while (*str) { 24 | if (*str >= 'a' && *str <= 'z') *str-='a'-'A'; 25 | str++; 26 | } 27 | return strwas; 28 | } 29 | -------------------------------------------------------------------------------- /src/LIB_31/SYSTEM.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | /* 17 | ** int system(char cmd[]); 18 | ** 19 | ** invoke command.com 20 | */ 21 | 22 | int system(char cmd[]) { 23 | char path[65], arg[129]; 24 | 25 | if(getenv("COMSPEC", path, sizeof(path))) { 26 | arg[0] = '/'; 27 | arg[1] = 'c'; 28 | strcpy(&arg[2], cmd); 29 | if(!exec(path, arg)) return 0; 30 | } 31 | return -1; 32 | } 33 | -------------------------------------------------------------------------------- /src/LIB_31/TAN.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | #include 17 | #include 18 | 19 | extern double fabs(); 20 | 21 | static double eps = 0x3E4E1094D643F785; /* 1.4e-8 */ 22 | static double eps1 = 0x0105F1CA820511B7; /* 1.0e-303 */ 23 | static double YMAX = 0x4197D78400000000; /* 1.0e8 */ 24 | static double twoOverPi = 0x3FE45F306DC9C883; /* 0.63661977236758134308 */ 25 | static double c1 = 0x3FF9220000000002; /* 1.57080078125 */ 26 | static double c2 = 0xBED2AEEF4B9EE59E; /* -4.454455103380768678308e-6 */ 27 | static double p1 = 0xBFC06B97BF03648A; /* -0.1282834704095743847 */ 28 | static double p2 = 0x3F66FC6FE2982A7B; /* 0.2805918241169988906e-2 */ 29 | static double p3 = 0xBEDF637DEA7C0B2B; /* -0.7483634966612065149e-5 */ 30 | static double q1 = 0xBFDD8B2134D70767; /* -0.4616168037429048840 */ 31 | static double q2 = 0x3F97E7B68D9A55F3; /* 0.2334485282206872802e-1 */ 32 | static double q3 = 0xBF2B525B10D0A169; /* -0.2084480442203870948e-3 */ 33 | static double dot5 = 0x3FE0000000000000; /* 0.5 */ 34 | static double zero = 0x0000000000000000; /* 0.0 */ 35 | 36 | static double _tc(x,iflag) 37 | double x; 38 | int iflag; 39 | { 40 | int n; 41 | double y, xn, f, g, xnum, xden; 42 | 43 | y = fabs(x); 44 | if(iflag && y < eps1) 45 | { 46 | errno = ERANGE; 47 | return (x < zero) ? -XMAX : XMAX; 48 | } 49 | if(y > YMAX) 50 | { 51 | errno = ERANGE; 52 | return zero; 53 | } 54 | xn = n = _intrnd(x * twoOverPi); 55 | f = (x - xn * c1) - xn * c2; 56 | if(fabs(f) < eps) 57 | { 58 | xnum = f; 59 | xden = 1.0; 60 | } 61 | else 62 | { 63 | g = f * f; 64 | xnum = ((p3 * g + p2) * g + p1) * g * f + f; 65 | xden = ((q3 * g + q2) * g + q1) * g + dot5 + dot5; 66 | } 67 | if(n & 1) 68 | xnum = -xnum; 69 | if(iflag == (n & 1)) 70 | return xnum / xden; 71 | return xden / xnum; 72 | } 73 | 74 | double tan(x) 75 | double x; 76 | { 77 | return _tc(x,0); 78 | } 79 | 80 | 81 | double cot(x) 82 | double x; 83 | { 84 | return _tc(x,1); 85 | } 86 | -------------------------------------------------------------------------------- /src/LIB_31/UMULDIV.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | include "config.h" 17 | ; umuldiv.a - four byte unsigned multiply, divide and mod. 18 | 19 | cseg 20 | public _UMUL4,_UDIV4,_UMOD4 21 | 22 | ; _UMOD4 -- dx:ax = dx:ax % bx:cx. 23 | 24 | _UMOD4: push si ;save si,di 25 | push di 26 | _call xdiv4 27 | mov dx,si 28 | mov ax,bx 29 | pop di 30 | pop si 31 | _ret 32 | 33 | 34 | ; _UDIV4 -- dx:ax = dx:ax / bx:cx. remainder = si:bx. 35 | 36 | _UDIV4: push si ;save si and di 37 | push di 38 | _call xdiv4 39 | pop di 40 | pop si 41 | _ret 42 | 43 | ; do the real work of division 44 | 45 | xdiv4: or bx,bx 46 | jnz dword_dword_div 47 | cmp cx,dx 48 | jbe dword_word_long 49 | div cx 50 | xor si,si 51 | mov bx,dx 52 | xor dx,dx 53 | _ret 54 | dword_word_long: 55 | mov bx,ax 56 | mov ax,dx 57 | xor dx,dx 58 | div cx 59 | xchg bx,ax 60 | div cx 61 | xchg dx,bx 62 | xor si,si 63 | _ret 64 | dword_dword_div: 65 | push bp 66 | mov bp,cx 67 | mov di,bx 68 | xor si,si 69 | mov bx,si 70 | mov cx, 32 71 | div_mod_loop: 72 | shl bx, 1 73 | rcl si, 1 74 | shl ax, 1 75 | rcl dx, 1 76 | adc bx, 0 77 | sub bx, bp 78 | sbb si, di 79 | inc ax 80 | jnc inc_remainder 81 | add bx, bp 82 | adc si, di 83 | dec ax 84 | inc_remainder: 85 | loop div_mod_loop 86 | pop bp 87 | _ret 88 | 89 | ; _mul4 -- dx:ax = dx:ax * bx:cx. 90 | 91 | 92 | _UMUL4: push si 93 | push di 94 | mov di,ax 95 | mov ax,dx 96 | mul cx 97 | mov si,ax 98 | mov ax,bx 99 | mul di 100 | add si,ax 101 | mov ax,cx 102 | mul di 103 | add dx,si 104 | pop di 105 | pop si 106 | _ret 107 | -------------------------------------------------------------------------------- /src/LIB_31/_ADX.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; This library is free software; you can redistribute it and/or modify 7 | ; it under the terms of the GNU Lesser General Public License as published 8 | ; by the Free Software Foundatation; either version 2.1 of the License, or 9 | ; any later version. 10 | ; 11 | ; This library is distributed in the hope that it will be useful, but 12 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | ; License for more details. 15 | ; 16 | INCLUDE "CONFIG.H" 17 | ; augment exponent double _adx(fp,n) 18 | ; double fp; 19 | ; int n; 20 | cseg 21 | 22 | public _adx_,_floadd 23 | _adx_: 24 | push bp ; old 25 | mov bp,sp ; frame 26 | 27 | mov ax,[bp+pbase+6] ; get sign + exp 28 | mov bx,ax ; save sign & sig 29 | mov cl,5 ; shift factor 30 | shl ax,1 ; ditch sign 31 | sar ax,cl ; pull high-bit as sign 32 | 33 | add ax,[bp+pbase+8] ; augment exp 34 | 35 | mov cl,5 ; shift factor 36 | shl ax,cl ; realign 37 | shr ax,1 ; clear sign 38 | 39 | and bx,800FH ; isolate sign & f 40 | or ax,bx ; put back 41 | mov [bp+pbase+6],ax ; on stack 42 | 43 | lea si,word [bp+pbase] ; real addr 44 | IF model 45 | PUSH SS 46 | POP ES 47 | ENDIF 48 | _call _floadd ; put on fp stack 49 | 50 | pop bp 51 | _ret 52 | -------------------------------------------------------------------------------- /src/LIB_31/_AINTRND.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | extern double fabs(); 17 | 18 | double _aintrnd(x) 19 | double x; 20 | { 21 | int i; 22 | 23 | i = fabs(x) + 0.5; 24 | return x < 0.0 ? -i : i; 25 | } 26 | -------------------------------------------------------------------------------- /src/LIB_31/_INTRND.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | extern double fabs(); 17 | 18 | _intrnd(x) 19 | double x; 20 | { 21 | int i; 22 | i = fabs(x) + 0.5; 23 | return x < 0.0 ? -i : i; 24 | } 25 | -------------------------------------------------------------------------------- /src/LIB_31/_PI.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | double _pi(void) { return 3.14159265358979323846; } 17 | -------------------------------------------------------------------------------- /src/LIB_31/_PI_2.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU LGPL. See http://www.gnu.org/licenses/lgpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * This library is free software * you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as published 8 | * by the Free Software Foundatation * either version 2.1 of the License, or 9 | * any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, but 12 | * WITHOUT ANY WARRANTY * without even the implied warranty of MERCHANTABILITY 13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | * License for more details. 15 | */ 16 | double _pi_2(void) { return 1.57079632679489661923; } 17 | -------------------------------------------------------------------------------- /src/MAKEODC.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | mkdir bin 4 | 5 | echo Building asm88.exe 6 | 7 | cd asm 8 | call make_asm.bat 9 | if not exist my_asm88.exe goto stop 10 | copy my_asm88.exe ..\bin\asm88.exe 11 | cd .. 12 | 13 | echo Building bind.exe 14 | 15 | cd bind 16 | call makebind.bat 17 | if not exist my_bind.exe goto stop 18 | copy my_bind.exe ..\bin\bind.exe 19 | cd .. 20 | 21 | echo Building c88.exe 22 | 23 | cd c 24 | call make_c88.bat 25 | if not exist my_c88.exe goto stop 26 | copy my_c88.exe ..\bin\c88.exe 27 | cd .. 28 | 29 | echo Building d88.exe 30 | 31 | cd d 32 | call make_d88.bat 33 | if not exist my_d88.exe goto stop 34 | copy my_d88.exe ..\bin\d88.exe 35 | cd .. 36 | 37 | echo Building gen.exe 38 | 39 | cd gen 40 | call make_gen.bat 41 | if not exist my_gen.exe goto stop 42 | copy my_gen.exe ..\bin\gen.exe 43 | cd .. 44 | 45 | echo Building lib88.exe 46 | 47 | cd lib88 48 | call make_l88.bat 49 | if not exist my_lib88.exe goto stop 50 | if not exist mysquish.exe goto stop 51 | copy my_lib88.exe ..\bin\lib88.exe 52 | copy mysquish.exe ..\bin\squish.exe 53 | cd .. 54 | 55 | echo Building nbind.exe 56 | 57 | cd nbind 58 | call make_nb.bat 59 | if not exist mynbind.exe goto stop 60 | copy mynbind.exe ..\bin\nbind.exe 61 | cd .. 62 | 63 | echo Building others 64 | 65 | cd other 66 | call other.bat 67 | if not exist toobj.exe goto stop 68 | if not exist dumpobj.exe goto stop 69 | copy toobj.exe ..\bin\toobj.exe 70 | copy dumpobj.exe ..\bin\dumpobj.exe 71 | cd .. 72 | 73 | echo Building see.exe 74 | 75 | cd see 76 | call make.bat 77 | if not exist s.exe goto stop 78 | copy s.exe ..\bin\see.exe 79 | cd .. 80 | 81 | echo Building tools 82 | 83 | cd tools 84 | call makeit.bat 85 | copy *.exe ..\bin 86 | cd .. 87 | 88 | echo Building more tools 89 | 90 | cd src 91 | c88 cb 92 | bind cb 93 | if not exist cb.exe goto stop 94 | copy cb.exe ..\bin\cbcheck.exe 95 | cd .. 96 | 97 | echo Building libraries 98 | 99 | cd lib_31 100 | call make_lib.bat 101 | 102 | echo Building big libraries 103 | 104 | call makeblib.bat 105 | 106 | copy bmylib.s ..\bin\bcstdio.s 107 | copy bmylib7.s ..\bin\bcstdio7.s 108 | copy mylib.s ..\bin\cstdio.s 109 | copy mylib7.s ..\bin\cstdio7.s 110 | cd .. 111 | 112 | echo Copying include files 113 | 114 | cd include 115 | copy *.* ..\bin 116 | cd .. 117 | 118 | echo Build complete. 119 | echo All files should no reside in bin directory. 120 | 121 | goto ok 122 | 123 | :stop 124 | 125 | cd .. 126 | 127 | :ok 128 | -------------------------------------------------------------------------------- /src/NBIND/MAKE_NB.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | asm88 _lmov 4 | if errorlevel 1 goto stop 5 | 6 | asm88 _lcmp 7 | if errorlevel 1 goto stop 8 | 9 | asm88 _lcpy 10 | if errorlevel 1 goto stop 11 | 12 | c88 nbind %1 13 | if errorlevel 1 goto stop 14 | 15 | if .%1.==.c. goto generate_chk 16 | 17 | bind nbind _lmov _lcmp _lcpy -omynbind 18 | goto stop 19 | 20 | bind nbind _lmov _lcmp _lcpy -omynbind -c 21 | 22 | :stop 23 | -------------------------------------------------------------------------------- /src/NBIND/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/NBIND/_LCMP.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; DeSmet C is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundatation; either version 2 of the License, or any 9 | ; later version. 10 | ; 11 | ; DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | ; for more details. 15 | ; 16 | ; int _lcmp(unsigned off, unsigned seg, unsigned off, unsigned seg, size_t n); 17 | 18 | cseg 19 | public _lcmp_ 20 | _lcmp_: push bp 21 | mov bp,sp 22 | 23 | push ds 24 | lds si,[bp+4] 25 | les di,[bp+8] 26 | mov cx,[bp+12] 27 | xor ax,ax 28 | jcxz eq 29 | cld 30 | rep cmpsb 31 | je eq 32 | ja gt 33 | 34 | dec ax 35 | 36 | pop ds 37 | pop bp 38 | ret 39 | gt: inc ax 40 | eq: pop ds 41 | pop bp 42 | ret 43 | -------------------------------------------------------------------------------- /src/NBIND/_LCPY.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; DeSmet C is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundatation; either version 2 of the License, or any 9 | ; later version. 10 | ; 11 | ; DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | ; for more details. 15 | ; 16 | ; int _lcpy(unsigned doff, unsigned dseg, unsigned soff, unsigned sseg); 17 | 18 | cseg 19 | public _lcpy_ 20 | _lcpy_: push bp 21 | mov bp,sp 22 | 23 | push ds 24 | lds si,[bp+8] 25 | les di,[bp+4] 26 | cld 27 | _lcpy0: lodsb 28 | stosb 29 | or al,al 30 | jnz _lcpy0 31 | mov ax,di 32 | pop ds 33 | pop bp 34 | ret 35 | -------------------------------------------------------------------------------- /src/NBIND/_LMOV.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | ; 4 | ; This program is part of the DeSmet C Compiler 5 | ; 6 | ; DeSmet C is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundatation; either version 2 of the License, or any 9 | ; later version. 10 | ; 11 | ; DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | ; for more details. 15 | ; 16 | ; int _lmov(count, from_offset, from_segment, to_offset, to_segment); 17 | 18 | ; returns 0 == O.K, !0 == error 19 | 20 | cseg 21 | public _lmov_ 22 | 23 | _lmov_ : push bp 24 | mov bp,sp 25 | push ds ;save ds 26 | lds si,[bp+6] ;from 27 | les di,[bp+10] ;to 28 | 29 | mov ax,ds ; get canonical from para 30 | mov cl,4 31 | mov bx,si 32 | shr bx,cl 33 | add ax,bx 34 | jc err ; wrapped around 1M 35 | mov ds,ax 36 | and si,15 ; set canonical offset 37 | 38 | mov dx,es ; get canonical to para 39 | mov bx,di 40 | shr bx,cl 41 | add dx,bx 42 | jc err ; wrap-around 43 | mov es,dx 44 | and di,15 45 | 46 | mov cx,[bp+4] ;count 47 | mov bx,si 48 | add bx,cx ; test for room 49 | jc err 50 | mov bx,di 51 | add bx,cx 52 | jc err 53 | 54 | cmp ax,dx ;moving up ? 55 | ja domov 56 | jb movdn 57 | cmp si,di 58 | jae domov 59 | 60 | movdn: 61 | add si,cx ;change to move down 62 | sub si,2 63 | mov di,bx 64 | sub di,2 65 | shr cx,1 ;do a word move 66 | std 67 | rep movsw ;move the bytes 68 | jnc end_moved 69 | inc si 70 | inc di 71 | movsb 72 | end_moved: 73 | xor ax,ax 74 | pop ds ;restore ds 75 | pop bp 76 | ret 77 | 78 | domov: 79 | shr cx,1 ;do a word move 80 | cld 81 | rep movsw ;move the bytes 82 | jnc end_move 83 | movsb 84 | end_move: 85 | xor ax,ax 86 | pop ds ;restore ds 87 | pop bp 88 | ret 89 | 90 | err: 91 | mov ax,1 92 | pop ds 93 | pop bp 94 | ret 95 | -------------------------------------------------------------------------------- /src/OTHER/LLINK.BAT: -------------------------------------------------------------------------------- 1 | c88 %1 m 2 | if errorlevel 1 goto stop 3 | link c %1,%1,nul,c88; 4 | :stop 5 | -------------------------------------------------------------------------------- /src/OTHER/OBJ.H: -------------------------------------------------------------------------------- 1 | /* 2 | * Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | * 4 | * This program is part of the DeSmet C Compiler 5 | * 6 | * DeSmet C is free software; you can redistribute it and/or modify it 7 | * under the terms of the GNU General Public License as published by the 8 | * Free Software Foundatation; either version 2 of the License, or any 9 | * later version. 10 | * 11 | * DeSmet C is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | * for more details. 15 | */ 16 | /* OBJ.H object record types */ 17 | 18 | /* P = found in pipe. */ 19 | /* O = found in .O file. */ 20 | 21 | #define OEOF 0 /* PO end of file. */ 22 | #define OPUBLIC 1 /* O name,0, number. */ 23 | #define ORESERVE 2 /* O number, # of bytes. */ 24 | #define OLOCAL 3 /* PO number (,segment, offset in .O). */ 25 | /* the above 3 must preceed the rest in .O files */ 26 | #define ODSEG 4 /* O following in DSEG. */ 27 | #define OCSEG 5 /* O following in CSEG. */ 28 | #define ONAMEREL 6 /* PO number of extrn or local. */ 29 | #define OJUMPREL 7 /* PO number of extrn or local. */ 30 | #define OJUMP 8 /* P jump type, label number. */ 31 | #define OEVEN 9 /* P even allign */ 32 | #define OLIST 10 /* L OLIST+n bytes of object follow. */ 33 | #define OPTYPE 11 /* O name of public, type. */ 34 | #define OLTYPE 12 /* O name of local, type, offset from BP. */ 35 | #define OMTYPE 13 /* O name of public, type, offset from start. */ 36 | #define ONAME 14 /* O file name. file is now open.*/ 37 | #define OLNAME 15 /* O name of function for locals, type. */ 38 | #define OLINE 16 /* PO line number. also location in .CHK. */ 39 | #define OOV 17 /* overlay number. in .CHK only. */ 40 | #define OSTATIC 18 /* O name,0, number. */ 41 | 42 | #define OESEG 19 /* O following in ESEG */ 43 | #define OBIG 20 /* O BIG object file */ 44 | #define OLNAMEREL 21 /* PO number of extrn of local. need 4 byte fixup. */ 45 | #define OSEGPTR 22 /* O number of extrn or local. need segment 46 | fixup. */ 47 | #define OPTR 23 /* O number of extrn or local. need offset of 48 | the 4 byte pointer that is in dseg. */ 49 | #define ODFIX 24 /* O data segment fixup needed. */ 50 | #define OCFIX 25 /* O code segment fixup needed. */ 51 | 52 | /* 129 to 228 PO bytes of contents -128, contents. */ 53 | -------------------------------------------------------------------------------- /src/OTHER/OTHER.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | c88 toobj 3 | if errorlevel 1 goto stop 4 | bind toobj -otoobj 5 | if errorlevel 1 goto stop 6 | c88 dumpo 7 | if errorlevel 1 goto stop 8 | bind dumpo -odumpobj 9 | if errorlevel 1 goto stop 10 | :stop 11 | -------------------------------------------------------------------------------- /src/SEE/EXEC.O: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/the-grue/OpenDC/88499f82a54969df344fbd53bf7857c01f8f5f1c/src/SEE/EXEC.O -------------------------------------------------------------------------------- /src/SEE/MAKE.BAT: -------------------------------------------------------------------------------- 1 | echo off 2 | 3 | c88 see -px 4 | if errorlevel 1 goto oops 5 | 6 | c88 more -px 7 | if errorlevel 1 goto oops 8 | 9 | c88 wrap -px 10 | if errorlevel 1 goto oops 11 | 12 | c88 screen -px 13 | if errorlevel 1 goto oops 14 | 15 | c88 buffer -px 16 | if errorlevel 1 goto oops 17 | 18 | c88 block -px 19 | if errorlevel 1 goto oops 20 | 21 | c88 extmem -px 22 | if errorlevel 1 goto oops 23 | 24 | c88 macro -px 25 | if errorlevel 1 goto oops 26 | 27 | c88 view -px 28 | if errorlevel 1 goto oops 29 | 30 | c88 dosint -px 31 | if errorlevel 1 goto oops 32 | 33 | asm88 pcfast 34 | if errorlevel 1 goto oops 35 | 36 | asm88 move 37 | if errorlevel 1 goto oops 38 | 39 | bind see more screen wrap buffer view block extmem macro dosint move exec pcfast -os.exe 40 | 41 | :oops 42 | -------------------------------------------------------------------------------- /src/SEE/MAKEFILE: -------------------------------------------------------------------------------- 1 | $C88FLAGS -px -c 2 | 3 | s.exe [ s.o pcfast.o ] 4 | bind s pcfast -os.exe -pmap -c -_ 5 | 6 | s.o [ see.o more.o wrap.o screen.o buffer.o block.o 7 | extmem.o dosint.o move.o view.o macro.o ] 8 | lib88 see more screen wrap buffer view block extmem macro dosint move exec -os.o -n 9 | 10 | see.o [ see.c world.h ] 11 | 12 | more.o [ more.c world.h ] 13 | 14 | wrap.o [ wrap.c world.h ] 15 | 16 | screen.o [ screen.c world.h ] 17 | 18 | buffer.o [ buffer.c world.h ] 19 | 20 | block.o [ block.c world.h ] 21 | 22 | extmem.o [ extmem.c world.h ] 23 | 24 | macro.o [ macro.c world.h ] 25 | 26 | dosint.o 27 | 28 | pcfast.o 29 | 30 | move.o 31 | 32 | view.o [ view.c world.h ] 33 | -------------------------------------------------------------------------------- /src/SEE/MOVE.A: -------------------------------------------------------------------------------- 1 | ; 2 | ; Released under the GNU GPL. See http://www.gnu.org/licenses/gpl.txt 3 | ; 4 | ; This program is part of the SEE editor 5 | ; 6 | ; SEE is free software; you can redistribute it and/or modify it 7 | ; under the terms of the GNU General Public License as published by the 8 | ; Free Software Foundatation; either version 2 of the License, or any 9 | ; later version. 10 | ; 11 | ; SEE is distributed in the hope that it will be useful, but WITHOUT 12 | ; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | ; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 | ; for more details. 15 | ; 16 | ; 17 | ; (c) Copyright 1983, Michael Ouye 18 | ; 19 | ; 20 | ; C interface to the hardware string functions 21 | ; 22 | cseg 23 | public f_find_,r_find_ 24 | 25 | unc: ; put other case in ah 26 | mov ah, al 27 | cmp al, 'a' 28 | jl upc_upper 29 | cmp al, 'z' 30 | jg upc_ret 31 | sub ah, ' ' ; convert to upper case 32 | upc_ret: ret 33 | upc_upper: cmp al, 'A' 34 | jl upc_ret 35 | cmp al, 'Z' 36 | jg upc_ret 37 | add ah, ' ' 38 | ret 39 | 40 | 41 | f_find_: ;(char, target, count, casing): index 42 | pop dx ; return address 43 | pop ax ; target character 44 | pop di ; string pointer 45 | pop cx ; max count 46 | pop bx ; case ignore flag 47 | sub sp,8 ; put it back on the stack 48 | push dx 49 | mov dx,ds 50 | mov es,dx 51 | inc cx 52 | or bx,bx 53 | cld 54 | jnz ic_ffind ; use the case ignore code 55 | repnz scasb 56 | mov ax,di 57 | dec ax ; fix up value 58 | ret 59 | ic_ffind: 60 | call unc ; puts 'other' case in ah 61 | mov bx, ax 62 | mov si, di 63 | ic_floop: 64 | lodsb ; char into al, inc si 65 | cmp bl,al 66 | je ic_ffound 67 | cmp bh,al 68 | je ic_ffound 69 | loop ic_floop 70 | ic_ffound: 71 | mov ax, si 72 | dec ax 73 | ret 74 | 75 | r_find_: ;(char, target, count, casing): index 76 | pop dx ; return 77 | pop ax ; search char 78 | pop di ; target pointer 79 | pop cx ; max count 80 | pop bx ; case ignore flag 81 | sub sp,8 82 | push dx 83 | std 84 | inc cx 85 | or bx,bx 86 | jnz ic_rfind 87 | mov bx,ds 88 | mov es,bx 89 | repnz scasb 90 | mov ax,di 91 | inc ax ; fix up value 92 | ret 93 | ic_rfind: 94 | call unc 95 | mov bx,ax 96 | mov si, di 97 | ic_rloop: 98 | lodsb ; char into al, dec si 99 | cmp bl,al 100 | je ic_rfound 101 | cmp bh,al 102 | je ic_rfound 103 | loop ic_rloop 104 | ic_rfound: 105 | mov ax, si 106 | inc ax 107 | ret 108 | 109 | 110 | -------------------------------------------------------------------------------- /src/SRC/CLOCK.C: -------------------------------------------------------------------------------- 1 | #include "graphics.h" 2 | 3 | Point minHand[360], hrHand[360], ctr, arcPoint(); 4 | 5 | int facer, /* clock face radius */ 6 | markr, /* clock mark radius */ 7 | hrr, /* hour hand radius */ 8 | hrs,mins, secs, /* current time */ 9 | hndx, mndx, sndx; /* time index 0..359 */ 10 | 11 | char ctime[9]; 12 | char blanks[] = " "; 13 | 14 | showtime(){ 15 | char ntime[9]; 16 | int nhrs, nmins, nsecs, nhndx, nmndx, nsndx; 17 | 18 | do 19 | times(ntime); 20 | while(strcmp(ntime, ctime) == 0); 21 | 22 | if((nhrs = atoi(ntime)) > 12) 23 | nhrs -= 12; 24 | nmins = atoi(&ntime[3]); 25 | nsecs = atoi(&ntime[6]); 26 | 27 | nhndx = (nhrs * 30) + (nmins >> 1); 28 | nmndx = (nmins * 6) + (nsecs / 10); 29 | nsndx = nsecs * 6; 30 | 31 | if(nsndx != sndx) 32 | line(ctr, minHand[sndx], 0); 33 | line(ctr, minHand[nsndx], 1); 34 | 35 | if(nmndx != mndx) 36 | line(ctr, minHand[mndx], 0); 37 | line(ctr, minHand[nmndx], 2); 38 | 39 | if(nhndx != hndx) 40 | line(ctr, hrHand[hndx], 0); 41 | line(ctr, hrHand[nhndx], 3); 42 | 43 | hndx = nhndx; 44 | mndx = nmndx; 45 | sndx = nsndx; 46 | strcpy(ctime, ntime); 47 | locate(1,1); 48 | scr_puts(ntime); 49 | } 50 | 51 | main(){ 52 | int i, a; 53 | 54 | screen(1); 55 | color(0,1); 56 | color(1,0); 57 | Fg(1); 58 | PSET; 59 | 60 | facer = scr_maxy >> 1; 61 | markr = (facer * 90) / 100; 62 | hrr = facer >> 1; 63 | 64 | ctr.x = scr_maxx >> 1; 65 | ctr.y = scr_maxy >> 1; 66 | 67 | for(i = 359, a = 91; i >= 0; i--, a++) { 68 | minHand[i] = arcPoint(ctr, markr, a); 69 | hrHand[i] = arcPoint(ctr, hrr, a); 70 | } 71 | arc(ctr, facer, 1, 0, 360); 72 | 73 | for(a = 0; a < 360; a += 30) 74 | line(arcPoint(ctr, markr, a), arcPoint(ctr, facer, a), 1); 75 | 76 | times(ctime); 77 | 78 | if((hrs = atoi(ctime)) > 11) 79 | hrs -= 12; 80 | mins = atoi(&ctime[3]); 81 | secs = atoi(&ctime[6]); 82 | 83 | hndx = (hrs * 30) + (mins >> 1); 84 | mndx = (mins * 6) + (secs / 10); 85 | sndx = secs * 6; 86 | 87 | line(ctr, minHand[sndx], 1); 88 | line(ctr, minHand[mndx], 2); 89 | line(ctr, hrHand[hndx], 3); 90 | 91 | while(csts() == 0) 92 | showtime(); 93 | screen(0); 94 | width(80); 95 | } 96 | 97 | -------------------------------------------------------------------------------- /src/SRC/DUMP.C: -------------------------------------------------------------------------------- 1 | /* dump.c core style dump of a file */ 2 | 3 | /* usage: A>DUMP B:BLIP.O */ 4 | 5 | # include 6 | 7 | char buffer[4096]; 8 | 9 | main(argc,argv) 10 | int argc; 11 | char *argv[]; { 12 | unsigned i,numin,tot,file; 13 | int cfrom; 14 | 15 | if (argc < 2) { 16 | puts("Missing Filename"); 17 | exit(1); 18 | } 19 | 20 | tot=0; 21 | if ((file=open(argv[1],0)) == -1) { 22 | fputs("Cannot Open ", stdout); 23 | puts(argv[1]); 24 | exit(1); 25 | } 26 | 27 | /* read and dump 4k at a time */ 28 | 29 | do { 30 | numin=read(file,buffer,4096); 31 | if (numin == -1) { 32 | fputs("Cannot Read ", stdout); 33 | puts(argv[1]); 34 | exit(1); 35 | } 36 | cfrom=0; 37 | while (cfrom < numin) { 38 | 39 | /* print the offset in hex */ 40 | 41 | ohw(cfrom+tot); 42 | putc(' ', stdout); 43 | 44 | /* print 16 bytes in hex */ 45 | 46 | for (i=0; i < 16; i++) { 47 | putc(i == 8 ? '-' :' ', stdout); 48 | ohb(buffer[cfrom++]); 49 | } 50 | cfrom-=16; 51 | putc(' ', stdout); 52 | putc('*', stdout); 53 | 54 | /* print the bytes in ascii */ 55 | 56 | for (i=0; i < 16; i++) { 57 | putc((buffer[cfrom] >= ' ' && buffer[cfrom] < 0x7f) 58 | ? buffer[cfrom]: '.', stdout); 59 | cfrom++; 60 | } 61 | puts("*"); 62 | } 63 | tot+=numin; 64 | } 65 | while (numin == 4096); 66 | } 67 | 68 | /* print a word in hex */ 69 | 70 | ohw(wrd) 71 | unsigned wrd; { 72 | ohb(wrd>>8); 73 | ohb(wrd); 74 | } 75 | 76 | /* print a byte in hex */ 77 | 78 | ohb(byt) 79 | char byt; { 80 | onib(byt>>4); 81 | onib(byt); 82 | } 83 | 84 | /* print a nibble as a hex character */ 85 | 86 | onib(nib) 87 | char nib; { 88 | 89 | nib&=15; 90 | putc((nib >= 10) ? nib-10+'A': nib+'0', stdout); 91 | } 92 | -------------------------------------------------------------------------------- /src/SRC/FLIP.A: -------------------------------------------------------------------------------- 1 | ; FLIP.A -- code to flip the screen. This version for the PC. 2 | 3 | VIDEO equ 10h 4 | 5 | dseg 6 | public flipok_ 7 | flipok_ db 1 ;flag to say flip is supported 8 | 9 | screen_save dw 0 10 | screen_at dw 0 11 | screen_len dw 0 12 | curmode db 0 13 | curpage db 0 14 | curloc dw 0 15 | addr_6845 dw 3D4H 16 | 17 | 18 | cseg 19 | public scr_clr_ 20 | 21 | ; FLIPINIT -- initilize for flipping the screen. 22 | ; paragraphs needed for screen image = flipinit(); 23 | 24 | public flipinit_ 25 | flipinit_: 26 | push bp 27 | mov screen_save,ds 28 | mov ah,15 29 | int VIDEO 30 | cmp al,7 ;monocrome ? 31 | jz monoinit 32 | mov screen_at,0b800h ;16k screen at b800 33 | mov screen_len,1024*8 34 | mov ax,1024 ;paragraphs needed to save 35 | pop bp 36 | ret 37 | 38 | monoinit: 39 | mov addr_6845,03b4h ;base of 6845 40 | mov screen_at,0b000h ;4k screen at b000 41 | mov screen_len,1024*2 42 | mov ax,256 ;paras needed to save 43 | pop bp 44 | ret 45 | 46 | 47 | 48 | 49 | 50 | ; SCR_SAVE -- save the screen. use screen_at. 51 | 52 | public scr_save_ 53 | scr_save_: 54 | push bp 55 | mov bp,sp 56 | mov ah,15 57 | int VIDEO 58 | mov curmode,al 59 | mov curpage,bh 60 | mov ah,3 61 | int VIDEO 62 | mov curloc,dx 63 | 64 | call disable_video 65 | push ds 66 | mov es,screen_save ;save the screen 67 | mov cx,screen_len 68 | mov ds,screen_at ;from here 69 | xor si,si 70 | mov di,si 71 | cld 72 | rep movsw 73 | pop ds 74 | call enable_video 75 | mov al,curmode 76 | cmp al,7 ;dont set monocrome mode 77 | jz clear_only 78 | cmp al,3 79 | jz clear_only 80 | mov ah,0 81 | mov al,3 82 | int VIDEO 83 | jmp saved 84 | clear_only: 85 | call scr_clr_ 86 | saved: pop bp 87 | ret 88 | 89 | 90 | ; SCR_REST -- restore the screen. use screen_at. 91 | 92 | public scr_rest_ 93 | scr_rest_: 94 | push bp 95 | mov bp,sp 96 | mov al,curmode 97 | cmp al,7 98 | jz dorest 99 | mov ah,0 100 | int VIDEO ;restore the mode 101 | dorest: 102 | call disable_video 103 | push ds 104 | mov es,screen_at ;restore the screen 105 | mov cx,screen_len 106 | mov ds,screen_save ;to here 107 | xor si,si 108 | mov di,si 109 | cld 110 | rep movsw 111 | pop ds 112 | call enable_video 113 | mov ah,5 114 | mov al,curpage 115 | int VIDEO 116 | mov ah,2 117 | mov bh,curpage 118 | mov dx,curloc 119 | int VIDEO 120 | pop bp 121 | ret 122 | 123 | disable_video: ; turn the screen refresh off 124 | mov dx,addr_6845 125 | add dx,4 126 | mov al,25H 127 | out dx,al ; disable video 128 | ret 129 | 130 | enable_video: ; set crt mode 131 | mov dx,addr_6845 132 | add dx,4 133 | mov bx,40H 134 | mov es,bx 135 | mov al,es:[65H] ; crt_mode_set 136 | out dx,al ; restore video 137 | ret 138 | 139 | 140 | -------------------------------------------------------------------------------- /src/SRC/LATER.C: -------------------------------------------------------------------------------- 1 | /* LATER.C -- Exit with a 1 if any file has a higher create 2 | date than the last or if the last file does not exist. 3 | A 2 is returned if any other files do not exist. 4 | Later only works on MS-DOS V2.0. 5 | 6 | A>LATER FILE1.C FILE1.O 7 | Later will set completion code to 1 if FILE1.C was 8 | created after FILE1.O. 9 | 10 | A>LATER FILE1.C FILE1.H FILE1.O 11 | Later will set completion code to 1 if FILE1.C or 12 | FILE1.H was created after FILE1.O. */ 13 | 14 | 15 | 16 | main(argc,argv) 17 | int argc; 18 | char *argv[]; { 19 | 20 | unsigned ifile,ofile,i; 21 | long odate,dateof(); 22 | 23 | puts("LATER V1.0 "); 24 | 25 | if (argc < 3 ) { 26 | puts("need two or more arguments"); 27 | exit(0); 28 | } 29 | 30 | if ((ofile=open(argv[argc-1],0)) == -1) 31 | exit(1); /* the last file does not exist */ 32 | 33 | odate=dateof(ofile); 34 | close(ofile); 35 | 36 | /* for each file see if it is later than the last one */ 37 | 38 | for (i=1; i < argc-1; i++) { 39 | if ((ifile=open(argv[i],0)) == -1) { 40 | puts(argv[i]); 41 | puts(" does not exist"); 42 | exit(2); /* an early file does not exist */ 43 | } 44 | if (dateof(ifile) > odate) exit(1); /* found a later file */ 45 | close(ifile); 46 | } 47 | 48 | /* none of the files are later. set completion code of zero */ 49 | 50 | exit(0); 51 | } 52 | 53 | 54 | /* return a long encoding the date and time of a file */ 55 | 56 | long dateof(fil) 57 | int fil; { 58 | static long ret_dt; 59 | 60 | #asm 61 | mov bx,[bp+4] ;file handle is here. only argument. 62 | and bx,0ffh ;low byte of file id is MS-DOS handle. 63 | mov al,0 ;code to retrieve date and time. 64 | mov ah,57h ;dos code for get file date and time. 65 | int 21h ;call dos. 66 | mov word dateof_ret_dt_+2,dx;store date in high word of ret_dt. 67 | mov word dateof_ret_dt_,cx ;store time in low word of ret_dt. 68 | ;note: "dateof_" is added to name 69 | ;because ret_dt is static. 70 | # 71 | return ret_dt; 72 | } 73 | -------------------------------------------------------------------------------- /src/SRC/RUBRBAND.C: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define UpChar 30 4 | #define DownChar 31 5 | #define LeftChar 29 6 | #define RightChar 28 7 | #define InsChar 206 8 | #define DelChar 207 9 | 10 | 11 | static 12 | cursor(x, y, c) 13 | int x, y, c; 14 | { 15 | line(x, y-1, x, y-3, c); 16 | line(x, y+1, x, y+3, c); 17 | line(x-3, y, x-1, y, c); 18 | line(x+1, y, x+3, y, c); 19 | } 20 | 21 | main() 22 | { 23 | int xb, yb, xc, yc; 24 | char c; 25 | 26 | scr_setup(); 27 | scr_cursoff(); 28 | scr_setmode( 4 ); 29 | scr_clr(); 30 | scr_color(0,1); 31 | scr_color(1,0); 32 | 33 | cursor(3, 3, 1); 34 | 35 | xb = yb = xc = yc = 3; 36 | 37 | while(( c = scr_ci()) != ' ') 38 | { 39 | switch(c) 40 | { 41 | case UpChar: 42 | if ( xb != xc || yb != yc) 43 | line(xb, yb, xc, yc, 0x82); 44 | cursor(xc, yc, 0x81); 45 | if ((yc-=8) < 3) 46 | yc = 3; 47 | line(xb, yb, xc, yc, 0x82); 48 | cursor(xc, yc, 0x81); 49 | break; 50 | case DownChar: 51 | if ( xb != xc || yb != yc) 52 | line(xb, yb, xc, yc, 0x82); 53 | cursor(xc, yc, 0x81); 54 | if ((yc+=8) > 195) 55 | yc = 195; 56 | line(xb, yb, xc, yc, 0x82); 57 | cursor(xc, yc, 0x81); 58 | break; 59 | case LeftChar: 60 | if ( xb != xc || yb != yc) 61 | line(xb, yb, xc, yc, 0x82); 62 | cursor(xc, yc, 0x81); 63 | if ((xc-=8) < 4) 64 | xc = 4; 65 | line(xb, yb, xc, yc, 0x82); 66 | cursor(xc, yc, 0x81); 67 | break; 68 | case RightChar: 69 | if ( xb != xc || yb != yc) 70 | line(xb, yb, xc, yc, 0x82); 71 | cursor(xc, yc, 0x81); 72 | if ((xc+=8) > 315) 73 | xc = 315; 74 | line(xb, yb, xc, yc, 0x82); 75 | cursor(xc, yc, 0x81); 76 | break; 77 | case InsChar: 78 | cursor(xc, yc, 0x81); 79 | line(xb, yb, xc, yc, 1); 80 | cursor(xc, yc, 0x81); 81 | xb = xc; 82 | yb = yc; 83 | break; 84 | default: 85 | beep(); 86 | } 87 | } 88 | 89 | scr_setmode( 3 ); 90 | scr_curson(); 91 | scr_clr(); 92 | } 93 | -------------------------------------------------------------------------------- /src/SRC/STUB.ASM: -------------------------------------------------------------------------------- 1 | ; STUB.ASM demonstrates segment controls needed 2 | ; to link MASM code to C88 with -M option. 3 | ; Called with hello();. 4 | 5 | ; notes: if you wish to start with an assembler module, there 6 | ; must be a public entry point of MAIN_ in the PROG segment. This 7 | ; is the starting point. 8 | 9 | ; PUBLIC and EXTRN statements should be in the same segment 10 | ; as the item is actually defined in. 11 | 12 | ; To communicate with a C program or the libraries, the 13 | ; GROUP and SEGMENT statements should be exactly as described. 14 | ; Remember that the supplied C.OBJ must be LINKed 15 | ; first. This is needed both to set up a stack and to 16 | ; establish the correct groups. 17 | 18 | ; The offset operator should always be followed by the 19 | ; GROUP name or you are likely to end up with the offset 20 | ; within the segment and not the group. See the example below. 21 | 22 | DGROUP GROUP DATA,UDATA 23 | 24 | PGROUP GROUP PROG 25 | 26 | PROG SEGMENT BYTE PUBLIC 'PROG' 27 | ASSUME CS:PGROUP,DS:DGROUP 28 | 29 | PUBLIC HELLO ;NOTE: ALTHOUGH C88 USES A TRAILING 30 | ;UNDERSCORE ON PUBLICS, THESE ARE 31 | ;DELETED IN .OBJ FORMAT. 32 | EXTRN PUTS:NEAR 33 | 34 | HELLO: MOV AX,OFFSET DGROUP:HELLO_MSG 35 | PUSH AX 36 | CALL PUTS 37 | POP AX 38 | RET 39 | PROG ENDS 40 | 41 | 42 | 43 | DATA SEGMENT WORD PUBLIC 'DATA' 44 | HELLO_MSG DB 'Hello World!!',13,10,0 45 | DATA ENDS 46 | 47 | ; ALL DATA IN UDATA WILL BE ZEROED OUT AT RUN TIME. 48 | 49 | UDATA SEGMENT WORD PUBLIC 'UDATA' 50 | BUFFER DB 100 DUP (?) 51 | UDATA ENDS 52 | END 53 | -------------------------------------------------------------------------------- /src/SRC/TGETPUT.C: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | main() 4 | { 5 | FORM *fp, *createForm(); 6 | char *cp; 7 | int i, j; 8 | 9 | screen(2); 10 | circle(50,50,25,1); 11 | paint(50,50,1,1); 12 | 13 | if((fp = createForm(100,100)) == 0) 14 | { 15 | puts("cannot open FORM\n"); 16 | exit(1); 17 | } 18 | 19 | get(0, 0, 99, 99, fp); 20 | put(100, 100, fp); 21 | scr_ci(); /* wait for key to proceed */ 22 | 23 | screen(1); 24 | circle(50,50,25,2); 25 | paint(50,50,1,2); 26 | 27 | if((fp = createForm(160,100)) == 0) 28 | { 29 | puts("cannot open FORM\n"); 30 | exit(1); 31 | } 32 | 33 | get(0, 0, 159, 99, fp); 34 | put(100, 100, fp); 35 | scr_ci(); 36 | 37 | screen(0, Burst(1)); 38 | width(80) -------------------------------------------------------------------------------- /src/SRC/TXDRAW.C: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | char A[]="M+2,-1M+2,-1M+3,-1R7"; /* U L CORNER */ 4 | char B[]="R3M+2,1M+1,1D2"; /* U R CORNER */ 5 | char C[]="M-1,1M-2,2M-2,1M-3,1M-3,1L4"; /* L R CORNER */ 6 | char D[]="L3M-3,-1M-2,-1M-1,-1U1M+1,-1";/* L L CORNER */ 7 | char L[]="NM320,182C0NM320,182C1"; /* LASER ORIGIN POINT */ 8 | char LL[]="NM320,182NU4ND5NL10NR10NE4NF5NG5NH4C0NM320,182NU4ND5NL10NR10NE4NF5NG5NH4C1"; /* SPARKLER ON END OF LASER */ 9 | 10 | main() 11 | { 12 | screen(2); 13 | cls(); 14 | locate(25,17); 15 | scr_printf("(C) Copyright COMPAQ Computer Corporation 1982, 83"); 16 | 17 | /* "C" */ 18 | draw("BM300,2;X",LL,"R21;X",L,"M-7,7;X",L,"L17;X",L,"M-10,10;X",L, 19 | "R17;X",L,"M-6,6;X",L,"L18;X",D,L,"M+15,-15;X",L,A,L, 20 | "R20M-7,7L17M-10,10R17M-6,6L18;X",D,"M+15,-15;X",A,0L); 21 | 22 | /* "O" */ 23 | draw("BM334,2",LL,"R21",L,B,L,"M-13,13",L,C,L, 24 | "L17",L,D,L,"M+15,-15",L,A,L,"BM-3,6",L, 25 | "R11",L,"M-11,11",L,"L11",L,"M+11,-11",L, 26 | "M-11,11R11M+11,-11L11BM334,2R21",B,"M-13,13",C,"L17",D, 27 | "M+15,-15",A,0L); 28 | 29 | /* "M" */ 30 | draw("BM379,2",LL,"R37",L,B,L,"M-19,19",L,"L14",L, 31 | "M+17,-17",L,"L7",L,"M-17,17",L,"L14",L,"M+17,-17",L, 32 | "NM-17,17L7",L,"M-17,17",L,"L14",L,"M+20,-20",L,A, 33 | "R35",B,"M-19,19L14M+17,-17L7M-17,17L14M+17,-17L7M-17,17L14",0L); 34 | 35 | /* "P" */ 36 | draw("BM440,2",LL,"R20",L,B,L,"M-7,7",L,C,L, 37 | "L11",L,"M+5,-5",L,"R7",L,"M+6,-6",L,"L12",L,"M-17,17",L, 38 | "L14",L,"M+20,-20",L,A,L,0L); 39 | 40 | /* REDRAW UPPER "P" */ 41 | draw("BM440,2R20",B,"M-7,+7",C, 42 | "L11M+5,-5R7M+6,-6L12M-17,17L14M+20,-20",A,0L); 43 | 44 | /* "A" */ 45 | draw("BM485,2",LL,"R17",L,"M-6,23",L,"L14",L,"M+1,-4L9",L, 46 | "M+7,-5",L,"R4",L,"M+2,-6",L,"M-23,+15",L,"L17",L, 47 | "M+37,-23",L,"M-37,23R17M+23,-15M-2,6L4M-7,5R9;",0L); 48 | 49 | /* "Q" */ 50 | draw("BM530,2",LL,"R20",L,B,L,"M-13,13",L,"R10",L, 51 | "M-6,6",L,"L36",L,D,L,"M+15,-15",L, 52 | "M-15,15BM+15,-15",A,L,"BM-3,6",L,"R11",L,"M-11,11",L, 53 | "L11",L,"M+11,-11",L,"M-11,11BM530,2R20",B, 54 | "M-13,13R10M-6,6L36",D,0L); 55 | 56 | /* UNDERLINE */ 57 | draw("BM140,30",LL,"R402",LL,"L402R402M-6,6",LL, 58 | "M+6,-6M-6,6L402",LL,"M+6,-6",LL,"BM140,30;R402M-6,6L402M+6,-6;",0L); 59 | 60 | /* PAINT TOP PART OF LOGO */ 61 | paint(291,6,1,1); 62 | paint(354,6,1,1); 63 | paint(400,6,1,1); 64 | paint(460,6,1,1); 65 | paint(488,6,1,1); 66 | paint(488,6,1,1); 67 | paint(550,6,1,1); 68 | paint(450,34,1,1); 69 | 70 | /* TRADEMARK */ 71 | draw("BM587,03",LL,0L); 72 | locate(1,73); 73 | scr_printf("T"); 74 | draw("BM590,03",LL,0L); 75 | locate(1,73); 76 | scr_printf("TM"); 77 | ci(); 78 | screen(0); 79 | width(80); 80 | } 81 | -------------------------------------------------------------------------------- /src/TOOLS/ENVIRON.C: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | This file contains the routine for searching the environment 4 | area for a given string. 5 | 6 | Interface: 7 | 8 | environ(search_str, buffer, buf_len) 9 | 10 | where search_str is the actual string being searched for, 11 | buffer is the location to store the string if found, 12 | buf_len is the maximum number of characters to store 13 | into the buffer (includes terminator). 14 | 15 | -1 is returned if the environment variable isn't found, 16 | otherwise the length of the string copied is returned. 17 | */ 18 | 19 | extern unsigned _pcb; /* c88 variable with the PSP segment */ 20 | 21 | int environ(search_str, buffer, buf_len) 22 | char *search_str, *buffer; int buf_len; { 23 | 24 | #asm 25 | 26 | mov ax, _pcb_; ; get the env segment into ES 27 | mov es, ax ; 28 | mov ax, es:[2CH] 29 | mov es,ax 30 | 31 | mov bx, [6][bp] ; buffer 32 | mov byte[bx],0 33 | mov si, 0 ; offset into the environment 34 | jmp outer_begin 35 | 36 | outer_loop: 37 | inc si 38 | outer_begin: 39 | mov di, [4][bp] ; search_str 40 | cmp byte es:[si],0 41 | jne cmp_loop 42 | ; not found 43 | mov ax,-1 44 | pop bp 45 | ret 46 | 47 | cmp_loop: 48 | mov al, byte es:[si] ; pick up the search character 49 | cmp al,'=' 50 | je end_str 51 | cmp al, byte[di] 52 | jne outer_next 53 | inc si 54 | inc di 55 | jmp cmp_loop 56 | 57 | end_str: 58 | cmp byte[di], 0 59 | jne outer_next 60 | ; got it, copy them bytes! 61 | mov cx, [8][bp] ; buf_len 62 | inc si ; beyond the '=' 63 | 64 | move_loop: 65 | mov al, byte es:[si] 66 | or al,al 67 | jz now_return 68 | dec cx 69 | jz now_return 70 | mov byte[bx],al 71 | inc si 72 | inc bx 73 | jmp move_loop 74 | 75 | now_return: 76 | mov byte[bx],0 77 | mov ax, [8][bp] 78 | sub ax, cx 79 | pop bp 80 | ret 81 | 82 | outer_next: 83 | cmp byte es:[si],0 ; skip to the next entry 84 | je outer_loop 85 | inc si 86 | jmp outer_next 87 | # 88 | } 89 | -------------------------------------------------------------------------------- /src/TOOLS/FASTSCR.DOC: -------------------------------------------------------------------------------- 1 | 2 | 3 | FASTSCR: Fast screen 4 | 5 | This is a simple program to make character output to the screen run 6 | faster than the standard IBM-PC BIOS routines. It works by 7 | intercepting the level 16 interrupts (int 10H) and routing the 8 | character output(write tty) requests to code which acts directly on 9 | the screen buffer. Requests which are not supported are passed on 10 | to the normal BIOS routine. 11 | 12 | Works for all programs which use the BIOS calls or DOS calls. 13 | 14 | 15 | To install the program, simply run 16 | 17 | fastscr 18 | 19 | -------------------------------------------------------------------------------- /src/TOOLS/FINDFILE.C: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | This file contains the routine to locate a file, utilizing the PATH 4 | environment variable for the directories to search. 5 | 6 | Interface: 7 | 8 | findfile(filename, target_buf) 9 | 10 | where filename is the name of the file to be searched for, 11 | target_buf is the buffer to place the path name if found. 12 | 13 | if the file is found, findfile return 1 and the pathname, 14 | otherwise it returns 0. 15 | 16 | This program uses the environ routines to access the PATH variable. 17 | 18 | Stack requirements: ~300 bytes 19 | 20 | */ 21 | 22 | findfile(filename, target_buf) 23 | char *filename, *target_buf; { 24 | int fid; 25 | char paths[256], *p_ptr, *t_ptr; 26 | 27 | /* first check in the local directory */ 28 | strcpy(target_buf, filename); 29 | fid = open(target_buf, 0); 30 | if (fid >= 0) { /* got it */ 31 | close(fid); 32 | return (1); 33 | } 34 | fid = environ("PATH", paths, 256); 35 | p_ptr = paths; 36 | 37 | while (*p_ptr != 0) { 38 | /* copy the directory name */ 39 | t_ptr = target_buf; 40 | while (*p_ptr != ';' && *p_ptr != 0) { 41 | *t_ptr++ = *p_ptr++; 42 | } 43 | if (*(t_ptr-1) != '/' && *(t_ptr-1) != '\\') *t_ptr++ = '\\'; 44 | *t_ptr = 0; 45 | if (*p_ptr) p_ptr++; /* beyond the ';' */ 46 | strcat(target_buf, filename); 47 | fid = open(target_buf, 0); 48 | if (fid >= 0) { /* got it */ 49 | close(fid); 50 | return (1); 51 | } 52 | } 53 | strcpy(target_buf, filename); 54 | return (0); /* can't find one */ 55 | } 56 | -------------------------------------------------------------------------------- /src/TOOLS/FREE.C: -------------------------------------------------------------------------------- 1 | /* 2 | * free: prints the amount of free space available on the indicated disk 3 | * 4 | * written by Michael Ouye 8/21/84. 5 | * the-grue - 20180825 6 | * Modified code to accurately display output 7 | * 8 | */ 9 | 10 | unsigned avail, total, sectors, bytes; 11 | 12 | long int free(device) 13 | int device; { 14 | 15 | #asm 16 | mov dl, byte [bp+4] ; device 17 | mov ah, 36H 18 | int 21H 19 | cmp AX,0FFFFH 20 | jne over 21 | mov DX,0FFFFH ; return -1 if bad device 22 | pop bp 23 | ret 24 | over: 25 | mov word avail_,bx 26 | mov word total_,dx 27 | mov word sectors_,ax 28 | mov word bytes_,cx 29 | # 30 | return ((long)avail * (long)sectors * (long)bytes); 31 | } 32 | 33 | main(argc, argv) 34 | int argc; char *argv[]; { 35 | long int how_much; 36 | int device; 37 | 38 | 39 | argv++; 40 | if (argc <= 1) 41 | device = 0; 42 | else 43 | device = toupper(**argv) - '@'; 44 | 45 | how_much = free(device); 46 | if (how_much == -1L) { 47 | puts("bad device\n"); 48 | exit(1); 49 | } 50 | printf("%lu bytes available\n", how_much); 51 | exit(0); 52 | } 53 | -------------------------------------------------------------------------------- /src/TOOLS/FREE.DOC: -------------------------------------------------------------------------------- 1 | 2 | 3 | FREE: free space display 4 | 5 | 6 | free is a very simple program to show the amount of free space 7 | left on a drive without having to watch a directory listing. The 8 | syntax for free is: 9 | 10 | free 11 | 12 | where is A: B: ... 13 | -------------------------------------------------------------------------------- /src/TOOLS/GREP.DOC: -------------------------------------------------------------------------------- 1 | 2 | 3 | GREP: a file search utility. 4 | 5 | 6 | grep is a program used to search files for lines containing a 7 | certain pattern. Whenever the pattern is found, the line is 8 | listed on the screen. The syntax for grep is: 9 | 10 | grep [ -y ] file ... 11 | 12 | where -y indicates that case is to be ignored during the search. 13 | 14 | is any sequence of characters. It may 15 | contain the wildcard characters * and ?. NOTE: if the 16 | pattern contains blanks or wildcard characters, then the 17 | search pattern must be enclosed with double quotes ("). 18 | 19 | file is any filename and may contain wildcard characters. 20 | 21 | When a match is found, grep will display the line along with the 22 | line number a filename. 23 | -------------------------------------------------------------------------------- /src/TOOLS/LS.DOC: -------------------------------------------------------------------------------- 1 | 2 | 3 | LS: a directory listing program 4 | 5 | 6 | ls is a directory listing program loosely based on the UNIX utility. 7 | It features multiple-column listing, sort by name or modification 8 | date and reverse order sorting. The syntax for running ls is: 9 | 10 | ls [ -ltr1? ] [ pathname ... ] 11 | 12 | where pathname can be a drive name ( C: ), a directory name, or a 13 | filename which may contain the wildcard search characters * 14 | and ?. If no pathname is given, the current directory is 15 | assumed. 16 | 17 | -l invokes the long format which is a single column listing 18 | with the following format: 19 | 20 |