├── F ├── 28DEC97 ├── ASM.DOC ├── EDITOR.DOC ├── EDLIN.DOC ├── FORTH.COM ├── MULTI.DOC ├── FORTH-F.COM ├── INSTALL.COM ├── INSTALL.DTA ├── README.md ├── READ.ME ├── CRCKLIST.CRC ├── MEMORY.MAC ├── COMPARE.MAC ├── BENCH.SCR ├── STACK.MAC ├── NUMBER.MAC ├── STRING.MAC ├── STRINGS.SCR ├── BLK2TXT.SCR ├── COPY.SCR ├── OVERLAY.SCR └── TXT2BLK.SCR ├── C ├── .gitignore ├── C.LIB ├── M.LIB ├── T.LIB ├── AS.COM ├── CC.COM ├── CC.MSG ├── LN.COM ├── ROM.LIB ├── SETJMP.H ├── FCNTL.H ├── ERRNO.H ├── HELLO.C ├── MATH.H ├── ECHO.C ├── README.md ├── CTYPE.H ├── SGTTY.H ├── LIBC.H ├── STDIO.H ├── IO.H └── DUMP.C ├── A ├── S.COM ├── A1.COM ├── ASM.COM ├── BE.COM ├── DDT.COM ├── DUMP.COM ├── ED.COM ├── FU.COM ├── LOAD.COM ├── STAT.COM ├── PAUSE.COM ├── SLASH.COM ├── SUBMIT.COM ├── AUTOEXEC.SUB ├── HELLO.ASM ├── PAUSE.ASM ├── README.md └── SLASH.ASM ├── E ├── WS.COM ├── WS.INS ├── WSU.COM ├── WSMSGS.OVR ├── WINSTALL.COM ├── WSOVLY1.OVR └── README.md ├── G ├── LIFE.COM ├── HITCH.COM ├── PLANET.COM ├── ZORK1.COM ├── ZORK1.DAT ├── ZORK2.COM ├── ZORK2.DAT ├── ZORK3.COM ├── ZORK3.DAT ├── GORILLA.COM ├── HITCHHIK.DAT ├── LEATHER.COM ├── LEATHER.DAT ├── LIHOUSE.COM ├── LORDTIME.COM ├── PLANETFA.DAT └── README.md ├── H ├── ASM.HLP ├── BDOS.HLP ├── BIOS.HLP ├── CPM.HLP ├── ED.HLP ├── EX.HLP ├── HELP.COM ├── HELP.HLP ├── NULU.HLP ├── PIP.HLP ├── STAT.HLP ├── BASCOM.HLP ├── CBASIC.HLP ├── EBASIC.HLP ├── MLOAD.HLP ├── RATFOR.HLP ├── SWEEP.HLP ├── XLATE.HLP ├── Z80MR.HLP ├── ZDASM.HLP ├── CBASIC2.HLP ├── README.md ├── UNCR.HLP ├── Z8E.HLP ├── VDE.HLP ├── LINK.HLP ├── ASM2.HLP ├── TURBOPAS.HLP └── CATLOG.HLP ├── M ├── cc.com ├── zsm.com ├── ccopt.com ├── hello.com ├── hextocom.com ├── stdbool.h ├── hello.c ├── rand.h ├── z80.h ├── qsort.h ├── bsearch.h ├── printf.h ├── README.md ├── atexit.h ├── setjmp.h ├── make_cc.c ├── c_string.c ├── sprintf.h ├── fprintf.h ├── redir.h ├── mem.h ├── c_iocon.c ├── c_iofile.c ├── ctype.h ├── string.h ├── alloc.h ├── conio.h └── c_error.c ├── P ├── READ.ME ├── MCDEMO.MCS ├── TINST.COM ├── TINST.DTA ├── TURBO.COM ├── TURBO.OVR ├── HELLO.PAS ├── CMDLIN.PAS ├── MC-MOD00.INC ├── MC-MOD01.INC ├── TURBO.MSG ├── README.md ├── MC-MOD02.INC ├── TINST.MSG ├── MC-MOD03.INC └── MC.HLP ├── B ├── MBASIC.COM ├── OBASIC.COM ├── STARS.BAS ├── TBASIC.COM ├── BBCBASIC.COM ├── CONVERT.COM ├── ASM.BBC ├── COLOR.BAS ├── VT100.BAS └── README.md ├── I ├── RNDTST.COM ├── zexall.com ├── zexdoc.com ├── README.md └── RNDTST.ASM ├── L ├── XLISP.COM └── README.md └── README.md /F/28DEC97: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /C/.gitignore: -------------------------------------------------------------------------------- 1 | *.O 2 | *.ASM 3 | -------------------------------------------------------------------------------- /A/S.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/S.COM -------------------------------------------------------------------------------- /C/C.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/C.LIB -------------------------------------------------------------------------------- /C/M.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/M.LIB -------------------------------------------------------------------------------- /C/T.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/T.LIB -------------------------------------------------------------------------------- /A/A1.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/A1.COM -------------------------------------------------------------------------------- /A/ASM.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/ASM.COM -------------------------------------------------------------------------------- /A/BE.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/BE.COM -------------------------------------------------------------------------------- /A/DDT.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/DDT.COM -------------------------------------------------------------------------------- /A/DUMP.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/DUMP.COM -------------------------------------------------------------------------------- /A/ED.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/ED.COM -------------------------------------------------------------------------------- /A/FU.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/FU.COM -------------------------------------------------------------------------------- /A/LOAD.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/LOAD.COM -------------------------------------------------------------------------------- /A/STAT.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/STAT.COM -------------------------------------------------------------------------------- /C/AS.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/AS.COM -------------------------------------------------------------------------------- /C/CC.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/CC.COM -------------------------------------------------------------------------------- /C/CC.MSG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/CC.MSG -------------------------------------------------------------------------------- /C/LN.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/LN.COM -------------------------------------------------------------------------------- /C/ROM.LIB: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/C/ROM.LIB -------------------------------------------------------------------------------- /E/WS.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/E/WS.COM -------------------------------------------------------------------------------- /E/WS.INS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/E/WS.INS -------------------------------------------------------------------------------- /E/WSU.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/E/WSU.COM -------------------------------------------------------------------------------- /F/ASM.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/ASM.DOC -------------------------------------------------------------------------------- /G/LIFE.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/LIFE.COM -------------------------------------------------------------------------------- /H/ASM.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/ASM.HLP -------------------------------------------------------------------------------- /H/BDOS.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/BDOS.HLP -------------------------------------------------------------------------------- /H/BIOS.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/BIOS.HLP -------------------------------------------------------------------------------- /H/CPM.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/CPM.HLP -------------------------------------------------------------------------------- /H/ED.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/ED.HLP -------------------------------------------------------------------------------- /H/EX.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/EX.HLP -------------------------------------------------------------------------------- /H/HELP.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/HELP.COM -------------------------------------------------------------------------------- /H/HELP.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/HELP.HLP -------------------------------------------------------------------------------- /H/NULU.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/NULU.HLP -------------------------------------------------------------------------------- /H/PIP.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/PIP.HLP -------------------------------------------------------------------------------- /H/STAT.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/STAT.HLP -------------------------------------------------------------------------------- /M/cc.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/M/cc.com -------------------------------------------------------------------------------- /M/zsm.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/M/zsm.com -------------------------------------------------------------------------------- /P/READ.ME: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/P/READ.ME -------------------------------------------------------------------------------- /A/PAUSE.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/PAUSE.COM -------------------------------------------------------------------------------- /A/SLASH.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/SLASH.COM -------------------------------------------------------------------------------- /A/SUBMIT.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/A/SUBMIT.COM -------------------------------------------------------------------------------- /B/MBASIC.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/B/MBASIC.COM -------------------------------------------------------------------------------- /B/OBASIC.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/B/OBASIC.COM -------------------------------------------------------------------------------- /B/STARS.BAS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/B/STARS.BAS -------------------------------------------------------------------------------- /B/TBASIC.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/B/TBASIC.COM -------------------------------------------------------------------------------- /E/WSMSGS.OVR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/E/WSMSGS.OVR -------------------------------------------------------------------------------- /F/EDITOR.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/EDITOR.DOC -------------------------------------------------------------------------------- /F/EDLIN.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/EDLIN.DOC -------------------------------------------------------------------------------- /F/FORTH.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/FORTH.COM -------------------------------------------------------------------------------- /F/MULTI.DOC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/MULTI.DOC -------------------------------------------------------------------------------- /G/HITCH.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/HITCH.COM -------------------------------------------------------------------------------- /G/PLANET.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/PLANET.COM -------------------------------------------------------------------------------- /G/ZORK1.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/ZORK1.COM -------------------------------------------------------------------------------- /G/ZORK1.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/ZORK1.DAT -------------------------------------------------------------------------------- /G/ZORK2.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/ZORK2.COM -------------------------------------------------------------------------------- /G/ZORK2.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/ZORK2.DAT -------------------------------------------------------------------------------- /G/ZORK3.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/ZORK3.COM -------------------------------------------------------------------------------- /G/ZORK3.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/ZORK3.DAT -------------------------------------------------------------------------------- /H/BASCOM.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/BASCOM.HLP -------------------------------------------------------------------------------- /H/CBASIC.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/CBASIC.HLP -------------------------------------------------------------------------------- /H/EBASIC.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/EBASIC.HLP -------------------------------------------------------------------------------- /H/MLOAD.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/MLOAD.HLP -------------------------------------------------------------------------------- /H/RATFOR.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/RATFOR.HLP -------------------------------------------------------------------------------- /H/SWEEP.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/SWEEP.HLP -------------------------------------------------------------------------------- /H/XLATE.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/XLATE.HLP -------------------------------------------------------------------------------- /H/Z80MR.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/Z80MR.HLP -------------------------------------------------------------------------------- /H/ZDASM.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/ZDASM.HLP -------------------------------------------------------------------------------- /I/RNDTST.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/I/RNDTST.COM -------------------------------------------------------------------------------- /I/zexall.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/I/zexall.com -------------------------------------------------------------------------------- /I/zexdoc.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/I/zexdoc.com -------------------------------------------------------------------------------- /L/XLISP.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/L/XLISP.COM -------------------------------------------------------------------------------- /M/ccopt.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/M/ccopt.com -------------------------------------------------------------------------------- /M/hello.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/M/hello.com -------------------------------------------------------------------------------- /P/MCDEMO.MCS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/P/MCDEMO.MCS -------------------------------------------------------------------------------- /P/TINST.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/P/TINST.COM -------------------------------------------------------------------------------- /P/TINST.DTA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/P/TINST.DTA -------------------------------------------------------------------------------- /P/TURBO.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/P/TURBO.COM -------------------------------------------------------------------------------- /P/TURBO.OVR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/P/TURBO.OVR -------------------------------------------------------------------------------- /B/BBCBASIC.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/B/BBCBASIC.COM -------------------------------------------------------------------------------- /B/CONVERT.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/B/CONVERT.COM -------------------------------------------------------------------------------- /E/WINSTALL.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/E/WINSTALL.COM -------------------------------------------------------------------------------- /E/WSOVLY1.OVR: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/E/WSOVLY1.OVR -------------------------------------------------------------------------------- /F/FORTH-F.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/FORTH-F.COM -------------------------------------------------------------------------------- /F/INSTALL.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/INSTALL.COM -------------------------------------------------------------------------------- /F/INSTALL.DTA: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/F/INSTALL.DTA -------------------------------------------------------------------------------- /G/GORILLA.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/GORILLA.COM -------------------------------------------------------------------------------- /G/HITCHHIK.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/HITCHHIK.DAT -------------------------------------------------------------------------------- /G/LEATHER.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/LEATHER.COM -------------------------------------------------------------------------------- /G/LEATHER.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/LEATHER.DAT -------------------------------------------------------------------------------- /G/LIHOUSE.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/LIHOUSE.COM -------------------------------------------------------------------------------- /G/LORDTIME.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/LORDTIME.COM -------------------------------------------------------------------------------- /G/PLANETFA.DAT: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/G/PLANETFA.DAT -------------------------------------------------------------------------------- /H/CBASIC2.HLP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/H/CBASIC2.HLP -------------------------------------------------------------------------------- /M/hextocom.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skx/cpm-dist/HEAD/M/hextocom.com -------------------------------------------------------------------------------- /P/HELLO.PAS: -------------------------------------------------------------------------------- 1 | program Hello; 2 | begin 3 | writeln ('Hello, world.'); 4 | end. 5 | -------------------------------------------------------------------------------- /C/SETJMP.H: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1983 by Manx Software Systems */ 2 | #define JBUFSIZE (5*sizeof(int)) 3 | 4 | typedef char jmp_buf[JBUFSIZE]; 5 | -------------------------------------------------------------------------------- /A/AUTOEXEC.SUB: -------------------------------------------------------------------------------- 1 | !CTRLC 1 2 | !output :CR=NONE,LF=BOTH 3 |  -------------------------------------------------------------------------------- /C/FCNTL.H: -------------------------------------------------------------------------------- 1 | #define O_RDONLY 0 2 | #define O_WRONLY 1 3 | #define O_RDWR 2 4 | #define O_CREAT 0x0100 5 | #define O_TRUNC 0x0200 6 | #define O_EXCL 0x0400 7 | #define O_APPEND 0x0800 8 | -------------------------------------------------------------------------------- /B/ASM.BBC: -------------------------------------------------------------------------------- 1 | 10 DIM code 4096 2 | 20 P%=&1000 3 | 25 O%=code 4 | 30 [ 5 | 40 LD E, 65 6 | 50 LD C, 6 7 | 60 CALL 0005 8 | 70 RET 9 | 80 ] 10 | 90 CALL &1000 11 | 100 E%=42 12 | 110 CALL &1002 13 | 120 E%=10 14 | 130 CALL &1002 15 | -------------------------------------------------------------------------------- /L/README.md: -------------------------------------------------------------------------------- 1 | # L: Lisp 2 | 3 | The L-drive contains a simple implementation of Lisp. 4 | 5 | Originally this was found [via the simtel archives](http://www.retroarchive.org/cpm/cdrom/SIMTEL/SIGM/VOLS100/VOL118/). 6 | 7 | * XLISP.COM - The binary. 8 | * XLISP.DOC - The documentation. 9 | -------------------------------------------------------------------------------- /C/ERRNO.H: -------------------------------------------------------------------------------- 1 | extern int errno; 2 | #define ENOENT -1 3 | #define E2BIG -2 4 | #define EBADF -3 5 | #define ENOMEM -4 6 | #define EEXIST -5 7 | #define EINVAL -6 8 | #define ENFILE -7 9 | #define EMFILE -8 10 | #define ENOTTY -9 11 | #define EACCES -10 12 | 13 | #define ERANGE -20 14 | #define EDOM -21 15 | -------------------------------------------------------------------------------- /E/README.md: -------------------------------------------------------------------------------- 1 | # E: EDITOR 2 | 3 | The E-drive contains a "proper Editor", Wordstar v3.3 in this case. 4 | 5 | There is a more complete version of Wordstar, version 4, in the following repository - but this version has nicer "ANSI graphics": 6 | 7 | * https://github.com/skx/z80-playground-cpm-fat/tree/main/dist/CPM/DISKS/E 8 | -------------------------------------------------------------------------------- /C/HELLO.C: -------------------------------------------------------------------------------- 1 | /* 2 | * CC HELLO 3 | * AS HELLO 4 | * LN HELLO.O T.LIB C.LIB 5 | */ 6 | #include "STDIO.H" 7 | 8 | main(argc, argv) 9 | int argc; 10 | char *argv[]; 11 | { 12 | printf("Hello, world\n"); 13 | printf("Hello, universe!\n"); 14 | return 0; 15 | } 16 | 17 | 18 |  -------------------------------------------------------------------------------- /C/MATH.H: -------------------------------------------------------------------------------- 1 | double sin(), cos(), tan(), cotan(); 2 | double asin(), acos(), atan(), atan2(); 3 | double ldexp(), frexp(), modf(); 4 | double floor(), ceil(); 5 | double log(), log10(), exp(), sqrt(), pow(); 6 | double sinh(), cosh(), tanh(), fabs(); 7 | 8 | #define HUGE 5.2e+151 9 | #define LOGHUGE 349.3 10 | #define TINY 7.5e-155 11 | #define LOGTINY -354.8 12 | -------------------------------------------------------------------------------- /F/README.md: -------------------------------------------------------------------------------- 1 | DX-Forth 1.0, 97-12-28 2 | ---------------------- 3 | 4 | * The manual is available in [DXFORTH.DOC](DXFORTH.DOC). 5 | * The glossary of words is in [DXFORTH.GLO](DXFORTH.GLO). 6 | * The other DOC files aren't readable outwith a CP/M system. 7 | * Enter `BYE` to exit. 8 | * Enter `WORDS` to see defined words. 9 | * `FORTH-F.COM` has the floating-point support missing in `FORTH.COM`. 10 | -------------------------------------------------------------------------------- /C/ECHO.C: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple echo-program, compile and use like so: 3 | * 4 | * C> CC ECHO 5 | * C> AS ECHO 6 | * C> LN ECHO.O T.LIB C.LIB 7 | * C> ECHO HELLO, WORLD 8 | * HELLO, WORLD 9 | */ 10 | #include "STDIO.H" 11 | 12 | main(argc, argv) 13 | int argc; 14 | char *argv[]; 15 | { 16 | int i; 17 | 18 | /* 19 | * Print each argument, add a newline on the last one, otherwise 20 | * add a trailing space. 21 | */ 22 | for( i = 1; i < argc; i++ ) { 23 | printf("%s%s", argv[i], ( i + 1 ) == argc ? "\n" : " "); 24 | } 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C/README.md: -------------------------------------------------------------------------------- 1 | # C: C 2 | 3 | The C-drive contains the [Aztec C compiler](https://en.wikipedia.org/wiki/Aztec_C). 4 | 5 | There is a second C-compiler included within this distribution, available within [M:](../M/). 6 | 7 | You can see brief usage information, and demos, as: 8 | 9 | * BE.C 10 | * A binary editor, written by Lars Lindehaven. 11 | * The binary is present in [A:](../A/). 12 | * ECHO.C 13 | * Echo command-line arguments. 14 | * FU.C 15 | * A file utility/manager, written by [me](https://github.com/skx). 16 | * The binary is present in [A:](../A/). 17 | * HELLO.C 18 | * Print the traditional greeting. 19 | -------------------------------------------------------------------------------- /H/README.md: -------------------------------------------------------------------------------- 1 | # H: HELP 2 | 3 | The H-drive contains "help-information". There is a HELP.COm driver, and a series of input-files for that utility: 4 | 5 | 6 | * HELP.COM - file system describing 7 | * HELP.HLP - file system 8 | * CPM.HLP - CP/M 1.4 9 | * CPM2.HLP - CP/M 2.2 10 | * ASM.HLP - CP/M 1.4 ASM (assembler) 11 | * ASM2.HLP - CP/M 2.2 ASM (assembler) 12 | * MAC.HLP - CP/M MAC (macro assembler) 13 | * MBASIC.HLP - Microsoft BASIC 14 | * CBASIC.HLP - CBasic 15 | * EBASIC.HLP - Basic-E 16 | * CBASIC2.HLP - CBasic-2 17 | * MASM.HLP - MACRO-80 (M80) 18 | * ALGOLM.HLP - ALGOL-M 19 | * C.HLP - BDS 'C' 20 | * FORTRAN.HLP - Microsoft Fortran 21 | * PASCAL.HLP - PASCAL/MT 22 | -------------------------------------------------------------------------------- /C/CTYPE.H: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1984 by Manx Software Systems */ 2 | 3 | extern char ctp_[]; 4 | 5 | #define isalpha(x) (ctp_[(x)+1]&0x03) 6 | #define isupper(x) (ctp_[(x)+1]&0x01) 7 | #define islower(x) (ctp_[(x)+1]&0x02) 8 | #define isdigit(x) (ctp_[(x)+1]&0x04) 9 | #define isxdigit(x) (ctp_[(x)+1]&0x08) 10 | #define isalnum(x) (ctp_[(x)+1]&0x07) 11 | #define isspace(x) (ctp_[(x)+1]&0x10) 12 | #define ispunct(x) (ctp_[(x)+1]&0x40) 13 | #define iscntrl(x) (ctp_[(x)+1]&0x20) 14 | #define isprint(x) (ctp_[(x)+1]&0xc7) 15 | #define isgraph(x) (ctp_[(x)+1]&0x47) 16 | #define isascii(x) (((x)&0x80)==0) 17 | 18 | #define toascii(x) ((x)&127) 19 | #define _tolower(x) ((x)|0x20) 20 | #define _toupper(x) ((x)&0x5f) 21 | -------------------------------------------------------------------------------- /G/README.md: -------------------------------------------------------------------------------- 1 | # G: GAMES 2 | 3 | The G-drive contains games, in this case: 4 | 5 | * GORILLA.COM 6 | * The classic missile-game, written by Francesco Sblendorio. 7 | * [The source repository](https://github.com/sblendorio/gorilla-cpm) lives on Github. 8 | * HITCH.COM 9 | * Hitchhiker's Guide To The Galaxy, Infocom 10 | * LEATHER.COM 11 | * Leather Goddesses of Phobos, Infocom 12 | * LIFE.COM 13 | * Game of life. 14 | * LIHOUSE.COM 15 | * [Lighthouse of Doom](https://github.com/skx/lighthouse-of-doom/), by me. 16 | * LORDTIME.COM 17 | * Lords of Time (1984) 18 | * PLANET.COM 19 | * Planetfall, Infocom 20 | * ZORK1.COM 21 | * Zork 1, Infocom 22 | * ZORK2.COM 23 | * Zork 2, Infocom 24 | * ZORK3.COM 25 | * Zork 3, Infocom 26 | -------------------------------------------------------------------------------- /P/CMDLIN.PAS: -------------------------------------------------------------------------------- 1 | program CommandLine; 2 | { 3 | COMMANDLINE PARAMETERS DEMONSTRATION PROGRAM Version 1.00A 4 | 5 | This program gets parameters from the command line: 6 | 7 | INSTRUCTIONS 8 | 1. Load the TURBO compiler and compile to a .COM file 9 | 2. Quit the TURBO compiler and execute the program with 10 | parameters. Try: 11 | 12 | cmdlin abc def 13 | cmdlin Greetings from Frank Borland! 14 | cmdlin 15 | 16 | NOTE: For information about these functions, please refer to your 17 | TURBO 3.0 Reference Manual. 18 | } 19 | 20 | 21 | var 22 | i : integer; 23 | 24 | begin 25 | for i := 1 to ParamCount do 26 | writeln(ParamSTR(i)); 27 | end. 28 | -------------------------------------------------------------------------------- /C/SGTTY.H: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1983 by Manx Software Systems */ 2 | 3 | #define TIOCGETP 0 /* read contents of tty control structure */ 4 | #define TIOCSETP 1 /* set contents of tty control structure */ 5 | #define TIOCSETN 1 /* ditto only don't wait for output to flush */ 6 | 7 | struct sgttyb { 8 | char sg_erase; /* ignored */ 9 | char sg_kill; /* ignored */ 10 | short sg_flags; /* control flags */ 11 | }; 12 | 13 | /* settings for flags */ 14 | #define _VALID 0x3a 15 | #define RAW 0x20 /* no echo or mapping of input/output BDOS(6) */ 16 | #define CRMOD 0x10 /* map input CR to NL, output NL to CR LF */ 17 | #define ECHO 0x08 /* ignored unless CBREAK is set */ 18 | #define CBREAK 0x02 /* input using BDOS(1), unless echo off then */ 19 | /* same as RAW */ 20 | -------------------------------------------------------------------------------- /I/README.md: -------------------------------------------------------------------------------- 1 | # I: Instruction Tester 2 | 3 | The I-drive contains the [Z80 Instruction Exerciser](https://mdfs.net/Software/Z80/Exerciser/), 4 | as distributed from the author. 5 | 6 | Expected output would look something like this: 7 | 8 | ``` 9 | A>zexall 10 | Z80all instruction exerciser 11 | hl,.... OK 12 | add hl,.......... OK 13 | add ix,.......... OK 14 | add iy,.......... OK 15 | aluop a,nn.................... OK 16 | aluop a,.. OK 17 | aluop a,..... OK 18 | aluop a,(+1)........... OK 19 | ... 20 | ``` 21 | 22 | Additionally there is a small program to identify the CPU and confirm the R-register can be used as a source of randomness: 23 | 24 | * `RNDTST.ASM` 25 | * Source code. 26 | * `RNDTST.COM` 27 | * Binary. 28 | -------------------------------------------------------------------------------- /F/READ.ME: -------------------------------------------------------------------------------- 1 | DX-Forth 1.0 is a full-featured Forth-83 compiler for all CP/M-80 2 | and Z-System users. 3 | 4 | In addition to Forth's usual benefits - interactive testing, 5 | debugging and compilation - DX-Forth provides compact application 6 | generation, video functions (installable for most terminals), 7 | fast floating point and trigonometric functions, multi-tasking, 8 | overlays, automatic access to all CP/M user areas, Z-System 9 | support, Forth assembler and full source code. 10 | 11 | Developed over several years, DX-Forth is the synthesis of what I 12 | always wanted in a CP/M Forth. I hope you enjoy DX-Forth. 13 | 14 | Please forward any comments, bug reports to: 15 | 16 | ed.smeda@bbs.tardis.net 17 | ed.smeda@tegan.apana.org.au 18 | 19 | 28-Dec-97 20 |  -------------------------------------------------------------------------------- /A/HELLO.ASM: -------------------------------------------------------------------------------- 1 | ; This is a simple example program written in assembler 2 | ; 3 | ; Assemble it via: 4 | ; 5 | ; ASM hello 6 | ; 7 | ; This will produce two output files: 8 | ; 9 | ; HELLO.PRN - This can be ignored 10 | ; HELLO.HEX - The loader will use this 11 | ; 12 | ; Once this has been done run the loader: 13 | ; 14 | ; LOAD hello 15 | ; 16 | ; This will read "hello.hex" and produce "hello.com", which you can then 17 | ; run. 18 | ; 19 | 20 | ORG 0100H ; CP/M base of TPA (transient program area) 21 | MVI C,09H ; Print string function 22 | LXI D,MESSAGE ; Point 23 | CALL 0005H ; Call bdos 24 | RET ; To cp/m 25 | MESSAGE:DB 0DH,0AH,'Hello, World!',0DH,0AH,'$' 26 | END 27 |  -------------------------------------------------------------------------------- /M/stdbool.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file stdbool.h 3 | * @brief Boolean type and values. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Boolean type and values for MESCC (Mike's Enhanced Small C Compiler 7 | * for Z80 & CP/M). 8 | * 9 | * Defined macros: 10 | * - bool 11 | * - true 12 | * - false 13 | * 14 | * Revisions: 15 | * - 13 May 2016 : 1st version. 16 | * 17 | * Notes: 18 | * - In standard / ISO C, bool type is _Bool, not int. 19 | * - ISO C defines bool_true_false_are_defined = 1. 20 | * 21 | * Copyright (c) 2016 Miguel I. Garcia Lopez / FloppySoftware. 22 | * 23 | * Licensed under the GNU General Public License v3. 24 | * 25 | * http://www.floppysoftware.es 26 | * floppysoftware@gmail.com 27 | */ 28 | #ifndef STDBOOL_H 29 | 30 | #define STDBOOL_H 31 | 32 | #define bool int 33 | #define true 1 34 | #define false 0 35 | 36 | #endif 37 | 38 |  -------------------------------------------------------------------------------- /P/MC-MOD00.INC: -------------------------------------------------------------------------------- 1 | {.PA} 2 | {*******************************************************************} 3 | {* SOURCE CODE MODULE: MC-MOD00 *} 4 | {* PURPOSE: Micellaneous utilities an commands. *} 5 | {*******************************************************************} 6 | 7 | 8 | procedure Msg(S: AnyString); 9 | begin 10 | GotoXY(1,24); 11 | ClrEol; 12 | Write(S); 13 | end; 14 | 15 | procedure Flash(X: integer; S: AnyString; Blink: boolean); 16 | begin 17 | HighVideo; 18 | GotoXY(X,23); 19 | Write(S); 20 | if Blink then 21 | begin 22 | repeat 23 | GotoXY(X,23); 24 | Blink:=not Blink; if Blink then HighVideo else LowVideo; 25 | Write(S); 26 | Delay(175); 27 | until KeyPressed; 28 | end; 29 | LowVideo; 30 | end; 31 | 32 | procedure Auto; 33 | begin 34 | AutoCalc:=not AutoCalc; 35 | if AutoCalc then Flash(65,'AutoCalc: ON ',false) 36 | else Flash(65,'AutoCalc: OFF',false); 37 | end; 38 | -------------------------------------------------------------------------------- /M/hello.c: -------------------------------------------------------------------------------- 1 | /* hello.c 2 | 3 | Hello world for MESCC. 4 | 5 | Copyright (c) 2015 Miguel I. Garcia Lopez. 6 | 7 | This program is free software; you can redistribute it and/or modify it 8 | under the terms of the GNU General Public License as published by the 9 | Free Software Foundation; either version 2, or (at your option) any 10 | later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 20 | 21 | Compile with: 22 | 23 | cc hello 24 | ccopt hello 25 | zsm hello 26 | hextocom hello 27 | 28 | 23 Feb 2015 29 | */ 30 | 31 | #include "mescc.h" 32 | #include "conio.h" 33 | 34 | main() 35 | { 36 | puts("Hello world!"); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /B/COLOR.BAS: -------------------------------------------------------------------------------- 1 | 20 ESC$ = CHR$(27)+"[" 2 | 3 | 100 REM foreground color 4 | 110 FOR I = 30 TO 37 5 | 120 PRINT ESC$ + MID$(STR$(I), 2) + "m" + "Color"; I 6 | 130 NEXT I 7 | 140 REM black again 8 | 150 PRINT ESC$ + "30m" + "Black Color again" 9 | 160 PRINT " " 10 | 11 | 200 REM background color 12 | 210 FOR I = 40 TO 47 13 | 220 PRINT ESC$ + MID$(STR$(I), 2) + "m" + "Background color"; I 14 | 230 NEXT I 15 | 240 REM white again 16 | 250 PRINT ESC$ + "47m" + "White Background again" 17 | 260 PRINT " " 18 | 19 | 300 REM attributes 20 | 310 PRINT ESC$ + "1m" + "Bold on" 21 | 320 PRINT ESC$ + "4m" + "Underline on" 22 | 330 PRINT ESC$ + "5m" + "Italic on" 23 | 340 PRINT ESC$ + "7m" + "Inverse on" 24 | 350 PRINT ESC$ + "8m" + "Coverd on" 25 | 360 PRINT ESC$ + "0m" + "turn off attributes" 26 | 370 PRINT " " 27 | 28 |  -------------------------------------------------------------------------------- /C/LIBC.H: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1981, 1982 by Manx Software Systems */ 2 | 3 | extern int errno; 4 | #define FLT_FAULT 0 /* vector for floating-point faults */ 5 | extern int (*Sysvec[])(); 6 | 7 | #define NULL 0 8 | #define EOF -1 9 | #define BUFSIZ 1024 10 | 11 | #define _BUSY 0x01 12 | #define _ALLBUF 0x02 13 | #define _DIRTY 0x04 14 | #define _EOF 0x08 15 | #define _IOERR 0x10 16 | 17 | typedef struct { 18 | char *_bp; /* current position in buffer */ 19 | char *_bend; /* last character in buffer + 1 */ 20 | char *_buff; /* address of buffer */ 21 | char _flags; /* open mode, etc. */ 22 | char _unit; /* token returned by open */ 23 | char _bytbuf; /* single byte buffer for unbuffer streams */ 24 | int _buflen; /* length of buffer */ 25 | } FILE; 26 | 27 | extern FILE Cbuffs[]; 28 | extern char *Stdbufs; /* free list of buffers */ 29 | long ftell(); 30 | 31 | #define stdin (&Cbuffs[0]) 32 | #define stdout (&Cbuffs[1]) 33 | #define stderr (&Cbuffs[2]) 34 | #define getchar() agetc(stdin) 35 | #define putchar(c) aputc(c, stdout) 36 | #define feof(fp) (((fp)->_flags&_EOF)!=0) 37 | #define ferror(fp) (((fp)->_flags&_IOERR)!=0) 38 | #define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF)) 39 | #define fileno(fp) ((fp)->_unit) 40 | -------------------------------------------------------------------------------- /A/PAUSE.ASM: -------------------------------------------------------------------------------- 1 | ; pause.ASM - Pause for a keypress. 2 | ; 3 | ; Assemble it via: 4 | ; 5 | ; ASM PAUSE 6 | ; 7 | ; This will produce two output files: 8 | ; 9 | ; PAUSE.PRN - This can be ignored 10 | ; PAUSE.HEX - The loader will use this 11 | ; 12 | ; Once this has been done run the loader: 13 | ; 14 | ; LOAD PAUSE 15 | ; 16 | ; This will read "PAUSE.hex" and produce "PAUSE.com", which you can then 17 | ; run. 18 | ; 19 | 20 | ORG 0100H ; CP/M base of TPA (transient program area) 21 | MVI C,09H ; Print string function 22 | LXI D,MESSAGE ; 23 | CALL 0005H ; Call bdos 24 | 25 | MVI C,01H ; Keyboard input function 26 | CALL 0005H ; Call bdos 27 | 28 | MVI C,09H ; Print string function 29 | LXI D,CLEAR ; 30 | CALL 0005H ; Call bdos 31 | RET ; To cp/m 32 | MESSAGE:DB 27, '[2J' ; "clear" 33 | DB 27, '[', 'H' ; "home" 34 | DB 0DH, 0AH, 'Press any key to continue ..',0DH,0AH,'$' 35 | CLEAR: DB 27, '[2J' ; "clear" 36 | DB 27, '[', 'H' ; "home" 37 | DB '$' 38 | END 39 |  -------------------------------------------------------------------------------- /M/rand.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rand.h 3 | * @brief Pseudo-random number generation. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Pseudo-random number generation, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 18 Mar 2015 : 1st version. 11 | * - 23 Mar 2015 : Trying to improve rand(). 12 | * - 15 Aug 2016 : Documented. GPL v3. 13 | * 14 | * Defined macros: 15 | * - RAND_MAX 16 | * 17 | * Copyright (c) 2015-2016 Miguel I. Garcia Lopez / FloppySoftware. 18 | * 19 | * Licensed under the GNU General Public License v3. 20 | * 21 | * http://www.floppysoftware.es 22 | * floppysoftware@gmail.com 23 | */ 24 | #ifndef RAND_H 25 | 26 | #define RAND_H 27 | 28 | #define RAND_MAX 32767 29 | 30 | int xs_seed = 1; // Initial value for seed 31 | 32 | /** 33 | * @fn int rand(void) 34 | * @brief Generate a pseudo-random value between 0 and RAND_MAX (both included). 35 | * @return value 36 | */ 37 | rand() 38 | { 39 | // return (xs_seed = ((xs_seed * 3) + 1) & 0x7FFF); 40 | 41 | return (xs_seed = (((xs_seed << 1) + xs_seed) + 1) & 0x7FFF); 42 | } 43 | 44 | /** 45 | * @fn void srand(unsigned int seed) 46 | * @brief Seeds the pseudo-random number generator used by rand(). 47 | * @param seed - value 48 | */ 49 | srand(seed) 50 | unsigned int seed; 51 | { 52 | xs_seed = seed; 53 | } 54 | 55 | #endif 56 | 57 |  -------------------------------------------------------------------------------- /B/VT100.BAS: -------------------------------------------------------------------------------- 1 | 10 REM test VT100 escape codes 2 | 20 REM 3 | 30 ESC$ = CHR$(27)+"[" 4 | 40 REM Clear Screen 5 | 50 CLS$ = ESC$ + "2J" 6 | 60 PRINT "Press Return to clear screen";: INPUT " ", Q$ 7 | 70 PRINT CLS$; 8 | 80 REM several cursor positioning examples 9 | 90 PRINT "Press Return to position cursor";: INPUT " ", Q$ 10 | 100 CP1$ = ESC$ + "10;20H" 11 | 110 PRINT CP1$; "Cursor at (10,20). Press Return to go to (15,15)";: INPUT " ", Q$ 12 | 120 CP2$ = ESC$ + "15;15f" 13 | 130 PRINT CP2$; "Cursor at (15,15). Press Return for diagonal positioning";: INPUT " ", Q$ 14 | 140 FOR I = 1 TO 24 15 | 150 T$ = ESC$ + MID$(STR$(I),2) + ";" + MID$(STR$(I), 2) + "H" 16 | 160 PRINT T$ + "$"; 17 | 170 NEXT I 18 | 180 REM Delete Line 19 | 190 CP2$ = ESC$ + "10;10f" 20 | 200 PRINT CP2$; 21 | 210 PRINT "Press Return to Delete Line demo";: INPUT " ", Q$ 22 | 220 FOR I = 1 TO 5 23 | 230 PRINT ESC$ + "2K"; 24 | 240 NEXT I 25 | 250 PRINT "Press Return for color demo";: INPUT " ", Q$ 26 | 260 REM foreground color 27 | 270 FOR I = 30 TO 37 28 | 280 PRINT ESC$ + MID$(STR$(I), 2) + "m" + "Color"; I 29 | 290 NEXT I 30 | 300 REM black again 31 | 310 PRINT ESC$ + "30m" + "Black again" 32 | 320 REM background color 33 | 330 FOR I = 40 TO 47 34 | 340 PRINT ESC$ + MID$(STR$(I), 2) + "m" + "Background color"; I 35 | 350 NEXT I 36 | 360 REM white again 37 | 370 PRINT ESC$ + "47m" + "White again" 38 | 380 END 39 | -------------------------------------------------------------------------------- /M/z80.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file z80.h 3 | * @brief Z80 specific functions. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Functions for the Z80 cpu, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 13 Dec 2014 : 1st version. 11 | * - 15 Aug 2016 : Documented. GPL v3. 12 | * 13 | * Copyright (c) 2014-2016 Miguel I. Garcia Lopez / FloppySoftware. 14 | * 15 | * Licensed under the GNU General Public License v3. 16 | * 17 | * http://www.floppysoftware.es 18 | * floppysoftware@gmail.com 19 | */ 20 | #ifndef Z80_H 21 | 22 | #define Z80_H 23 | 24 | /** 25 | * @fn int Z80in(int port) 26 | * @brief Input a byte from a port. 27 | * @return byte value 28 | */ 29 | #asm 30 | 31 | Z80in 32 | LD C,L 33 | IN A,(C) 34 | LD H,0 35 | LD L,A 36 | RET 37 | 38 | #endasm 39 | 40 | /** 41 | * @fn void Z80out(int port, int value)) 42 | * @brief Output a byte to a port. 43 | */ 44 | #asm 45 | 46 | Z80out 47 | POP DE 48 | POP HL 49 | POP BC 50 | PUSH BC 51 | PUSH HL 52 | PUSH DE 53 | OUT (C),L 54 | RET 55 | 56 | #endasm 57 | 58 | /** 59 | * @fn void Z80di(void) 60 | * @brief Disable interrupts. 61 | */ 62 | #asm 63 | 64 | Z80di 65 | DI 66 | RET 67 | 68 | #endasm 69 | 70 | /** 71 | * @fn void Z80ei(void) 72 | * @brief Enable interrupts. 73 | */ 74 | #asm 75 | 76 | Z80ei 77 | EI 78 | RET 79 | 80 | #endasm 81 | 82 | #endif 83 | 84 |  -------------------------------------------------------------------------------- /A/README.md: -------------------------------------------------------------------------------- 1 | # A: Standard Utilities 2 | 3 | The A-drive contains some "standard" utilities that you might expect to find on a CP/M system: 4 | 5 | * ASM.COM 6 | * CP/M Assembler - see "hello.asm" for example usage. 7 | * A1.COM 8 | * An Apple emulator, [from David Lee](https://github.com/davidly/a1). 9 | * BE.COM 10 | * Binary editor, source is included as BE.C in [C:](../C/). 11 | * [Originally found here](https://github.com/lindehaven/CP-M). 12 | * DDT.COM 13 | * A simple debugger. 14 | * DUMP.COM 15 | * Dump file contents - this is enhanced to show both HEX and ASCII contents of files. 16 | * Written using the Aztec C-compiler, you can find in [C:](../C/), along with source code. 17 | * ED.COM 18 | * A simple editor. 19 | * FU.COM 20 | * A simple file utility/manager, written by me. 21 | * Source is included as FU.C in [C:](../C/). 22 | * LOAD.COM 23 | * Loader for generated .hex files, produced by ASM.COM 24 | * PAUSE.COM 25 | * Pause for a key-press. Source included in `PAUSE.ASM`. 26 | * S.COM 27 | * A simple vi-like editor, source code can be found in [this repository](https://github.com/udo-munk/s/). 28 | * SLASH.COM 29 | * Submit commands without a ".SUB" file 30 | * Example "SLASH G: ; ZORK1" 31 | * Source from [slant](http://www.retroarchive.org/cpm/cdrom/SIMTEL/SIGM/VOLS000/VOL072/) 32 | * STAT.COM 33 | * Show file details; note that currently file-sizes are not correct. 34 | 35 | Note that the assembler presented here is pretty basic, and you should probably prefer the one included in the [C:](../C/), alongside the Aztec C-compiler. 36 | -------------------------------------------------------------------------------- /C/STDIO.H: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1982, 1984 by Manx Software Systems */ 2 | #define fgetc getc 3 | #define fputc putc 4 | #define NULL 0 5 | #define EOF -1 6 | 7 | #ifdef TINY 8 | struct fcb { 9 | char f_driv; 10 | char f_name[8]; 11 | char f_type[3]; 12 | char f_ext; 13 | char f_resv[2]; 14 | char f_rc; 15 | char f_sydx[16]; 16 | char f_cr; 17 | unsigned f_record; char f_overfl; 18 | }; 19 | 20 | typedef struct { 21 | char *_bp; 22 | struct fcb _fcb; 23 | char user; 24 | } FILE; 25 | 26 | #else 27 | 28 | #define BUFSIZ 1024 29 | #define MAXSTREAM 11 30 | 31 | #define _BUSY 0x01 32 | #define _ALLBUF 0x02 33 | #define _DIRTY 0x04 34 | #define _EOF 0x08 35 | #define _IOERR 0x10 36 | 37 | typedef struct { 38 | char *_bp; /* current position in buffer */ 39 | char *_bend; /* last character in buffer + 1 */ 40 | char *_buff; /* address of buffer */ 41 | char _flags; /* open mode, etc. */ 42 | char _unit; /* token returned by open */ 43 | char _bytbuf; /* single byte buffer for unbuffer streams */ 44 | int _buflen; /* length of buffer */ 45 | } FILE; 46 | 47 | extern FILE Cbuffs[]; 48 | FILE *fopen(); 49 | long ftell(); 50 | 51 | #define stdin (&Cbuffs[0]) 52 | #define stdout (&Cbuffs[1]) 53 | #define stderr (&Cbuffs[2]) 54 | #define getchar() agetc(stdin) 55 | #define putchar(c) aputc(c, stdout) 56 | #define feof(fp) (((fp)->_flags&_EOF)!=0) 57 | #define ferror(fp) (((fp)->_flags&_IOERR)!=0) 58 | #define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF)) 59 | #define fileno(fp) ((fp)->_unit) 60 | #define fflush(fp) flsh_(fp,-1) 61 | #endif 62 | -------------------------------------------------------------------------------- /B/README.md: -------------------------------------------------------------------------------- 1 | # B: BASIC 2 | 3 | The B-drive contains BASIC, in this case: 4 | 5 | * CONVERT.COM 6 | * Converts files between BBC BASIC (.BBC) and ASCII (.BAS) 7 | * BBCBASIC.COM 8 | * BBC BASIC, with integrated assembler. 9 | * Enter "*CPM" to exit. 10 | * Enter "*DIR", to list files, etc. 11 | * MBASIC.COM 12 | * Microsoft BASIC v5.29 [28-Jul-85] 13 | * Enter "SYSTEM" to exit. 14 | * OBASIC.COM 15 | * An older Microsoft BASIC, v5.21 [28-Jul-81] 16 | * Enter "SYSTEM" to exit. 17 | * TBASIC.COM 18 | * [Tasty BASIC](https://github.com/dimitrit/tastybasic) 19 | * Enter "BYE" to exit. 20 | 21 | 22 | 23 | ## Sample Programs 24 | 25 | * [STARS.BAS](STARS.BAS) 26 | * Show a sin-wave of stars. 27 | * [ASM.BBC](ASM.BBC) 28 | * Simple assembly language demonstration program. 29 | * Ouptuts `A*`. 30 | * [VT100.BAS](VT100.BAS) and [COLOR.BAS](COLOR.BAS) 31 | * Both work with MBASIC to demonstrate ANSI escape codes and terminal colour-updates. 32 | 33 | 34 | 35 | ## Microsoft Basic: Saving & Loading Programs 36 | 37 | If you enter a program you can save it via `SAVE "NAME"`, this will create a file named `NAME.BAS` with a tokenized representation of the program you entered. If you prefer to save the literal ASCII version of the program run: 38 | 39 | ``` 40 | SAVE "STEVE", A 41 | ``` 42 | 43 | That will create `STEVE.BAS` with readable contents. 44 | 45 | Loading files can be achieved via `LOAD "NAME"`, again the "`.BAS`" suffix is implied and shouldn't be specified. Note that loading will load either a tokenized file or the raw ASCII version. 46 | 47 | There are some file-related primitives built into MBASIC, for example try entering `FILES` at the prompt. 48 | -------------------------------------------------------------------------------- /F/CRCKLIST.CRC: -------------------------------------------------------------------------------- 1 | 2 | --> FILE: -28DEC97. CRC = 00 00 3 | --> FILE: ARITH .MAC CRC = CC 13 4 | --> FILE: ASM .DOC CRC = A9 28 5 | --> FILE: ASM .SCR CRC = 14 08 6 | --> FILE: BENCH .SCR CRC = 27 CD 7 | --> FILE: BLK2TXT .SCR CRC = 9A 0E 8 | --> FILE: COMPARE .MAC CRC = 86 10 9 | --> FILE: CONTROL .MAC CRC = AD 47 10 | --> FILE: COPY .SCR CRC = FA F6 11 | --> FILE: COPYFAST.SCR CRC = 22 4E 12 | --> FILE: DISK .MAC CRC = 76 FF 13 | --> FILE: DXFORTH .DOC CRC = 65 38 14 | --> FILE: DXFORTH .GLO CRC = A8 95 15 | --> FILE: EDITOR .DOC CRC = 58 A7 16 | --> FILE: EDITOR .SCR CRC = 21 73 17 | --> FILE: EDLIN .DOC CRC = 4A 4C 18 | --> FILE: EDLIN .SCR CRC = 8D F9 19 | --> FILE: FLOAT .MAC CRC = F0 39 20 | --> FILE: FORTH .COM CRC = 82 32 21 | --> FILE: FORTH .Z80 CRC = FA 7F 22 | --> FILE: FORTH-F .COM CRC = 52 BC 23 | --> FILE: FORTH83 .GLO CRC = D7 AC 24 | --> FILE: INSTALL .DTA CRC = 31 A1 25 | --> FILE: INSTALL .COM CRC = E3 D2 26 | --> FILE: INSTALL .SCR CRC = 66 5B 27 | --> FILE: MEMORY .MAC CRC = B7 9A 28 | --> FILE: MISC .SCR CRC = 0A 54 29 | --> FILE: MULTI .DOC CRC = FF A6 30 | --> FILE: MULTI .SCR CRC = 4E 8E 31 | --> FILE: NUMBER .MAC CRC = 13 88 32 | --> FILE: OVERLAY .SCR CRC = D7 02 33 | --> FILE: READ .ME CRC = 57 BA 34 | --> FILE: STACK .MAC CRC = A6 8B 35 | --> FILE: STRING .MAC CRC = 57 26 36 | --> FILE: STRINGS .SCR CRC = C4 FD 37 | --> FILE: TXT2BLK .SCR CRC = F9 5A 38 | --> FILE: UTILITY .MAC CRC = D0 D2 39 | --> FILE: ZINS .SCR CRC = B4 F8 -------------------------------------------------------------------------------- /M/qsort.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file qsort.h 3 | * @brief Sort function. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * This library implements a sort function of general use, 7 | * which uses the bubble sort algorithm, for MESCC (Mike's Enhanced 8 | * Small C Compiler for Z80 & CP/M). 9 | * 10 | * Revisions: 11 | * - 30 Nov 2015 : First version (bubble sort). 12 | * - 15 Aug 2016 : Documented. GPL v3. 13 | * 14 | * Copyright (c) 2015-2016 Miguel I. Garcia Lopez / FloppySoftware. 15 | * 16 | * Licensed under the GNU General Public License v3. 17 | * 18 | * http://www.floppysoftware.es 19 | * floppysoftware@gmail.com 20 | */ 21 | #ifndef QSORT_H 22 | 23 | #define QSORT_H 24 | 25 | /** 26 | * @fn void qsort(void *base, size_t items, size_t size, int (*comp)(const void *, const void*)) 27 | * @brief Sort an array of elements. 28 | * 29 | * Sort an array of elements into ascending order. 30 | * 31 | * The comparison function must return: 32 | * - <0 on elem1 < elem2 33 | * - =0 on elem1 == elem2 34 | * - >0 on elem1 > elem2 35 | * 36 | * @param base - address of first element 37 | * @param items - number of elements in the array 38 | * @param size - size in bytes of each element 39 | * @param comp - comparison function 40 | */ 41 | qsort(base, items, size, comp) 42 | BYTE *base; int items, size; WORD comp; 43 | { 44 | int i, j, k; 45 | BYTE *pi, *pj, t; 46 | 47 | for(i = 0; i < items; ++i) 48 | { 49 | for(j = i + 1; j < items; ++j) 50 | { 51 | pi = base + i * size; 52 | pj = base + j * size; 53 | 54 | if(comp(pi, pj) > 0) 55 | { 56 | for(k = 0; k < size; ++k) { 57 | t = *pi; 58 | *pi++ = *pj; 59 | *pj++ = t; 60 | } 61 | } 62 | } 63 | } 64 | } 65 | 66 | #endif 67 | 68 |  -------------------------------------------------------------------------------- /P/MC-MOD01.INC: -------------------------------------------------------------------------------- 1 | {.PA} 2 | 3 | {*******************************************************************} 4 | {* SOURCE CODE MODULE: MC-MOD01 *} 5 | {* PURPOSE: Display grid and initialize all cells *} 6 | {* in the spread sheet. *} 7 | {*******************************************************************} 8 | 9 | 10 | 11 | procedure Grid; 12 | var I: integer; 13 | Count: Char; 14 | begin 15 | HighVideo; 16 | For Count:='A' to FXMax do 17 | begin 18 | GotoXY(XPos[Count],1); 19 | Write(Count); 20 | end; 21 | GotoXY(1,2); 22 | for I:=1 to FYMax do writeln(I:2); 23 | LowVideo; 24 | if AutoCalc then Flash(65,'AutoCalc: ON' ,false) 25 | else Flash(65,'AutoCalc: OFF',false); 26 | Flash(33,' Type / for Commands',false); 27 | end; 28 | 29 | 30 | procedure Init; 31 | var 32 | I: ScreenIndex; 33 | J: Integer; 34 | LastName: string[2]; 35 | begin 36 | for I:='A' to FXMAX do 37 | begin 38 | for J:=1 to FYMAX do 39 | begin 40 | with Screen[I,J] do 41 | begin 42 | CellStatus:=[Txt]; 43 | Contents:=''; 44 | Value:=0; 45 | DEC:=2; { Default number of decimals } 46 | FW:=10; { Default field whith } 47 | end; 48 | end; 49 | end; 50 | AutoCalc:=True; 51 | FX:='A'; FY:=1; { First field in upper left corner } 52 | end; 53 | 54 | procedure Clear; 55 | begin 56 | HighVideo; 57 | GotoXY(1,24); ClrEol; 58 | Write('Clear this worksheet? (Y/N) '); 59 | repeat Read(Kbd,Ch) until Upcase(Ch) in ['Y','N']; 60 | Write(Upcase(Ch)); 61 | if UpCase(Ch)='Y' then 62 | begin 63 | ClrScr; 64 | Init; 65 | Grid; 66 | end; 67 | end; 68 | 69 | -------------------------------------------------------------------------------- /M/bsearch.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file bsearch.h 3 | * @brief Binary search. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * This library implements a binary search function of general use, 7 | * for MESCC (Mike's Enhanced Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 30 Nov 2015 : First version. 11 | * - 15 Aug 2016 : Bug solved. Documented. GPL v3. 12 | * 13 | * Copyright (c) 2015-2016 Miguel I. Garcia Lopez / FloppySoftware. 14 | * 15 | * Licensed under the GNU General Public License v3. 16 | * 17 | * http://www.floppysoftware.es 18 | * floppysoftware@gmail.com 19 | */ 20 | #ifndef BSEARCH_H 21 | 22 | #define BSEARCH_H 23 | 24 | /** 25 | * @fn void *bsearch(const void *key, const void *base, size_t items, size_t size, int (*comp)(const void *, const void *)) 26 | * @brief Binary search. 27 | * 28 | * Search an element in an array, which must be in ascending order. 29 | * 30 | * The comparison function must return: 31 | * - <0 on key < base[x] 32 | * - =0 on key == base[x] 33 | * - >0 on key > base[x] 34 | * 35 | * @param key - element to search 36 | * @param base - address of first element 37 | * @param items - number of elements in the array 38 | * @param size - size in bytes of each element 39 | * @param comp - comparison function 40 | * @return pointer to matching element, or null pointer on failure 41 | */ 42 | BYTE *bsearch(key, base, items, size, comp) 43 | BYTE *key, *base; int items, size; WORD comp; 44 | { 45 | int a, b, c, dir; 46 | BYTE *p; 47 | 48 | a = 0; 49 | b = items - 1; 50 | 51 | while (a <= b) { 52 | 53 | c = (a + b) >> 1; // c = (a + b) / 2; 54 | p = (base + (c * size)); 55 | 56 | if (dir = comp(p, key)) { 57 | if (dir > 0) 58 | b = c - 1; 59 | else 60 | a = c + 1; 61 | } 62 | else 63 | return p; 64 | } 65 | 66 | return NULL; 67 | } 68 | 69 | #endif 70 | 71 |  -------------------------------------------------------------------------------- /M/printf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file printf.h 3 | * @brief Library for printf() function. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Implementation of printf() function, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 20 Oct 2000 : Last revision. 11 | * - 16 Apr 2007 : GPL'd. 12 | * - 25 Aug 2016 : Documented. GPL v3. 13 | * 14 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 15 | * 16 | * Licensed under the GNU General Public License v3. 17 | * 18 | * http://www.floppysoftware.es 19 | * floppysoftware@gmail.com 20 | */ 21 | #ifndef PRINTF_H 22 | 23 | #define PRINTF_H 24 | 25 | // Dependencies 26 | // ------------ 27 | 28 | #ifndef XPRINTF_H 29 | #include 30 | #endif 31 | 32 | #ifndef CONIO_H 33 | #include 34 | #endif 35 | 36 | /** 37 | * @fn int printf(char *fmt, arg1, arg2, ...) 38 | * @brief Formatted output to stdout (or console). 39 | * 40 | * See the documentation for xprintf.h to learn about the string format. 41 | * 42 | * @param fmt - string format 43 | * @param arg1 - argument #1 44 | * @param arg? - argument #? 45 | * @return number or characters written, or -1 on failure (currently always #). 46 | */ 47 | #asm 48 | 49 | printf: 50 | ADD HL,HL 51 | ADD HL,SP 52 | INC HL 53 | INC HL ;HL=Adr. fmt 54 | 55 | LD DE,xpfout 56 | PUSH DE 57 | LD DE,xpfend 58 | PUSH DE 59 | PUSH HL 60 | 61 | CALL xprintf 62 | 63 | POP BC 64 | POP BC 65 | POP BC 66 | 67 | RET 68 | #endasm 69 | 70 | // int xpfout(char ch) : output ch to stdout; return 0 on success, !=0 on failure (currently always returns 0). 71 | 72 | #asm 73 | 74 | xpfout: 75 | PUSH HL 76 | CALL putchar 77 | POP BC 78 | LD HL,0 79 | RET 80 | 81 | #endasm 82 | 83 | // void xpfend(void) : end formatted output; currently does nothing. 84 | 85 | #asm 86 | 87 | xpfend: 88 | RET 89 | 90 | #endasm 91 | 92 | #endif 93 | 94 |  -------------------------------------------------------------------------------- /M/README.md: -------------------------------------------------------------------------------- 1 | # M: - Mike's Enhanced Small C Compiler for Z80 and CP/M 2 | 3 | The M-drive contains the [Mike's Enhanced Small C Compiler](https://github.com/MiguelVis/mescc). 4 | 5 | This complements the Aztec Compiler located in [C:](../C). 6 | 7 | Original content now follows: 8 | 9 | 10 | 11 | MESCC / Mike's Enhanced Small C Compiler 12 | ======================================== 13 | 14 | MESCC v1.24 - 14 Sep 2021 15 | 16 | Mike's Enhanced Small C Compiler for Z80 and CP/M 17 | 18 | Copyright (c) 1999-2021 Miguel García / FloppySoftware 19 | 20 | **MESCC** is my project of a **C compiler** for the [CP/M operating system](https://en.wikipedia.org/wiki/CP/M) and the Z80 cpu. 21 | 22 | [http://www.floppysoftware.es](http://www.floppysoftware.es) 23 | 24 | **NOTE**: This project has been extracted from my [RetroProjects](https://github.com/MiguelVis/RetroProjects) repository. 25 | 26 | Overview 27 | -------- 28 | 29 | As it is written in MESCC, it can compile itself. 30 | 31 | It is based on the version 1.7 (Oct. 1985) of [Small C](https://en.wikipedia.org/wiki/Small-C) by Ron Cain, Mike Bernson's and John Hill. 32 | 33 | MESCC outputs **Z80 assembler** code that can be assembled with **ZSM/Z80ASMUK** (supplied with MESCC), in order to build an HEX file. 34 | 35 | The HEX file can be converted to an executable COM file with LOAD (supplied with CP/M 2), HEXCOM (supplied with CP/M 3) or **HEXTOCOM** (supplied with MESCC). 36 | 37 | Also is supplied **CCOPT**, a peephole optimizer. 38 | 39 | I use MESCC for nearly all my software projects. 40 | 41 | ![MESCC image](http://www.floppysoftware.es/images/cpm-mescc.jpg "MESCC image") 42 | 43 | License 44 | ------- 45 | 46 | This program is freeware, and it's licensed under the GNU GPL license. 47 | 48 | See the file `copying.txt` for more details. 49 | 50 | About this file 51 | --------------- 52 | 53 | This file is only an introduction to MESCC. 54 | 55 | Please, read [MESCC.TXT](mescc.txt) for more information. 56 | -------------------------------------------------------------------------------- /M/atexit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file atexit.h 3 | * @brief Library for the atexit() function. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Support library for the atexit() function, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 30 Nov 2015 : First version. 11 | * - 02 Dec 2016 : Prefix private names with '_' as supported in ZSM v3.1. 12 | * - 07 Dec 2016 : GPL v3. 13 | * 14 | * Copyright (c) 2015-2016 Miguel I. Garcia Lopez / FloppySoftware. 15 | * 16 | * Licensed under the GNU General Public License v3. 17 | * 18 | * http://www.floppysoftware.es 19 | * floppysoftware@gmail.com 20 | */ 21 | #ifndef ATEXIT_H 22 | 23 | #define ATEXIT_H 24 | 25 | #define ATEXIT_MAX 3 // Max. # of allowed functions 26 | 27 | int _atexit_now; // Counter for # of stored functions 28 | WORD _atexit_arr[ATEXIT_MAX]; // Array for stored functions 29 | 30 | /** 31 | * @fn int atexit(void (*func)(void)) 32 | * @brief Register function to be called when the program terminates normally. 33 | * 34 | * This function registers a function to be called when the program 35 | * terminates normally (either with exit(), or an implicit or 36 | * explicit return in the main() function. 37 | * 38 | * The registered functions will be called in reverse order (last 39 | * registered function first). 40 | * 41 | * @param func - function to call 42 | * @return 0 on sucess, other values on failure 43 | */ 44 | int atexit(func) 45 | WORD func; 46 | { 47 | // Patch exit() 48 | 49 | #asm 50 | LD A,0CDH 51 | LD (exit),A 52 | LD HL,_exit_patch 53 | LD (exit + 1),HL 54 | #endasm 55 | 56 | if(_atexit_now < ATEXIT_MAX) { 57 | _atexit_arr[_atexit_now++] = func; return 0; 58 | } 59 | 60 | return -1; 61 | } 62 | 63 | // void _exit_patch(void) : call registered functions in reverse order. 64 | 65 | _exit_patch() 66 | { 67 | while(_atexit_now) 68 | _atexit_arr[--_atexit_now](); 69 | } 70 | 71 | // Cleaning 72 | 73 | #undef ATEXIT_MAX 74 | 75 | #endif 76 | 77 |  -------------------------------------------------------------------------------- /H/UNCR.HLP: -------------------------------------------------------------------------------- 1 | :UNCR [d:] [d:] [/Q | /V | /C] 2 | 3 | where [d:] is any filename (with optional drive spec). The second 4 | [d:] is an optional drive specifier where the output will be 5 | directed. If either "d:" is not specified, the default (logged) 6 | drive will be used. All input & output takes place in the cur- 7 | rent user area. 8 | 9 | Note that the resulting filename will be recreated from the name 10 | of the file that was originally crunched. 11 | 12 | It is not necessary that the file to be uncrunched have "Z" as 13 | the middle letter of the extension; an attempt will be made to 14 | uncrunch any filename explicitly specified. Note however that 15 | "UNCR *.*" will be internally converted to "UNCR *.?Z?" to facil- 16 | itate quickly uncrunching all crunched files in a mixed group. 17 | ~ 18 | UNCR [d:] [d:] [/Q | /V | /C] 19 | 20 | Three command line options, "/Q", "/V" or "/C", are available. 21 | If used, the option should be last on the command line, and the 22 | "/" must be preceded by a space. Only one option may be selected. 23 | 24 | "/Q" and "/V" will "quiet down" a version of UNCR which has 25 | been configured to be "verbose", or cause a "verbose" run of a 26 | program normally configured to be "quiet". This relates to the 27 | amount of information sent to the console. 28 | 29 | "/C", the confirm option, is used for selective uncrunching. 30 | When used in conjunction with wildcard filespecs, this option 31 | causes the program to ask "Y/N" for each matching file. Only the 32 | files to which "Y" is responded will be uncrunched. Selecting 33 | this option causes the program to automatically ask for added 34 | confirmation if a pre-existing file is about to be overwritten, 35 | regardless of the program's configuration. 36 |  -------------------------------------------------------------------------------- /C/IO.H: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 1982 by Manx Software Systems */ 2 | /* 3 | * if MAXCHAN is changed then the initialization of chantab in croot.c 4 | * should be adjusted so that it initializes EXACTLY MAXCHAN elements of 5 | * the array. If this is not done, the I/O library may exhibit 6 | * strange behavior. 7 | */ 8 | #define MAXCHAN 11 /* maximum number of I/O channels */ 9 | 10 | /* 11 | * argument to device routines. 12 | * this is a typedef to allow future redeclaration to guarantee 13 | * enough space to store either a pointer or an integer. 14 | */ 15 | typedef char *_arg; 16 | 17 | /* 18 | * device control structure 19 | */ 20 | struct device { 21 | char d_read; 22 | char d_write; 23 | char d_ioctl; /* used by character special devices (eg CON:) */ 24 | char d_seek; /* used by random I/O devices (eg: a file) */ 25 | int (*d_open)(); /* for special open handling */ 26 | }; 27 | 28 | /* 29 | * device table, contains names and pointers to device entries 30 | */ 31 | struct devtabl { 32 | char *d_name; 33 | struct device *d_dev; 34 | _arg d_arg; 35 | }; 36 | 37 | /* 38 | * channel table: relates fd's to devices 39 | */ 40 | struct channel { 41 | char c_read; 42 | char c_write; 43 | char c_ioctl; 44 | char c_seek; 45 | int (*c_close)(); 46 | _arg c_arg; 47 | } ; 48 | extern struct channel chantab[MAXCHAN]; 49 | 50 | struct fcb { 51 | char f_driv; 52 | char f_name[8]; 53 | char f_type[3]; 54 | char f_ext; 55 | char f_resv[2]; 56 | char f_rc; 57 | char f_sydx[16]; 58 | char f_cr; 59 | unsigned f_record; char f_overfl; 60 | }; 61 | 62 | struct fcbtab { 63 | struct fcb fcb; 64 | char offset; 65 | char flags; 66 | char user; 67 | }; 68 | 69 | #define OPNFIL 15 70 | #define CLSFIL 16 71 | #define DELFIL 19 72 | #define READSQ 20 73 | #define WRITSQ 21 74 | #define MAKFIL 22 75 | #define SETDMA 26 76 | #define GETUSR 32 77 | #define READRN 33 78 | #define WRITRN 34 79 | #define FILSIZ 35 80 | #define SETREC 36 81 | 82 | #define Wrkbuf ((char *)0x80) 83 | -------------------------------------------------------------------------------- /P/TURBO.MSG: -------------------------------------------------------------------------------- 1 |  are not allowed 2 |  can not be 3 |  constant 4 |  does not 5 |  expression 6 |  identifier 7 |  file 8 |  here 9 | Integer 10 | File 11 | Illegal 12 |  or 13 | Undefined 14 |  match 15 |  real 16 | String 17 | Textfile 18 |  out of range 19 |  variable 20 |  overflow 21 |  expected 22 |  type 23 | Invalid 24 |  pointer 25 | 01';' 26 | 02':' 27 | 03',' 28 | 04'(' 29 | 05')' 30 | 06'=' 31 | 07':=' 32 | 08'[' 33 | 09']' 34 | 10'.' 35 | 11'..' 36 | 12BEGIN 37 | 13DO 38 | 14END 39 | 15OF 40 | 17THEN 41 | 18TO DOWNTO 42 | 20Boolean 43 | 21  44 | 22  45 | 23  46 | 24  47 | 25  48 | 26  49 | 27  50 | 28Pointer 51 | 29Record 52 | 30Simple 53 | 31Simple 54 | 32 55 | 33 56 | 34 57 | 35 58 | 36Type 59 | 37Untyped 60 | 40 label 61 | 41Unknown syntax error 62 | 42 in preceding definitions 63 | 43Duplicate label 64 | 44Type mismatch 65 | 45 66 | 46 and CASE selector 67 | 47Operand(s) operator 68 | 48 result 69 | 49  length 70 | 50 length 71 | 51 subrange base 72 | 52Lower bound > upper bound 73 | 53Reserved word 74 | 54 assignment 75 | 55 exceeds line 76 | 56Error in integer 77 | 57Error in 78 | 58 character in 79 | 60s 80 | 61 s ands 81 | 62Structureds 82 | 63s 83 | 64s and untypeds 84 | 65Untypeds 85 | 66I/O 86 | 67 s must be parameters 87 | 68 componentss 88 | 69dering of fields 89 | 70Set base 90 | 71 GOTO 91 | 72Label not within current block 92 | 73 FORWARD procedure(s) 93 | 74INLINE error 94 | 75 use of ABSOLUTE 95 | 90 not found 96 | 91Unexpected end of source 97 | 97Too many nested WITH's 98 | 98Memory 99 | 99Compilerd WITH's 100 | 98Memory 101 | 99Compiler -------------------------------------------------------------------------------- /F/MEMORY.MAC: -------------------------------------------------------------------------------- 1 | ; 2 | ; MEMORY.MAC - Memory Operations 3 | ; 4 | ; 97/12/28 5 | ; 6 | ; @ ! C@ C! 2@ 2! +! MOVE FILL ERASE 7 | ; 8 | 9 | ; @ ( a-addr -- x ) 10 | 11 | hdr 1,'@' 12 | at: pop hl 13 | at1: ld e,(hl) 14 | inc hl 15 | ld d,(hl) 16 | push de 17 | jp next 18 | 19 | ; ! ( x a-addr -- ) 20 | 21 | hdr 1,'!' 22 | store: pop hl 23 | store1: pop de 24 | ld (hl),e 25 | inc hl 26 | ld (hl),d 27 | jp next 28 | 29 | ; C@ ( c-addr -- char ) 30 | 31 | hdr 2,'C@' 32 | cat: pop hl 33 | ld l,(hl) 34 | ld h,0 35 | jp hpush 36 | 37 | ; C! ( char c-addr -- ) 38 | 39 | hdr 2,'C!' 40 | cstor: pop hl 41 | pop de 42 | ld (hl),e 43 | jp next 44 | 45 | ; 2@ ( a-addr -- x1 x2 ) 46 | 47 | hdr 2,'2@' 48 | tat: pop hl 49 | tat1: ld e,(hl) 50 | inc hl 51 | ld d,(hl) 52 | inc hl 53 | ld a,(hl) 54 | inc hl 55 | ld h,(hl) 56 | ld l,a 57 | ex de,hl 58 | jp dpush 59 | 60 | ; 2! ( x1 x2 a-addr -- ) 61 | 62 | hdr 2,'2!' 63 | tstor: pop hl 64 | tstor1: pop de 65 | ld (hl),e 66 | inc hl 67 | ld (hl),d 68 | inc hl 69 | jp store1 70 | 71 | ; +! ( x a-addr -- ) 72 | 73 | hdr 2,'+!' 74 | pstor: pop hl 75 | pop de 76 | ld a,(hl) 77 | add a,e 78 | ld (hl),a 79 | inc hl 80 | ld a,(hl) 81 | adc a,d 82 | ld (hl),a 83 | jp next 84 | 85 | ; MOVE ( addr1 addr2 u -- ) 86 | 87 | hdr 4,'MOVE' ; ANS 88 | move: ld l,c 89 | ld h,b 90 | pop bc 91 | pop de 92 | ex (sp),hl 93 | call cmpu 94 | jp c,cmovu1 95 | jp cmove1 96 | 97 | ; FILL ( c-addr u char -- ) 98 | 99 | hdr 4,'FILL' 100 | fill: pop de 101 | fill1: ld l,c 102 | ld h,b 103 | pop bc 104 | ex (sp),hl 105 | jp fill3 106 | 107 | fill2: ld (hl),e 108 | inc hl 109 | dec bc 110 | fill3: ld a,c 111 | or b 112 | jp nz,fill2 113 | pop bc 114 | jp next 115 | 116 | ; ERASE ( addr u -- ) 117 | 118 | hdr 5,'ERASE' 119 | erase: ld e,0 120 | jp fill1 121 | 122 | ; end 123 |  -------------------------------------------------------------------------------- /M/setjmp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file setjmp.h 3 | * @brief Non-local jumps. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Non-local jumps functions, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Only one jmp_buf is allowed. 10 | * 11 | * Call to setjmp is performed as - ie: setjmp(env): 12 | * LD HL,(env) 13 | * PUSH HL 14 | * CALL setjmp 15 | * POP BC 16 | * 17 | * Call to longjmp is performed as - ie: longjmp(env, 1): 18 | * 19 | * LD HL,(env) 20 | * PUSH HL 21 | * LD HL,1 22 | * PUSH HL 23 | * CALL longjmp 24 | * POP BC 25 | * POP BC 26 | * 27 | * Defined macros: 28 | * - jmp_buf 29 | * 30 | * Revisions: 31 | * - 21 Ago 2015 : Initial version. 32 | * - 22 Ago 2015 : Changed jmp_buf from char to int. 33 | * - 15 Ago 2016 : Documented. GPL v3. 34 | * 35 | * Copyright (c) 2015-2016 Miguel I. Garcia Lopez / FloppySoftware. 36 | * 37 | * Licensed under the GNU General Public License v3. 38 | * 39 | * http://www.floppysoftware.es 40 | * floppysoftware@gmail.com 41 | */ 42 | #ifndef SETJMP_H 43 | 44 | #define SETJMP_H 45 | 46 | #define jmp_buf int // Just something 47 | 48 | WORD setjmp_rt; // Return address 49 | WORD setjmp_sp; // SP 50 | 51 | /** 52 | * @fn int setjmp (jmp_buf env) 53 | * @brief Save state information for later use of longjmp(). 54 | * @param env - buffer for state data 55 | * @return 0 from direct call, other values from a longjmp call 56 | */ 57 | #asm 58 | setjmp 59 | POP HL 60 | LD (setjmp_rt), HL 61 | LD (setjmp_sp), SP 62 | PUSH HL 63 | LD HL, 0 64 | RET 65 | #endasm 66 | 67 | /** 68 | * @fn void longjmp (jmp_buf env, int rv) 69 | * @brief Resume execution after setjmp(). 70 | * 71 | * This function resumes the execution after setjmp(), restoring 72 | * the previously stored state in env. 73 | * 74 | * @param env - buffer with state data 75 | * @param rv - value to return; must be != 0 76 | * @return rv value 77 | */ 78 | #asm 79 | longjmp 80 | POP BC 81 | POP HL 82 | LD SP,(setjmp_sp) 83 | LD DE,(setjmp_rt) 84 | PUSH DE 85 | RET 86 | #endasm 87 | 88 | #endif 89 | 90 |  -------------------------------------------------------------------------------- /M/make_cc.c: -------------------------------------------------------------------------------- 1 | /* make_cc.c 2 | 3 | Mike's Enhanced Small C Compiler for Z80 & CP/M 4 | 5 | Build the compiler itself with MESCC under a z80 & CP/M environment. 6 | 7 | Copyright (c) 1999-2016 Miguel I. Garcia Lopez, FloppySoftware. 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22 | 23 | How to build MESCC with this file: 24 | 25 | cc make_cc -s:1024 26 | ccopt make_cc 27 | zsm make_cc 28 | hextocom make_cc 29 | 30 | Now MAKE_CC.COM is the new version of the compiler. 31 | 32 | Revisions: 33 | 34 | 16 Jan 2001 : Last revision. 35 | 16 Apr 2007 : GPL'd. 36 | 04 Sep 2015 : Modified some comments. 37 | 26 Oct 2015 : Added c_defs.c. Modified some comments. 38 | 10 Jan 2015 : Added CC_FILEIO_SMALL def. 39 | 19 Jul 2016 : Removed CC_FILEIO_SMALL def. 40 | 11 Oct 2016 : Added c_parser.c. Documented. 41 | 20 Oct 2016 : Added c_string.c. 42 | */ 43 | 44 | // MESCC #definitions 45 | // ------------------ 46 | 47 | // Nothing yet... 48 | 49 | // MESCC runtime 50 | // ------------- 51 | 52 | #include 53 | 54 | // MESCC libraries 55 | // --------------- 56 | 57 | #include 58 | #include 59 | #include 60 | #include 61 | #include 62 | 63 | // Compiler modules 64 | // ---------------- 65 | 66 | #include "c_defs.c" 67 | #include "c_string.c" 68 | #include "c_main.c" 69 | #include "c_parser.c" 70 | #include "c_cpp.c" 71 | #include "c_expr.c" 72 | #include "c_asm.c" 73 | #include "c_error.c" 74 | #include "c_buf.c" 75 | #include "c_iocon.c" 76 | #include "c_iofile.c" 77 |  -------------------------------------------------------------------------------- /M/c_string.c: -------------------------------------------------------------------------------- 1 | /* c_string.c 2 | 3 | Mike's Enhanced Small C Compiler for Z80 & CP/M 4 | 5 | String handling module. 6 | 7 | Copyright (c) 1999-2016 Miguel I. Garcia Lopez, FloppySoftware. 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22 | 23 | Revisions: 24 | 25 | 20 Oct 2016 : Documented and slightly optimized. Added int2str_5(). 26 | */ 27 | 28 | // Private globals for this module 29 | 30 | char cc_str[7]; // -12345 + ZERO 31 | 32 | // Output int as signed decimal number 33 | 34 | int2str(n) 35 | int n; 36 | { 37 | #ifdef C_USEPRINTF 38 | sprintf(cc_str, "%d", n); 39 | 40 | return cc_str; 41 | #else 42 | char *p; 43 | int sign; 44 | 45 | if(n >= 0) 46 | { 47 | sign = 0; 48 | } 49 | else if(n != -32768) 50 | { 51 | sign = 1; 52 | n = -n; 53 | } 54 | else 55 | { 56 | return strcpy(cc_str, "-32768"); 57 | } 58 | 59 | *(p = cc_str + 6) = '\0'; 60 | 61 | do 62 | { 63 | *(--p) = '0' + n % 10; 64 | } while((n /= 10)); 65 | 66 | if(sign) 67 | { 68 | *(--p) = '-'; 69 | } 70 | 71 | return p; 72 | #endif 73 | } 74 | 75 | // Output int as signed decimal number, 5 digits, padded with spaces. 76 | 77 | int2str_5(n) 78 | int n; 79 | { 80 | #ifdef C_USEPRINTF 81 | sprintf(cc_str, "%5d", n); 82 | 83 | return cc_str; 84 | #else 85 | char *p; 86 | int i, k; 87 | 88 | k = 5 - strlen((p = int2str(n))); 89 | 90 | for(i = 0; i < k; ++i) 91 | { 92 | cc_str[i] = ' '; 93 | } 94 | 95 | strcpy(cc_str + i, p); 96 | 97 | return cc_str; 98 | #endif 99 | } 100 | 101 |  -------------------------------------------------------------------------------- /M/sprintf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sprintf.h 3 | * @brief Library for sprintf() function. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Implementation of sprintf() function, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 20 Oct 2000 : Last revision. 11 | * - 16 Apr 2007 : GPL'd. 12 | * - 14 Apr 2015 : Ammended a bad closed comment. 13 | * - 25 Aug 2016 : Documented. GPL v3. 14 | * 15 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 16 | * 17 | * Licensed under the GNU General Public License v3. 18 | * 19 | * http://www.floppysoftware.es 20 | * floppysoftware@gmail.com 21 | */ 22 | #ifndef SPRINTF_H 23 | 24 | #define SPRINTF_H 25 | 26 | // Dependencies 27 | // ------------ 28 | 29 | #ifndef XPRINTF_H 30 | #include 31 | #endif 32 | 33 | /** 34 | * @fn int sprintf(char *dst, char *fmt, arg1, arg2, ...) 35 | * @brief Formatted output to memory. 36 | * 37 | * See the documentation for xprintf.h to learn about the string format. 38 | * 39 | * @param dst - destination 40 | * @param fmt - string format 41 | * @param arg1 - argument #1 42 | * @param arg? - argument #? 43 | * @return number or characters written, or -1 on failure (currently always #). 44 | */ 45 | #asm 46 | 47 | sprintf: 48 | ADD HL,HL 49 | ADD HL,SP ;HL=Adr. fmt 50 | 51 | LD DE,xspfout 52 | PUSH DE 53 | LD DE,xspfend 54 | PUSH DE 55 | PUSH HL 56 | 57 | INC HL 58 | INC HL ;HL=Adr. dst 59 | LD A,(HL) 60 | INC HL 61 | LD H,(HL) 62 | LD L,A 63 | LD (xspfout+2),HL 64 | 65 | CALL xprintf 66 | 67 | POP BC 68 | POP BC 69 | POP BC 70 | 71 | RET 72 | #endasm 73 | 74 | // int xspfout(char ch) : output ch to memory; return 0 on success, !=0 on failure (currently always returns 0). 75 | 76 | #asm 77 | 78 | xspfout: 79 | LD A,L 80 | LD HL,0 ;Adr. 81 | LD (HL),A 82 | 83 | INC HL 84 | LD (xspfout+2),HL 85 | 86 | LD HL,0 87 | 88 | RET 89 | #endasm 90 | 91 | // void xspfend(void) : end formatted output; writes a trailing zero byte. 92 | 93 | #asm 94 | 95 | xspfend: 96 | LD HL,(xspfout+2) 97 | LD (HL),0 98 | RET 99 | 100 | #endasm 101 | 102 | #endif 103 | 104 |  -------------------------------------------------------------------------------- /M/fprintf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fprintf.h 3 | * @brief Library for fprintf() function. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Implementation of fprintf() function, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 23 Jan 2001 : Last revision. 11 | * - 16 Apr 2007 : GPL'd. 12 | * - 25 Aug 2016 : Documented. GPL v3. 13 | * 14 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 15 | * 16 | * Licensed under the GNU General Public License v3. 17 | * 18 | * http://www.floppysoftware.es 19 | * floppysoftware@gmail.com 20 | */ 21 | #ifndef FPRINTF_H 22 | 23 | #define FPRINTF_H 24 | 25 | // Dependencies 26 | // ------------ 27 | 28 | #ifndef XPRINTF_H 29 | #include 30 | #endif 31 | 32 | #ifndef FILEIO_H 33 | #include 34 | #endif 35 | 36 | /** 37 | * @fn int fprintf(FILE *fp, char *fmt, arg1, arg2, ...) 38 | * @brief Formatted output to a file. 39 | * 40 | * See the documentation for xprintf.h to learn about the string format. 41 | * 42 | * @param fp - file pointer 43 | * @param fmt - string format 44 | * @param arg1 - argument #1 45 | * @param arg? - argument #? 46 | * @return number or characters written, or -1 on failure. 47 | */ 48 | #asm 49 | 50 | fprintf: 51 | ADD HL,HL 52 | ADD HL,SP ;HL=Adr. fmt 53 | 54 | LD DE,xfpfout 55 | PUSH DE 56 | LD DE,xfpfend 57 | PUSH DE 58 | PUSH HL 59 | 60 | INC HL 61 | INC HL ;HL=Adr. *fp 62 | LD A,(HL) 63 | INC HL 64 | LD H,(HL) 65 | LD L,A 66 | LD (xfpfout+2),HL 67 | 68 | CALL xprintf 69 | 70 | POP BC 71 | POP BC 72 | POP BC 73 | 74 | RET 75 | #endasm 76 | 77 | // int xfpfout(char ch) : output ch to a file; return 0 on success, !=0 on failure. 78 | 79 | #asm 80 | 81 | xfpfout: 82 | PUSH HL ;Char. 83 | LD HL,0 ;*FP 84 | PUSH HL 85 | 86 | CALL fputc 87 | 88 | POP BC 89 | POP BC 90 | 91 | EX DE,HL 92 | LD HL,0 93 | 94 | LD A,255 95 | CP D 96 | RET NZ 97 | CP E 98 | RET NZ 99 | 100 | INC L 101 | RET 102 | #endasm 103 | 104 | // void xfpfend(void) : end formatted output; currently does nothing. 105 | 106 | #asm 107 | 108 | xfpfend: 109 | RET 110 | 111 | #endasm 112 | 113 | #endif 114 | 115 |  -------------------------------------------------------------------------------- /H/Z8E.HLP: -------------------------------------------------------------------------------- 1 | : Z8E - Z80 DEBUGGING MONITOR COMMAND SUMMARY REFERENCE 2 | 3 | [] Denotes Optional Argument 4 | [/] Do Not Trace Subroutine 5 | [*] Do Not Trace BDOS Call 6 | [(] [)] I/O Port Monitor Mode 7 | 8 | CMD Description Arguments 9 | 10 | A Inline Assembly StartAddr 11 | B Set Breakpoint Addr1[,Pass Count] [Addr2..AddrN] 12 | C Clear Breakpoint Addr1 [Addr2..AddrN] 13 | D Dump Memory [StartAddr] [End/Count] 14 | E Examine Memory StartAddr 15 | F Find StartAddr MatchData 16 | G Go ExecutionAddr 17 | H Display Symbol Table [FirstSymbol] 18 | I Input File FileName [,Load Address] 19 | J Full Screen/Animated Debug [/] [*] [Addr] [Timeout] 20 | K Set Memory Window StartAddr [Size] 21 | M Move Memory SourceStart SourceEnd DestStart 22 | ~ 23 | [] Denotes Optional Argument 24 | [/] Do Not Trace Subroutine 25 | [*] Do Not Trace BDOS Call 26 | [(] [)] I/O Port Monitor Mode 27 | 28 | CMD Description Arguments 29 | 30 | N Output to Port NO Pre-Read [(] PortAddr [)] 31 | O Output Current Breakpoints 32 | P Exam/Modify PSW (Flag Reg) 33 | Q Query I/O Port [(] PortAddr [)] 34 | R Examine/Modify Registers RegSpecifier 35 | S Single-Step [/] [Count] 36 | U Write Symbol Table To Disk FileName 37 | V Verify Memory SourceStart SourceEnd DestStart 38 | W Write to Disk FileName [StartAddr] [EndAddr] 39 | X Examine Machine State 40 | Y Fill Memory FromAddr ToAddr Data 41 | Z Disassemble StartAddr End/Count FileName 42 |  -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CP/M Distribution 2 | 3 | This repository contains a list of binaries, Z80-based, for use with CP/M systems. 4 | 5 | 6 | 7 | ## Organization 8 | 9 | The layout of the repository is based upon "drives". CP/M did not initially support directories, and many systems exist which are not running those versions that did. Instead CP/M had a notion of a drive, for example "A:", "B:", etc. 10 | 11 | This repository has grouped the drives into what seemed like a consistent fashion. 12 | 13 | 14 | 15 | ## Usage 16 | 17 | If you have a CP/M system, or emulator, which supports the use of a directory-as-a-drive you should be able to clone the repository and start using things. 18 | 19 | Using my [cpmulator](https://github.com/skx/cpmulator/) for example: 20 | 21 | ```sh 22 | $ cpmulator -directories 23 | A> G: 24 | G> ZORK1 25 | .. 26 | West of House 27 | You are standing in an open field west of a white house, with 28 | a boarded front door. 29 | There is a small mailbox here. 30 | ``` 31 | 32 | 33 | 34 | ## Contents 35 | 36 | Currently the contents are in-flux, but when we have more this section will be expanded. 37 | 38 | | Drive | Contents | Notes | 39 | |----------|------------|------------------------------------------| 40 | | [A:](A/) | Standard | Standard utilities for general use. | 41 | | [B:](B/) | BASIC | Various BASIC Interpreters. | 42 | | [C:](C/) | C compiler | The Aztec C Compiler. | 43 | | D: | | | 44 | | [E:](E/) | Editor | The Wordstar Editor, v3.3. | 45 | | [F:](F/) | FORTH | An installation of Dx-FORTH. | 46 | | [G:](G/) | Games | Text-based adventure-games. | 47 | | [H:](H/) | Help | Help files for various tools & systems. | 48 | | [I:](I/) | Utility | Instruction-tester for our Z80 emulator. | 49 | | J: | | | 50 | | K: | | | 51 | | [L:](L/) | Lisp | A simple lisp-interpreter. | 52 | | [M:](M/) | C Compiler | Mike's Enhanced Small Compiler. | 53 | | N: | | | 54 | | O: | | | 55 | | [P:](P/) | Pascal | Turbo Pascal 3.00A. | 56 | -------------------------------------------------------------------------------- /M/redir.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file redir.h 3 | * @brief I/O redirection in command line. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Support library for I/O redirection in command line, 7 | * for MESCC (Mike's Enhanced Small C Compiler for Z80 & CP/M). 8 | * 9 | * Supported redirections: 10 | * - echo < address.txt 11 | * - echo 'Park Avenue, 234b' > address.txt 12 | * - echo 'Call Elvis' >> todo.txt 13 | * 14 | * Revisions: 15 | * - 08 Dec 2014 : 1st version. 16 | * - 29 Nov 2016 : Support for '>>' redirection. Optimizations in NULL comparisons. 17 | * - 07 Dec 2016 : GPL v3. 18 | * 19 | * Copyright (c) 2014-2016 Miguel I. Garcia Lopez / FloppySoftware. 20 | * 21 | * Licensed under the GNU General Public License v3. 22 | * 23 | * http://www.floppysoftware.es 24 | * floppysoftware@gmail.com 25 | */ 26 | #ifndef REDIR_H 27 | 28 | #define REDIR_H 29 | 30 | /** 31 | * @fn int redir(int argc, char *argv[]) 32 | * @brief Stdin & stdout redirection in command line. 33 | * @param argc - number of arguments 34 | * @param argv - array of arguments 35 | * @return number of arguments after redirection parsing 36 | */ 37 | redir(argc, argv) 38 | int argc, argv[]; 39 | { 40 | int i, z; char *p; 41 | char *fnin, *fnout; 42 | FILE *fp; 43 | 44 | #ifdef CC_FOPEN_A 45 | int append; 46 | #endif 47 | 48 | fnin = fnout = NULL; 49 | 50 | for(i = 1; i < argc; ++i) 51 | { 52 | p = argv[i]; 53 | 54 | #ifdef CC_FOPEN_A 55 | if(((*p == '<' || *p == '>') && !(p[1])) || (*p == '>' && p[1] == '>' && !(p[2]))) 56 | #else 57 | if((*p == '<' || *p == '>') && !(p[1])) 58 | #endif 59 | { 60 | if(i + 1 == argc) 61 | return -1; /* No filename */ 62 | 63 | if(*p == '<') 64 | fnin = argv[i + 1]; 65 | else 66 | { 67 | fnout = argv[i + 1]; 68 | 69 | #ifdef CC_FOPEN_A 70 | append = p[1]; 71 | #endif 72 | } 73 | 74 | argc -= 2; 75 | 76 | for(z = i; z < argc; ++z) 77 | argv[z] = argv[z + 2]; 78 | --i; 79 | } 80 | } 81 | 82 | if(fnin) 83 | { 84 | if((fp = fopen(fnin, "r"))) 85 | stdin = fp; 86 | else 87 | return -2; 88 | } 89 | 90 | if(fnout) 91 | { 92 | #ifdef CC_FOPEN_A 93 | if((fp = fopen(fnout, (append ? "a" : "w")))) 94 | #else 95 | if((fp = fopen(fnout, "w"))) 96 | #endif 97 | stdout = fp; 98 | else 99 | return -3; 100 | } 101 | 102 | return argc; 103 | } 104 | 105 | #endif 106 | 107 |  -------------------------------------------------------------------------------- /P/README.md: -------------------------------------------------------------------------------- 1 | # Turbo Pascal 2 | 3 | This brief page documents how to get started with Turbo Pascal 3.00A, compiling a hello-world program. 4 | 5 | To get started run: 6 | 7 | P> turbo 8 | 9 | You should now be looking at the Turbo Pascal splash screen, showing the version, copyright message and which terminal is configured. At the bottom you'll be asked whether you want to `Include error messages`. For the moment press `Y`. 10 | 11 | Now you will be presented with the main screen. You have a number of commands on this screen, which are accessed by a single letter as indicated by the `(X)` brackets: 12 | 13 | Logged drive: P 14 | 15 | Work file: 16 | Main file: 17 | 18 | (E)dit (C)ompile (R)un (S)ave 19 | 20 | e(X)ecute (D)ir (Q)uit compiler (O)ptions 21 | 22 | Text: 0 bytes (8118-8118) 23 | Free: 22253 bytes (8119-D806) 24 | 25 | > 26 | 27 | The first thing you should do is to configure things to actually generate `.com` files when you run the compilation step. Start by pressing `O` to choose the `compiler Options`, which will show you this: 28 | 29 | compile -> Memory 30 | Com-file 31 | cHn-file 32 | 33 | Find run-time error Quit 34 | 35 | Choose `Com-file` by pressing `C`, then press `Q` to go back to the main-menu. If the main menu doesn't appear press `?`. 36 | 37 | Now you can launch the editor by pressing `E`. You'll be prompted for a file to edit, so you can choose something like "steve.pas". Enter the following program: 38 | 39 | 40 | Line 1 Col 1 Insert Indent A:STEVE.PAS 41 | program Hello; 42 | begin 43 | writeln ('Hello, world.'); 44 | end. 45 | 46 | Now you can exit the editor by pressing `Ctrl-k d`, once again you'll be at the main-menu. If that doesn't appear press `?`. 47 | 48 | Compile your work by pressing `C`: 49 | 50 | > 51 | 52 | Compiling --> A:STEVE.COM 53 | 5 lines 54 | 55 | Code: 54 bytes (20E2-2118) 56 | Free: 47009 bytes (2119-D8BA) 57 | Data: 135 bytes (D8BB-D942) 58 | 59 | 60 | Press `Q` to exit the environment, and you'll then be able to execute your binary: 61 | 62 | P> STEVE 63 | Hello, world. 64 | 65 | 66 | ## Keybindings 67 | 68 | Keybindings within the editor-environment are based on those used in Wordstar, the following reference is a useful resource: 69 | 70 | * http://www.wordstar.org/index.php/wsdos-documentation/wsdos-commands/108-wordstar-3-for-dos-commands-reference 71 | -------------------------------------------------------------------------------- /C/DUMP.C: -------------------------------------------------------------------------------- 1 | /* 2 | * dump.c - A file-dumping program for CP/M which shows ASCII as 3 | * well as the hex contents of files. 4 | * 5 | * Compile via the Aztec C compiler: 6 | * 7 | * CC DUMP 8 | * AS DUMP 9 | * LN DUMP.O C.LIB 10 | * 11 | * NOTE: The C compiler doesn't understand "%02X" to output a hex 12 | * value as upper-case, it only understands "%02x", and I added a 13 | * manual step to upper-case the hex-digits. 14 | * 15 | * Steve Kemp 29/04/2024 16 | * https://github.com/skx/cpm-dist/ 17 | * 18 | */ 19 | #include "libc.h" 20 | 21 | main(argc, argv) 22 | int argc; char **argv ; 23 | { 24 | char tmp[16]; 25 | int i; 26 | int offset; 27 | int c, f; 28 | 29 | i = 0; 30 | offset = 0; 31 | 32 | if ( argc != 2 ) { 33 | printf("Usage: DUMP filename.ext\n"); 34 | exit(1); 35 | } 36 | 37 | /* open the file */ 38 | f = fopen(argv[1], "r"); 39 | if ( !f ) { 40 | printf("Failed to open %s\n", argv[1]); 41 | exit(1); 42 | } 43 | 44 | /* read character by character, until the end of file */ 45 | while(( c = getc(f)) != EOF) 46 | { 47 | 48 | /* read character into our temporary buffer */ 49 | tmp[i] = c; 50 | i++; 51 | 52 | /* Got a full line? */ 53 | if ( i == 16 ){ 54 | 55 | /* build a line of output here. 56 | specifically so we can upper-case it. */ 57 | char buf[100]; 58 | 59 | /* set the buffer to be full of nulls */ 60 | for ( i = 0; i < sizeof(buf); i++) 61 | buf[i] = 0x00; 62 | 63 | /* Add the offset */ 64 | sprintf(buf, "%04x ", offset); 65 | 66 | /* Add the hex contents */ 67 | for (i = 0; i < 16 ; i++ ) 68 | sprintf(buf + strlen(buf), "%02x ", tmp[i]); 69 | 70 | /* Upper case the output line - before we add the ASCII*/ 71 | for ( i = 0 ; i < sizeof(buf); i++ ) 72 | buf[i] = toupper(buf[i]); 73 | 74 | /* Add the ASCII */ 75 | for (i = 0; i < 16 ; i++ ) 76 | if ( tmp[i]>= 32 && tmp[i]<128) 77 | sprintf(buf + strlen(buf), "%c", tmp[i]); 78 | else 79 | sprintf(buf + strlen(buf), " "); 80 | 81 | /* Now output a complete line */ 82 | printf("%s\n", buf); 83 | 84 | /* reset our position, and bump the offset */ 85 | i= 0; 86 | offset= offset + 16; 87 | } 88 | } 89 | 90 | /* All done */ 91 | fclose(f); 92 | exit(0); 93 | 94 | } 95 | -------------------------------------------------------------------------------- /I/RNDTST.ASM: -------------------------------------------------------------------------------- 1 | TITLE 'rndtst - test - Test R register as random number generator' 2 | ; 26-Dec-2016 3 | ORG 100H 4 | ; 5 | BDOS EQU 5 ;BDOS entry point 6 | COUT EQU 2 ;BDOS Output character 7 | CR EQU 13 8 | LF EQU 10 9 | ; 10 | START: 11 | LXI H,INTRO ;address of intro string 12 | CALL STROUT 13 | ; 14 | LXI H,ITSA ;address type message string 15 | CALL STROUT 16 | XRA A ;zero A 17 | DCR A 18 | JPE NOTZ80 19 | LXI H,NMZ80 ;address Z80 string 20 | CALL STROUT 21 | CALL CRLF 22 | JMP DORND 23 | NOTZ80: LXI H,NM8080 ;address 8080 string 24 | CALL STROUT 25 | JMP CRLF 26 | ; 27 | DORND: CALL TSTRND 28 | CALL TSTRND 29 | CALL TSTRND 30 | CALL TSTRND 31 | JMP TSTRND ;return to CCP 32 | 33 | ; 34 | ; TSTRND - get random number and print it 35 | ; 36 | TSTRND: LXI H,0 37 | DB 0EDH, 5FH ; LD A,R in hex for 8080 ASM 38 | MOV L,A 39 | CALL DECPRT 40 | JMP CRLF 41 | 42 | ; 43 | ; DECPRT - print byte in M/HL as decimal number 44 | ; 45 | DECPRT: PUSH H 46 | PUSH D 47 | PUSH B 48 | MVI B,0 ;leading-zero flag 49 | LXI D,-10000 50 | CALL SUBTR 51 | LXI D,-1000 52 | CALL SUBTR 53 | LXI D,-100 54 | CALL SUBTR 55 | LXI D,-10 56 | CALL SUBTR 57 | MOV A,L 58 | ADI '0' 59 | CALL CHROUT 60 | POP B 61 | POP D 62 | POP H 63 | RET 64 | 65 | ; 66 | SUBTR: MVI C,'0'-1 67 | SUBT2: INR C 68 | DAD D 69 | JC SUBT2 70 | ; 71 | ; SBC HL,DE 72 | MOV A,L 73 | SUB E 74 | MOV L,A 75 | MOV A,H 76 | SBB D 77 | MOV H,A 78 | ; 79 | MOV A,C ;get count 80 | ; 81 | CPI '1' ;less than 1? 82 | JNC NZERO ;no 83 | MOV A,B ;check flag 84 | ORA A ;is set? 85 | MOV A,C ;restore count 86 | RZ ;skip leading 0 87 | JMP CHROUT 88 | ;set flag on non-zero chars 89 | NZERO: MVI B,0FFH 90 | JMP CHROUT 91 | 92 | ; 93 | ; STROUT - print null terminated string 94 | ; 95 | STROUT: 96 | STLOOP: MOV A,M 97 | ORA A 98 | JZ STRDON 99 | CALL CHROUT 100 | INX H 101 | JMP STLOOP 102 | STRDON: 103 | RET 104 | 105 | 106 | ; 107 | ; CRLF - print CR and LF 108 | ; 109 | CRLF MVI A,CR 110 | CALL CHROUT 111 | MVI A,LF 112 | ; 113 | ; FALL THROUGH 114 | 115 | ; 116 | ; CHROUT - print one char via BDOS 2 117 | ; 118 | CHROUT: PUSH H 119 | PUSH A 120 | MOV E,A 121 | MVI C,COUT 122 | CALL BDOS 123 | POP A 124 | POP H 125 | RET 126 | ; 127 | 128 | INTRO: DB 'RNDTST - Test R register as random number generator', CR, LF, 0 129 | ITSA: DB 'CPU is a',0 130 | NMZ80: DB ' Z80',0 131 | NM8080: DB 'n 8080',0 132 | 133 | END START 134 | -------------------------------------------------------------------------------- /M/mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mem.h 3 | * @brief Memory functions. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Memory functions, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 25 Oct 2000 : Last revision. 11 | * - 16 Apr 2007 : GPL'd. 12 | * - 25 Aug 2016 : Documented. GPL v3. 13 | * - 25 Dec 2018 : Optimize memset() for speed. 14 | * 15 | * Copyright (c) 1999-2018 Miguel I. Garcia Lopez / FloppySoftware. 16 | * 17 | * Licensed under the GNU General Public License v3. 18 | * 19 | * http://www.floppysoftware.es 20 | * floppysoftware@gmail.com 21 | */ 22 | #ifndef MEM_H 23 | 24 | #define MEM_H 25 | 26 | /** 27 | * @fn char *memset(char *dst, char data, int count) 28 | * @brief Fill 'count' bytes with 'data' into 'dst'. 29 | * @param dst - destination 30 | * @param data - fill byte 31 | * @param count - how many 32 | * @return pointer to 'dst' 33 | */ 34 | #asm 35 | 36 | memset: 37 | POP AF 38 | POP BC 39 | POP DE 40 | POP HL 41 | PUSH HL 42 | PUSH DE 43 | PUSH BC 44 | PUSH AF 45 | 46 | LD A,B 47 | OR C 48 | RET Z 49 | 50 | PUSH HL 51 | 52 | LD (HL),E 53 | LD D,H 54 | LD E,L 55 | INC DE 56 | DEC BC 57 | LDIR 58 | 59 | POP HL 60 | RET 61 | #endasm 62 | 63 | /** 64 | * @fn char *memcpy(char *dst, char *src, int count) 65 | * @brief Copy 'count' bytes from 'src' to 'dst'. 66 | * @param dst - destination 67 | * @param src - source 68 | * @param count - how many 69 | * @return pointer to 'dst' 70 | */ 71 | #asm 72 | 73 | memcpy: 74 | POP AF 75 | POP BC 76 | POP HL 77 | POP DE 78 | PUSH DE 79 | PUSH HL 80 | PUSH BC 81 | PUSH AF 82 | PUSH DE 83 | LD A,B 84 | OR C 85 | JR Z,memcpy2 86 | LDIR 87 | memcpy2 88 | POP HL 89 | RET 90 | #endasm 91 | 92 | /** 93 | * @fn int memcmp(char *mem1, char *mem2, int count) 94 | * @brief Compare 'count' bytes. 95 | * @param mem1 - pointer 96 | * @param mem2 - pointer 97 | * @param count - how many 98 | * @return <0 on mem1 < mem2; =0 on mem1 == mem2; >0 on mem1 > mem2 99 | */ 100 | #asm 101 | 102 | memcmp 103 | POP AF 104 | POP BC 105 | POP HL 106 | POP DE 107 | PUSH DE 108 | PUSH HL 109 | PUSH BC 110 | PUSH AF 111 | 112 | memcmp1 113 | LD A,C 114 | OR B 115 | JR Z,memcmp2 116 | 117 | DEC BC 118 | 119 | LD A,(DE) 120 | CP (HL) 121 | INC DE 122 | INC HL 123 | JR Z,memcmp1 124 | 125 | memcmp2 126 | LD HL,0 127 | RET Z 128 | JR NC,memcmp3 129 | DEC HL 130 | RET 131 | 132 | memcmp3 133 | INC L 134 | RET 135 | #endasm 136 | 137 | #endif 138 | 139 |  -------------------------------------------------------------------------------- /H/VDE.HLP: -------------------------------------------------------------------------------- 1 | VDE Version 2.1 Command Summary 2 | CURSOR MOVEMENT: ^S cursor left ^F fast right |DELETION: 3 | CPM arrow keys work ^E cursor up ^R scroll up | delete left 4 | BUT up/down always ^D cursor right ^C scroll down |^G delete at cursor 5 | does "fast left" ^X cursor down ESC-T top of file|^U undelete char 6 | first ^Q to blk begin ESC-E end of file|^Y del line left 7 | ESC- ESC- scroll up/down 4 lines |ESC-D delete block 8 | ESC- ESC- horiz. scroll right/left 30 columns ======================== 9 | ======================================================|MISCELANEOUS: 10 | BLOCK COMMANDS: |INSERTION: |^O toggle pagination 11 | ^Q move to blk begin |^N or new line |^W toggle window 12 | ESC-B set block begin |^V toggle insert |^T toggle case 13 | (block end is cursor) | or ^I insert real tab|^B reformat para. 14 | ESC-D delete block |ESC insert space tab |^? help menu 15 | ESC-Y yank into buffer |ESC-I insert disk file |ESC-R set right margin 16 | ESC-G get text from buffer|===========================|ESC-H center "heading" 17 | ESC-W write buffer to disk|FILE COMMANDS: ||ESC-ESC cancel ESC cmd 18 | ==========================|ESC-V view disk dir |======================= 19 | Find/Replace: |ESC-L load new file |MACRO COMMANDS: 20 | ^A repeat find |ESC-N chg file name |ESC-M define macro 21 | ^Z repeat replace |ESC-S save/continue |ESC-K store macro key 22 | ESC-F find |ESC-X save/exit |ESC-n use stored macro 23 | ESC-C replace string |ESC-Q quit/no save | (n=0...9) 24 | just found |ESC-W write buffer to disk|^W pause (in macro only) 25 | ==========================|ESC-I insert disk file | command prompts: 26 | PRINTER CONTROL: |ESC-P print file | * = execute 255 times 27 | ^P insert control code ===========================| q = no update 'til done 28 | [Use twice in Macros] ^D (toggle) ========================= 29 | (use these after ^P): ^Y (toggle) ^R (switch) 30 | ^L insert formfeed ^S (toggle) ^E (switch) 31 | ^H overstrike ^W (switch) ^Q (switch) 32 | ============================================================================== 33 | SPECIAL PRINTER FUNCTONS AND DEFINED MACROS: 34 | ESC-1 ESC-6 35 | ESC-2 ESC-7 36 | ESC-3 ESC-8 37 | ESC-4 ESC-9 38 | ESC-5 ESC-0 39 |  -------------------------------------------------------------------------------- /H/LINK.HLP: -------------------------------------------------------------------------------- 1 | Linker for Microsoft/Cromemco Products 2 | Command Line 3 | Switches 4 | Error Messages 5 | :LINK: 6 | The linker is used to link assembled, Compiled programs modules 7 | together, load them into memory, and begin execution if desired. The 8 | program modules can come from different sources Some of the sources are 9 | BASCOM 10 | COBOL 11 | FORTRAN 12 | ASSEMBLER 13 | RPG 14 | 15 | :LINK: 16 | The format for the involk of Linker is 17 | 18 | 19 | LINK 20 | 21 | where filename stands for Disk drive letter followed by a colon 22 | followed by the absolute file name 23 | 24 | ext is used if the module extension is different than .rel 25 | 26 | /s stands for switch options. 27 | EXAMPLE of a link 28 | 29 | LINK MAIN,FORLIB/S,MAIN/N/G/E 30 | 31 | The first MAIN is the name of the module from the fortran compiler 32 | The FORLIB/S is the library of standard fortran routines that will 33 | be selected 34 | The MAIN/N/G/E means to name the .COM file MAIN and to save it on 35 | current disk then execute MAIN automatically. 36 | 37 | :LINK: 38 | SWITCH OPTIONS 39 | 40 | Each switch option is preceded by a / 41 | 42 | E .... Exit to operating system 43 | 44 | G .... Go start execution 45 | Start execution of the program as soon as the current command 46 | line has been interpreted. 47 | 48 | M .... Map all symbols 49 | List both all the defined globals and their values and all 50 | undefined globals followed by an asterisk. 51 | 52 | R .... Reset the linker 53 | Puts the linker back to its initial state. the /R is used 54 | to restart LINK if the wrong file was loaded by mistake. 55 | 56 | S .... Search file 57 | Search the disk file having the filename immediately preceding 58 | the /S in the command string, to satisfy any undefined globals. 59 | This is convenient for having the linker search a library file 60 | of musch-used routines. 61 | 62 | U .... List all undefined globals 63 | List all undefined globals as soon as the current command line 64 | has been interpreted and executed. Link defaults to this 65 | switch; therefore it is generally not needed. 66 | :LINK: 67 | ERRORS 68 | 69 | No start address a /G is issued but no main program module 70 | has been loaded. 71 | 72 | Loading error The file given is not a properly formatted 73 | link object file. 74 | 75 | Fatal Table Collision There is not enough memory 76 | 77 | Command error Unrecognizable link command 78 | 79 | File not found Specified file not on specified disk 80 | 81 | mult def global More than one definition of the global name 82 | (possibly wrong modules combined) 83 | :LINK: 84 |  -------------------------------------------------------------------------------- /F/COMPARE.MAC: -------------------------------------------------------------------------------- 1 | ; 2 | ; COMPARE.MAC - Comparison Functions 3 | ; 4 | ; 97/12/28 5 | ; 6 | ; 0= = 0< 0> < U< > MIN MAX WITHIN D0= D= D0< D< DU< 7 | ; DMIN DMAX 8 | ; 9 | 10 | ; 0= ( x -- flag ) 11 | 12 | hdr 2,'0=' 13 | zequ: pop hl 14 | ld a,l 15 | or h 16 | jp z,true 17 | jp false 18 | 19 | ; = ( x1 x2 -- flag ) - 0= 20 | 21 | hdr 1,'=' 22 | equal: pop de 23 | pop hl 24 | equal1: call cmpu 25 | jp z,true 26 | jp false 27 | 28 | ; 0< ( n -- flag ) 29 | 30 | hdr 2,'0<' 31 | zless: pop hl 32 | zless1: add hl,hl 33 | jp c,true 34 | jp false 35 | 36 | ; 0> ( n -- flag ) 37 | 38 | hdr 2,'0>' 39 | zgreat: pop hl 40 | ld a,h 41 | or a 42 | jp m,false 43 | or l 44 | jp nz,true 45 | jp false 46 | 47 | ; < ( n1 n2 -- flag ) 48 | 49 | hdr 1,'<' 50 | less: pop de 51 | pop hl 52 | less1: call cmps 53 | jp c,true 54 | jp false 55 | 56 | ; U< ( u1 u2 -- flag ) 57 | 58 | hdr 2,'U<' 59 | uless: pop de 60 | pop hl 61 | uless1: call cmpu 62 | jp c,true 63 | jp false 64 | 65 | ; > ( n1 n2 -- flag ) 66 | 67 | hdr 1,'>' 68 | great: pop hl 69 | pop de 70 | call cmps 71 | jp c,true 72 | jp false 73 | 74 | ; MIN ( n1 n2 -- n1 | n2 ) 2dup > if swap then drop 75 | 76 | hdr 3,'MIN' 77 | min: pop de 78 | pop hl 79 | call cmps 80 | jp max1 81 | 82 | ; MAX ( n1 n2 -- n1 | n2 ) 2dup < if swap then drop 83 | 84 | hdr 3,'MAX' 85 | max: pop de 86 | pop hl 87 | call cmps 88 | ex de,hl 89 | max1: jp c,hpush 90 | ex de,hl 91 | jp hpush 92 | 93 | ; WITHIN ( n1 n2 n3 -- flag ) over - >r - r> u< 94 | 95 | hdr 6,'WITHIN' ; ANS 96 | within: pop hl 97 | pop de 98 | call ssub 99 | ex (sp),hl 100 | call ssub 101 | pop de 102 | jp uless1 103 | 104 | ; D0= ( d -- flag ) or 0= 105 | 106 | hdr 3,'D0=' 107 | dzequ: call docol 108 | dw orr,zequ 109 | dw exit 110 | 111 | ; D= ( d1 d2 -- flag ) 112 | 113 | hdr 2,'D=' 114 | dequ: pop de 115 | pop hl 116 | ex (sp),hl 117 | call cmpu 118 | pop de 119 | pop hl 120 | jp nz,false 121 | jp equal1 122 | 123 | ; D0< ( d -- flag ) swap drop 0< 124 | 125 | hdr 3,'D0<' ; ANS 126 | dzle: pop hl 127 | pop de 128 | jp zless1 129 | 130 | ; D< ( d1 d2 -- flag ) rot 2dup = if 2drop u< exit then 2swap 2drop > 131 | 132 | hdr 2,'D<' 133 | dless: pop de 134 | pop hl 135 | ex (sp),hl 136 | call cmpu 137 | jp z,uless 138 | inc sp 139 | inc sp 140 | inc sp 141 | inc sp 142 | jp less1 143 | 144 | ; DU< ( ud1 ud2 -- flag ) rot swap 2dup u< if 2drop 2drop -1 exit 145 | ; then - if 2drop 0 exit then u< 146 | 147 | hdr 3,'DU<' 148 | dules: pop de 149 | pop hl 150 | ex (sp),hl 151 | call cmpu 152 | pop de 153 | pop hl 154 | jp c,true 155 | jp nz,false 156 | jp uless1 157 | 158 | ; DMIN ( d1 d2 -- d1 | d2 ) 2over 2over d< 0= if 2swap then 2drop 159 | 160 | hdr 4,'DMIN' 161 | dmin: call docol 162 | dw tover,tover 163 | dw dless,zequ 164 | dmin1: dw zbran,dmin2 165 | dw tswap 166 | dmin2: dw tdrop 167 | dw exit 168 | 169 | ; DMAX ( d1 d2 -- d1 | d2 ) 2over 2over d< if 2swap then 2drop 170 | 171 | hdr 4,'DMAX' 172 | dmax: call docol 173 | dw tover,tover 174 | dw dless 175 | dw bran,dmin1 176 | 177 | ; end 178 |  -------------------------------------------------------------------------------- /M/c_iocon.c: -------------------------------------------------------------------------------- 1 | /* c_iocon.c 2 | 3 | Mike's Enhanced Small C Compiler for Z80 & CP/M 4 | 5 | I/O console module. 6 | 7 | Copyright (c) 1999-2016 Miguel I. Garcia Lopez, FloppySoftware. 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22 | 23 | Revisions: 24 | 25 | 16 Jan 2001 : Last revision. 26 | 16 Apr 2007 : GPL'd. 27 | 26 Oct 2015 : Cleaned. 28 | 11 Oct 2016 : Documented and slightly optimized. 29 | 21 Oct 2016 : Modified co_dec() an co_dec_5(). 30 | */ 31 | 32 | // Print a character 33 | // out: character value 34 | 35 | co_ch(c) 36 | char c; 37 | { 38 | putchar(c); return c; 39 | } 40 | 41 | // Print a string 42 | // out: string address 43 | 44 | co_str(s) 45 | char *s; 46 | { 47 | 48 | #if C_USEPRINTF 49 | printf("%s", s); 50 | #else 51 | /******************** 52 | char *p; 53 | 54 | p = s; 55 | 56 | while(*p) 57 | co_ch(*p++); 58 | *********************/ 59 | putstr(s); 60 | #endif 61 | 62 | return s; 63 | } 64 | 65 | // Print a string + '\n' 66 | // out: string address 67 | 68 | co_line(s) 69 | char *s; 70 | { 71 | #if C_USEPRINTF 72 | printf("%s\n", s); 73 | #else 74 | /*********************** 75 | co_str(s); co_ch('\n'); 76 | ***********************/ 77 | puts(s); 78 | #endif 79 | 80 | return s; 81 | } 82 | 83 | // Print '\n' 84 | 85 | co_nl() 86 | { 87 | co_ch('\n'); 88 | } 89 | 90 | // Print signed decimal number 91 | // out: value 92 | 93 | co_dec(n) 94 | int n; 95 | { 96 | #ifdef C_USEPRINTF 97 | printf("%d", n); 98 | #else 99 | /******************************************************************** 100 | int i; 101 | 102 | if(n < 0) 103 | { 104 | // Possible $8000 can't be negatived 105 | // if((number^0xFFFF)==0x7FFF){outstr("0-32768");return;} 106 | 107 | co_ch('-'); 108 | 109 | if(n == -32768) 110 | { 111 | co_str("32768"); return; 112 | } 113 | 114 | n = -n; 115 | } 116 | 117 | if(i = n / 10) 118 | co_dec(i); 119 | 120 | co_ch(n % 10 + '0'); 121 | *********************************************************************/ 122 | 123 | co_str(int2str(n)); 124 | #endif 125 | 126 | return n; 127 | } 128 | 129 | // Print signed decimal number 130 | 131 | co_dec_5(n) 132 | int n; 133 | { 134 | #ifdef C_USEPRINTF 135 | printf("%05d", n); 136 | #else 137 | /******************************************************************** 138 | if(n < 10000) 139 | { 140 | co_ch('0'); 141 | 142 | if(n < 1000) 143 | { 144 | co_ch('0'); 145 | 146 | if(n < 100) 147 | { 148 | co_ch('0'); 149 | 150 | if(n < 10) 151 | co_ch('0'); 152 | } 153 | } 154 | } 155 | 156 | co_dec(n); 157 | *********************************************************************/ 158 | 159 | co_str(int2str_5(n)); 160 | #endif 161 | } 162 |  -------------------------------------------------------------------------------- /M/c_iofile.c: -------------------------------------------------------------------------------- 1 | /* c_iofile.c 2 | 3 | Mike's Enhanced Small C Compiler for Z80 & CP/M 4 | 5 | I/O file module. 6 | 7 | Copyright (c) 1999-2016 Miguel I. Garcia Lopez 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22 | 23 | Revisions: 24 | 25 | 16 Jan 2001 : Last revision. 26 | 16 Apr 2007 : GPL'd. 27 | 16 Aug 2015 : Cleaned and simplified (see c_main.h). 28 | 25 Oct 2015 : Modified init_files(), fi_ch(), fo_dec(). Added some comments. 29 | 26 Oct 2015 : Moved included files control to c_cpp.c. Cleaned. 30 | 07 Nov 2015 : Modified fo_dec(). Now prints negative numbers as -32, instead of 0-32. 31 | 18 Dec 2015 : Modified fo_dec() to print -32768 correctly. 32 | 11 Oct 2016 : Documented and slightly optimized. 33 | 21 Oct 2016 : Modified fo_dec(). 34 | */ 35 | 36 | // Open file for input 37 | 38 | fi_open(fname) 39 | char *fname; 40 | { 41 | if(!(fi_fp = fopen(fname, "r"))) 42 | errfile(EROPEN, fname); 43 | 44 | strcpy(fi_name, fname); 45 | fi_line = fi_eof = 0; 46 | } 47 | 48 | // Input character from file 49 | // out: character on success, or EOF on end of file 50 | 51 | fi_ch() 52 | { 53 | return fi_eof != EOF ? (fi_eof = fgetc(fi_fp)) : EOF; 54 | } 55 | 56 | // Close input file 57 | 58 | fi_close() 59 | { 60 | if(fclose(fi_fp)) 61 | errfile(ERCLOSE, fi_name); 62 | } 63 | 64 | // Open file for output 65 | 66 | fo_open(fname) 67 | char *fname; 68 | { 69 | if(!(fo_fp=fopen(fname, "w"))) 70 | errfile(EROPEN, fname); 71 | 72 | strcpy(fo_name, fname); 73 | } 74 | 75 | // Close output file 76 | 77 | fo_close() 78 | { 79 | if(fclose(fo_fp)) 80 | errfile(ERCLOSE, fo_name); 81 | } 82 | 83 | // Output character to file 84 | 85 | fo_ch(c) 86 | int c; 87 | { 88 | if(fputc(c, fo_fp) == EOF) 89 | errfile(ERWRITE, fo_name); 90 | } 91 | 92 | // Output string to file 93 | 94 | fo_str(s) 95 | char *s; 96 | { 97 | while(*s) 98 | fo_ch(*s++); 99 | } 100 | 101 | // Output newline to file 102 | 103 | fo_nl() 104 | { 105 | fo_ch('\n'); 106 | } 107 | 108 | // Output colon to file 109 | 110 | fo_colon() 111 | { 112 | fo_ch(':'); 113 | } 114 | 115 | // Output string + newline to file 116 | 117 | fo_line(s) 118 | char *s; 119 | { 120 | fo_str(s); fo_nl(); 121 | } 122 | 123 | // Output signed decimal number to file 124 | 125 | fo_dec(n) 126 | int n; 127 | { 128 | #ifdef C_USEPRINTF 129 | fprintf(fo_fp, "%d", n); 130 | #else 131 | /*********************************************************************** 132 | int i; 133 | 134 | if(n < 0) 135 | { 136 | // Possible $8000 can't be negatived 137 | // if((number^0xFFFF)==0x7FFF){outstr("0-32768");return;} 138 | 139 | fo_ch('-'); 140 | 141 | if(n == -32768) 142 | { 143 | fo_str("32768"); return; 144 | } 145 | 146 | n = -n; 147 | } 148 | 149 | if(i = n / 10) 150 | fo_dec(i); 151 | 152 | fo_ch(n % 10 + '0'); 153 | ************************************************************************/ 154 | 155 | fo_str(int2str(n)); 156 | #endif 157 | } 158 |  -------------------------------------------------------------------------------- /H/ASM2.HLP: -------------------------------------------------------------------------------- 1 | Invoking the Assembler 2 | Assembler Pseudo-Ops 3 | Assembler In-Line Error Messages 4 | Assembler Console Error Messages 5 | :Invoking the Assembler 6 | 7 | The CP/M Assembler is invoked by typing -- 8 | 9 | ASM filename or ASM filename.parms 10 | 11 | where 'filename' is the name of the file 'filename.ASM' to be assembled. 12 | 13 | In the case of the first command, the following files are created -- 14 | 15 | filename.HEX - "HEX" file containing machine code in 16 | Intel hex format 17 | filename.PRN - listing file 18 | 19 | 20 | In the case of the second command, these files are created according 21 | to the parameters specified -- 22 | 23 | ASM filename.pqr 24 | 25 | where 26 | p : A,B,... - designates the disk name which contains the source 27 | q : A,B,... - designates the disk name to receive the hex file 28 | Z - skips generation of the hex file 29 | r : A,B,... - designates the disk name which will receive the 30 | print file 31 | X - outputs the listing to the console 32 | Z - skips generation of the print file 33 | :Assembler Pseudo-Ops 34 | 35 | ORG Set the program or data origin 36 | END End program 37 | EQU Numeric equate 38 | SET Numeric set 39 | IF Begin conditional assembly 40 | ENDIF End conditional assembly 41 | DB Define data bytes 42 | DW Define data words 43 | DS Define data storage area 44 | :Assembler In-Line Error Messages 45 | 46 | D Data error: element in data statement cannot be placed in the 47 | specified data area 48 | E Expression error: expression is ill-formed and cannot be 49 | computed at assembly line 50 | 51 | L Label error: label cannot appear in this context (may be 52 | duplicate label) 53 | N Not implemented: features which will appear in future ASM 54 | versions 55 | 56 | O Overflow: expression is too complicated to compute; simplify 57 | P Phase error: label does not have the same value on two 58 | subsequent passes through the program 59 | 60 | R Register error: the value specified as a register is not 61 | compatible with the operation code 62 | V Value error: operand encountered in expression is improperly 63 | formed 64 | :Assembler Console Error Messages 65 | 66 | NO SOURCE FILE PRESENT The file specified in the ASM command 67 | does not exist on disk 68 | 69 | NO DIRECTORY SPACE The disk directory is full, erase files 70 | which are not needed, and retry 71 | 72 | SOURCE FILE NAME ERROR Improperly formed ASM file name 73 | 74 | SOURCE FILE READ ERROR Source file cannot be read properly by 75 | the assembler, execute a TYPE to 76 | determine the point of error 77 | 78 | OUTPUT FILE WRITE ERROR Output files cannot be written properly, 79 | most likely cause is a full disk, erase 80 | and retry 81 | 82 | CANNOT CLOSE FILE Output file cannot be closed, check to 83 | see if disk is write protected 84 |  -------------------------------------------------------------------------------- /M/ctype.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ctype.h 3 | * @brief Character tests and conversion functions. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Character tests and conversion functions, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 19 Dec 2000 : Last revision. 11 | * - 16 Apr 2007 : GPL'd. 12 | * - 15 Aug 2016 : Documented. GPL v3. 13 | * 14 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 15 | * 16 | * Licensed under the GNU General Public License v3. 17 | * 18 | * http://www.floppysoftware.es 19 | * floppysoftware@gmail.com 20 | */ 21 | #ifndef CTYPE_H 22 | 23 | #define CTYPE_H 24 | 25 | /** 26 | * @fn int isalpha(char ch) 27 | * @brief Test if ch is a letter. 28 | * @param ch - character to test 29 | * @return true or false 30 | */ 31 | #asm 32 | 33 | isalpha 34 | ld a,l 35 | ld hl,0 36 | cp 'A' 37 | ret c 38 | cp 'Z'+1 39 | jr c,isalpha1 40 | cp 'a' 41 | ret c 42 | cp 'z'+1 43 | ret nc 44 | isalpha1 45 | inc l 46 | ret 47 | 48 | #endasm 49 | 50 | /** 51 | * @fn int isdigit(char ch) 52 | * @brief Test if ch is a decimal digit. 53 | * @param ch - character to test 54 | * @return true or false 55 | */ 56 | #asm 57 | 58 | isdigit 59 | ld a,l 60 | ld hl,0 61 | cp '0' 62 | ret c 63 | cp '9'+1 64 | ret nc 65 | inc l 66 | ret 67 | 68 | #endasm 69 | 70 | /** 71 | * @fn int isxdigit(char ch) 72 | * @brief Test if ch is an hexadecimal digit. 73 | * @param ch - character to test 74 | * @return true or false 75 | */ 76 | #asm 77 | 78 | isxdigit 79 | LD C,L 80 | CALL isdigit 81 | RET C 82 | LD HL,0 83 | LD A,C 84 | CP 'A' 85 | RET C 86 | CP 'G' 87 | JR C,isxdigit1 88 | CP 'a' 89 | RET C 90 | CP 'g' 91 | RET NC 92 | isxdigit1 93 | INC L 94 | RET 95 | 96 | #endasm 97 | 98 | /** 99 | * @fn int isalnum(char ch) 100 | * @brief Test if ch is a letter or a decimal digit. 101 | * @param ch - character to test 102 | * @return true or false 103 | */ 104 | #asm 105 | 106 | isalnum 107 | LD C,L 108 | CALL isdigit 109 | RET C 110 | LD L,C 111 | JP isalpha 112 | 113 | #endasm 114 | 115 | /** 116 | * @fn int isupper(char ch) 117 | * @brief Test if ch is a letter in uppercase. 118 | * @param ch - character to test 119 | * @return true or false 120 | */ 121 | #asm 122 | 123 | isupper 124 | ld a,l 125 | ld hl,0 126 | cp 'A' 127 | ret c 128 | cp 'Z'+1 129 | ret nc 130 | inc l 131 | ret 132 | 133 | #endasm 134 | 135 | /** 136 | * @fn int islower(char ch) 137 | * @brief Test if ch is a letter in lowercase. 138 | * @param ch - character to test 139 | * @return true or false 140 | */ 141 | #asm 142 | 143 | islower 144 | ld a,l 145 | ld hl,0 146 | cp 'a' 147 | ret c 148 | cp 'z'+1 149 | ret nc 150 | inc l 151 | ret 152 | 153 | #endasm 154 | 155 | /** 156 | * @fn int toupper(char ch) 157 | * @brief Convert letter to uppercase. 158 | * 159 | * If ch is not a letter in lowercase, returns ch unchanged. 160 | * 161 | * @param ch - character to convert 162 | * @return ch in uppercase 163 | */ 164 | #asm 165 | 166 | toupper 167 | ld a,l 168 | cp 'a' 169 | ret c 170 | cp 'z'+1 171 | ret nc 172 | sub 20h 173 | ld l,a 174 | ret 175 | 176 | #endasm 177 | 178 | /** 179 | * @fn int tolower(char ch) 180 | * @brief Convert letter to lowercase. 181 | * 182 | * If ch is not a letter in uppercase, returns ch unchanged. 183 | * 184 | * @param ch - character to convert 185 | * @return ch in lowercase 186 | */ 187 | #asm 188 | 189 | tolower 190 | ld a,l 191 | cp 'A' 192 | ret c 193 | cp 'Z'+1 194 | ret nc 195 | add 20h 196 | ld l,a 197 | ret 198 | 199 | #endasm 200 | 201 | #endif 202 | 203 |  -------------------------------------------------------------------------------- /P/MC-MOD02.INC: -------------------------------------------------------------------------------- 1 | {.PA} 2 | {*******************************************************************} 3 | {* SOURCE CODE MODULE: MC-MOD02 *} 4 | {* PURPOSE: Display values in cells and move between *} 5 | {* cells in the spread sheet. *} 6 | {*******************************************************************} 7 | 8 | 9 | procedure FlashType; 10 | begin 11 | with Screen[FX,FY] do 12 | begin 13 | GotoXY(1,23); 14 | Write(FX,FY:2,' '); 15 | if Formula in CellStatus then write('Formula:') else 16 | if Constant in CellStatus then Write('Numeric ') else 17 | if Txt in CellStatus then Write('Text '); 18 | GotoXY(1,24); ClrEol; 19 | if Formula in CellStatus then Write(Contents); 20 | end; 21 | end; 22 | 23 | 24 | { The following procedures move between the Cells on the calc sheet.} 25 | { Each Cell has an associated record containing its X,Y coordinates } 26 | { and data. See the type definition for "Cell". } 27 | 28 | procedure GotoCell(GX: ScreenIndex; GY: integer); 29 | begin 30 | with Screen[GX,GY] do 31 | begin 32 | HighVideo; 33 | GotoXY(XPos[GX],GY+1); 34 | Write(' '); 35 | GotoXY(XPos[GX],GY+1); 36 | if Txt in CellStatus then Write(Contents) 37 | else 38 | begin 39 | if DEC>=0 then Write(Value:FW:DEC) 40 | else Write(Value:FW); 41 | end; 42 | FlashType; 43 | GotoXY(XPos[GX],GY+1); 44 | end; 45 | LowVideo; 46 | end; 47 | 48 | {.CP20} 49 | 50 | procedure LeaveCell(FX:ScreenIndex;FY: integer); 51 | begin 52 | with Screen[FX,FY] do 53 | begin 54 | GotoXY(XPos[FX],FY+1); 55 | LowVideo; 56 | if Txt in CellStatus then Write(Contents) 57 | else 58 | begin 59 | if DEC>=0 then Write(Value:FW:DEC) 60 | else Write(Value:FW); 61 | end; 62 | end; 63 | end; 64 | 65 | 66 | {.CP20} 67 | 68 | procedure Update; 69 | var 70 | UFX: ScreenIndex; 71 | UFY: integer; 72 | begin 73 | ClrScr; 74 | Grid; 75 | for UFX:='A' to FXMax do for UFY:=1 to FYMax do 76 | if Screen[UFX,UFY].Contents<>'' then LeaveCell(UFX,UFY); 77 | GotoCell(FX,FY); 78 | end; 79 | 80 | {.CP20} 81 | 82 | procedure MoveDown; 83 | var Start: integer; 84 | begin 85 | LeaveCell(FX,FY); 86 | Start:=FY; 87 | repeat 88 | FY:=FY+1; 89 | if FY>FYMax then FY:=1; 90 | until (Screen[FX,FY].CellStatus*[OverWritten,Locked]=[]) or (FY=Start); 91 | if FY<>Start then GotoCell(FX,FY); 92 | end; 93 | 94 | {.CP20} 95 | 96 | procedure MoveUp; 97 | var Start: integer; 98 | begin 99 | LeaveCell(FX,FY); 100 | Start:=FY; 101 | repeat 102 | FY:=FY-1; 103 | if FY<1 then FY:=FYMax; 104 | until (Screen[FX,FY].CellStatus*[OverWritten,Locked]=[]) or (FY=Start); 105 | if FY<>Start then GotoCell(FX,FY); 106 | end; 107 | 108 | {.CP20} 109 | 110 | procedure MoveRight; 111 | var Start: ScreenIndex; 112 | begin 113 | LeaveCell(FX,FY); 114 | Start:=FX; 115 | repeat 116 | FX:=Succ(FX); 117 | if FX>FXMax then 118 | begin 119 | FX:='A'; 120 | FY:=FY+1; 121 | if FY>FYMax then FY:=1; 122 | end; 123 | until (Screen[FX,FY].CellStatus*[OverWritten,Locked]=[]) or (FX=Start); 124 | if FX<>Start then GotoCell(FX,FY); 125 | end; 126 | 127 | {.CP20} 128 | 129 | procedure MoveLeft; 130 | var Start: ScreenIndex; 131 | begin 132 | LeaveCell(FX,FY); 133 | Start:=FX; 134 | repeat 135 | FX:=Pred(FX); 136 | if FX<'A' then 137 | begin 138 | FX:=FXMax; 139 | FY:=FY-1; 140 | if FY<1 then FY:=FYMax; 141 | end; 142 | until (Screen[FX,FY].CellStatus*[OverWritten,Locked]=[]) or (FX=Start); 143 | if FX<>Start then GotoCell(FX,FY); 144 | end; 145 | -------------------------------------------------------------------------------- /F/BENCH.SCR: -------------------------------------------------------------------------------- 1 | \ A Collection of Computer Benchmark Programs Screen 1 SIEVE - Byte, 9/81 2 BENCH - Interface Age, 6/80 (?) \ BYTE Benchmark - Sieve of Eratosthenes 8190 CONSTANT SIZE VARIABLE FLAGS SIZE ALLOT : PRIME ( -- ) FLAGS SIZE 1 FILL 0 SIZE 0 DO FLAGS I + C@ IF I DUP + 3 + DUP I + BEGIN DUP SIZE < WHILE 0 OVER FLAGS + C! OVER + REPEAT DROP DROP 1+ THEN LOOP CR . ." Primes " ; : SIEVE ( -- ) CR 10 0 DO PRIME LOOP ; \ Interface Age Benchmark : BENCH ( 1000 -- ) DUP 2 / 1+ SWAP CR ." STARTING " CR 1 DO DUP I 1 ROT 2 DO DROP DUP I /MOD DUP 0= IF DROP DROP 1 LEAVE ELSE 1 = IF DROP 1 ELSE DUP 0 > IF DROP 1 ELSE 0= IF 0 LEAVE THEN THEN THEN THEN LOOP IF 4 .R ELSE DROP THEN LOOP DROP CR ." FINISHED. " ; -------------------------------------------------------------------------------- /F/STACK.MAC: -------------------------------------------------------------------------------- 1 | ; 2 | ; STACK.MAC - Stack Manipulation 3 | ; 4 | ; 97/12/28 5 | ; 6 | ; SP@ SP! RP@ RP! >R R> R@ 2>R 2R> 2R@ DROP DUP ?DUP 7 | ; SWAP OVER ROT ROLL PICK 2DROP 2DUP 2SWAP 2OVER 2ROT 8 | ; DEPTH 9 | ; 10 | 11 | ; SP@ ( -- addr ) 12 | 13 | hdr 3,'SP@' 14 | spat: ld hl,0 15 | add hl,sp 16 | jp hpush 17 | 18 | ; SP! ( addr -- ) 19 | 20 | hdr 3,'SP!' 21 | spsto: pop hl 22 | ld sp,hl 23 | jp next 24 | 25 | ; RP@ ( -- addr ) 26 | 27 | hdr 3,'RP@' 28 | rpat: ld hl,(rpp) 29 | jp hpush 30 | 31 | ; RP! ( addr -- ) 32 | 33 | hdr 3,'RP!' 34 | rpsto: pop hl 35 | ld (rpp),hl 36 | jp next 37 | 38 | ; >R ( x -- ) 39 | 40 | hdr 2,'>R' 41 | tor: ld hl,(rpp) 42 | pop de 43 | dec hl 44 | ld (hl),d 45 | dec hl 46 | ld (hl),e 47 | ld (rpp),hl 48 | jp next 49 | 50 | ; R> ( -- x ) 51 | 52 | hdr 2,'R>' 53 | fromr: ld hl,(rpp) 54 | ld e,(hl) 55 | inc hl 56 | ld d,(hl) 57 | inc hl 58 | ld (rpp),hl 59 | push de 60 | jp next 61 | 62 | ; R@ ( -- x ) 63 | 64 | hdr 2,'R@' 65 | rat: ld hl,(rpp) 66 | jp at1 67 | 68 | ; 2>R ( x1 x2 -- ) 69 | 70 | hdr 3,'2>R' 71 | ttor: ld hl,(rpp) 72 | ld de,-4 73 | add hl,de 74 | ld (rpp),hl 75 | jp tstor1 76 | 77 | ; 2R> ( -- x1 x2 ) 78 | 79 | hdr 3,'2R>' 80 | tfrom: ld hl,(rpp) 81 | push hl 82 | ld de,4 83 | add hl,de 84 | ld (rpp),hl 85 | jp tat 86 | 87 | ; 2R@ ( -- x1 x2 ) 88 | 89 | hdr 3,'2R@' 90 | trat: ld hl,(rpp) 91 | jp tat1 92 | 93 | ; DROP ( x -- ) 94 | 95 | hdr 4,'DROP' 96 | drop: pop hl 97 | jp next 98 | 99 | ; DUP ( x -- x x ) 100 | 101 | hdr 3,'DUP' 102 | dup: pop hl 103 | push hl 104 | jp hpush 105 | 106 | ; ?DUP ( x -- 0 | x x ) 107 | 108 | hdr 4,'?DUP' 109 | qdup: pop hl 110 | ld a,l 111 | or h 112 | jp z,hpush 113 | push hl 114 | jp hpush 115 | 116 | ; SWAP ( x1 x2 -- x2 x1 ) 117 | 118 | hdr 4,'SWAP' 119 | swap: pop hl 120 | ex (sp),hl 121 | jp hpush 122 | 123 | ; OVER ( x1 x2 -- x1 x2 x1 ) 124 | 125 | hdr 4,'OVER' 126 | over: pop de 127 | pop hl 128 | push hl 129 | jp dpush 130 | 131 | ; ROT ( x1 x2 x3 -- x2 x3 x1 ) 132 | 133 | hdr 3,'ROT' 134 | rot: pop de 135 | pop hl 136 | ex (sp),hl 137 | jp dpush 138 | 139 | ; ROLL ( xu xn .. x0 u -- xn .. x0 xu ) 140 | 141 | hdr 4,'ROLL' 142 | roll: pop hl 143 | add hl,hl 144 | ld e,l 145 | ld d,h 146 | add hl,sp 147 | push bc 148 | ld c,(hl) 149 | inc hl 150 | ld b,(hl) 151 | push bc 152 | ld c,e 153 | ld b,d 154 | ld e,l 155 | ld d,h 156 | inc de 157 | dec hl 158 | call movu1 159 | pop hl 160 | pop bc 161 | ex (sp),hl 162 | jp next 163 | 164 | ; PICK ( xu .. x1 x0 u -- xu .. x1 x0 xu ) 165 | 166 | hdr 4,'PICK' 167 | pick: pop hl 168 | add hl,hl 169 | add hl,sp 170 | jp at1 171 | 172 | ; 2DROP ( xd -- ) 173 | 174 | hdr 5,'2DROP' 175 | tdrop: pop hl 176 | pop hl 177 | jp next 178 | 179 | ; 2DUP ( xd -- xd xd ) 180 | 181 | hdr 4,'2DUP' 182 | tdup: pop hl 183 | pop de 184 | push de 185 | push hl 186 | jp dpush 187 | 188 | ; 2SWAP ( xd1 xd2 -- xd2 xd1 ) 189 | 190 | hdr 5,'2SWAP' 191 | tswap: pop de 192 | pop hl 193 | inc sp 194 | inc sp 195 | ex (sp),hl 196 | dec sp 197 | dec sp 198 | ex de,hl 199 | ex (sp),hl 200 | jp dpush 201 | 202 | ; 2OVER ( xd1 xd2 -- xd1 xd2 xd1 ) 203 | 204 | hdr 5,'2OVER' 205 | tover: ld hl,4 206 | add hl,sp 207 | jp tat1 208 | 209 | ; 2ROT ( xd1 xd2 xd3 -- xd2 xd3 xd1 ) 5 roll 5 roll 210 | 211 | hdr 4,'2ROT' 212 | trot: call docol 213 | dw clit 214 | db 5 215 | dw roll 216 | dw clit 217 | db 5 218 | dw roll 219 | dw exit 220 | 221 | ; DEPTH ( -- u ) sp@ s0 @ swap - 2/ 222 | 223 | hdr 5,'DEPTH' 224 | depth: call docol 225 | dw spat 226 | dw szero,at 227 | dw swap,subb 228 | dw twodiv 229 | dw exit 230 | 231 | ; end 232 |  -------------------------------------------------------------------------------- /F/NUMBER.MAC: -------------------------------------------------------------------------------- 1 | ; 2 | ; NUMBER.MAC - Numeric Conversion 3 | ; 4 | ; 97/12/28 5 | ; 6 | ; DECIMAL HEX digit CONVERT (number?) NUMBER? HOLD <# #> SIGN 7 | ; # #S 8 | ; 9 | 10 | ; DECIMAL ( -- ) 10 base ! 11 | 12 | hdr 7,'DECIMAL' 13 | dec: call docol 14 | dw clit 15 | db 10 16 | dw base,store 17 | dw exit 18 | 19 | ; HEX ( -- ) 16 base ! 20 | 21 | hdr 3,'HEX' 22 | hex: call docol 23 | dw clit 24 | db 16 25 | dw base,store 26 | dw exit 27 | 28 | ; digit ( char base -- u -1 | 0 ) 29 | 30 | hdr 0,'DIGIT' 31 | digit: pop hl 32 | pop de 33 | ld a,e 34 | call upc ; make uppercase 35 | sub '0' 36 | jp m,false 37 | cp 10 38 | jp m,digit1 39 | sub 7 40 | cp 10 41 | jp m,false 42 | digit1: cp l 43 | jp p,false 44 | ld e,a 45 | push de 46 | jp true 47 | 48 | ; CONVERT ( d1 addr1 -- d2 addr2 ) begin 1+ dup >r c@ base @ digit 49 | ; while swap base @ um* drop rot base 50 | ; @ um* d+ r> repeat r> 51 | 52 | hdr 7,'CONVERT' 53 | conv: call docol 54 | conv1: dw onep 55 | dw dup,tor 56 | dw cat 57 | dw base,at 58 | dw digit 59 | dw zbran,conv2 60 | dw swap 61 | dw base,at 62 | dw umstr,drop 63 | dw rot 64 | dw base,at 65 | dw umstr 66 | dw dplus 67 | dw fromr 68 | dw bran,conv1 69 | conv2: dw fromr 70 | dw exit 71 | 72 | ; (number?) ( addr -- d -1 | 0 ) 0 0 rot dup 1+ c@ [char] - = dup >r - 73 | ; convert dup c@ [char] . = dup not dpl 74 | ; ! - c@ bl - if r> drop 2drop 0 exit 75 | ; then r> if dnegate then -1 76 | 77 | hdr 0,'(NUMBER?)' 78 | pnumq: call docol ; convert counted string to double number 79 | dw zero,zero 80 | dw rot 81 | dw dup,onep,cat 82 | dw clit 83 | db '-' 84 | dw equal 85 | dw dup,tor 86 | dw subb 87 | dw conv 88 | dw dup,cat 89 | dw clit 90 | db '.' ; trailing '.' for double number (ANS) 91 | dw equal 92 | dw dup,nott 93 | dw dpl,store 94 | dw subb 95 | dw cat,bl,subb 96 | dw zbran,pnumq1 97 | dw fromr,drop 98 | dw tdrop,zero 99 | dw exit 100 | pnumq1: dw fromr 101 | dw zbran,pnumq2 102 | dw dnegat 103 | pnumq2: dw true 104 | dw exit 105 | 106 | ; NUMBER? ( c-addr u -- d -1 | 0 ) 31 min (sbuf) swap 2dup 1+ blank 107 | ; cmove (sbuf-1) (number?) 108 | 109 | hdr 7,'NUMBER?' ; uses SBUF 110 | numq: call docol 111 | dw clit 112 | db 31 113 | dw min 114 | dw lit,sbuf 115 | dw swap 116 | dw tdup ; add trailing blank 117 | dw onep,blank 118 | dw cmove 119 | dw lit,sbuf-1 120 | dw pnumq 121 | dw exit 122 | 123 | ; HOLD ( char -- ) -1 hld +! hld @ c! 124 | 125 | hdr 4,'HOLD' 126 | hold: call docol 127 | dw true 128 | dw hld,pstor 129 | dw hld,at 130 | dw cstor 131 | dw exit 132 | 133 | ; <# ( -- ) pad hld ! 134 | 135 | hdr 2,'<#' 136 | bdigs: call docol 137 | dw pad 138 | dw hld,store 139 | dw exit 140 | 141 | ; #> ( d -- c-addr u ) 2drop hld @ pad over - 142 | 143 | hdr 2,'#>' 144 | edigs: call docol 145 | dw tdrop 146 | dw hld,at 147 | dw pad 148 | dw over 149 | dw subb 150 | dw exit 151 | 152 | ; SIGN ( n -- ) 0< if [char] - hold then 153 | 154 | hdr 4,'SIGN' 155 | sign: call docol 156 | dw zless 157 | dw zbran,sign1 158 | dw clit 159 | db '-' 160 | dw hold 161 | sign1: dw exit 162 | 163 | ; # ( +d1 -- +d2 ) base @ >r 0 r@ um/mod r> swap >r um/mod 164 | ; r> rot 9 over < if 7 + then [char] 0 + hold 165 | 166 | hdr 1,'#' 167 | dig: call docol 168 | dw base,at,tor 169 | dw zero 170 | dw rat,umslm 171 | dw fromr 172 | dw swap,tor 173 | dw umslm 174 | dw fromr 175 | dw rot 176 | dw clit 177 | db 9 178 | dw over,less 179 | dw zbran,dig1 180 | dw clit 181 | db 7 182 | dw plus 183 | dig1: dw clit 184 | db '0' 185 | dw plus 186 | dw hold 187 | dw exit 188 | 189 | ; #S ( +d -- 0 0 ) begin # 2dup or 0= until 190 | 191 | hdr 2,'#S' 192 | digs: call docol 193 | digs1: dw dig 194 | dw tdup 195 | dw orr,zequ 196 | dw zbran,digs1 197 | dw exit 198 | 199 | ; end 200 | 201 |  -------------------------------------------------------------------------------- /F/STRING.MAC: -------------------------------------------------------------------------------- 1 | ; 2 | ; STRING.MAC - String Functions 3 | ; 4 | ; 97/12/28 5 | ; 6 | ; CMOVE CMOVE> BLANK COUNT PLACE SCAN SKIP -TRAILING /STRING 7 | ; COMPARE SEARCH 8 | ; 9 | 10 | ; CMOVE ( c-addr1 c-addr2 u -- ) 11 | 12 | hdr 5,'CMOVE' 13 | cmove: ld l,c 14 | ld h,b 15 | pop bc 16 | pop de 17 | ex (sp),hl 18 | cmove1: call movd 19 | pop bc 20 | jp next 21 | 22 | ; CMOVE> ( c-addr1 c-addr2 u -- ) 23 | 24 | hdr 6,'CMOVE>' 25 | cmovu: ld l,c 26 | ld h,b 27 | pop bc 28 | pop de 29 | ex (sp),hl 30 | cmovu1: call movu 31 | pop bc 32 | jp next 33 | 34 | ; BLANK ( c-addr u -- ) bl fill 35 | 36 | hdr 5,'BLANK' 37 | blank: ld e,' ' 38 | jp fill1 39 | 40 | ; COUNT ( c-addr1 -- c-addr2 u ) dup 1+ swap c@ 41 | 42 | hdr 5,'COUNT' 43 | count: pop de 44 | ld a,(de) 45 | inc de 46 | push de 47 | jp apush 48 | 49 | ; PLACE ( c-addr1 u c-addr2 -- ) 2dup 2>r 1+ swap move 2r> c! 50 | 51 | hdr 5,'PLACE' 52 | place: call docol 53 | dw tdup 54 | dw ttor 55 | dw onep,swap 56 | dw move 57 | dw tfrom 58 | dw cstor 59 | dw exit 60 | 61 | ; SCAN ( c-addr1 u1 char -- c-addr2 u2 ) 62 | 63 | hdr 4,'SCAN' 64 | scan: pop de 65 | ld l,c 66 | ld h,b 67 | pop bc 68 | ex (sp),hl 69 | scan1: ld a,c 70 | or b 71 | jp z,scan2 72 | ld a,e 73 | cp (hl) 74 | jp z,scan2 75 | inc hl 76 | dec bc 77 | jp scan1 78 | 79 | scan2: ex (sp),hl 80 | scan3: push bc 81 | ld c,l 82 | ld b,h 83 | jp next 84 | 85 | ; SKIP ( c-addr1 u1 char -- c-addr2 u2 ) 86 | 87 | hdr 4,'SKIP' 88 | skip: pop de 89 | ld l,c 90 | ld h,b 91 | pop bc 92 | ex (sp),hl 93 | skip1: ld a,c 94 | or b 95 | jp z,scan2 96 | ld a,e 97 | cp (hl) 98 | jp nz,scan2 99 | inc hl 100 | dec bc 101 | jp skip1 102 | 103 | ; -TRAILING ( c-addr u1 -- c-addr u2 ) 104 | 105 | hdr 9,'-TRAILING' 106 | dtrai: pop de 107 | pop hl 108 | push hl 109 | add hl,de 110 | ex de,hl 111 | dtrai1: dec de 112 | ld a,l 113 | or h 114 | jp z,hpush 115 | ld a,(de) 116 | cp ' ' 117 | jp nz,hpush 118 | dec hl 119 | jp dtrai1 120 | 121 | ; /STRING ( c-addr1 u1 n -- c-addr2 u2 ) over dup 0< if drop else min 122 | ; then rot over + rot rot - 123 | 124 | hdr 7,'/STRING' ; ANS 125 | sstr: pop de 126 | pop hl 127 | ld a,h 128 | or a 129 | jp m,sstr1 130 | call cmps 131 | jp nc,sstr1 132 | ld d,h 133 | ld e,l 134 | sstr1: call ssub 135 | ex (sp),hl 136 | add hl,de 137 | ex (sp),hl 138 | jp hpush 139 | 140 | ; COMPARE ( c-addr1 u1 c-addr2 u2 -- -1 | 0 | 1 ) 141 | 142 | hdr 7,'COMPARE' ; ANS 143 | cmp: pop de 144 | pop hl 145 | ex (sp),hl 146 | ld a,d 147 | cp h 148 | jp nz,cmp1 149 | ld a,e 150 | cp l 151 | cmp1: jp c,cmp2 152 | ex de,hl 153 | cmp2: ld l,c 154 | ld h,b 155 | pop bc 156 | ex (sp),hl 157 | push af 158 | call cmp5 159 | jp z,cmp4 160 | pop bc 161 | cmp3: pop bc 162 | jp c,one 163 | jp z,false 164 | jp true 165 | 166 | cmp4: pop af 167 | jp cmp3 168 | 169 | ; string match subroutine HL = a1 BC = a2 DE = len Z if match 170 | 171 | cmp5: ld a,e 172 | or d 173 | ret z 174 | ld a,(bc) 175 | cp (hl) 176 | ret nz 177 | inc hl 178 | inc bc 179 | dec de 180 | jp cmp5 181 | 182 | ; SEARCH ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 -1 | c-addr1 u1 0 ) 183 | 184 | hdr 6,'SEARCH' ; ANS 185 | sear: pop hl 186 | ld (sear7),hl 187 | ld a,l 188 | or h 189 | ld l,c 190 | ld h,b 191 | pop bc 192 | ex (sp),hl 193 | ld (sear6),hl 194 | ex de,hl 195 | pop hl 196 | ex (sp),hl 197 | ld (sear5),hl 198 | jp z,sear2 199 | dec hl 200 | inc de 201 | sear1: inc hl 202 | dec de 203 | ld a,e 204 | or d 205 | jp nz,sear4 206 | sear2: ld bc,0 207 | ld hl,(sear6) 208 | ex de,hl 209 | ld hl,(sear5) 210 | sear3: ex (sp),hl 211 | push de 212 | jp scan3 213 | 214 | sear4: ld a,(bc) 215 | cp (hl) 216 | jp nz,sear1 217 | push de 218 | push bc 219 | push hl 220 | ex de,hl 221 | ld hl,(sear7) 222 | ex de,hl 223 | call cmp5 224 | pop hl 225 | pop bc 226 | pop de 227 | jp nz,sear1 228 | ld bc,-1 229 | jp sear3 230 | 231 | sear5: ds 2 232 | sear6: ds 2 233 | sear7: ds 2 234 | 235 | ; end 236 |  -------------------------------------------------------------------------------- /P/TINST.MSG: -------------------------------------------------------------------------------- 1 | 1 TURBO Pascal installation menu. 2 | 2 Choose installation item from the following: 3 | 3 4 | 4 [S]creen installation | [C]ommand installation | [Q]uit 5 | 5 6 | 6 Enter S, C, or Q: 7 | 10 Duplicate definition. Error occurred between question 8 | 11 Commands starting with the same letter must have the same length. 9 | Error occurred between question 10 | 12 The total maximum length of commands are execeeded 11 | 13 -> 12 | 13 | 14 | 14 CURSOR MOVEMENTS: 15 | 16 | 20 Character left 17 | 21 Alternative 18 | 22 Character right 19 | 23 Word left 20 | 24 Word right 21 | 25 Line up 22 | 26 Line down 23 | 27 Scroll down 24 | 28 Scroll up 25 | 29 Page up 26 | 30 Page down 27 | 31 To left on line 28 | 32 To right on line 29 | 33 To top of page 30 | 34 To bottom of page 31 | 35 To top of file 32 | 36 To end of file 33 | 37 To begining of block 34 | 38 To end of block 35 | 39 To last cursor position 36 | 37 | 38 | 15 INSERT & DELETE: 39 | 40 | 40 Insert mode on/off 41 | 41 Insert line 42 | 42 Delete line 43 | 43 Delete to end of line 44 | 44 Delete right word 45 | 45 Delete character under cursor 46 | 46 Delete left character 47 | 47 Alternative 48 | 49 | 50 | 16 BLOCK COMMANDS: 51 | 52 | 48 Mark block begin 53 | 49 Mark block end 54 | 50 Mark single word 55 | 51 Hide/display block 56 | 52 Copy block 57 | 53 Move block 58 | 54 Delete block 59 | 55 Read block from disk 60 | 56 Write block to disk 61 | 62 | 63 | 17 MISC. EDITING COMMANDS: 64 | 65 | 57 End edit 66 | 58 Tab 67 | 59 Auto tab on/off 68 | 60 Restore line 69 | 61 Find 70 | 62 Find & replace 71 | 63 Repeat last find 72 | 64 Control character prefix 73 | 74 | 101 Nothing 75 | ^Q: Quit, ^R: Last page, ^C: Next page, : Select terminal: 76 | Wait Sorting Definitions 77 | Change to: 78 | (Y/N)? 79 | y 80 | n 81 | Text file name: 82 | Command: 83 | Numeric entry expected 84 | Legal range is 85 | , please re-enter: 86 | Choose one of the following terminals: 87 | None of the above ( Max. 20 Characters ) 88 | Delete a definition ( Max. 20 Characters ) 89 | Which terminal? (Enter no. or ^Q to exit): 90 | Delete terminal? (Enter no. or ^Q to exit): 91 | Do you want to modify this definition before installation? 92 | Terminal type: 93 | Send an initialization string to the terminal? 94 | Initializaion defined as a command string? (No = a file) 95 | Send a reset string to the terminal 96 | Reset defined as a command? (No = a file) 97 | CURSOR LEAD-IN command: 98 | CURSOR POSITIONING COMMAND to send between line and column: 99 | CURSOR POSITIONING COMMAND to send after both line and column: 100 | Column first 101 | OFFSET to add to LINE: 102 | OFFSET to add to COLUMN: 103 | Binary address 104 | Number of ASCII digits (2 or 3): 105 | CLEAR SCREEN command: 106 | Does CLEAR SCREEN also HOME cursor 107 | HOME command: 108 | DELETE LINE command: 109 | INSERT LINE command: 110 | ERASE TO END OF LINE command: 111 | START HIGHLIGHTING command: 112 | END HIGHLIGHTING command: 113 | Number of rows (lines) on your screen: 114 | Number of columns on your screen: 115 | Delay after CURSOR ADDRESS (0-255 ms): 116 | Delay after CLEAR, DELETE and INSERT (0-255 ms): 117 | Delay after ERASE TO END OF LINE and HIGHLIGHT (0-255 ms): 118 | Is this definition correct? 119 | Hardware dependent information 120 | Operating frequency of your microprocessor in MHz (for delays): 121 | pendent information 122 | Operating frequency of your microprocessor in MHz (for delays): 123 |  -------------------------------------------------------------------------------- /M/string.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file string.h 3 | * @brief String functions. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * String functions, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Revisions: 10 | * - 19 Mar 2001 : Last revision. 11 | * - 16 Apr 2007 : GPL'd. 12 | * - 15 Aug 2016 : Documented. GPL v3. 13 | * 14 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 15 | * 16 | * Licensed under the GNU General Public License v3. 17 | * 18 | * http://www.floppysoftware.es 19 | * floppysoftware@gmail.com 20 | */ 21 | #ifndef STRING_H 22 | 23 | #define STRING_H 24 | 25 | /** 26 | * @fn int strlen(char *str) 27 | * @brief Return string length. 28 | * @param str - string 29 | * @return length in characters 30 | */ 31 | #asm 32 | strlen: 33 | LD D,H 34 | LD E,L 35 | LD BC,0FFFFH 36 | XOR A 37 | CPIR 38 | OR A 39 | SBC HL,DE 40 | DEC HL 41 | RET 42 | #endasm 43 | 44 | /** 45 | * @fn char *strcpy(char *dst, char *src) 46 | * @brief Copy string. 47 | * @param dst - destination string 48 | * @param src - source string 49 | * @return pointer to dst 50 | */ 51 | #asm 52 | strcpy: 53 | POP BC 54 | POP HL 55 | POP DE 56 | PUSH DE 57 | PUSH HL 58 | PUSH BC 59 | 60 | PUSH DE 61 | 62 | strcpy2: 63 | LD A,(HL) 64 | LD (DE),A 65 | INC HL 66 | INC DE 67 | OR A 68 | JR NZ,strcpy2 69 | POP HL 70 | RET 71 | #endasm 72 | 73 | /** 74 | * @fn char *strcat(char *dst, char *src) 75 | * @brief Copy string at the end of another string. 76 | * @param dst - destination string 77 | * @param src - source string 78 | * @return pointer to dst 79 | */ 80 | #asm 81 | strcat: 82 | POP BC 83 | POP HL 84 | POP DE 85 | PUSH DE 86 | PUSH HL 87 | PUSH BC 88 | 89 | PUSH DE 90 | 91 | strcat2 92 | LD A,(DE) 93 | OR A 94 | JR Z,strcpy2 95 | INC DE 96 | JR strcat2 97 | #endasm 98 | 99 | /** 100 | * @fn int strcmp(char *str1, char *str2) 101 | * @brief Compare two strings. 102 | * @param str1 - a string 103 | * @param str2 - a string 104 | * @return <0 on str1 < str2; =0 on str1 == str2; >0 on str1 > str2 105 | */ 106 | #asm 107 | strcmp 108 | POP BC 109 | POP HL 110 | POP DE 111 | PUSH DE 112 | PUSH HL 113 | PUSH BC 114 | strcmp1 115 | LD A,(DE) 116 | CP (HL) 117 | JR NZ,strcmp2 118 | 119 | OR A 120 | JR Z,strcmp2 121 | 122 | INC DE 123 | INC HL 124 | JR strcmp1 125 | 126 | strcmp2 127 | LD HL,0 128 | RET Z 129 | JR NC,strcmp3 130 | DEC HL 131 | RET 132 | strcmp3 133 | INC L 134 | RET 135 | #endasm 136 | 137 | /** 138 | * @fn char *strchr(char *str, char ch) 139 | * @brief Search a character in a string. 140 | * @param str - the string where to search 141 | * @param ch - the character to find 142 | * @return pointer to ch in the string, or NULL on failure 143 | */ 144 | #asm 145 | strchr 146 | POP BC 147 | POP DE 148 | POP HL 149 | PUSH HL 150 | PUSH DE 151 | PUSH BC 152 | 153 | 154 | strchr2 155 | LD A,(HL) 156 | CP E 157 | RET Z 158 | 159 | INC HL 160 | OR A 161 | JR NZ,strchr2 162 | 163 | LD H,A 164 | LD L,A 165 | RET 166 | #endasm 167 | 168 | /** 169 | * @fn char *strupr(char *str) 170 | * @brief Convert a string to upper case. 171 | * @param str - a string 172 | * @return pointer to str 173 | */ 174 | #asm 175 | strupr 176 | POP BC 177 | POP HL 178 | PUSH HL 179 | PUSH BC 180 | 181 | PUSH HL 182 | 183 | strupr1 184 | LD A,(HL) 185 | OR A 186 | JR Z,strupr3 187 | 188 | CP 'a' 189 | JR C,strupr2 190 | CP 'z'+1 191 | JR NC,strupr2 192 | SUB 32 193 | LD (HL),A 194 | 195 | strupr2 196 | INC HL 197 | JR strupr1 198 | 199 | strupr3 200 | POP HL 201 | RET 202 | #endasm 203 | 204 | /** 205 | * @fn int atoi(char *s) 206 | * @brief Convert string to a integer. 207 | * 208 | * This function parses a string, interpreting its content as 209 | * a decimal integer number, until the end of the string, or 210 | * a non decimal digit: 211 | * 212 | * [+|-][[0..9]...][ZERO|NON_DECIMAL_DIGIT] 213 | * 214 | * Examples: 215 | * - "-256" == -256 216 | * - "64" == 64 217 | * - "1024 bytes" == 1024 218 | * - "what?" == 0 219 | * 220 | * @param s - a string 221 | * @return integer value 222 | */ 223 | atoi(s) 224 | char *s; 225 | { 226 | int sign, val; 227 | 228 | if(*s == '+') 229 | { 230 | ++s; sign = 1; 231 | } 232 | else if(*s == '-') 233 | { 234 | ++s; sign = -1; 235 | } 236 | else 237 | sign = 1; 238 | 239 | val=0; 240 | 241 | while(*s >= '0' && *s <= '9') 242 | val = val * 10 + (*s++ - '0'); 243 | 244 | return val * sign; 245 | } 246 | 247 | #endif 248 | 249 |  -------------------------------------------------------------------------------- /A/SLASH.ASM: -------------------------------------------------------------------------------- 1 | ;/.ASM by John M. Kodis 2 | 3 | ;CP/M U.G. contrubution November 1980 4 | ; 5 | ;The "slant" program reads a command line which 6 | ;may contain several program invocations. A $$$.SUB 7 | ;file is built with these commands. This file is 8 | ;then executed. 9 | ; 10 | ;For example, the command line: 11 | ; 12 | ;/ asm copy; load copy; dir copy*.*; type copy.prn 13 | ; 14 | ;will build a file containing commands to assemble 15 | ;and load the file named 'copy', search the directory 16 | ;for all copy programs, and type the COPY.PRN file. 17 | ; 18 | ;Based on "/.ASM", CPMUG 40.1. This program was 19 | ;written because the abstract for volume 40 states 20 | ;that 40.1 works only under CP/M version 1.4, 21 | ;and that the source code cannot be provided. This 22 | ;version overcomes both of these difficulties. 23 | ; (Note: 40.1 "1.4 only" meant "not 1.3". 24 | ; it does work with 2.2 ) 25 | ; 26 | ;PROCESSOR: ASM 27 | ;DEPENDENCIES: NONE 28 | ;NOTES: Set "DUP" to true, to define a version 29 | ; which will write "/.SUB" out to disk 30 | ; to facilitate re-executing the same commands. 31 | ; To re-execute them, REN $$$.SUB=/.SUB 32 | ; then ^C. Alternatively, PIP $$$.SUB=/.SUB 33 | ; 34 | ; You might wish to name the version of this 35 | ; program assembled with DUP true, as ".COM 36 | ; 37 | ; (but this will "screw up" the Master CATalog 38 | ; system which reauires its "-name.xxx" to be 39 | ; the first file found) 40 | ; 41 | ; A program for quickie, use once and throw away submits. 42 | ; 43 | ; The command syntax is: 44 | ; 45 | ; A>/ [[;] ... ] 46 | ; 47 | closef equ 16 48 | delete equ 19 49 | writef equ 21 50 | makef equ 22 51 | dmaf equ 26 52 | ; 53 | boot equ 0 ;for a warm start 54 | bdos equ 5 ;cp/m entry point 55 | chcnt equ 080h ;character count 56 | cibuf equ 081h ;console input buffer 57 | tpa equ 100h ;transient program area 58 | ; 59 | dup equ 0 60 | ; 61 | org tpa 62 | ; 63 | slant: lxi h,chcnt 64 | mov a,l 65 | add m 66 | inr a 67 | mov l,a 68 | mvi m,0 ;zero the byte after the end of the command line. 69 | ; 70 | lxi d,cibuf ;de is the source pointer. 71 | lxi h,subbuf+1;hl is the destination pointer. 72 | ; 73 | nxtcmd: ldax d 74 | cpi ' ' 75 | jnz xfer ;skip over leading blanks. 76 | inx d 77 | jmp nxtcmd 78 | ; 79 | xfer: ldax d 80 | ana a ;end of line? 81 | jz cmdend 82 | cpi ';' ;end of command? 83 | jz cmdend 84 | mov m,a ;if neither, xfer it to the output buffer, 85 | inx d 86 | inx h ;bump both pointers, 87 | jmp xfer ;and try again. 88 | ; 89 | cmdend: mvi m,0 ;zero the byte after the end of the line. 90 | mov a,l 91 | dcr a 92 | ani 7fh ;accumulator has character count. 93 | mov b,a ;save it. 94 | mov a,l 95 | ani 80h 96 | mov l,a ;hl points to the character count byte. 97 | mov m,b 98 | ; 99 | ldax d 100 | ana a ;if we've reached the end of the input line... 101 | jz fileit ;let's "file it". 102 | lxi b,129 103 | dad b 104 | inx d ;point to the next character in the input. 105 | jmp nxtcmd ;loop back for the next command. 106 | ; 107 | fileit: push h ;save address of last zone 108 | if dup 109 | lxi d,xfcb 110 | mvi c,delete 111 | call bdos 112 | endif 113 | lxi d,fcb 114 | mvi c,delete 115 | call bdos ;delete any existing command files. 116 | ; 117 | if dup 118 | lxi d,xfcb 119 | mvi c,makef 120 | call bdos 121 | endif 122 | lxi d,fcb 123 | mvi c,makef 124 | call bdos ;create the new command files. 125 | ; 126 | pop h 127 | wrloop: push h 128 | xchg 129 | mvi c,dmaf 130 | call bdos 131 | ; 132 | if dup 133 | lxi d,xfcb 134 | mvi c,writef 135 | call bdos 136 | endif 137 | lxi d,fcb 138 | mvi c,writef 139 | call bdos ;write the new commands, one command per 140 | ;disk sector, writing the last command first. 141 | ; 142 | pop h ;get current dma address 143 | lxi d,-128 144 | dad d 145 | lxi d,subbuf 146 | mov a,l 147 | sub e 148 | mov a,h 149 | sbb d 150 | jnc wrloop 151 | ; 152 | if dup 153 | lxi d,xfcb 154 | mvi c,closef 155 | call bdos 156 | endif 157 | lxi d,fcb 158 | mvi c,closef 159 | call bdos ;close the files after writing the last sector. 160 | ; 161 | rst boot ;back to cp/m via a warm start. 162 | ;changing this to a "ret" will return 163 | ;to CP/M without the warm start, and so 164 | ;the command file will not be executed 165 | ;until the next boot from this disk. 166 | ; 167 | fcb: db 1, '$$$ SUB' 168 | dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 169 | xfcb: db 1, '/ SUB' 170 | dw 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 171 | ; 172 | org ($+0ffh) and 0ff00h 173 | ; 174 | subbuf: ds 0 175 | ; 176 | end slant 177 |  -------------------------------------------------------------------------------- /F/STRINGS.SCR: -------------------------------------------------------------------------------- 1 | \ Strings - Information 971228esA sample string handling package (based on the Ralph Deane article in Dr. Dobbs Journal #50). Functions include - STRING create a string variable MLEN return the maximum length of a string variable S! store a string into the string variable The following functions operate on any string that returns an address and count (including STRING variables). LEN return the length of a string MID$ return the substring LEFT$ return the left-most substring RIGHT$ return the right-most substring S+ concatenate two strings \ Strings - Load screen 971228esFORTH DEFINITIONS DECIMAL APPLICATION 0 WARNING ! ( disable warning messages ) CR .( loading Strings ) 2 4 THRU 1 WARNING ! \ Strings - STRING MLEN S! 971228es\ Create a string variable of max length u (255 max). When \ executing get the address and length of the current string. : STRING CREATE ( u -- ) 255 MIN 1 MAX DUP C, 0 C, ALLOT DOES> ( -- sadr slen ) 1+ COUNT ; \ Return the maximum length of the string variable : MLEN ( sadr slen -- u ) DROP 2- C@ ; \ Store the string c-addr u into the string variable sadr slen : S! ( c-addr u sadr slen -- ) OVER >R MLEN MIN R> 1- PLACE ; \ Strings - LEN MID$ LEFT$ RIGHT$ 971228es\ Return the string length : LEN ( c-addr u -- u ) SWAP DROP ; \ Return u2 characters from the string starting at offset n : MID$ ( c-addr1 u1 n u2 -- c-addr2 u3 ) >R 0 MAX /STRING R> MIN ; \ Return u2 left-most characters from the string : LEFT$ ( c-addr1 u1 u2 -- c-addr2 u3 ) 0 SWAP MID$ ; \ Return u2 right-most characters from the string : RIGHT$ ( c-addr1 u1 u2 -- c-addr2 u3 ) 2DUP - SWAP MID$ ; \ Strings - S+ 971228esHERE 255 ALLOT ( temporary string buffer ) \ Concatenate two strings placing result in a temporary buffer : S+ ( c-addr1 u1 c-addr2 u2 -- c-addr3 u3 ) 2SWAP 255 MIN 0 MAX >R [ DUP ] LITERAL R@ CMOVE [ DUP ] LITERAL R> 2SWAP 2OVER 255 SWAP /STRING ROT MIN 0 MAX DUP >R CMOVE R> + ; DROP -------------------------------------------------------------------------------- /M/alloc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file alloc.h 3 | * @brief Dynamic memory allocation. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Dynamic memory allocation functions, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Format of each memory block: 10 | * - WORD size; size of data 11 | * - BYTE used; 0 = no, 1 = yes 12 | * - BYTE data[size]; data 13 | * 14 | * Revisions: 15 | * - 13 Dec 2000 : Last revision. 16 | * - 16 Apr 2007 : GPL'd. 17 | * - 26 Aug 2012 : Changed some things for more speed. 18 | * - 19 Feb 2015 : Now free() checks if pointer is NULL. 19 | * - 15 Aug 2016 : Optimized and documented. GPL v3. 20 | * - 21 Aug 2018 : Optimized a bit. 21 | * 22 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 23 | * 24 | * Licensed under the GNU General Public License v3. 25 | * 26 | * http://www.floppysoftware.es 27 | * floppysoftware@gmail.com 28 | */ 29 | #ifndef ALLOC_H 30 | 31 | #define ALLOC_H 32 | 33 | //#define XM_DEBUG 34 | 35 | #define XM_HDR_SIZE 3 // Header size of block in bytes 36 | #define XM_INI_SIZE 6 // Size in bytes needed for setup 37 | 38 | extern BYTE *ccfreefirst; 39 | extern WORD ccfreebytes; 40 | 41 | BYTE *xm_top, // First block 42 | *xm_end; // Last block 43 | 44 | /** 45 | * @fn void *malloc(unsigned int size) 46 | * @brief Allocate memory. 47 | * 48 | * This function tries to allocated a memory block of requested 49 | * size in bytes. 50 | * 51 | * The contents of the allocated memory block is undefined. 52 | * 53 | * @param size - needed size in bytes 54 | * @return pointer to allocated memory, or null pointer on failure 55 | */ 56 | malloc(size) 57 | unsigned int size; 58 | { 59 | BYTE *mptr; 60 | unsigned int msize; 61 | WORD *pw; 62 | 63 | // Setup library if needed 64 | 65 | if(!xm_top) 66 | { 67 | if(ccfreebytes > XM_INI_SIZE) 68 | { 69 | xm_top = ccfreefirst; 70 | xm_end = xm_top + ccfreebytes - XM_HDR_SIZE; 71 | 72 | // First block has all free memory 73 | *(pw = xm_top) = ccfreebytes - XM_INI_SIZE; 74 | xm_top[2] = 0; 75 | 76 | // Last block uses 0 bytes 77 | *(pw = xm_end) = 0; 78 | xm_end[2] = 1; 79 | } 80 | } 81 | 82 | // Search a free block 83 | 84 | for(mptr = xm_top; mptr != xm_end; mptr += msize + XM_HDR_SIZE) 85 | { 86 | msize = *(pw = mptr); 87 | 88 | if(!mptr[2]) 89 | { 90 | if(msize >= size) 91 | { 92 | mptr[2] = 1; 93 | 94 | if(msize >= size + XM_HDR_SIZE) 95 | { 96 | *(pw = mptr) = size; 97 | *(pw = mptr + size + XM_HDR_SIZE) = msize - size - XM_HDR_SIZE; 98 | *(mptr + size + 5) = 0; 99 | } 100 | 101 | #ifdef XM_DEBUG 102 | alloc_dbg("malloc", size); 103 | #endif 104 | return mptr + XM_HDR_SIZE; 105 | } 106 | } 107 | } 108 | 109 | #ifdef XM_DEBUG 110 | alloc_dbg("malloc", size); 111 | #endif 112 | 113 | return NULL; 114 | } 115 | 116 | /** 117 | * @fn void free(void *ptr) 118 | * @brief Deallocate memory. 119 | * 120 | * This function deallocates memory, previously allocated with malloc. 121 | * 122 | * If ptr is a null pointer, the function does nothing. 123 | * 124 | * @param ptr - memory block to deallocate 125 | */ 126 | free(ptr) 127 | BYTE *ptr; 128 | { 129 | BYTE *mptr; 130 | unsigned int msize; 131 | WORD *pw; 132 | 133 | // Do nothing on null pointer 134 | 135 | if(!ptr) 136 | return; 137 | 138 | // Make free 139 | 140 | *(ptr - 1) = 0; 141 | 142 | // Join to another free memory blocks if possible 143 | 144 | for(mptr = xm_top; mptr != xm_end; mptr += msize + XM_HDR_SIZE) 145 | { 146 | msize = *(pw = mptr); 147 | 148 | if(!mptr[2]) 149 | { 150 | if(!(*(mptr + msize + 5))) 151 | { 152 | msize += *(pw = mptr + msize + XM_HDR_SIZE) + XM_HDR_SIZE; 153 | 154 | if(!(*(mptr + msize + 5))) 155 | msize += *(pw = mptr + msize + XM_HDR_SIZE) + XM_HDR_SIZE; 156 | 157 | *(pw = mptr) = msize; 158 | 159 | break; 160 | } 161 | } 162 | } 163 | 164 | #ifdef XM_DEBUG 165 | alloc_dbg("free", ptr); 166 | #endif 167 | } 168 | 169 | #ifdef XM_DEBUG 170 | 171 | // void alloc_dbg(char *fn, WORD wrd) : Quick and dirty debug. 172 | 173 | alloc_dbg(fn, wrd) 174 | char *fn; WORD wrd; 175 | { 176 | BYTE *pb, data[4]; 177 | WORD size, *pw; 178 | int use; 179 | 180 | printf("SP = %04x (%s %04x)\n", alloc_sp(), fn, wrd); 181 | 182 | printf("Addr Size Next Use Data\n"); 183 | 184 | for(pb = xm_top; pb != xm_end; pb += size + XM_HDR_SIZE) 185 | { 186 | pw = pb; 187 | size = *pw; 188 | use = pb[2]; 189 | memcpy(data, pb + XM_HDR_SIZE, 4); 190 | 191 | printf("%04x %04x %5u %04x %s \n", pb, size, size, pb + XM_HDR_SIZE + size, use ? "Used" : "Free"); 192 | } 193 | 194 | getch(); 195 | } 196 | 197 | #asm 198 | alloc_sp 199 | LD HL,0 200 | ADD HL,SP 201 | RET 202 | #endasm 203 | 204 | #endif 205 | 206 | // Cleaning 207 | 208 | #undef XM_DEBUG 209 | #undef XM_HDR_SIZE 210 | #undef XM_INI_SIZE 211 | 212 | #endif 213 | 214 |  -------------------------------------------------------------------------------- /H/TURBOPAS.HLP: -------------------------------------------------------------------------------- 1 | Turbo Pascal Common Compiler Directives (standard?) 2 | B Directive for input/output mode selection 3 | C Directive for control character interpretation during console I/O 4 | I Directive for I/O error handling 5 | R Directive for run-time index checks 6 | V Directive controls type checking on strings passed as var 7 | U Directive controls user interrupts 8 | X Directive controls array optimization 9 | A Directive controls generation of absolute non-recursive code 10 | W Directive controls level of nesting of With statements 11 | K Directive controls generation of stack check code 12 | :All compiler directives have default values. These have been chosen 13 | to optimize execution speed and minimuze code size. This means that 14 | code generation for recursive procedures and index checking has been 15 | disabled. 16 | : 17 | B defaults to B+ 18 | 19 | It controls i/o mode selection. When active, {$B+}, the CON: 20 | device is assigned to the standard files Input and Output. When 21 | passive, {$B-}, the TRm: device is used. This directive is global 22 | to an entire program block and cannot be redefined throughout 23 | the program. 24 | : 25 | C defaults to C+ 26 | 27 | It controls control character interpretation during console I/O. 28 | When active, {$C+}, a Ctl-C entered in response to a Read or Readln 29 | statement will interrupt program execution, and a Ctrl-S will 30 | toggle screen output off and on. When passive, etc., control 31 | characters are not interpreted. the active state slows screen 32 | output somewhat, so if screen output speed is imperative, you 33 | should switch off this directive. 34 | : 35 | I defaults to I+ 36 | 37 | This controls I/O error handling. When active all I/O operations 38 | are checked for errors. When passive, it is the responsibility 39 | of the programmer to check I/O errors throughout the standard function 40 | I/O result. The I directive succeeded by a file name instructs 41 | the compiler to include the file with the specified name in the 42 | compilation. Include files are discussed in (chapter 17). 43 | : 44 | R defaults to R- 45 | 46 | It controls run-time index checks. When active all array indexing 47 | operations are checked to be within the defined bounds, and all 48 | assignments to scalar and subrange variables are checked to be 49 | within range. When passive, no checks are performed, and index 50 | errors may well cause a program to go haywire. It is a good idea 51 | to activate this directive while developing a program. Once debugged, 52 | execution will be speeded up by setting it passive. 53 | : 54 | V defaults to V+ 55 | 56 | This directive controls type checking on strings passed as var-parameters. 57 | When active strict type checking is performed, i.e., the lengths of 58 | actual and formal parameters must match. When passive the compiler 59 | allows passing of actual parameters which do not match the length 60 | of the formal parameter. 61 | : 62 | U defaults to U- 63 | 64 | It controls user interrupts. When active the user may interrupt 65 | the program anytime during execution by entering a Ctrl-C. When 66 | passive this has no effect. Activating this directive will significantly 67 | slow down execution speed. 68 | : 69 | X defaults to X+ 70 | 71 | This directive controls array optimization. When active code 72 | generation for arrays is optimized for maximum speed. When passive 73 | the compiler minimizes the code size instead. 74 | : 75 | CP/M-80 Compiler Directives (as opposed to CP/M-86 or MSDOS) 76 | 77 | A defaults to A+ 78 | 79 | This controls generation of absolute, non-recursive code. When 80 | active, absolute code is generated. When passive the compiler 81 | generates code which allows recursive calls. This code requires 82 | more memory and executes slower. 83 | : 84 | W defaults to W2 85 | 86 | This controls the level of nesting of With statements, i.e., the 87 | number of records which may be "opened" within one block. The 88 | W must be immediately followed by a digit between 1 and 9. 89 | : 90 | CP/M-86 / MS-DOS directives 91 | 92 | K defaults to K+ 93 | 94 | It controls the generation of stack check code. When active, 95 | a check is made to insure that space is available for local variables 96 | on the stack before each call to a subprogram. When passive no 97 | checks are made. 98 | : 99 | Other Turbo vs. Standard (Jensen & Wirth) PASCAL 100 | 101 | Extensions offered by TURBO Pascal are not discussed. 102 | 103 | Dynamic variables and pointers use the standard procedures, New, 104 | Mark, and Release instead of the New and Dispose procedures. 105 | Primarily this deviation from the standard is far more efficient 106 | in terms of execution speed and required support code, and secondly 107 | it offers compatibility with other popular Pascal compilers (UCSD). 108 | 109 | The procedure New will not accept variant record specifications. 110 | This restriction, however, is easily circumvented by using the 111 | standard procedure GetMem. 112 | 113 |  -------------------------------------------------------------------------------- /P/MC-MOD03.INC: -------------------------------------------------------------------------------- 1 | {.PA} 2 | {*******************************************************************} 3 | {* SOURCE CODE MODULE: MC-MOD03 *} 4 | {* PURPOSE: Read, Save and Print a spread sheet. *} 5 | {* Display on-line manual. *} 6 | {*******************************************************************} 7 | 8 | type 9 | String3 = string[3]; 10 | 11 | var 12 | FileName: string[14]; 13 | Line: string[100]; 14 | 15 | function Exist(FileN: AnyString): boolean; 16 | var F: file; 17 | begin 18 | {$I-} 19 | assign(F,FileN); 20 | reset(F); 21 | {$I+} 22 | if IOResult<>0 then Exist:=false 23 | else Exist:=true; 24 | end; 25 | 26 | 27 | procedure GetFileName(var Line: AnyString; FileType:String3); 28 | begin 29 | Line:=''; 30 | repeat 31 | Read(Kbd,Ch); 32 | if Upcase(Ch) in ['A'..'Z',^M] then 33 | begin 34 | write(Upcase(Ch)); 35 | Line:=Line+Ch; 36 | end; 37 | until (Ch=^M) or (length(Line)=8); 38 | if Ch=^M then Delete(Line,Length(Line),1); 39 | if Line<>'' then Line:=Line+'.'+FileType; 40 | end; 41 | 42 | {.CP20} 43 | 44 | procedure Save; 45 | var I: screenIndex; 46 | J: integer; 47 | begin 48 | HighVideo; 49 | Msg('Save: Enter filename '); 50 | GetFileName(Filename,'MCS'); 51 | if FileName<>'' then 52 | begin 53 | Assign(MCFile,FileName); 54 | Rewrite(MCFile); 55 | for I:='A' to FXmax do 56 | begin 57 | for J:=1 to FYmax do 58 | write(MCfile,Screen[I,J]); 59 | end; 60 | Grid; 61 | Close(MCFile); 62 | LowVideo; 63 | GotoCell(FX,FY); 64 | end; 65 | end; 66 | 67 | {.CP30} 68 | 69 | procedure Load; 70 | begin 71 | HighVideo; 72 | Msg('Load: Enter filename '); 73 | GetFileName(Filename,'MCS'); 74 | if (Filename<>'') then if (not exist(FileName)) then 75 | repeat 76 | Msg('File not Found: Enter another filename '); 77 | GetFileName(Filename,'MCS'); 78 | until exist(FileName) or (FileName=''); 79 | if FileName<>'' then 80 | begin 81 | ClrScr; 82 | Msg('Please Wait. Loading definition...'); 83 | Assign(MCFile,FileName); 84 | Reset(MCFile); 85 | for FX:='A' to FXmax do 86 | for FY:=1 to FYmax do read(MCFile,Screen[FX,FY]); 87 | FX:='A'; FY:=1; 88 | LowVideo; 89 | UpDate; 90 | end; 91 | GotoCell(FX,FY); 92 | end; 93 | 94 | 95 | {.PA} 96 | 97 | procedure Print; 98 | var 99 | I: screenIndex; 100 | J,Count, 101 | LeftMargin: Integer; 102 | P: string[20]; 103 | MCFile: Text; 104 | begin 105 | HighVideo; 106 | Msg('Print: Enter filename "P" for Printer> '); 107 | GetFileName(Filename,'LST'); 108 | Msg('Left margin > '); Read(LeftMargin); 109 | if FileName='P.LST' then FileName:='Printer'; 110 | Msg('Printing to: ' + FileName + '....'); 111 | Assign(MCFile,FileName); 112 | Rewrite(MCFile); 113 | For Count:=1 to 5 do Writeln(MCFile); 114 | for J:=1 to FYmax do 115 | begin 116 | Line:=''; 117 | for I:='A' to FXmax do 118 | begin 119 | with Screen[I,J] do 120 | begin 121 | while (Length(Line)0 then Str(Value:FW:DEC,P) else Str(Value:FW,P); 127 | Line:=Line+P; 128 | end; 129 | end else Line:=Line+Contents; 130 | end; { With } 131 | end; { One line } 132 | For Count:=1 to LeftMargin do Write(MCFile,' '); 133 | writeln(MCFile,Line); 134 | end; { End Column } 135 | Grid; 136 | Close(MCFile); 137 | LowVideo; 138 | GotoCell(FX,FY); 139 | end; 140 | 141 | {.PA} 142 | 143 | procedure Help; 144 | var 145 | H: text; 146 | HelpFileName: string[14]; 147 | Line: string[80]; 148 | I,J: integer; 149 | Bold: boolean; 150 | 151 | begin 152 | if Exist('MC.HLP') then 153 | begin 154 | Assign(H,'MC.HLP'); 155 | Reset(H); 156 | while not Eof(H) do 157 | begin 158 | Readln(H,Line); 159 | ClrScr; I:=1; Bold:=false; LowVideo; 160 | repeat 161 | For J:=1 to Length(Line) do 162 | begin 163 | if Line[J]=^B then 164 | begin 165 | Bold:=not Bold; 166 | if Bold then HighVideo else LowVideo; 167 | end else write(Line[J]); 168 | end; 169 | Writeln; 170 | I:=I+1; 171 | Readln(H,Line); 172 | until Eof(H) or (I>23) or (Copy(Line,1,3)='.PA'); 173 | GotoXY(26,24); HighVideo; 174 | write('<<< Please press any key to continue >>>'); 175 | LowVideo; 176 | read(Kbd,Ch); 177 | end; 178 | GotoXY(20,24); HighVideo; 179 | write('<<< Please press to start MicroCalc >>>'); 180 | LowVideo; 181 | Readln(Ch); 182 | UpDate; 183 | end else { Help file did not exist } 184 | begin 185 | Msg('To get help the file MC.HLP must be on your disk. Press '); 186 | repeat Read(kbd,Ch) until Ch=^M; 187 | GotoCell(FX,FY); 188 | end; 189 | end; 190 | -------------------------------------------------------------------------------- /M/conio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file conio.h 3 | * @brief Console I/O. 4 | * @author Miguel I. Garcia Lopez / FloppySoftware 5 | * 6 | * Console I/O functions, for MESCC (Mike's Enhanced 7 | * Small C Compiler for Z80 & CP/M). 8 | * 9 | * Supports following #defines: 10 | * - CC_STDIO Support for stdin, stdout & stderr. 11 | * - CC_CONIO_BIOS Support for direct console I/O. 12 | * 13 | * Revisions: 14 | * - 22 Jan 2001 : Last revision. 15 | * - 16 Apr 2007 : GPL'd. 16 | * - 21 Apr 2007 : Changed puts for ANSI compatibility. 17 | * - 15 May 2007 : Bug solved - added LF output to puts. 18 | * - 13 Jul 2014 : Added kbhit(). 19 | * - 08 Dec 2014 : Added support for stdin, stdout & stderr. 20 | * - 31 Dec 2014 : Solved bug in putstr when characters are > 0x7F. 21 | * - 20 Dec 2015 : Added macro CC_CONIO_BIOS to support direct console I/O using BIOS, instead of BDOS. 22 | * - 08 Jan 2015 : Modified getch() when access BDOS (fn. 6 instead of 1). 23 | * - 10 Dec 2016 : Documented. GPL v3. 24 | * 25 | * Copyright (c) 1999-2016 Miguel I. Garcia Lopez / FloppySoftware. 26 | * 27 | * Licensed under the GNU General Public License v3. 28 | * 29 | * http://www.floppysoftware.es 30 | * floppysoftware@gmail.com 31 | */ 32 | #ifndef CONIO_H 33 | 34 | #define CONIO_H 35 | 36 | /** 37 | * @fn int putch(int ch) 38 | * @brief Send character to the console. 39 | * @param ch - character 40 | * @return ch 41 | */ 42 | #ifdef CC_CONIO_BIOS 43 | #asm 44 | 45 | putch 46 | PUSH HL 47 | LD C,L 48 | LD E,9 49 | CALL xbios 50 | POP HL 51 | RET 52 | 53 | xbios 54 | LD HL,(1) 55 | LD D,0 56 | ADD HL,DE 57 | JP (HL) 58 | 59 | #endasm 60 | #else 61 | #asm 62 | 63 | putch 64 | PUSH HL 65 | LD C,2 66 | LD E,L 67 | CALL 5 68 | POP HL 69 | RET 70 | #endasm 71 | #endif 72 | 73 | /** 74 | * @fn int getch(void) 75 | * @brief Get character from the console without echo. 76 | * 77 | * Waits until a character is available. 78 | * 79 | * @return character 80 | */ 81 | #ifdef CC_CONIO_BIOS 82 | #asm 83 | 84 | getch 85 | LD E,6 86 | CALL xbios 87 | LD H,0 88 | LD L,A 89 | RET 90 | 91 | #endasm 92 | #else 93 | #asm 94 | 95 | getch 96 | LD C,6 97 | LD E,255 98 | CALL 5 99 | OR A 100 | JR Z,getch 101 | LD H,0 102 | LD L,A 103 | RET 104 | #endasm 105 | #endif 106 | 107 | /** 108 | * @fn int kbhit(void) 109 | * @brief Tests console input status. 110 | * @return != 0 if a character is available, else 0. 111 | */ 112 | #ifdef CC_CONIO_BIOS 113 | #asm 114 | 115 | kbhit 116 | LD E, 3 117 | CALL xbios 118 | LD H,A 119 | LD L,A 120 | RET 121 | 122 | #endasm 123 | #else 124 | #asm 125 | 126 | kbhit 127 | LD C,11 128 | CALL 5 129 | LD H,A 130 | LD L,A 131 | RET 132 | #endasm 133 | #endif 134 | 135 | /** 136 | * @fn int getchar(void) 137 | * @brief Get character from the console or stdin. 138 | * 139 | * Waits until a character is available. 140 | * 141 | * #ifdef CC_STDIO: Returns a character from stdin, or EOF on end of file or error. 142 | * #ifndef CC_STDIO: Returns a character from the console. Echoes the character. 143 | * 144 | * @return character on success, else EOF. 145 | */ 146 | getchar() 147 | { 148 | 149 | #ifdef CC_STDIO 150 | 151 | return fgetc(stdin); 152 | 153 | #else 154 | 155 | return putchar(getch()); 156 | 157 | #endif 158 | 159 | } 160 | 161 | /** 162 | * @fn int putchar(int ch) 163 | * @brief Send character to the console or stdout. 164 | * 165 | * #ifdef CC_STDIO: Returns ch, or EOF on error. 166 | * #ifndef CC_STDIO: Returns ch. 167 | * 168 | * @param ch - character 169 | * @return ch on success, else EOF. 170 | */ 171 | putchar(ch) 172 | int ch; 173 | { 174 | 175 | #ifdef CC_STDIO 176 | 177 | return fputc(ch, stdout); 178 | 179 | #else 180 | 181 | if(ch == '\n') 182 | putch('\r'); 183 | 184 | return putch(ch); 185 | 186 | #endif 187 | 188 | } 189 | 190 | /** 191 | * @fn int putstr(char *s) 192 | * @brief Send string to the console or stdout. 193 | * 194 | * #ifdef CC_STDIO: Returns the number of characters sent, or EOF on error. 195 | * #ifndef CC_STDIO: Returns a non-negative value to indicate success. 196 | * 197 | * @param s - string 198 | * @return number of characters sent on success, else EOF. 199 | */ 200 | putstr(s) 201 | char *s; 202 | { 203 | 204 | #ifdef CC_STDIO 205 | 206 | /* FIXME : Better if call to fputs (if available) */ 207 | 208 | int i, c; 209 | 210 | i = 0; 211 | 212 | while(*s) 213 | { 214 | /* FIXME : -1 hardcoded -- < 0 causes strange 215 | behaviour if ch > 0x7F */ 216 | 217 | if((c = putchar(*s++)) == -1) 218 | return c; 219 | ++i; 220 | } 221 | 222 | return i; 223 | #else 224 | while(*s) 225 | putchar(*s++); 226 | 227 | return 0; 228 | #endif 229 | 230 | } 231 | 232 | /** 233 | * @fn int puts(char *s) 234 | * @brief Send string + '\n' to the console or stdout. 235 | * 236 | * #ifdef CC_STDIO: Returns the number of characters sent, or EOF on error. 237 | * #ifndef CC_STDIO: Returns a non-negative value to indicate success. 238 | * 239 | * @param s - string 240 | * @return number of characters sent on success, else EOF. 241 | */ 242 | puts(s) 243 | char *s; 244 | { 245 | putstr(s); 246 | 247 | return putchar('\n'); /* FIXME */ 248 | } 249 | 250 | #endif 251 | 252 |  -------------------------------------------------------------------------------- /P/MC.HLP: -------------------------------------------------------------------------------- 1 | INTRODUCTION 2 | 3 | MicroCalc is a tiny spread sheet program a la VisiCalc. It is 4 | provided with the TURBO-Pascal system as an example program. 5 | 6 | Since MicroCalc is only a demonstation program it has its limita- 7 | tions (which you may have fun eliminating): 8 | 9 | * You cannot copy formulas from one cell to others. 10 | * You cannot insert and delete lines or columns. 11 | 12 | In spite of its limitations MicroCalc does provide some interest- 13 | ing features among which are: 14 | 15 | * 11 digits floating point reals (Thanks to TURBO Pascal!) 16 | * Full set of mathematical functions (SIN,COS,LN,EXP etc.) 17 | * Built in line editor for text and formula editing. 18 | * Text can be entered across cells. 19 | * Once entered a formula is protected from accidental erasure. 20 | .PA 21 | 22 | 23 | In addition to this MicroCalc offers all the usual features of a 24 | spread sheet program: 25 | 26 | 27 | * Load a spread sheet from the disk. 28 | * Save a spread sheet on the disk. 29 | * Automatic recalculation after each entry. (May be disabled). 30 | * Print the spread sheet on the printer. 31 | * Clear the current spread sheet. 32 | 33 | The spread sheet is an electronic piece of paper on which you can 34 | enter text, numbers and formulas and have MicroCalc do calcula- 35 | tions automatically. 36 | 37 | The next page shows the electronic spread sheet. 38 | .PA 39 | ---------------------------------------------------------------- 40 | A B C D .... 41 | 1 22.00 42 | 2 1.00 43 | 3 2.00 44 | 4 3.00 45 | 5 28.00 46 | . 47 | . 48 | A 5 Formula: 49 | (A1+A2+A3+A4+A5) 50 | ----------------------------------------------------------------- 51 | 52 | In the example the next last line shows that the active cell is 53 | cell A5 and that A5 contains a formula: (A1+A2+A3+A4) which 54 | means that the numbers in A1,A2,A3 and A4 should be added and 55 | placed in A5. 56 | 57 | The formula can be abbreviated to: (A1>A4) meaning: add all cells 58 | from A1 to A4. 59 | .PA 60 | 61 | You move the cursor around just like you do in the TURBO editor: 62 | 63 | (Up) 64 | Ctrl-E 65 | (Left) Ctrl-S Ctrl-G (Right) 66 | Ctrl-X 67 | (Down) 68 | 69 | A cell may contain a number, a formula or some text. The type of of the cell 70 | and its coordinates are shown in the bottom left corner of the screen: 71 | 72 | A 5 Formula: (Means that the current cell is A5 and that it 73 | contains a formula) 74 | 75 | A 1 Text (Cell A1 contains text) 76 | 77 | A 2 Numeric (Cell A2 contains a number and no cell references) 78 | 79 | .PA 80 | Summary of MicroCalc 81 | Cells are denoted A1 through G21 giving a total of 147 cells. 82 | 83 | Summary of standard functions and operators: 84 | SIN, COS, ARCT, ABS, FACT, EXP, LN, +,-,/,* 85 | Futhermore the operator '>' can be used to denote a range of cells to add. 86 | 87 | Entering data 88 | To enter data in any field move the cursor to the cell and enter the 89 | data. MicroCalc automatically determines if the field is numeric or a 90 | a text field. 91 | 92 | 93 | When moving between fields: 94 | ^S,^D,^E,^X move left right up and down. 95 | 96 | When editing a field 97 | ^S,^D moves left and right. ^A,^F moves to beginning/end of line. 98 | DEL,^G deletes left or right character. 99 | ESC makes it possible to regret changes and to edit an existing cell. 100 | .PA 101 | 102 | 103 | Summary of commands 104 | 105 | 106 | / will restore the screen 107 | Q will Quit MicroCalc 108 | L will Load a spread sheet from the disk. 109 | S will Save a spread sheet on the disk. 110 | R will Recalculate 111 | P will Print the spread sheet. 112 | F makes it possible to change the output format for numbers. 113 | A switches Autocalc ON and OFF 114 | 115 | Note: to use scientific notation use the the F command and enter minus one 116 | -1 for the number of decimals. 117 | 118 | .PA 119 | 120 | EXAMPLES 121 | 122 | The following are examples of valid cell formulas: 123 | 124 | A1+(B2-C7) subtract cell C7 from B2 and add the result to cell A1 125 | (A1>A23) the sum of cells: A1,A2,A3..A23 126 | (A1>B5) the sum of cells: A1..A5 and B1..B5 127 | 128 | The formulas may be as complicated as you want:  129 | 130 | SIN(A1)*COS(A2)/((1.2*A8)+LN(FACT(A8)+8.9E-3))+(C1>C5) 131 | 132 | To edit an existing formula or text simply move to the cell and 133 | press ESC, make your changes and press . If you make 134 | a mistake you may press ESC again, the old value of the cell will 135 | then be restored. 136 | 137 | To try MicroCalc now you may use the /L command and load the file: 138 | CALCDEMO. 139 | 140 | 141 |  try MicroCalc now you may use the /L command and load the file: 142 | CALCDEMO. 143 | 144 | 145 |  -------------------------------------------------------------------------------- /H/CATLOG.HLP: -------------------------------------------------------------------------------- 1 | General Information on Cataloging system 2 | Format of MAST.CAT file 3 | Volume Identifiers 4 | Updating Process 5 | Retreiving data from catalog 6 | Special Features of FMAP 7 | :CATALOG:General Information on Cataloging system 8 | 9 | This document describes a system for cataloging all of a users 10 | CP/M diskettes. Written by Ward Christensen. 11 | 12 | The master cataloging system consists of the following: 13 | 14 | MAST.CAT The catalog itself 15 | 16 | FMAP.COM Used to create NAMES.SUB, the 17 | "transaction file" for catalog update 18 | 19 | CAT.COM Like DIR, i.e. the lookup program 20 | 21 | CAT2.COM Quick kludge program, lists entire 22 | catalog, printing each filename only 23 | once, & stringing disk names out after. 24 | 25 | UCAT.COM The update program, merges NAMES.SUB 26 | into MAST.CAT 27 | 28 | UCAT.COM It now catalogs the "volume serial" 29 | (-name.nnn). 30 | :CATALOG:Format of MAST.CAT file 31 | 32 | The format of MAST.CAT is: 33 | 34 | First, a list of names of files not to be cataloged, in 35 | parentheses. The list supplied with the sample is: 36 | 37 | (ASM.COM 38 | DDT.COM 39 | LOAD.COM 40 | PIP.COM 41 | SID.COM 42 | STAT.COM 43 | SUB.COM <-- I renamed SUBMIT on most disks 44 | SUBMIT.COM) 45 | 46 | Then a list of all cataloged files, in the form: 47 | 48 | filename.type diskname.serial 49 | 50 | For example: ALLOC.COM SYSRES.802 51 | 52 | :CATALOG:Volume identifiers 53 | A disk must have a special filename on it, which is the 54 | volume indentifier: -diskname.serial, such as "-SYSRES.801". 55 | This may be done via: 56 | 57 | save 0 b:-sysres.801 (FOR CP/M SYSTEMS) 58 | save b:-sysres.801 1 (FOR CDOS SYSTEMS) 59 | 60 | NOTE that the SAP (sort and pack directory) program 61 | previously distributed by the CP/M U.G. deletes all 0-length 62 | file entries, so if you use this utility, do a save 1, not a 63 | save 0. 64 | :CATALOG:Updating Process 65 | 66 | To update the catalog for a disk, use FMAP to create 67 | the NAMES.SUB file (which contains a sorted listing of the 68 | files on the particular disk). Filename $$$.SUB is 69 | automatically skipped, as I recall. 70 | 71 | FMAP B: Q 72 | 73 | will write NAMES.SUB to the logged in disk. Then type 74 | UCAT which will merge NAMES.SUB with MAST.CAT, and erase 75 | NAMES.SUB. 76 | Note that UCAT is a "belts and suspenders" type 77 | program, i. e. it creates NEW.CAT, and merges NAMES.SUB with 78 | MAST.CAT and puts it there. It then does: 79 | 80 | era mast.bak 81 | ren mast.bak=mast.cat 82 | ren mast.cat=new.cat 83 | 84 | This means that unless you era mast.bak, there will be 85 | 3 copies of the master catalog on the disk during the ucat 86 | execution. If you don't have sufficient space for it, era 87 | mast.bak first. 88 | :CATALOG:Retreving data from catalog 89 | CAT works just like DIR, i.e. "*" and "?" are allowed. 90 | However, it takes a second operand (after the filename/type) 91 | which is the disk information, in the form NAME.SERIAL - 92 | without the dash. Sample queries: 93 | 94 | CAT <-- ALL FILES 95 | CAT *.* WORK.* <-- ALL FILES ON ANY "WORK" DISK 96 | CAT *.ASM <-- ALL .ASM FILES 97 | CAT *.* *.8* <-- ALL FILES ON DISKS WITH SERIAL 98 | NUMBERS 8xx 99 | 100 | Note that the "-diskname.serial" file is written to the 101 | disk (it wasn't under the earlier UCAT in the CP/M users 102 | group). Thus you can get a list of all disk serials via: 103 | 104 | CAT -*.* 105 | 106 | but other than this one file entry, the "-" characters 107 | are eliminated from the directory, i.e. the disk names are 108 | stored as 7 characters (or less). 109 | :CATALOG:Special Features of FMAP 110 | FMAP has some additional options: 111 | 112 | FMAP 113 | displays a sorted listing on the console 114 | FMAP specs 115 | displays a selective listing. Specs mean *.asm, etc just 116 | like DIR. 117 | FMAP specs D 118 | writes the names to NAMES.SUB with $1 $2 before the name, 119 | and $3 after: 120 | 121 | $1 $2FOO.COM $3 122 | 123 | Thus $1 may be substituted with a command name, $2 with 124 | a disk name, and $3 if the program takes options (only 125 | my programs do, as far as I know) 126 | FMAP specs Q 127 | writes the sorted names, without any "$", to NAMES.SUB. 128 | FMAP specs M 129 | writes the names to NAMES.SUB with $1 $2 $3 before the name, 130 | and $4 after: 131 | 132 | $1 $2 $3FOO.COM $4 133 | 134 | This is specifically for use with the modem program. For 135 | example, to send all .ASM files from the B: disk to another 136 | person: 137 | 138 | FMAP B: M <-- MAKE NAMES.SUB 139 | MODEM SO.600 NAMES.SUB <-- SEND THEM NAMES.SUB 140 | SUBMIT NAMES MODEM SO.600 B: <-- SUBMIT THE SEND 141 | 142 | MODEM gets substituted for $1, SO.600 for $2, and B: for $3. 143 | FMAP specs UNN 144 | creates CP/M users group catalog volume "nn". Not generally 145 | useful, but thought you might like to know how it was done. 146 | 147 | NOTE that I have found the FIND program (also 148 | distributed on this users group disk) to be very useful when 149 | used with MAST.CAT - suppose you have the following in 150 | MAST.CAT: 151 | 152 | BIOS1.ASM 153 | BVIOS.ASM 154 | CBIOS.ASM 155 | M2BIOS.ASM 156 | 157 | It's ovbious that CAT cannot find all your BIOS related files - 158 | but if you type: 159 | 160 | FIND MAST.CAT IOS 161 | 162 | You will find them all 163 |  -------------------------------------------------------------------------------- /M/c_error.c: -------------------------------------------------------------------------------- 1 | /* c_error.c 2 | 3 | Mike's Enhanced Small C Compiler for Z80 & CP/M 4 | 5 | Errors module. 6 | 7 | Copyright (c) 1999-2016 Miguel I. Garcia Lopez, FloppySoftware. 8 | 9 | This program is free software; you can redistribute it and/or modify it 10 | under the terms of the GNU General Public License as published by the 11 | Free Software Foundation; either version 2, or (at your option) any 12 | later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program; if not, write to the Free Software 21 | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 22 | 23 | Revisions: 24 | 25 | 16 Jan 2001 : Last revision. 26 | 16 Apr 2007 : GPL'd. 27 | 26 Oct 2015 : Cleaned. 28 | 27 Nov 2015 : Modified some text messages. 29 | 11 Oct 2016 : Documented and slightly optimized. Errors by id or message. 30 | 14 Feb 2018 : Added errors ERESCSQ (bad escape sequence) and ERNOMEM (not enough memory for buffers). Added errinit macro. Added errinit(). 31 | */ 32 | 33 | // Need a character (it's missing) 34 | 35 | errndch(c) 36 | char c; 37 | { 38 | char s[8]; // "Need: ?" + '\0' 39 | 40 | strcpy(s, "Need: ?"); 41 | s[6] = c; 42 | 43 | errcont_str(s); 44 | } 45 | 46 | // Command line error 47 | 48 | errcmdl(id) 49 | int id; 50 | { 51 | co_str("\nError! "); co_line(errmsg(id)); 52 | exit(1); 53 | } 54 | 55 | // Initialization error 56 | errinit(id) 57 | int id; 58 | { 59 | errcmdl(id); 60 | } 61 | 62 | // File error 63 | 64 | errfile(id, fname) 65 | int id; char *fname; 66 | { 67 | co_str("\nError! File: "); co_str(fname); co_str(" - "); co_line(errmsg(id)); 68 | exit(1); 69 | } 70 | 71 | // Print error and continue 72 | 73 | errcont(id) 74 | int id; 75 | { 76 | errcont_str(errmsg(id)); 77 | } 78 | 79 | // Print error and continue 80 | 81 | errcont_str(msg) 82 | char *msg; 83 | { 84 | errshow_str(msg); 85 | 86 | if(errcnt == errmax) 87 | { 88 | co_line("\nToo many errors, compilation aborted!"); 89 | exit(1); 90 | } 91 | 92 | if(errstop) 93 | { 94 | if(getch() == '.') 95 | errstop = 0; 96 | } 97 | } 98 | 99 | // Print error and exit 100 | 101 | errexit(id) 102 | int id; 103 | { 104 | errshow(id); 105 | exit(1); 106 | } 107 | 108 | // Print error 109 | 110 | errshow(id) 111 | int id; 112 | { 113 | errshow_str(errmsg(id)); 114 | } 115 | 116 | // Print error 117 | 118 | errshow_str(msg) 119 | char *msg; 120 | { 121 | int i; 122 | 123 | fo_nl(); co_nl(); 124 | 125 | comment(); 126 | fo_str(co_str("Error!")); fo_dec(co_dec_5(++errcnt)); fo_ch(co_ch(' ')); 127 | fo_str(co_str("Line: ")); fo_dec(co_dec_5(fi_line)); fo_ch(co_ch(' ')); 128 | fo_str(co_str("File: ")); fo_line(co_line(fi_name)); 129 | 130 | comment(); 131 | fo_line(co_line(msg)); 132 | 133 | comment(); 134 | for(i = 0; line[i]; ++i) 135 | { 136 | fo_ch(co_ch(line[i] == '\t' ? ' ' : line[i])); 137 | } 138 | 139 | fo_nl(); co_nl(); 140 | 141 | comment(); 142 | for(i = 0; i < lptr; ++i) 143 | { 144 | fo_ch(co_ch(' ')); 145 | } 146 | 147 | fo_ch(co_ch('^')); 148 | fo_nl(); co_nl(); 149 | } 150 | 151 | // Return error message 152 | 153 | errmsg(id) 154 | int id; 155 | { 156 | switch(id) 157 | { 158 | // Compiler 159 | case ERCONST : return "Must be constant"; 160 | case ERARRPT : return "Illegal *[]"; 161 | case ERARRSZ : return "Illegal array size"; 162 | case ERCNTAS : return "Can't assign"; 163 | case ERARGNB : return "Illegal number of arguments"; 164 | case ERARGNM : return "Need name of argument"; 165 | case ERFUNDE : return "Illegal function declaration"; 166 | case ERSYMNM : return "Illegal symbol name"; 167 | case ERALDEF : return "Already defined"; 168 | case EROFGLB : return "Global symbol table is full"; 169 | case EROFLOC : return "Local symbol table is full"; 170 | case ERTMWHI : return "Too many whiles"; 171 | case ERNOWHI : return "No active whiles"; 172 | case EREXWHI : return "Need a while"; 173 | case ERLTLNG : return "Line too long"; 174 | case ERTMCAS : return "Too many cases"; 175 | 176 | // Expression parser 177 | case ERSIZOF : return "Illegal use of sizeof"; 178 | case EROFSTR : return "String table is full"; 179 | case ERILADR : return "Illegal address"; 180 | case ERCTSUB : return "Can't index"; 181 | case ERINVEX : return "Illegal expression"; 182 | case ERMBLVL : return "Must be lvalue"; 183 | case ERESCSQ : return "Bad escape sequence"; 184 | 185 | // Preprocessor 186 | case ERASMWE : return "#asm without #endasm"; 187 | case EREASWA : return "#endasm without #asm"; 188 | case ERMACAD : return "Macro already defined"; 189 | case ERTMIFS : return "Too many active #ifs"; 190 | case ERELSEW : return "#else without #if"; 191 | case ERENDIF : return "#endif without #if"; 192 | case ERBADCM : return "Illegal # command"; 193 | case EROFMAC : return "Macro table if full"; 194 | case ERTMINC : return "Too many active includes"; 195 | 196 | // File I/O 197 | case EROPEN : return "Can't open"; 198 | case ERWRITE : return "Can't write"; 199 | case ERCLOSE : return "Can't close"; 200 | 201 | // Command line 202 | case ERCMDLN : return "Illegal option"; 203 | case ERCMDER : return "Illegal max. number of errors"; 204 | case ERCMDLB : return "Illegal label"; 205 | case ERCMDST : return "Illegal size of stack"; 206 | 207 | // Initialization 208 | #ifdef C_USEMALLOC 209 | case ERNOMEM : return "Not enough memory for buffers"; 210 | #endif 211 | } 212 | 213 | // Unknown error id 214 | return "Unknown error"; 215 | } 216 |  -------------------------------------------------------------------------------- /F/BLK2TXT.SCR: -------------------------------------------------------------------------------- 1 | \ BLK2TXT - Information 971228es Convert block files to ascii text. \ BLK2TXT - Load screen 971228esFORTH DEFINITIONS DECIMAL APPLICATION 2 LOAD \ compile program TURNKEY COPY BLK2TXT.COM \ create turnkey application \ BLK2TXT - INFILE OUTFILE HELP ERROR 971228es \ Create file handles for input and output 1 FILE INFILE \ use buffer 1 2 FILE OUTFILE \ use buffer 2 \ Show help and exit : HELP ( -- ) CR ." Convert Forth BLOCK files to Text" CR CR ." Use: blk2txt file[.SCR] file[.TXT]" ABORT ; \ Encountered file error, display filename and quit : ERROR ( -- ) FILENAME TYPE ABORT ; --> \ BLK2TXT - CMD ARG 971228es\ Parse the CP/M command line for the n'th blank delimited \ parameter. Return the address and length and a true flag if \ found, otherwise return false. : CMD ( n -- adr u -1 | 0 ) 0 0 ROT 128 COUNT ROT 0 ?DO 2SWAP 2DROP BL SKIP 2DUP BL SCAN ROT OVER - ROT ROT LOOP 2DROP DUP IF -1 ELSE AND THEN ; \ Get argument - if none show help : ARG ( n -- adr u ) CMD 0= IF ( none ) HELP THEN ; --> \ BLK2TXT - OPEN-FILES COPY-ALL 971228es\ Open source and destination files : OPEN-FILES ( -- ) INFILE 1 ARG S" SCR" +FILENAME OPEN-FILE IF ." Can't open: " ERROR THEN OUTFILE 2 ARG S" TXT" +FILENAME CREATE-FILE IF ." Can't create: " ERROR THEN ; \ Copy loop : COPY-ALL ( -- ) BEGIN INFILE PAD 64 READ-FILE SWAP DROP 0= WHILE OUTFILE PAD 64 -TRAILING WRITE-LINE ABORT" Error; probably out of disk space" REPEAT ; --> \ BLK2TXT - CLOSE-FILES COPY 971228es \ Close source and destination files : CLOSE-FILES ( -- ) INFILE CLOSE-FILE DROP OUTFILE FLUSH-FILE CLOSE-FILE OR IF ." Error closing " ERROR THEN ; \ Main : COPY ( -- ) OPEN-FILES COPY-ALL CLOSE-FILES BYE ; -------------------------------------------------------------------------------- /F/COPY.SCR: -------------------------------------------------------------------------------- 1 | \ Filecopy - Information 971228es A simple filecopy utility to demonstrate the use of the buffered disk functions READ-CHAR and WRITE-CHAR. \ Filecopy - Load screen 971228esFORTH DEFINITIONS DECIMAL APPLICATION 2 LOAD \ compile program TURNKEY COPY COPY.COM \ create turnkey application \ Filecopy - INFILE OUTFILE HELP ERROR 971228es \ Create file handles for input and output 1 FILE INFILE \ use buffer 1 2 FILE OUTFILE \ use buffer 2 \ Show help and exit : HELP ( -- ) 1 ABORT" Usage: A>copy file1 file2 " ; \ Encountered file error, display filename and quit : ERROR ( -- ) FILENAME TYPE ABORT ; --> \ Filecopy - CMD ARG 971228es\ Parse the CP/M command line for the n'th blank delimited \ parameter. Return the address and length and a true flag if \ found, otherwise return false. : CMD ( n -- adr u -1 | 0 ) 0 0 ROT 128 COUNT ROT 0 ?DO 2SWAP 2DROP BL SKIP 2DUP BL SCAN ROT OVER - ROT ROT LOOP 2DROP DUP IF -1 ELSE AND THEN ; \ Get argument - if none show help : ARG ( n -- adr u ) CMD 0= IF ( none ) HELP THEN ; --> \ Filecopy - OPEN-FILES COPY-ALL 971228es \ Open source and destination files : OPEN-FILES ( -- ) INFILE 1 ARG OPEN-FILE IF ." Can't open: " ERROR THEN OUTFILE 2 ARG CREATE-FILE IF ." Can't create: " ERROR THEN ; \ Copy loop : COPY-ALL ( -- ) BEGIN INFILE READ-CHAR 0= WHILE OUTFILE WRITE-CHAR ABORT" Error; probably out of disk space" REPEAT DROP ; --> \ Filecopy - CLOSE-FILES COPY 971228es \ Close source and destination files : CLOSE-FILES ( -- ) INFILE CLOSE-FILE DROP OUTFILE FLUSH-FILE CLOSE-FILE OR IF ." Error closing " ERROR THEN ; \ Main : COPY ( -- ) OPEN-FILES COPY-ALL CLOSE-FILES BYE ; -------------------------------------------------------------------------------- /F/OVERLAY.SCR: -------------------------------------------------------------------------------- 1 | \ Overlay - Information 971228es These screens shows how to implement an overlay system for DX-Forth. It allows the creation of applications larger than would otherwise be possible. Saving and loading of overlays uses the read/write record file commands - this makes for very fast operation and does not require any file buffer space. NOTE: when running or debugging programs using overlays, do not attempt to execute a word in an overlay if that overlay is not currently loaded - it will cause the system to crash. \ Overlay - Load screen 971228esFORTH DEFINITIONS DECIMAL APPLICATION CR .( loading Overlay ) 2 LOAD CR .( .. making demo ) 4 LOAD .( .. testing ) TEST \ Overlay - OBASE OSIZE OFILE LOAD-OVERLAY 971228esFORTH DEFINITIONS DECIMAL APPLICATION VARIABLE OBASE \ base address of the overlay segment VARIABLE OSIZE \ size of largest overlay segment (records) \ Create file handle for overlays 0 FILE OFILE \ no file-buffer required \ Load overlay segment : LOAD-OVERLAY ( c-addr u -- ior ) OFILE OPEN-FILE >R OBASE @ OSIZE @ READ-RECORD SWAP DROP CLOSE-FILE R> OR OR ; --> \ Overlay - OVERLAY 971228esSYSTEM \ Save overlay to disk and discard segment memory : OVERLAY ( -- ) BL WORD COUNT OFILE CREATE-FILE ABORT" can't create overlay" OBASE @ HERE OVER - DUP >R \ overlay size 128 /MOD SWAP 0= NOT - \ records to save DUP OSIZE @ MAX OSIZE ! \ update max size WRITE-RECORD ABORT" can't write overlay" CLOSE-FILE ABORT" can't close overlay" R> NEGATE ALLOT ; \ discard memory APPLICATION \ Overlay - Demo 971228esAPPLICATION \ MUST be located in application space HERE OBASE ! \ overlay start address 0 OSIZE ! \ initial size : WORD1 ( -- ) CR ." This is WORD1 from SAMPLE1.OVL" ; OVERLAY SAMPLE1.OVL : WORD2 ( -- ) CR ." This is WORD2 from SAMPLE2.OVL" ; OVERLAY SAMPLE2.OVL : WORD3 ( -- ) CR ." This is WORD3 from SAMPLE3.OVL" ; OVERLAY SAMPLE3.OVL OSIZE @ 128 * ALLOT \ reserve memory for overlays --> \ Overlay - Demo 971228es\ Display file error msg and abort : FILE-ERROR ( c-addr u -- ) CR TYPE FILENAME TYPE ABORT ; \ Load overlay, handle any errors : OLOAD ( c-addr u -- ) LOAD-OVERLAY IF S" Error loading overlay: " FILE-ERROR THEN ; \ Create loader for each overlay : OVERLAY1 ( -- ) S" SAMPLE1.OVL" OLOAD ; : OVERLAY2 ( -- ) S" SAMPLE2.OVL" OLOAD ; : OVERLAY3 ( -- ) S" SAMPLE3.OVL" OLOAD ; \ Test the overlays : TEST ( -- ) OVERLAY1 WORD1 OVERLAY2 WORD2 OVERLAY3 WORD3 ; -------------------------------------------------------------------------------- /F/TXT2BLK.SCR: -------------------------------------------------------------------------------- 1 | \ TXTBLK - Information 971228es Convert ascii text files to forth screens. \ TXT2BLK - Load screen 971228esFORTH DEFINITIONS DECIMAL APPLICATION 2 LOAD \ compile program TURNKEY COPY TXT2BLK.COM \ create turnkey application \ TXT2BLK - INFILE OUTFILE HELP ERROR 971228es \ Create file handles for input and output 1 FILE INFILE \ use buffer 1 2 FILE OUTFILE \ use buffer 2 \ Show help and exit : HELP ( -- ) CR ." Convert Text files to Forth BLOCKs" CR CR ." Use: txt2blk file[.TXT] file[.SCR]" ABORT ; \ Encountered file error, display filename and quit : ERROR ( -- ) FILENAME TYPE ABORT ; --> \ TXT2BLK - CMD ARG 971228es\ Parse the CP/M command line for the n'th blank delimited \ parameter. Return the address and length and a true flag if \ found, otherwise return false. : CMD ( n -- adr u -1 | 0 ) 0 0 ROT 128 COUNT ROT 0 ?DO 2SWAP 2DROP BL SKIP 2DUP BL SCAN ROT OVER - ROT ROT LOOP 2DROP DUP IF -1 ELSE AND THEN ; \ Get argument - if none show help : ARG ( n -- adr u ) CMD 0= IF ( none ) HELP THEN ; --> \ TXT2BLK - OPEN-FILES COPY-ALL 971228es\ Open source and destination files : OPEN-FILES ( -- ) INFILE 1 ARG S" TXT" +FILENAME OPEN-FILE IF ." Can't open: " ERROR THEN OUTFILE 2 ARG S" SCR" +FILENAME CREATE-FILE IF ." Can't create: " ERROR THEN ; \ Copy loop : COPY-ALL ( -- ) BEGIN INFILE PAD 64 2DUP BLANK READ-LINE SWAP DROP 0= WHILE OUTFILE PAD 64 OVER + SWAP DO I C@ BL MAX I C! LOOP PAD 64 WRITE-FILE ABORT" Error; probably out of disk space" REPEAT ; --> \ TXT2BLK - CLOSE-FILES COPY 971228es \ Close source and destination files : CLOSE-FILES ( -- ) INFILE CLOSE-FILE DROP OUTFILE FLUSH-FILE CLOSE-FILE OR IF ." Error closing " ERROR THEN ; \ Main : COPY ( -- ) OPEN-FILES COPY-ALL CLOSE-FILES BYE ; --------------------------------------------------------------------------------