diff --git a/Manx Aztec C86 v42b/41DRELDOC.txt b/Manx Aztec C86 v42b/41DRELDOC.txt new file mode 100644 index 0000000..0ebbcfa --- /dev/null +++ b/Manx Aztec C86 v42b/41DRELDOC.txt @@ -0,0 +1,396 @@ + + + + + Aztec C86, version 4.10d + Release Document + 26 Oct 88 + + This "readme" file describes what's new version 4.10d of Aztec C86. For + more information on Aztec C86, see the printed release documents for + versions 4.10a and 4.10c. In particular, these printed documents contain + packaging information and describe features in Aztec C86 that have been + added since the manual was last printed. + + Version 4.10d of Aztec C86 differs from version 4.10c in the following + ways: (1) sdb has been enhanced; and (2) bugs have been fixed. + + The programs and functions that have had bugs fixed are: + + * cc + * cgen + * as + * z + * hex86 + * signal() and raise() + * all libraries + + The new versions of cc, cgen, and as must be used together; you can't, + for example, use v4.10c of cc with v4.10d of cgen. + + The following paragraphs describe the new features of sdb. + + + 1. SDB: New Features + + Version 4.10d of sdb has the following new features: + + * Separate virtual screens for sdb and the program being debugged are + now required. + * sdb's screen is now formatted, with different sections of the screen + being used for different purposes. + * The Microsoft mouse, and compatibles, are now supported by sdb. + * A new program, initsdb, is used to configure sdb. THIS PROGRAM MUST BE + RUN BEFORE SDB. + * A new environment variable, SDBOPT, can be used to pass options to + sdb. + * sdb's bm command (memory-change breakpoint) now works. + * The new be command sets an expression breakpoint. When the specified + expression is true, a breakpoint is taken. + * sdb now supports the 43-line mode of EGA display adaptors. + * The -w option has been changed. It now suppresses restoration of the + program screen when single-stepping, thus reducing screen flicker. The + old meaning of -w has been taken over by the new -p option. + * The w command has been changed. It now toggles screen restoration + mode. For example, if screen restoration was disabled, the w command + disables it. + * The new -p option, defines the display page that sdb is to use for its + screen. + * The new -m option defines the memory address at which the display + memory begins. + + + + Page 1 + + + + + Aztec C86, v4.10d Release Document + + The following paragraphs describe these features in detail. + + 1.1 Virtual screens + + Separate virtual screens for sdb and the program being debugged are now + required. sdb uses one virtual screen to display its information and to get + operator commands, and the program uses the other. + + As with previous versions of sdb, virtual screens can either be stored in + display adaptor pages or in sdb buffers: + + Virtual screens can be stored in a display adaptor page, if the + display adaptor has multiple pages. (The CGA is one such adaptor). + sdb's screen is stored in one page, and the program is free to use any + other page. Screen swapping is fast, since to switch the display from + one virtual screen to the other, sdb simply outputs a single command + to the display adaptor. + + Virtual screens can be stored in sdb buffers, if the display adaptor + has only one display page; it can also be used if you want sdb to + share display page 0 with the program that's being debugged. To switch + the display from one virtual screen to the other, sdb stores the + screen page in one of its buffers, and restores the virtual screen + that's in the other buffer. + + You define the display type when you run initsdb. If the display contains + only one page, then sdb will automatically store virtual pages in its own + buffers. If the display contains multiple pages you tell initsdb where + virtual screens are to be stored. If display pages are to be used, you tell + initsdb the page that sdb is to use; this can be overriden when sdb is + started, using the new -p option. + + The -p option has the form -px, where x is the number of the page that + sdb is to use. + + 1.2 Formatted Screen + + sdb's virtual screen is now formatted, with different sections of the + screen displaying different information, as follows: + + * The top line lists the name of the source file currently being + displayed, and specifies whether sdb is in source or assembly mode. + * The next few lines display lines in the current source file. These + lines act like a window into the source file, a window that can be + moved (as described below) to display different sections of the source + file. + * The next line is used to enter and display commands. sdb maintains a + log of commands, and this line acts like a window into that log. You + can move the window around within the log, and then easily rexecute a + previously-entered command. + * The remaining lines are used for sdb output. sdb remembers data that + it has previously displayed, and these lines act like a window onto + that data, a window that can be moved to recall different sections of + the displayed data. + * The rightmost column contains a scroll bar and other features that are + used with a mouse. + + + + + + Page 2 + + + + + Aztec C86, v4.10d Release Document + + 1.3 Keys used to manipulate sdb + + Function keys and cursor-motion keys have meaning to sdb, as follows: + + Key Meaning + F1 Scroll source window up one line + F2 Scroll source window down one line + F3 Move command line up one line (also makes source window + one line smaller and data window one line larger) + F4 Move command line down one line (also makes source + window one line larger and data window one line + smaller) + F5 Scroll data window up one line + F6 Scroll data window down one line + Alt-F1 Move source window to the top of the source file + Alt-F2 Move source window to the bottom of the source file + Alt-F3 Move the command line to the top of the screen + Alt-F4 Move the command line to the bottom of the screen + Alt-F5 Move the data window to the top of the data buffer + Alt-F6 Move the data window to the bottom of the data buffer + Shift-F1 Move the source window to the position at which it was + located before the previous Alt-F1 or Alt-F2 + Shift-F2 Same as Shift-F1 + Shift-F3 Move the command line to the position at which it was + located before the previous Alt-F3 or Alt-F4 + Shift-F4 Same as Shift-F3 + Shift-F5 Move the data window to the position at which it was + located before the previous Alt-F5 or Alt-F6 + Shift-F6 Same as Shift-F5 + F9 Scroll source window to current source line + F10 Toggle between Source and Assembly modes + PgUp Move the source window up one page + PgDn Move the source window down one page + Up arrow Move command window up one line in the command log + Dn arrow Move command window down one line in the command log + Left arrow + Move cursor left one character on the command line + Right arrow + Move cursor right one character on the command line + Delete Delete the character on the command line that's under + the cursor + Home Move the cursor to the beginning of the command line + End Move the cursor to the end of the command line + Escape Display the other virtual screen + Right single quote + Same as Escape + Control-L Redraw the screen + + 1.4 Using a mouse + + There are three sections of the sdb screen in which a mouse can be used: + the scroll bar at the right of the screen, the top line of the screen, and + the command line. These sections are described in the following paragraphs. + + + + + + + Page 3 + + + + + Aztec C86, v4.10d Release Document + + 1.4.1 The scroll bar + + The scroll bar has three sections. The box in the middle of the bar with + the up and down triangles positions the command line on the screen, and + hence indirectly controls the size of the source and data windows. The area + above the triangles positions the source window; the area below the + triangles positions the data window. + + 1.4.1.1 Moving the command line + + To move the command line with the mouse, move the mouse cursor to the box + that contains the triangles. Press and hold the left mouse button, drag the + cursor to the desired location, and release the mouse button. + + 1.4.1.2 Positioning the source window + + The area of the scroll bar that positions the source window contains a + solid rectangle; this indicates the current position of the window within + the source file. When the rectangle is at the top of the area, the window + is at the top of the file; when the rectangle is at the bottom of the area, + the window is at the bottom of the file; and so on. Using the mouse, you + can move the rectangle within the scroll bar; this causes the source window + to move the source window within the source file. To do this, put the mouse + cursor in the rectangle, press and hold the left mouse button, move the + mouse cursor to the desired position in the scroll bar, and release the + button. + + At the top of the source window's section of the scroll bar are two + upward-facing arrows. To scroll the source window up a line at a line, move + the mouse cursor to the arrows, press and hold the left mouse button. The + source window will begin scrolling upward. When it reaches the desired + location, release the button. + + At the bottom of the source window's section of the scroll bar are two + downward-facing arrows. They are used to scroll the source window down a + line at a time, in a manner analagous to the up arrows. + + To move the source window up a page, move the mouse cursor somewhere + below the up arrows and above the rectangle, and click the left mouse + button. + + To move the source window down a page, move the mouse cursor somewhere + above the down arrows and below the rectangle, and click the left mouse + button. + + To move the source window to the beginning or end of the source file, + move the mouse cursor to the up or down arrows, respectively, and click + both mouse buttons. + + 1.4.1.3 Positioning the data window + + The data window's section of the scroll bar looks just like the source + window's, and is used in the same way. For example, (1) the rectangle + indicates the position of the window in the data buffer and can be used to + move to the data window within the data buffer; (2) the up arrows scroll + the data window up in the data buffer one line; (3) the down arrows scroll + the data window down one line; (4) and so on. + + + Page 4 + + + + + Aztec C86, v4.10d Release Document + + 1.4.2 Using the mouse on the top line + + The top line of sdb's virtual screen has a section that specifies whether + sdb is in source or assembly mode, and a section that lists the file that's + currently displayed in the source window. To use the mouse to toggle + between source and assembly mode, move the mouse cursor to the top line's + source/assembly mode section and click the left mouse button. + + To move the source window back to the source line at which execution is + currently stopped, move the mouse cursor to the top line's source file + section and click the left mouse button. + + 1.4.3 Using the mouse on the command line + + The mouse can be used to position the text cursor on the command line. To + do this, just move the mouse cursor to the desired location and click the + left mouse button. + + 1.4.4 Switching screens with the mouse + + The mouse can be used to switch the display from one virtual screen to + another: just click the right mouse button. + + 1.5 The SDBOPT environment variable + + The SDBOPT environment variable can be used to pass frequently-used + options to sdb, without having to explicitly list them on the command line + when sdb is started. + + For example, if you always want the -p2 option to be specified when sdb + is started, you could set SDBOPT like this: + + set SDBOPT=-p2 + + 1.6 The initsdb utility + + The initsdb utility is used to define the attributes of your monitor to + sdb and the way you want the lines on sdb's virtual screen to appear. The + information you select is written to a file named sdb.ini. + + 1.6.1 Using initsdb + + initsdb's screen is organized into four sections. The top three sections + are used to set options, and the bottom section summarizes the keys that + you can use with initsdb. The three option-selecting sections are entitled + Basic Options, Advanced Options, and Color selection. Selections are + toggled using the key. + + In the Basic Options section you define the type of monitor you have, and + for CGA monitors, whether you want "snow" removed. This section also has + options that you select to write your choices to the sdb.ini file, to abort + without writing anything, and to quit after writing. + + In the Color Selection section you define the attributes of the various + lines that appear on sdb's screen; i.e. the foreground and background color + of each type of line. There are five lines in the Color Selection section, + each of which corresponds to one type of line on the sdb screen. To select + the attributes of a line, move the cursor to a line; then type 'f' or 'F' + + Page 5 + + + + + Aztec C86, v4.10d Release Document + + to advance or decrement the line's forground color. Type 'b' or 'B' to + advance or decrement the line's background color. + + The Advanced Options section contains several display-dependent options. + You are only allowed to change the ones that are relevant to your monitor. + For example, if you have an EGA monitor, you can select the option that + causes sdb to use a 43 line screen. If you have a CGA monitor, you can + select whether you want sdb and the program that's being debugged to share + the same display page or whether you want sdb and the program to each have + a separate display page. + + 1.6.2 The sdb.ini file + + Configuration options are stored in a file named sdb.ini. When sdb and + initsdb start, they look for this file first in the current drive's current + directory, and then in the directories specified in the PATH environment + variable. + + initsdb writes configuration options back to the same file; if it didn't + find an sdb.ini file, it writes the options to an sdb.ini file in the + current directory. + + 1.7 Summary of new and changed sdb options + + Here is a summary of the new sdb options: + + -px On a CGA monitor, have sdb use page x for its screen. + -mx Display memory begins at paragraph x, where x is a + hexadecimal number. If this option isn't used, sdb will use + the standard value for your type of display. + -w When single-stepping, don't restore the program's screen. + + 1.8 Summary of new and changed commands + + Here is a summary of the sdb commands that are new or have changed: + + w Toggle screen restoration mode. + be Set or remove a memory change breakpoint + + + + + + + + + + + + + + + + + + + + + + Page 6 + + diff --git a/Manx Aztec C86 v42b/ARC/BUILD.ARC b/Manx Aztec C86 v42b/ARC/BUILD.ARC new file mode 100644 index 0000000..5267db9 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/BUILD.ARC @@ -0,0 +1,890 @@ + build.bat +echo off +if NOT '%1'=='RESTART' goto makeall +shift +goto %RESTART% +:makeall +make clean +:SMALL +set RESTART=SMALL +make MODEL= AMODEL=0 %1 %2 %3 %4 %5 %6 +if ERRORLEVEL 1 goto quit +make clean +:COMPACT +set RESTART=COMPACT +make MODEL=lc AMODEL=1 %1 %2 %3 %4 %5 %6 +if ERRORLEVEL 1 goto quit +make clean +:MEDIUM +set RESTART=MEDIUM +make MODEL=ld AMODEL=2 %1 %2 %3 %4 %5 %6 +if ERRORLEVEL 1 goto quit +make clean +:LARGE +set RESTART=LARGE +make MODEL=l AMODEL=3 %1 %2 %3 %4 %5 %6 +if ERRORLEVEL 1 goto quit +make clean +set RESTART= +echo All models built OK. +goto done +:quit +echo Build failed making %RESTART% model libraries. +echo To restart build type "build RESTART [parameters]" +:done + c.bld +dos20/dosdir.o +dos20/monitor.o +dos20/profil.o +stdio/tmpfile.o +stdio/perror.o +stdio/fdopen.o +stdio/fgets.o +stdio/assert.o +stdio/fprintf.o +stdio/fputs.o +stdio/fread.o +stdio/fscanf.o +stdio/fseek.o +stdio/gets.o +stdio/getchar.o +stdio/getw.o +stdio/puterr.o +stdio/puts.o +stdio/putw.o +stdio/scanf.o +stdio/agetc.o +stdio/getc.o +stdio/setbuf.o +stdio/ungetc.o +stdio/tmpnam.o +stdio/mktemp.o +misc/atoi.o +misc/atol.o +misc/calloc.o +misc/lcalloc.o +misc/qsort.o +misc/sscanf.o +misc/scan.o +misc/rand.o +misc/abort.o +misc/raise.o +dos20/bdos.o +dos20/bdosx.o +dos20/chmod.o +dos20/csread.o +dos20/ctime.o +dos20/asctime.o +dos20/dostime.o +dos20/dup.o +dos20/execl.o +dos20/execlp.o +dos20/execvp.o +dos20/execv.o +dos20/exec.o +dos20/fexecl.o +dos20/fexecv.o +dos20/fcbinit.o +dos20/getcwd.o +dos20/ioctl.o +dos20/dioctl.o +dos20/localtim.o +dos20/mkdir.o +dos20/stat.o +dos20/system.o +misc/sprintf.o +dos20/fexec.o +dos20/getenv.o +dos20/utime.o +dos20/ftime.o +dos20/time.o +dos20/wait.o +dos20/access.o +mch86/cswt.o +mch86/cswit.o +mch86/clswit.o +mch86/farcall.o +mch86/fcall.o +mch86/index.o +mch86/olsubs.o +mch86/movblock.o +mch86/peek.o +mch86/port.o +mch86/rindex.o +mch86/segread.o +mch86/setjmp.o +mch86/setmem.o +mch86/strcat.o +mch86/strcpy.o +mch86/strncpy.o +mch86/strstr.o +mch86/stricmp.o +mch86/strlwr.o +mch86/strrev.o +mch86/swapmem.o +dos20/lmalloc.o +mch86/sysint.o +mch86/toupper.o +mch86/csav.o +dos20/dos.o +dos20/dosx.o +mch86/memccpy.o +mch86/memchr.o +mch86/memcmp.o +mch86/memcpy.o +mch86/memset.o +dos20/syserr.o +mch86/pointers.o +mch86/fptrs.o +mch86/ptradd.o +mch86/strchr.o +mch86/strrchr.o +dos20/clock.o +misc/signal.o +dos20/sighand.o +dos20/sigfix.o +misc/sigtable.o +dos20/mon.o +dos20/clk.o +stdio/fopen.o +stdio/fwrite.o +stdio/printf.o +stdio/putchar.o +stdio/aputc.o +stdio/putc.o +stdio/getbuff.o +misc/malloc.o +misc/format.o +misc/ctype.o +dos20/open.o +mch86/lsubs.o +mch86/strcmp.o +mch86/strlen.o +dos20/sys.o +mch86/ptrdiff.o +dos20/sbegin.o +dos20/croot.o +mch86/fltstub.o +dos20/stkover.o +dos20/stksiz.o +dos20/io.o +dos20/ttyio.o +mch86/movmem.o +dos20/isatty.o +dos20/ssbrk.o +dos20/filelock.o + c86.bld +stdio/tmpfile.o +stdio/perror.o +stdio/fdopen.o +stdio/fgets.o +stdio/fopen.o +stdio/assert.o +stdio/fprintf.o +stdio/fputs.o +stdio/fread.o +stdio/fscanf.o +stdio/fseek.o +stdio/fwrite.o +stdio/gets.o +stdio/getchar.o +stdio/getw.o +stdio/printf.o +stdio/puterr.o +stdio/puts.o +stdio/putchar.o +stdio/aputc.o +stdio/putw.o +stdio/putc.o +stdio/scanf.o +stdio/agetc.o +stdio/getc.o +stdio/getbuff.o +stdio/setbuf.o +stdio/ungetc.o +stdio/tmpnam.o +stdio/mktemp.o +misc/atoi.o +misc/atol.o +misc/calloc.o +misc/qsort.o +misc/sscanf.o +misc/scan.o +misc/rand.o +misc/abort.o +misc/raise.o +misc/signal.o +misc/sigtable.o +misc/malloc.o +misc/sprintf.o +misc/format.o +misc/ctype.o +mch86/cswt.o +mch86/cswit.o +mch86/clswit.o +mch86/farcall.o +mch86/fcall.o +mch86/index.o +mch86/lsubs.o +mch86/olsubs.o +mch86/peek.o +mch86/port.o +mch86/rindex.o +mch86/segread.o +mch86/setjmp.o +mch86/strlen.o +mch86/strncpy.o +mch86/swapmem.o +mch86/sysint.o +mch86/toupper.o +cpm86/sbrk.o +mch86/memccpy.o +mch86/memchr.o +mch86/memcmp.o +mch86/memcpy.o +mch86/memset.o +cpm86/access.o +cpm86/csread.o +mch86/movblock.o +cpm86/execl.o +cpm86/exec.o +cpm86/ioctl.o +cpm86/isatty.o +cpm86/lseek.o +cpm86/read.o +cpm86/rename.o +cpm86/write.o +cpm86/blkio.o +mch86/csav.o +mch86/pointers.o +mch86/fptrs.o +mch86/ptrdiff.o +mch86/ptradd.o +mch86/strchr.o +mch86/strrchr.o +cpm86/stkover.o +cpm86/begin.o +cpm86/croot.o +cpm86/close.o +cpm86/open.o +mch86/strcmp.o +cpm86/ceof.o +cpm86/find.o +mch86/setmem.o +mch86/strcat.o +mch86/strcpy.o +mch86/movmem.o +cpm86/unlink.o +mch86/fltstub.o +cpm86/bdos.o +cpm86/fcbinit.o +cpm86/user.o + cl.bld +dos20/monitor.o +dos20/profil.o +dos20/dosdir.o +stdio/tmpfile.o +stdio/perror.o +stdio/fdopen.o +stdio/fgets.o +stdio/assert.o +stdio/fprintf.o +stdio/fputs.o +stdio/fread.o +stdio/fscanf.o +stdio/fseek.o +stdio/gets.o +stdio/getchar.o +stdio/getw.o +stdio/puterr.o +stdio/puts.o +stdio/putw.o +stdio/scanf.o +stdio/agetc.o +stdio/getc.o +stdio/setbuf.o +stdio/ungetc.o +stdio/tmpnam.o +stdio/mktemp.o +misc/atoi.o +misc/atol.o +misc/calloc.o +misc/lcalloc.o +misc/qsort.o +misc/sscanf.o +misc/scan.o +misc/rand.o +misc/abort.o +misc/raise.o +dos20/bdos.o +dos20/bdosx.o +dos20/chmod.o +dos20/csread.o +dos20/ctime.o +dos20/asctime.o +dos20/dostime.o +dos20/dup.o +dos20/execl.o +dos20/execlp.o +dos20/execvp.o +dos20/execv.o +dos20/exec.o +dos20/fexecl.o +dos20/fexecv.o +dos20/fcbinit.o +dos20/getcwd.o +dos20/ioctl.o +dos20/dioctl.o +dos20/localtim.o +dos20/mkdir.o +dos20/stat.o +dos20/system.o +misc/sprintf.o +dos20/fexec.o +dos20/getenv.o +dos20/utime.o +dos20/ftime.o +dos20/time.o +dos20/wait.o +dos20/access.o +mch86/cswit.o +mch86/clswit.o +mch86/farcall.o +mch86/fcall.o +mch86/index.o +mch86/movblock.o +mch86/peek.o +mch86/port.o +mch86/rindex.o +mch86/segread.o +mch86/setjmp.o +mch86/setmem.o +mch86/strcat.o +mch86/strcpy.o +mch86/strncpy.o +mch86/strstr.o +mch86/stricmp.o +mch86/strlwr.o +mch86/strrev.o +mch86/swapmem.o +mch86/sysint.o +mch86/toupper.o +mch86/csav.o +dos20/dos.o +dos20/dosx.o +mch86/memccpy.o +mch86/memchr.o +mch86/memcmp.o +mch86/memcpy.o +mch86/memset.o +dos20/syserr.o +mch86/pointers.o +mch86/fptrs.o +mch86/strchr.o +mch86/strrchr.o +dos20/clock.o +misc/signal.o +dos20/sighand.o +dos20/sigfix.o +misc/sigtable.o +dos20/mon.o +dos20/clk.o +stdio/fopen.o +stdio/fwrite.o +stdio/printf.o +stdio/putchar.o +stdio/aputc.o +stdio/putc.o +stdio/getbuff.o +misc/ldlmallo.o +misc/ldmalloc.o +misc/format.o +misc/ctype.o +dos20/open.o +mch86/lsubs.o +mch86/strcmp.o +mch86/strlen.o +dos20/sys.o +mch86/ptrdiff.o +mch86/ptradd.o +dos20/lbegin.o +dos20/stksiz.o +dos20/croot.o +mch86/fltstub.o +dos20/stkover.o +dos20/io.o +dos20/ttyio.o +mch86/movmem.o +dos20/isatty.o +dos20/lsbrk.o +dos20/filelock.o + clc.bld +stdio/tmpfile.o +dos20/monitor.o +dos20/profil.o +dos20/dosdir.o +stdio/perror.o +stdio/fdopen.o +stdio/fgets.o +stdio/assert.o +stdio/fprintf.o +stdio/fputs.o +stdio/fread.o +stdio/fscanf.o +stdio/fseek.o +stdio/gets.o +stdio/getchar.o +stdio/getw.o +stdio/puterr.o +stdio/puts.o +stdio/putw.o +stdio/scanf.o +stdio/agetc.o +stdio/getc.o +stdio/setbuf.o +stdio/ungetc.o +stdio/tmpnam.o +stdio/mktemp.o +misc/atoi.o +misc/atol.o +misc/calloc.o +misc/lcalloc.o +misc/qsort.o +misc/sscanf.o +misc/scan.o +misc/rand.o +misc/abort.o +misc/raise.o +dos20/bdos.o +dos20/bdosx.o +dos20/chmod.o +dos20/csread.o +dos20/ctime.o +dos20/asctime.o +dos20/dostime.o +dos20/dup.o +dos20/execl.o +dos20/execlp.o +dos20/execvp.o +dos20/execv.o +dos20/exec.o +dos20/fexecl.o +dos20/fexecv.o +dos20/fcbinit.o +dos20/getcwd.o +dos20/ioctl.o +dos20/dioctl.o +dos20/localtim.o +dos20/mkdir.o +dos20/stat.o +dos20/system.o +misc/sprintf.o +dos20/fexec.o +dos20/getenv.o +dos20/utime.o +dos20/ftime.o +dos20/time.o +dos20/wait.o +dos20/access.o +mch86/cswit.o +mch86/clswit.o +mch86/farcall.o +mch86/fcall.o +mch86/index.o +mch86/movblock.o +mch86/peek.o +mch86/port.o +mch86/rindex.o +mch86/segread.o +mch86/setjmp.o +mch86/setmem.o +mch86/strcat.o +mch86/strcpy.o +mch86/strncpy.o +mch86/strstr.o +mch86/stricmp.o +mch86/strlwr.o +mch86/strrev.o +mch86/swapmem.o +dos20/lmalloc.o +mch86/sysint.o +mch86/toupper.o +mch86/csav.o +dos20/dos.o +dos20/dosx.o +mch86/memccpy.o +mch86/memchr.o +mch86/memcmp.o +mch86/memcpy.o +mch86/memset.o +dos20/syserr.o +mch86/pointers.o +mch86/fptrs.o +mch86/ptradd.o +mch86/strchr.o +mch86/strrchr.o +dos20/clock.o +misc/signal.o +dos20/sighand.o +dos20/sigfix.o +misc/sigtable.o +dos20/mon.o +dos20/clk.o +stdio/fopen.o +stdio/fwrite.o +stdio/printf.o +stdio/putchar.o +stdio/aputc.o +stdio/putc.o +stdio/getbuff.o +misc/malloc.o +misc/format.o +misc/ctype.o +dos20/open.o +mch86/lsubs.o +mch86/strcmp.o +mch86/strlen.o +dos20/sys.o +mch86/ptrdiff.o +dos20/sbegin.o +dos20/croot.o +mch86/fltstub.o +dos20/stkover.o +dos20/io.o +dos20/ttyio.o +mch86/movmem.o +dos20/isatty.o +dos20/ssbrk.o +dos20/stksiz.o +dos20/filelock.o + cld.bld +dos20/monitor.o +dos20/profil.o +dos20/dosdir.o +stdio/tmpfile.o +stdio/perror.o +stdio/fdopen.o +stdio/fgets.o +stdio/assert.o +stdio/fprintf.o +stdio/fputs.o +stdio/fread.o +stdio/fscanf.o +stdio/fseek.o +stdio/gets.o +stdio/getchar.o +stdio/getw.o +stdio/puterr.o +stdio/puts.o +stdio/putw.o +stdio/scanf.o +stdio/agetc.o +stdio/getc.o +stdio/setbuf.o +stdio/ungetc.o +stdio/tmpnam.o +stdio/mktemp.o +misc/atoi.o +misc/atol.o +misc/calloc.o +misc/lcalloc.o +misc/qsort.o +misc/sscanf.o +misc/scan.o +misc/rand.o +misc/abort.o +misc/raise.o +dos20/bdos.o +dos20/bdosx.o +dos20/chmod.o +dos20/csread.o +dos20/ctime.o +dos20/asctime.o +dos20/dostime.o +dos20/dup.o +dos20/execl.o +dos20/execlp.o +dos20/execvp.o +dos20/execv.o +dos20/exec.o +dos20/fexecl.o +dos20/fexecv.o +dos20/fcbinit.o +dos20/getcwd.o +dos20/ioctl.o +dos20/dioctl.o +dos20/localtim.o +dos20/mkdir.o +dos20/stat.o +dos20/system.o +misc/sprintf.o +dos20/fexec.o +dos20/getenv.o +dos20/utime.o +dos20/ftime.o +dos20/time.o +dos20/wait.o +dos20/access.o +mch86/cswit.o +mch86/clswit.o +mch86/farcall.o +mch86/fcall.o +mch86/index.o +mch86/movblock.o +mch86/peek.o +mch86/port.o +mch86/rindex.o +mch86/segread.o +mch86/setjmp.o +mch86/setmem.o +mch86/strcat.o +mch86/strcpy.o +mch86/strncpy.o +mch86/swapmem.o +mch86/sysint.o +mch86/csav.o +mch86/strstr.o +mch86/stricmp.o +mch86/strlwr.o +mch86/strrev.o +mch86/toupper.o +dos20/dos.o +dos20/dosx.o +mch86/memccpy.o +mch86/memchr.o +mch86/memcmp.o +mch86/memcpy.o +mch86/memset.o +dos20/syserr.o +mch86/pointers.o +mch86/fptrs.o +mch86/strchr.o +mch86/strrchr.o +dos20/clock.o +misc/signal.o +dos20/sighand.o +dos20/sigfix.o +misc/sigtable.o +dos20/mon.o +dos20/clk.o +stdio/fopen.o +stdio/fwrite.o +stdio/printf.o +stdio/putchar.o +stdio/aputc.o +stdio/putc.o +stdio/getbuff.o +misc/ldlmallo.o +misc/ldmalloc.o +misc/format.o +misc/ctype.o +dos20/open.o +mch86/lsubs.o +mch86/strcmp.o +mch86/strlen.o +dos20/sys.o +mch86/ptrdiff.o +mch86/ptradd.o +dos20/lbegin.o +dos20/stksiz.o +dos20/croot.o +mch86/fltstub.o +dos20/stkover.o +dos20/io.o +dos20/ttyio.o +mch86/movmem.o +dos20/isatty.o +dos20/lsbrk.o +dos20/filelock.o + m.bld +math/asin.o +math/atan.o +math/floor.o +math/pow.o +math/log.o +math/random.o +math/sin.o +math/sinh.o +math/sqrt.o +math/tan.o +math/tanh.o +math/exp.o +stdio/fprintf.o +stdio/printf.o +misc/sprintf.o +misc/fformat.o +stdio/fscanf.o +stdio/scanf.o +misc/sscanf.o +misc/fscan.o +math/atof.o +math/ftoa.o +math/frexp.o +math/fabs.o +math/fpst.o +math/fsubs.o + m87.bld +math/floor87.o +math/pow87.o +math/log87.o +math/random87.o +math/sin87.o +math/sinh87.o +math/tan87.o +math/tanh87.o +stdio/fprintf.o +stdio/printf.o +misc/sprintf.o +misc/fformat.o +stdio/fscanf.o +stdio/scanf.o +misc/sscanf.o +misc/fscan87.o +math/atof87.o +math/ftoa87.o +math/asin87.o +math/sqrt87.o +math/atan87.o +math/exp1087.o +math/exp87.o +math/fmod87.o +math/frexp87.o +math/fabs87.o +math/fpst.o +math/isnan.o +math/fsubs87.o +math/chk87.o + m87s.bld +math/asin.o +math/atan.o +math/floor.o +math/pow.o +math/log.o +math/random.o +math/sin.o +math/sinh.o +math/sqrt87s.o +math/tan.o +math/tanh.o +math/exp.o +stdio/fprintf.o +stdio/printf.o +misc/sprintf.o +misc/fformat.o +stdio/fscanf.o +stdio/scanf.o +misc/sscanf.o +misc/fscan.o +math/atof.o +math/ftoa.o +math/frexp87s.o +math/fabs.o +math/fpst.o +math/fsubs87s.o + makefile +MODEL= +AMODEL=0 + +all: dos math86 math87 maths graph scn rom + @echo all done + +math: math86 math87 maths + @echo math all done + +clean: + del dos20\*.o + del math\*.o + del mch86\*.o + del misc\*.o + del stdio\*.o + del cpm86\*.o + del graphics\*.o + del screen\*.o + +dos: mkdos20 mkmch86 mkmisc mkstdio + del libs\c$(MODEL).lib + lb libs/c$(MODEL).lib -f c$(MODEL).bld + +cpm: mkcpm mkmch86 mkmisc mkstdio + del libs\c86$(MODEL).lib + lb libs/c86$(MODEL).lib -f c86$(MODEL).bld + +math86: mkmath mathmisc mathstdio + del libs\m$(MODEL).lib + lb libs/m$(MODEL).lib -f m.bld + +maths: mkmath mathmisc mathstdio + del libs\m87s$(MODEL).lib + lb libs/m87s$(MODEL).lib -f m87s.bld + +math87: mkmath87 mathmisc mathstdio + del libs\m87$(MODEL).lib + lb libs/m87$(MODEL).lib -f m87.bld + +graph: + cd graphics + make MODEL=$(MODEL) AMODEL=$(AMODEL) DIR=..\libs\ ..\libs\g$(MODEL).lib + cd .. + +scn: + cd screen + make MODEL=$(MODEL) AMODEL=$(AMODEL) DIR=..\libs\ ..\libs\s$(MODEL).lib + cd .. + +rom: + cd mch86 + make MODEL=$(MODEL) AMODEL=$(AMODEL) DIR=..\libs\ ..\libs\\$(MODEL)rom.o + cd .. + +ovly: + cd mch86 + make MODEL=$(MODEL) AMODEL=$(AMODEL) DIR=..\libs\ ovly$(MODEL) + cd .. + +mkdos20: + cd dos20 + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld$(MODEL) + cd .. + +mkcpm: + cd cpm86 + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld$(MODEL) + cd .. + +mkmath: + cd math + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld$(MODEL) + cd .. + +mkmath87: + cd math + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld87$(MODEL) + cd .. + +mkmch86: + cd mch86 + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld$(MODEL) + cd .. + +mkmisc: + cd misc + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld$(MODEL) + cd .. + +mathmisc: + cd misc + make MODEL=$(MODEL) AMODEL=$(AMODEL) math + cd .. + +mkstdio: + cd stdio + make MODEL=$(MODEL) AMODEL=$(AMODEL) bld$(MODEL) + cd .. + +mathstdio: + cd stdio + make MODEL=$(MODEL) AMODEL=$(AMODEL) math + cd .. + +arc: + mkarcv build.arc fcb); + if (fp->fcb.f_record == 0) { + fp->offset = 0; + return 0; + } + --fp->fcb.f_record; /* backup to last record */ + if (_find(fp)) + return -1; + + for (cp = Wrkbuf+128 ; cp > Wrkbuf ; ) + if (*--cp != 0x1a) { + ++cp; + break; + } + if ((fp->offset = (char)((int)(cp-Wrkbuf))) == 128) { + ++fp->fcb.f_record; + fp->offset = 0; + } + return 0; +} + close.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "errno.h" +#include "io.h" + +close(fd) +{ + register struct channel *chp; + extern int bdf_(); + + if (fd < 0 || fd > MAXCHAN) { + errno = EBADF; + return -1; + } + chp = &chantab[fd]; + fd = (*chp->c_close)(chp->c_arg); + chp->c_read = chp->c_write = chp->c_ioctl = chp->c_seek = 0; + chp->c_close = bdf_; + return fd; +} + croot.c +/* Copyright (C) 1981,1982,1984 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" +#include "io.h" + +int bdf_(), ret_(); + +/* + * channel table: relates fd's to devices + */ +struct channel chantab[] = { + { 2, 0, 1, 0, ret_, (_arg)2 }, + { 0, 2, 1, 0, ret_, (_arg)2 }, + { 0, 2, 1, 0, ret_, (_arg)2 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, + { 0, 0, 0, 0, bdf_, (_arg)0 }, +}; + +#define MAXARGS 30 +static char *Argv[MAXARGS]; +static char Argbuf[128]; +static int Argc; +int (*cls_)() = ret_; + +Croot() +{ + register char *cp, *fname; + register int k; + + movmem((char *)0x81, Argbuf, 127); + Argbuf[*(char *)0x80 & 0x7f] = 0; + Argv[0] = ""; + cp = Argbuf; + Argc = 1; + while (Argc < MAXARGS) { + while (*cp == ' ' || *cp == '\t') + ++cp; + if (*cp == 0) + break; +#ifndef NOREDIR + if (*cp == '>') { /* redirect output */ + k = 1; + goto redirect; + } else if (*cp == '<') { /* redirect input */ + k = 0; +redirect: + while (*++cp == ' ' || *cp == '\t') + ; + fname = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + close(k); + if (k) + k = creat(fname, 0666); + else + k = open(fname, O_RDONLY); + if (k == -1) { + strcpy(0x80, "Can't open file for redirection: "); + strcat(0x80, fname); + strcat(0x80, "$"); + bdos(9,0x80); + exit(10); + } + } else +#endif + { + Argv[Argc++] = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + } + } + main(Argc,Argv); + exit(0); +} + +exit(code) +{ + register int fd; + + (*cls_)(); + for (fd = 0 ; fd < MAXCHAN ; ) + close(fd++); + if (code && (bdos(24)&1) != 0) + unlink("A:$$$.SUB"); + _exit(); +} + +bdf_() +{ + errno = EBADF; + return -1; +} + +ret_() +{ + return 0; +} + + csread.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +extern int errno; +extern unsigned _dsval, _csval; + +_csread(fd, buffer, len) +char *buffer; +{ + register unsigned l = 0; + register struct fcbtab *fp; + register struct channel *chp; + unsigned k,j; + + chp = &chantab[fd]; + if (chp->c_read != 1) { /* only valid for disk files */ + errno = EINVAL; + return -1; + } + + fp = (struct fcbtab *)chp->c_arg; + setusr(fp->user); + + if (fp->offset) { + if ((l = 128 - fp->offset) > len) + l = len; + if (getsect(fp, buffer, l)) { + l = 0; + goto done; + } + } + if (k = (len-l)/128) { + bdos(51, _csval); /* set dma segment to CS */ + j = blkrd(&fp->fcb, buffer+l, k); + bdos(51, _dsval); /* set dma segment back to DS */ + if (j != 0) { + l += (k-j)*128; + goto done; + } + } + l += k*128; + if (l < len) + if (getsect(fp, buffer+l, len-l)) + goto done; + l = len; + +done: + rstusr(); + return l; +} + +static +getsect(fp, buf, len) +register struct fcbtab *fp; char *buf; unsigned len; +{ + if (_find(fp)) + return -1; + movblock(Wrkbuf+fp->offset,_dsval, buf,_csval, len); + if ((fp->offset = (fp->offset + len) & 127) == 0) + ++fp->fcb.f_record; + return 0; +} + + exec.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execlp(path, args) +char *path, *args; +{ + return execvp(path, &args); +} + +execvp(path, argv) +char *path, **argv; +{ + char buffer[130]; + register char *cp, *xp; + + cp = buffer; + for (xp = path ; *xp && cp < buffer+128 ; ) + *cp++ = *xp++; + if (*argv) { + ++argv; /* skip arg0, used for unix (tm) compatibility */ + while (*argv) { + *cp++ = ' '; + for (xp = *argv++ ; *xp && cp < buffer+128 ; ) + *cp++ = *xp++; + } + } + *cp = 0; + bdos(26, buffer); + bdos(47, 0); +} + + execl.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execl(path, args) +char *path, *args; +{ + return execvp(path, &args); +} + +execv(path, argv) +char *path, **argv; +{ + return execvp(path, argv); +} + fcbinit.asm +; :ts=8 +; Copyright (C) 1983, 1984 by Manx Software Systems +codeseg segment para public 'code' +; + include lmacros.h + public fcbinit_ +fcbinit_ proc near + mov bx,sp + push di + push si + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + mov si,word ptr 2[bx] ;si contains name + mov di,word ptr 4[bx] ;di contains fcb address +; clear name to blanks + mov dx,di ;save fcb address in dx + inc di + mov cx,11 ;clear name and ext to blanks + mov al,' ' +rep stosb + mov cx,4 + sub al,al +rep stosb + mov di,dx ;restore fcb address +; + sub dx,dx ;init user # + mov cl,10 ;multiplier inside loop +userloop: ;loop packing leading digits into DL + lodsb + cmp al,'0' + jb userdone + cmp al,'9' + ja userdone + sub al,'0' + xchg ax,dx ;get accumlated value into AL for multiply + mul cl ;value *= 10 + add al,dl ;add in new digit + xchg ax,dx ;put result back into DL + jmp userloop +; +userdone: + cmp al,'/' ;check if user # prefix + je haveuser + mov dl,255 ;set user # to default indicator + mov si,word ptr 2[bx] ;reset filename pointer +haveuser: +; + sub al,al ;default drive # + cmp byte ptr 1[si],':' + jnz setdrive +; + lodsb + inc si ;skip over colon + and al,127 + cmp al,'A' + jl badname + cmp al,'Z' + jg lowerc + sub al,'A'-1 + jmp short setdrive +; +lowerc: + cmp al,'a' + jl badname + cmp al,'z' + jg badname + sub al,'a'-1 +setdrive: + stosb +; move name in mapping to upper case + mov cx,8 +nameskp: + inc cx +namelp: + lodsb + cmp al,'.' + jz namedn + test al,al + jz alldone + loop store + jmp short nameskp +store: + call toupper + stosb + jmp short namelp +; +namedn: + dec cx + add di,cx +; move extension mapping to upper case + mov cx,3 +extlp: + lodsb + test al,al + jz alldone + call toupper + stosb + loop extlp +; +alldone: + xchg ax,dx + and ax,255 +retn: + pop si + pop di + ret +; +badname: + sub ax,ax + dec ax + jmp short retn +; +toupper: + cmp al,'*' + jne nostar + dec si ;backup so we see star again + mov al,'?' ;and map into question mark + ret +nostar: + cmp al,'a' + jl notrans + cmp al,'z' + jg notrans + sub al,'a'-'A' +notrans: + ret +fcbinit_ endp +codeseg ends + end + find.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "io.h" + +static struct fcbtab *Wfp; +static unsigned Wsct; + +_zap() /* invalidate work buffer */ +{ + Wfp = 0; +} + +_find(fp) +register struct fcbtab *fp; +{ + extern int errno; + + bdos(SETDMA, Wrkbuf); + if (Wfp != fp || fp->fcb.f_record != Wsct) { + if ((errno = bdos(READRN, &fp->fcb)) == 1 || errno == 4) { + errno = 0; + setmem(Wrkbuf, 128, 0x1a); + Wfp = 0; + return 1; + } else if (errno) + return -1; + Wfp = fp; + Wsct = fp->fcb.f_record; + } + return 0; +} + + ioctl.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" +#include "sgtty.h" + +#define TIME 10 /* number of iterations of raw_rd loop */ +#define MIN 1 /* minimum number of chars returned from read */ + +extern int (*Rd_tab[])(); +extern int (*Wrt_tab[])(); + +struct sgttyb Tty_ctl; +extern char _Eol; +extern int tty_rd(); +static int raw_rd(), raw_wr(); +static int rd_func, wrt_func; + +ioctl(fd, cmd, arg) +struct sgttyb *arg; +{ + register struct channel *chp; + + chp = &chantab[fd]; + if (chp->c_ioctl == 0) { + errno = ENOTTY; + return -1; + } + switch (cmd) { + case TIOCGETP: + *arg = Tty_ctl; + break; + case TIOCSETP: + Tty_ctl = *arg; + Wrt_tab[2] = raw_wr; + Rd_tab[2] = raw_rd; + if (Tty_ctl.sg_flags&RAW) { + rd_func = + wrt_func = 6; + _Eol = '\r'; + break; + } else if (Tty_ctl.sg_flags&CBREAK) { + rd_func = (Tty_ctl.sg_flags&ECHO) ? 1 : 6; + wrt_func = 2; + } else { + Rd_tab[2] = tty_rd; + wrt_func = 2; + } + if (Tty_ctl.sg_flags&CRMOD) + _Eol = '\n'; + else + _Eol = '\r'; + } + return 0; +} + +raw_rd(x, buff, len) +register char *buff; +{ + int c, i; + register int count; + + for (count = 0 ; count < len ; ) { + for (i = TIME ; i-- ; ) + if ((c = bdos(rd_func,0xff)) != 0) + goto have_char; + if (count < MIN) + continue; + break; +have_char: + if (c == '\r') + c = _Eol; + *buff++ = c; + ++count; + } + return count; +} + +raw_wr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) { + if (*buff == '\n' && (Tty_ctl.sg_flags&CRMOD)) + bdos(wrt_func,'\r'); + bdos(wrt_func,*buff++); + } + return len; +} + isatty.c +/* Copyright (C) 1983 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +isatty(fd) +{ + return chantab[fd].c_ioctl; +} + + lseek.c +/* Copyright (C) 1982, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +long lseek(fd, pos, how) +long pos; +{ + register struct fcbtab *fp; + + if (chantab[fd].c_seek == 0) { +Badf: + errno = EBADF; + return -1L; + } + fp = (struct fcbtab *)chantab[fd].c_arg; + + switch (how) { + case 2: + /* + * Close the file because CP/M doesn't know how big an open file is. + * However, the fcb is still valid. + */ + setusr(fp->user); + fp->fcb.f_name[4] |= 0x80; /* set parital close flag for MP/M */ + bdos(CLSFIL, &fp->fcb); + fp->fcb.f_name[4] &= 0x7f; /* clear parital close flag */ + _Ceof(fp); + rstusr(); + case 1: + pos += fp->offset + ((long)fp->fcb.f_record << 7); + case 0: + break; + + default: + errno = EINVAL; + return -1L; + } + + fp->fcb.f_overfl = 0; + if (pos < 0) { + fp->offset = fp->fcb.f_record = 0; + errno = EINVAL; + return -1L; + } + fp->offset = (unsigned)pos & 127; + fp->fcb.f_record = pos >> 7; + return pos; +} + + open.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" +#include "io.h" + +#define MAXFILE 8 /* maximum number of open DISK files */ +int bdf_(), ret_(), fileop(); +/* + * note: The ioctl function knows that the condev read/write numbers are + * 2. It uses this information to patch the read/write tables. + */ +static struct device condev = { 2, 2, 1, 0, ret_ }; +static struct device bdosout= { 0, 3, 0, 0, ret_ }; +static struct device bdosin = { 3, 0, 0, 0, ret_ }; +static struct device filedev= { 1, 1, 0, 1, fileop }; + +/* + * device table, contains names and pointers to device entries + */ +static struct devtabl devtabl[] = { + { "con:", &condev, (_arg)2 }, + { "CON:", &condev, (_arg)2 }, + { "lst:", &bdosout,(_arg)5 }, + { "LST:", &bdosout,(_arg)5 }, + { "prn:", &bdosout,(_arg)5 }, + { "PRN:", &bdosout,(_arg)5 }, + { "pun:", &bdosout,(_arg)4 }, + { "PUN:", &bdosout,(_arg)4 }, + { "rdr:", &bdosin, (_arg)3 }, + { "RDR:", &bdosin, (_arg)3 }, + { 0, &filedev, (_arg)0 } /* this must be the last slot in the table! */ +}; + + +creat(name, mode) +char *name; +{ + return open(name, O_WRONLY|O_TRUNC|O_CREAT, mode); +} + +open(name, flag, mode) +char *name; +{ + register struct devtabl *dp; + register struct channel *chp; + register struct device *dev; + int fd, mdmask; + + for (chp = chantab, fd = 0 ; fd < MAXCHAN ; ++chp, ++fd) + if (chp->c_close == bdf_) + goto fndchan; + errno = EMFILE; + return -1; + +fndchan: + for (dp = devtabl ; dp->d_name ; ++dp) + if (strcmp(dp->d_name, name) == 0) + break; + dev = dp->d_dev; + mdmask = (flag&3) + 1; + if (mdmask&1) { + if ((chp->c_read = dev->d_read) == 0) { + errno = EACCES; + return -1; + } + } + if (mdmask&2) { + if ((chp->c_write = dev->d_write) == 0) { + errno = EACCES; + return -1; + } + } + chp->c_arg = dp->d_arg; + chp->c_ioctl = dev->d_ioctl; + chp->c_seek = dev->d_seek; + chp->c_close = ret_; + if ((*dev->d_open)(name, flag, mode, chp, dp) < 0) { + chp->c_close = bdf_; + return -1; + } + return fd; +} + +static struct fcbtab fcbtab[MAXFILE]; + +static +fileop(name,flag,mode,chp,dp) +char *name; struct channel *chp; struct devtabl *dp; +{ + register struct fcbtab *fp; + int filecl(); + int user; + + for ( fp = fcbtab ; fp < fcbtab+MAXFILE ; ++fp ) + if ( fp->flags == 0 ) + goto havefcb; + errno = EMFILE; + return -1; + +havefcb: + if ((user = fcbinit(name,&fp->fcb)) == -1) { + errno = EINVAL; + return -1; + } + if (user == 255) + user = getusr(); + setusr(user); + if (flag & O_TRUNC) + bdos(DELFIL, &fp->fcb); + if (bdos(OPNFIL,&fp->fcb) == 0xff) { + if ((flag&(O_TRUNC|O_CREAT)) == 0 || bdos(MAKFIL,&fp->fcb) == 0xff) { + errno = ENOENT; + rstusr(); + return -1; + } + } else if ((flag&(O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) { + errno = EEXIST; + goto punt; + } else if ((flag&3) > 0 && fp->fcb.f_type[0]&0x80) { + errno = EACCES; +punt: + bdos(CLSFIL, &fp->fcb); + rstusr(); + return -1; + } + + fp->offset = fp->fcb.f_overfl = fp->fcb.f_record = 0; + fp->user = user; + chp->c_arg = (_arg)fp; + fp->flags = (flag&3)+1; + chp->c_close = filecl; + if (flag&O_APPEND) + _Ceof(fp); + rstusr(); + return 0; +} + +static +filecl(fp) +register struct fcbtab *fp; +{ + _zap(); /* zap work buffer, so data is not reused */ + setusr(fp->user); + bdos(CLSFIL,&fp->fcb); + rstusr(); + fp->flags = 0; + return 0; +} + + read.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" +#include "fcntl.h" + +int bdf_(), filerd(), tty_rd(), bdosrd(); + +int (*Rd_tab[])() = { + bdf_, filerd, tty_rd, bdosrd, +}; +extern int errno; + +read(fd, buff, len) +char *buff; +{ + register struct channel *chp; + + chp = &chantab[fd]; + return (*Rd_tab[chp->c_read])((struct fcbtab *)chp->c_arg, buff, len); +} + +static +filerd(afp,buffer,len) +struct fcbtab *afp; +char *buffer; unsigned len; +{ + register unsigned l = 0; + register struct fcbtab *fp; + unsigned k,j; + + fp = afp; + setusr(fp->user); + if (fp->offset) { + if ((l = 128 - fp->offset) > len) + l = len; + if (getsect(fp, buffer, l)) { + rstusr(); + return 0; + } + } + if (k = (len-l)/128) + if ((j = blkrd(&fp->fcb, buffer+l, k)) != 0) { + rstusr(); + return (k-j)*128 + l; + } + l += k*128; + if (l < len) + if (getsect(fp, buffer+l, len-l)) { + rstusr(); + return l; + } + rstusr(); + return len; +} + +static +getsect(fp, buf, len) +register struct fcbtab *fp; char *buf; unsigned len; +{ + if (_find(fp)) + return -1; + movmem(Wrkbuf+fp->offset, buf, len); + if ((fp->offset = (fp->offset + len) & 127) == 0) + ++fp->fcb.f_record; + return 0; +} + +char _Eol = '\n'; + +tty_rd(x,buff,len) +char *buff; +{ + static char buffer[258]; + static int used; + register int l; + + if (buffer[1] == 0) { + buffer[0] = 255; + buffer[1] = buffer[2] = 0; + bdos(10,buffer); + bdos(2,'\n'); + if (buffer[2] == 0x1a) { + buffer[1] = 0; + return 0; + } + buffer[++buffer[1] + 1] = _Eol; + used = 2; + } + if ((l = buffer[1]) > len) + l = len; + movmem(buffer+used, buff, l); + used += l; + buffer[1] -= l; + return l; +} + +static +bdosrd(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = 0 ; count < len ; ++count) { + if ((*buff++ = bdos(kind)) == 0x1a) + break; + } + return count; +} + rename.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "errno.h" + +rename(old, new) +char *old, *new; +{ + auto char buff[60]; + register int user; + + user = fcbinit(old,buff); + fcbinit(new,buff+16); + setusr(user); + user = 0; + if (bdos(15,buff+16) != 0xff) { + bdos(16,buff+16); + errno = EEXIST; + user = -1; + } else if (bdos(23,buff) == 0xff) { + errno = ENOENT; + user = -1; + } + rstusr(); + return user; +} + sbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn errno_:word +stkred dw 512 +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + mov ax,siz + mov di,$MEMRY + add ax,di + push ax + call brk_ + pop cx + jnz brk_error + mov ax,di ;return original value of the break +ifdef LONGPTR + mov dx,ds + pop di + pret +endif +brk_error: + pop di +ifdef LONGPTR + mov dx,ax +endif + test ax,ax ;set flags for C + pret + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<> + mov ax,addr + inc ax + and al,-2 + mov bx,sp + sub bx,stkred + cmp ax,bx ;double check with sp for saftey + jae brk_ov + cmp ax,_mbot_ + jb brk_ov + mov $MEMRY,ax ;new value is good so save it away + add ax,stkred + mov _sbot_,ax + sub ax,ax + pret +; invalid request +brk_ov: + mov errno_,-4 + mov ax,-1 + test ax,ax + pret + pend brk +; +; rsvstk(size): set saftey margin for stack +; this will make sure that at least size +; bytes of stack below the current level remain. +; + procdef rsvstk,<> + mov ax,stksize + mov stkred,ax + add ax,$MEMRY + mov _sbot_,ax + pret + pend rsvstk + finish + end + stkover.c +_stkover() +{ + bdos(9, "STACK OVERFLOW, INCREASE STACK SIZE\r\n$"); + _exit(200); +} + unlink.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "errno.h" + +unlink(name) +char *name; +{ + auto char delfcb[40]; + register int user; + + user = fcbinit(name,delfcb); + setusr(user); + user = bdos(19,delfcb); + rstusr(); + if (user == 0xff) { + errno = ENOENT; + return -1; + } + return 0; +} + + user.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + +codeseg segment para public 'code' +dataseg segment para public 'data' +olduser db 0 +dataseg ends + assume cs:codeseg,ds:dataseg + public getusr_ +getusr_ proc near + push bp + push si + push di + mov cl,32 + mov dl,255 + int 224 + and ax,255 + pop di + pop si + pop bp + ret +getusr_ endp +; + public setusr_ +setusr_ proc near + push bp + mov bp,sp + push si + push di + mov cl,32 + mov dl,255 + int 224 + mov olduser,al +; + mov dl,4[bp] + cmp dl,255 + je skipset + mov cl,32 + int 224 +skipset: + pop di + pop si + pop bp + ret +setusr_ endp +; + public rstusr_ +rstusr_ proc near + push bp + push si + push di + mov cl,32 + mov dl,olduser + int 224 + pop di + pop si + pop bp + ret +rstusr_ endp +codeseg ends + end + write.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "io.h" +#include "errno.h" + +int tty_wr(), bdoswr(), filewr(), bdf_(); + +int (*Wrt_tab[])() = { + bdf_, filewr, bdoswr, bdoswr +}; + +write(fd, buff, len) +char *buff; +{ + register struct channel *chp; + + chp = &chantab[fd]; + return (*Wrt_tab[chp->c_write])((struct fcbtab *)chp->c_arg, buff, len); +} + +static +filewr(afp,buffer,len) +struct fcbtab *afp; +char *buffer; unsigned len; +{ + register unsigned l = 0; + register struct fcbtab *fp; + unsigned k,j; + + fp = afp; + setusr(fp->user); + if (fp->offset) { + if ((l = 128 - fp->offset) > len) + l = len; + if (putsect(fp, buffer, l)) { + rstusr(); + return -1; + } + } + if (k = (len-l)/128) + if ((j = blkwr(&fp->fcb, buffer+l, k)) != 0) { + rstusr(); + if ((l += (k-j)*128) == 0) + return -1; + else + return l; + } + l += k*128; + if (l < len) + if (putsect(fp, buffer+l, len-l)) { + rstusr(); + return l; + } + rstusr(); + return len; +} + +static +putsect(fp, buf, len) +register struct fcbtab *fp; char *buf; unsigned len; +{ + if (_find(fp) < 0) + return -1; + movmem(buf, Wrkbuf+fp->offset, len); + if ((errno = bdos(WRITRN, &fp->fcb)) != 0) + return -1; + if ((fp->offset = (fp->offset + len) & 127) == 0) + ++fp->fcb.f_record; + return 0; +} + +tty_wr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) { + if (*buff == '\n') + bdos(2,'\r'); + bdos(2,*buff++); + } + return len; +} + +static +bdoswr(kind, buff, len) +register char *buff; +{ + register int count; + + for (count = len ; count-- ; ) + bdos(kind,*buff++); + return len; +} + + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/DBG-README.txt b/Manx Aztec C86 v42b/ARC/DBG-README.txt new file mode 100644 index 0000000..1e4630c --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/DBG-README.txt @@ -0,0 +1,13 @@ + +August 24, 1987 + +The DBGMAP program converts an Aztec .DBG file to an Microsoft .MAP file. +It currently converts global data and source line data. The usage is: + + dbgmap filename + +Let me know if there are any questions. + +Paul McClintock +Computer Dymamics +(803) 877-8700 diff --git a/Manx Aztec C86 v42b/ARC/DBGMAP.C b/Manx Aztec C86 v42b/ARC/DBGMAP.C new file mode 100644 index 0000000..9744804 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/DBGMAP.C @@ -0,0 +1,668 @@ +/******************************************** + + dbgmap - conversion utily for + Aztec C + + This utility converts an Aztec C + symbol table file (.DBG) into a + RDSD compatible symbol file (.MAP). + + Paul McClintock April 21, 1987 + + Last Edit April 21, 1987 + + (c) Lines Unlimited April 1987 + +*******************************************/ + + +/****************************************** + +The following definition of the Aztec .DBG +file is the results of a phone coversation with +Tom Ferwick of Aztec. The .DBG file is a +complex binary symbol file containing substancially +more data then the Microsoft .MAP file is able +to contain. + +The .DBG file format is based on 64 byte records. +Each record type has a unique structure. + + + +HEADER RECORD : + type_def dw 13678 ; 0356Eh + num_struct dw ; number of structure records + start_struct dw ; starting record # for struct + + num_strings dw ; total # of strings + total_string_lnth dw ; total string table length + start_string dw ; starting record for strings + + num_src_line_rec dw ; number of src line records + num_block_rec dw ; number of block records + num_sym_rec dw ; number of symbol records + + ; offsets into symbol data + s_abs_symbol dw ; 1st aboslute symbol + s_code_symbol dw ; 1st code symbol + s_data_symbol dw ; 1st data symbol + + +SYMBOL RECORD : + type_def dw 15431 ; 03C47h + + name_idx dw ; name string subscript + type_idx dw ; type string subscript + struct_idx dw ; index into struct table + add_offset dw ; + add_segment dw ; also used as a flag word + + -2 = Auto variable BP.[add_offset] + -3 = Register variable + add_offset == 5 for SI + add_offset == 6 for DI + -4 = argument BP.[add_offset] + -5 = argument, Register variable + -6 = TYPE DEF name + + + + + Type Strings Modifers + * = 16 Bit Pointer + # = 32 Bit Pointer + [size = size of array + ( = Near Function + { = Far Function + + + Base Type Characters + c = char + C = unsigned char + i = int + I = unsigned int + l = long + L = unsigned int + f = float + D = double + V = void + : = struct + + + +SOURCE LINE RECORD : + type_def dw 12345 ; 3039h + + add_offset dw ; starting address offset + add_segment dw ; starting address segment + file_name dw ; file name string subscript + line_number dw ; starting source line number + object_displacement db ; obj code displacement / line + + Special flag bit + 0FFH == end of obj offsets array + 00h to 07Fh == 8 bit object code displacement + 080h to 0FEh == 15 bit object code displacement + + + + +SYMBOL SCOPE DEF RECORD : + type_def dw 15432 ; 03C48h (BLOCK) + + Unknown record format + + + + + +STRUCT DEF RECORD : + ; no type_def + ; + name_idx dw ; name string subscript + type_idx dw ; type string subscript + struct_idx dw ; index into struct table + add_segment dw ; also used as a flag word + + + +*******************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include + + +/* .DBG Header record */ + +struct HEADER +{ + unsigned int type_def, /* 13678 */ + num_struct, /* nuber of struct records */ + start_struct, /* starting record for struct */ + + num_strings, /* total num of strings */ + tot_str_lnth, /* total strings length */ + start_string, /* starting record for string */ + + num_src_rec, /* total src records */ + num_block_rec, /* total block records */ + num_sym_rec, /* total symbol records */ + + s_abs_sym, /* starting abs symbol */ + s_code_sym, /* starting code symbol */ + s_data_sym; /* starting data symbol */ + + unsigned int fill[20]; /* total size of 64 bytes */ + +}; + + +/* Public Symbols */ + +struct SYMBOL +{ + unsigned int name_idx, /* symbol name index */ + type_idx, /* symbol type index */ + struct_idx, /* index into struct table */ + add_offset, /* address offset value */ + add_segment; /* address segment value */ +}; + +struct SYM_RECORD +{ + unsigned int type_def; /* 15431 */ + struct SYMBOL sym_data[6]; + unsigned int fill[1]; /* total size of 64 bytes */ +}; + + +/* Internal Format */ + +struct SYM_DATA +{ + struct SYM_DATA *next; /* linked list */ + + unsigned int name_idx, /* symbol name index */ + type_idx, /* symbol type index */ + add_offset, /* address offset value */ + add_segment, /* address segment value */ + struct_idx; /* index into struct table */ +}; + + + + +#define RECORDSIZE 64 +#define LINEENTRY (RECORDSIZE - 5*sizeof(short)) + + +/* Source Line numbers */ + +struct SRC_RECORD +{ + unsigned short type_def, /* 12345 */ + add_offset, /* address offset value */ + add_segment, /* address segment value */ + file_idx, /* function's src file index */ + line_num; /* starting line number */ + + unsigned char obj_displ[LINEENTRY]; /* object code displacement */ + +}; + + + +/* internal format */ +struct SRC_DATA +{ + struct SRC_DATA *next; /* linked list */ + + unsigned int file_idx, /* src file index */ + line_num, /* specified line number */ + add_offset, + add_segment; +}; + + + +/* Global DATA */ + +struct HEADER dbg_header; + +struct SYM_DATA *sym_list = NULL; /* header for linked list */ +int sym_count = 0; /* number of entries */ +unsigned short max_symbol ; /* max valid symbol index */ + +struct SRC_DATA *src_list = NULL; /* header for linked list */ +int src_count = 0; /* number of entries */ + +char **str_idx, *str_buff; /* string buffer pointers */ +char *dbg_file, *map_file; /* file paths */ + +char *filename() ; + + + + +main (argc, argv) +int argc; /* number of paramiters */ +char **argv; /* array of paramiters */ +{ + int count ; /* loop counter */ + unsigned int *buff ; /* input buffer */ + + int dbg ; /* input file handle */ + int error ; /* file operations return value */ + + FILE *map ; /* output map file */ + + + printf("\nAztec .DBG to Microsoft compatible .MAP symbol file converter"); + printf("\n(c) Lines Unlimited 8-24-87 \n"); + + if (argc != 2) + { + printf("\n\nusage: dbgmap filename"); + exit(1); + } + + ++argv; /* skip command name */ + dbg_file = filename( *argv, ".dbg"); + map_file = filename( *argv, ".map"); + + dbg = open( dbg_file, O_RDONLY | O_BINARY); + if (dbg == -1) + err_abort(dbg_file); /* abort on error */ + + /* Read header record */ + error = read( dbg, &dbg_header, sizeof(struct HEADER) ); + if (error == -1) + err_abort(dbg_file); /* abort on read error */ + + buff = (int *) malloc(64); /* block buffer */ + if (buff == NULL) + err_abort("buff - out of memory "); + + max_symbol = 0xffff ; /* initialize */ + + + /* build data structures from the .DBG file */ + + for (count = dbg_header.start_struct - 1 ; count ; --count) + { + error = read( dbg, buff, 64); + if (error == -1) + err_abort( dbg_file); + + switch (*buff) /* type_def */ + { + case 15431 : /* SYMBOL RECORD */ + save_symbols( buff); + break; + + case 12345 : /* SOURCE LINE RECORD */ + save_src_line( buff); + break; + + } + + } + + free(buff); + read_strings( dbg); /* read in strings */ + + + /* Time to generate the .MAP file */ + + map = fopen ( map_file, "w"); + if (map == NULL) + err_abort ( map_file); + + + print_symbols ( map); + print_src_data ( map); + + if ( fclose ( map) ) + err_abort( map_file); + + exit (0); + + +} + + +save_symbols ( buff) +struct SYM_RECORD *buff; +{ + int count; + struct SYMBOL *c_symbol; + struct SYM_DATA *tmp; + + + c_symbol = buff->sym_data; + + for (count = 0 ; count < 6 ; ++count, ++c_symbol) + { + if ( c_symbol->name_idx < dbg_header.num_strings ) + { + tmp = (struct SYM_DATA *) malloc(sizeof(struct SYM_DATA) ); + if (tmp == NULL) + err_abort( "save_symbols - out of memory "); + + tmp->name_idx = c_symbol->name_idx; + tmp->type_idx = c_symbol->type_idx; + tmp->add_offset = c_symbol->add_offset; + tmp->add_segment = c_symbol->add_segment; + tmp->struct_idx = c_symbol->struct_idx; + + if ((tmp->type_idx < max_symbol) && (tmp->type_idx != 0 ) ) + max_symbol = tmp->type_idx ; /* type strings follow global + symbols strings */ + + /* add to linked list in memory */ + tmp->next = sym_list; + sym_list = tmp; /* update linked list */ + ++sym_count; + + } + } +} + +print_symbols( map) +FILE *map; /* output file descriptor */ +{ + struct SYM_DATA **idx, **tmp, *cur; + int count, tot_sym ; + int sym_by_name(), sym_by_value(); + + tmp = idx = (struct SYM_DATA **) + malloc( sizeof(struct SYM_DATA) * (sym_count + 1) ) ; + if (idx == NULL) + err_abort("print_symbols - out of memory "); + + + /* generate index for quick sort */ + for ( tot_sym = 0 , cur = sym_list; cur != NULL ; cur = cur->next ) + { + if ( ( cur->add_segment < (unsigned) -6 ) && + (cur->name_idx < max_symbol ) ) + { + *tmp++ = cur ; + ++tot_sym ; + } + } + *tmp = NULL ; + + fprintf ( map, "\n\n Address Publics by Name\n"); + qsort ( idx, tot_sym, sizeof(struct SYM_DATA *), sym_by_name ); + for ( tmp = idx; *tmp ; ++tmp) + { + fprintf( map, "\n %04X:%04X %s", (*tmp)->add_segment, + (*tmp)->add_offset, str_idx[ (*tmp)->name_idx] ); + + } + + + fprintf ( map, "\n\n Address Publics by Value\n"); + qsort ( idx, tot_sym, sizeof(struct SYM_DATA *), sym_by_value ); + for ( tmp = idx; (*tmp) ; ++tmp) + { + fprintf( map, "\n %04x:%04x %s", (*tmp)->add_segment, + (*tmp)->add_offset, str_idx[ (*tmp)->name_idx] ); + + } + + free(idx); /* return to free memory */ +} + + +sym_by_name(a, b) +struct SYM_DATA **a, **b; +{ + return ( strcmp( str_idx[ (*a)->name_idx], str_idx[ (*b)->name_idx]) ); +} + +sym_by_value ( a, b) +struct SYM_DATA **a, **b; +{ + long a_add, b_add, add_to_long() ; + int ret_value; + + a_add = add_to_long( (*a)->add_segment, (*a)->add_offset); + b_add = add_to_long( (*b)->add_segment, (*b)->add_offset); + + (a_add == b_add) ? ( ret_value = 0) : + ((a_add < b_add) ? (ret_value = -1) : (ret_value = 1) ) ; + + return (ret_value); + +} + +long add_to_long ( segment, offset) +unsigned int segment, offset; +{ + long ret_value ; + + ret_value = (long) segment << 4 ; + ret_value += (long) offset ; + + return (ret_value); +} + + + + +save_src_line ( src) +struct SRC_RECORD *src; +{ + unsigned char *obj_offset; + int cnt ; + + + store_src ( src); /* save start of function */ + + /* Process the source lines for this function */ + /* each offset byte represents a source line */ + + for ( obj_offset = src->obj_displ , cnt = 0 ; cnt < LINEENTRY ; + ++obj_offset, ++src->line_num, ++cnt ) + { + if ( *obj_offset) + { + if (*obj_offset == 0xff) + break ; /* end of table */ + + store_src ( src); + + if ( *obj_offset < 0x80 ) + src->add_offset += *obj_offset ; /* additional offset */ + else + { + /* 15 bit object code offset */ + + *obj_offset &= 0x7f ; /* mask off flag bit */ + src->add_offset += ( *obj_offset++ << 8) ;/* high 7 bits */ + src->add_offset += *obj_offset ; /* low 8 bits */ + } + } + } +} + + +store_src ( src) +struct SRC_RECORD *src; +{ + struct SRC_DATA *tmp; + + tmp = (struct SRC_DATA *) malloc( sizeof(struct SRC_DATA)) ; + if (tmp == NULL) + err_abort( "store_src - out of memory "); + + /* copy to memory storage */ + + tmp->add_offset = src->add_offset ; + tmp->add_segment = src->add_segment ; + tmp->line_num = src->line_num ; + tmp->file_idx = src->file_idx ; + + if (tmp->file_idx < max_symbol) + max_symbol = tmp->file_idx; /* global symbols proceed + file names in the string + table */ + + /* add to linked list */ + tmp->next = src_list ; + src_list = tmp ; + ++src_count ; + +} + +print_src_data( map) +FILE *map; +{ + struct SRC_DATA **tmp, **idx, *cur; + int src_data_cmp(); + char *src_file, *obj_file; + int count ; + + /* generate source line data index */ + tmp = idx = (struct SRC_DATA **) + malloc( sizeof(struct SRC_DATA *) * (src_count + 1) ) ; + if (idx == NULL) + err_abort("print_src_data - out of memory "); + + for ( cur = src_list ; cur != NULL ; cur = cur->next) + { + *tmp++ = cur ; + *tmp = NULL ; + } + + qsort( idx, src_count, sizeof(struct SRC_DATA *), src_data_cmp); + + for ( tmp = idx; *tmp != NULL ; ) + { + src_file = str_idx[ (*tmp)->file_idx ] ; + obj_file = filename( src_file, ".obj"); + + fprintf( map,"\n\nLine numbers for %s(%s)\n\n", + obj_file, src_file); + + free( obj_file); /* release free memory */ + + /* print line data for this source module */ + for ( count = 1 ; (*tmp != NULL) && + (strcmp( src_file, str_idx[ (*tmp)->file_idx]) == 0 ) ; + ++tmp ) + { + if (( *(tmp + 1) == NULL) || + ( (*tmp)->add_segment != (*(tmp + 1))->add_segment) || + ( (*tmp)->add_offset != (*(tmp + 1))->add_offset) ) + { + fprintf (map, "%6d %04X:%04X%s", (*tmp)->line_num, + (*tmp)->add_segment, (*tmp)->add_offset, + (count % 4) ? "" : "\n" ); + + ++count; + } + } + + } + + fprintf (map, "\n\n"); + free(idx); +} + +src_data_cmp ( a, b) +struct SRC_DATA **a, **b; +{ + int ret_value; + + ret_value = strcmp( str_idx[ (*a)->file_idx], str_idx[ (*b)->file_idx] ); + + if ( ret_value == 0) + ( (*a)->line_num < (*b)->line_num) ? + ( ret_value = -1) : (ret_value = 1) ; + + return (ret_value); + +} + + +char *filename( path, ext) +char *path, *ext; +{ + char *f_path, *bf; + + f_path = malloc( strlen(path) + 5); /* get buffer space */ + if (f_path == NULL) + err_abort("filename - out of memory "); + + strcpy( f_path, path); + if ((bf = strchr( f_path, '.')) != NULL ) + *bf = '\0'; /* truncate extension */ + + strcat( f_path, ext); /* add the extension */ + + return( f_path); + +} + +read_strings( dbg) +int dbg ; /* input file handle */ +{ + char **idx_ptr; /* string index pointer */ + char *s_ptr; + int count ; + long position ; /* return value for lseek() */ + int error ; /* return value for file operations */ + + /* Read in strings (symbol names ) */ + + position = lseek( dbg, (long) dbg_header.start_string * 64, SEEK_SET); + if (position == -1L) + err_abort( dbg_file); + + s_ptr = str_buff = malloc( dbg_header.tot_str_lnth); /* get string buffer */ + if (str_buff == NULL) + err_abort ("read_strings - out of memory "); + + error = read( dbg, str_buff, dbg_header.tot_str_lnth); + if (error == -1) + err_abort (dbg_file); + + /* string index buffer */ + idx_ptr = str_idx = + (char **) malloc( sizeof(char *) * (dbg_header.num_strings + 2) ); + if (str_idx == NULL) + err_abort ("read_strings - out of memory "); + + *idx_ptr++ = NULL; /* string indexes are base 1 */ + for( count = dbg_header.num_strings ; count ; --count) + { + *idx_ptr++ = s_ptr ; /* current string starting address */ + s_ptr += strlen( s_ptr) + 1 ; /* advance to the next string */ + } + *idx_ptr = NULL; + +} + + +err_abort(msg) +char *msg; +{ + perror(msg); /* display error message */ + exit (1); /* abort */ +} + +/* */ + + diff --git a/Manx Aztec C86 v42b/ARC/DBGMAP.MAK b/Manx Aztec C86 v42b/ARC/DBGMAP.MAK new file mode 100644 index 0000000..37597d1 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/DBGMAP.MAK @@ -0,0 +1,12 @@ +# +# convert a .DBG file to a .MAP file +# Paul McClintock April 22, 1987 +# + +dbgmap.obj : dbgmap.c + msc dbgmap /Od /Zd; + +dbgmap.exe : dbgmap.obj + link dbgmap /line /m; + + diff --git a/Manx Aztec C86 v42b/ARC/DOS20.ARC b/Manx Aztec C86 v42b/ARC/DOS20.ARC new file mode 100644 index 0000000..817d2bc --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/DOS20.ARC @@ -0,0 +1,3922 @@ + makefile +OBJ=access.o asctime.o bdos.o bdosx.o chmod.o clk.o clock.o croot.o csread.o\ + ctime.o dioctl.o dos.o dosdir.o dostime.o dosx.o dup.o exec.o execl.o\ + execlp.o execv.o execvp.o fcbinit.o fexec.o fexecl.o fexecv.o filelock.o\ + ftime.o getcwd.o getenv.o io.o ioctl.o isatty.o localtim.o mkdir.o mon.o\ + monitor.o open.o profil.o sigfix.o sighand.o stat.o stkover.o\ + sys.o syserr.o system.o time.o ttyio.o utime.o wait.o stksiz.o + +CC=cc +AS=as +MODEL= +AMODEL=0 + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +bld bldlc: $(OBJ) sbegin.o ssbrk.o lmalloc.o + @echo dos20 done + +bldld bldl: $(OBJ) lbegin.o lsbrk.o + @echo dos20 done + access.c +#include +#include + +access(path, amode) +char *path; +{ + struct { + char rsvd[21]; + char attr; + long time; + long size; + char name[13]; + } sbuf; + register char *cp; + + _sys(0x1a,&sbuf); + if (_sys(0x4e,path,~ST_VLABEL) == -1) { + if (errno == ENOMORE) + errno = ENOENT; + return -1; + } + if (amode & 02 && sbuf.attr & ST_RDONLY) { + errno = EACCES; + return -1; + } + if (amode & 01) { /* execute or search */ + if ((sbuf.attr & ST_DIRECT) == 0) { + for (cp = sbuf.name ; *cp ;) + if (*cp++ == '.') + break; + if (strcmp(cp,"EXE") != 0 && strcmp(cp,"COM") != 0 + && strcmp(cp,"BAT") != 0) { + errno = EACCES; + return -1; + } + } + } + return 0; +} + + asctime.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include + +char * +asctime(tm) +struct tm *tm; +{ + static char days[7][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + }; + static char months[12][4] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + }; + static char buffer[26]; + + sprintf(buffer, "%s %s %2d %02d:%02d:%02d %4d\n", + days[tm->tm_wday], months[tm->tm_mon], tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year+1900); + return buffer; +} + bdos.asm +;Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef bdos,<,,> + push es + mov ax,func + test ah,ah + jnz valok + xchg ah,al +valok: + mov dx,dxval + mov cx,cxval + int 21H + mov dx,es + pop es + and ax,0ffH + pret + pend bdos + finish + end + bdosx.asm +;Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef bdosx,<,,,> + push es + push ds + mov ax,func + test ah,ah + jnz valok + xchg ah,al +valok: + mov dx,dxval + mov cx,cxval + push dsval + pop ds + int 21H + mov dx,es + pop ds + pop es + and ax,0ffH + pret + pend bdosx + finish + end + chmod.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef chmod, <,> + pushds + mov ax,4301h + ldptr dx,filnam,ds + mov cx,attr + int 21h + popds + jnc retok + mov ds:errno_,ax + mov ax,-1 + pret +retok: + sub ax,ax + pret + pend chmod + finish + end + clk.asm +;:ts=8 +;Copyright (C) 1985 by Manx Software Systems, Inc. +; +; IBM PC Clock Support routines +; + include lmacros.h +; +; divsor for 121 Hz clock is 9861 dec. +; hex value 0x4DE0 will give exactly 60 inters. per second + codemacro killtime + db 0EBH + db 0 + endm + +INTVEC equ 20h ;location of interrupt vector for clock +TIMER equ 40h +CNTRL equ 43h +EXITVEC equ 88h +TIME_LOW equ 61 +TIME_HIGH equ 98 +TIMES equ 6 + +dataseg segment para public 'data' + +reset_ct db TIMES +scale dw 0 +ifdef LONGPTR +buff_add dd 0 +else +buff_add dw 0 +endif +buf_size dw 0 +ifdef FARPROC +ofset dd 0 +else +ofset dw 0 +endif + extrn _mon_off_:word + extrn _speed_:word + extrn _ticks_:word + extrn _PSP_:word + +dataseg ends + +data_add dw ? ;codesegment variable for location of dataseg in 'C' +clk_ipvec dw ? ;memory location of the stored clock int vector's ip +clk_csvec dw ? ;memory location of the stored clock int vector's cs + +;memory location of all the int vectors on how to exit a program +int22_ip dw ? ;memory location of the stored int 22 vector's ip +int22_cs dw ? ;memory location of the stored int 22 vector's cs + +;memory location of all the int vectors in the PSP +PSP_ip dw ? ;memory location of the stored PSP int 22 vector's ip +PSP_cs dw ? ;memory location of the stored PSP int 22 vector's cs + + assume cs:codeseg, ds:dataseg + + procdef _clkinit,<,,,> + push es ;get args. off stack for later use + mov ax,word ptr ibufad + mov word ptr buff_add,ax +ifdef LONGPTR + mov ax,word ptr ibufad+2 + mov word ptr buff_add+2,ax +endif + mov ax,ibufsz + mov buf_size,ax +ifndef FARPROC + mov ax,word ptr iofset + mov ofset,ax +else + push cx + mov cx,4 + mov ax,word ptr iofset + mov dx,word ptr 2+iofset ;convert to physical address + rol dx,cl + mov bx,dx + and dx,0fh + and bx,0fff0h + add ax,bx + adc dx,0 + mov word ptr ofset,ax + mov word ptr ofset+2,dx + pop cx +endif + mov ax,iscl + mov scale,ax + + sub ax,ax + mov es,ax + mov ax, es:[INTVEC] ;save contents of interupt table + mov cs:clk_ipvec, ax + mov ax,es:[INTVEC+2] ;ditto + mov cs:clk_csvec,ax + mov ax, es:[EXITVEC] ;save contents of interupt table + mov cs:int22_ip, ax + mov ax,es:[EXITVEC+2] ;ditto + mov cs:int22_cs,ax + mov es,_PSP_ ;save contents of the PSP + mov ax,es:[0ah] + mov cs:PSP_ip,ax + mov ax,es:[0ch] + mov cs:PSP_cs,ax + cli + xor ax,ax + mov es,ax + mov es:[INTVEC],offset intsr ;insert the address of int. handler + mov es:[INTVEC+2],cs + mov cs:data_add,ds ;mov 'C' dataseg address to var. + mov es:[EXITVEC],offset int_22 ;insert the address of int. handler + mov es:[EXITVEC+2],cs + mov es,_PSP_ + mov es:[0ah], offset int_22 ;move handler into PSP + mov es:[0ch], cs + sti + xor ax,ax + mov al,36h ;use mode 3 for timer 0 + cli + out CNTRL,al + killtime + mov ax,word ptr _speed_ + out TIMER,al ; + killtime + mov al,ah + out TIMER,al + killtime + sti + sub ax,ax + mov _speed_,ax + pop es + pret + pend _clkinit + + + procdef _clkrest + push es + sub ax,ax + + cli + mov al,36h ;use mode 3 for timer 0 + out CNTRL,al + killtime + mov al,0h ;load low byte + out TIMER,al ;restore to 18.2 intrs. per second + killtime + out TIMER,al + + sub ax,ax + mov es,ax + mov ax, cs:clk_ipvec ;restore interupt vec. table + mov es:[INTVEC], ax + mov ax, cs:clk_csvec ;restore interupt vec. table + mov es:[INTVEC+2],ax + mov ax, cs:int22_ip ;restore interupt vec. table + mov es:[EXITVEC], ax + mov ax, cs:int22_cs ;restore interupt vec. table + mov es:[EXITVEC+2],ax + mov es,_PSP_ ;restore the PSP + mov ax,cs:PSP_ip + mov es:[0ah],ax + mov ax,cs:PSP_cs + mov es:[0ch],ax + + sti + pop es + pret + pend _clkrest + +int_22: + sti + push ax + push dx + push es + push ds + call _clkrest_ + pop ds + pop es + pop dx + mov al,020h ;send EOI to 8259 + out 020h,al + pop ax + jmp dword ptr cs:int22_ip + +intsr: + sti + push bp + mov bp,sp + push ds + push si + push ax + push bx + push dx + mov ds,cs:data_add + + add word ptr _ticks_,1 ;get total number of interupts + adc word ptr _ticks_+2,0 +ifndef FARPROC + mov ax,word ptr 4[bp] ;get cs value in interrupted code + mov dx,cs + cmp ax,dx ;compare with current cs + jne quit ;if not = punt + mov ax,word ptr 2[bp] ;get ip value in interrupted code + sub ax,ofset ;sub ofset (lowpc) from ip + jb quit ;if negative punt + cmp scale,1 + jz nodiv + xor dx,dx + div scale ;div. by scale factor done in monitor +else + mov ax,ss:word ptr 2[bp] ;get ip value in interrupted code + mov dx,ss:word ptr 4[bp] ;get cs value in interrupted code + rol dx,1 + rol dx,1 + rol dx,1 + rol dx,1 + mov bx,dx + and dx,0fh + and bx,0fff0h + add ax,bx + adc dx,0 ;convert to physical address + sub ax,word ptr ofset + sbb dx,word ptr ofset+2 + jb quit ;if beyond bottom of range,punt + cmp dx,word ptr scale + jge quit ;if divide will overflow,punt + cmp word ptr scale,1 + jz nodiv ;skip divide if index is good as is + div word ptr scale +endif +nodiv: + cmp ax,buf_size ;check to see if out of buff + ja quit ;if out of range punt + shl ax,1 ;shift to get on a word boundary + mov si,ax + ldptr bx,buff_add,ds + add ds:word ptr [bx][si],1 ;else increment word + jnc quit ;check to see if we overflowed a bucket + sub ds:word ptr 0[bx][si],1 +ifdef LONGPTR + mov ds,cs:data_add +endif + call _clkrest_ + sub ax,ax + mov ax,si + mov _mon_off_,ax +quit: +ifdef LONGPTR + mov ds,cs:data_add +endif + dec reset_ct + jz time_out + pop dx + pop bx + pop ax + pop si + pop ds + pop bp + push ax + mov al,020h ;send EOI to 8259 + out 020h,al + pop ax + iret +time_out: + mov reset_ct,TIMES + pop dx + pop bx + pop ax + pop si + pop ds + pop bp + jmp dword ptr cs:clk_ipvec + finish + end + clock.asm +; Copyright (C) 1985, 1986 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment word public 'data' +last dw 0,0 +dataseg ends + assume ds:dataseg + + procdef clock + mov ah,2ch + int 21h ; get time + mov al,100 + mul dh ;get seconds as hundredths into ax + sub dh,dh + add ax,dx ;add in hundredths + mov bx,ax ;save total hundredths + mov al,60 + mul ch ; get hours as mins into ax + sub ch,ch + add ax,cx ; add minutes to converted hours + mov cx,6000 + mul cx ; convert to hundredths of seconds + add ax,bx ; add in seconds+hundredths + adc dx,0 ; axdx now contains value in hunredths + cmp dx,word ptr last+2 + ja valok + jne clktrn + cmp ax,word ptr last + jae valok +clktrn: ; clock turned over since last call + add ax,0d600h + adc dx,083h ; add in 24 hours +valok: + mov word ptr last+2,dx + mov word ptr last,ax + pret + pend clock + finish + end + croot.asm + largecode + name croot_ +codeseg segment para public 'code' +dataseg segment para public 'data' +dataseg ends + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg + extrn $begin:far +;/* Copyright (C) 1981,1982, 1983 by Manx Software Systems */ +;#include "errno.h" +;#include "fcntl.h" +; +;static char **Argv; +;static int Argc; +; +;noper() +;{ +# 8 'croot.c' +^| $3 + public noper_ +noper_ proc far +ifdef $20004 + push bp + mov bp,sp +endif +ifdef $20001 + add sp,$20001 +endif +ifdef $20002 + push di +endif +ifdef $20003 + push si +endif +; return 0; +^ mov ax,00H +$20005: +ifdef $20003 + pop si +endif +ifdef $20002 + pop di +endif +ifdef $20004 + mov sp,bp + pop bp +endif + ret +;} +^noper_ endp +$3: +; +;int (*cls_)() = noper; +dataseg segment word public 'data' + public cls__ +cls__ equ this word + dd noper_ +dataseg ends +;extern char _ioflg[]; +; +;Croot(cp, first) +;register char *cp; +# 16 +^| $5 + public Croot_ +Croot_ proc far +ifdef $20009 + push bp + mov bp,sp +endif +ifdef $20006 + add sp,$20006 +endif +ifdef $20007 + push di +endif +ifdef $20008 + push si +endif +;{ +; register char **cpp; +; char *sbrk(); +;#ifdef REDIR +; +; _ioflg[0] = isatty(0); /* set flag for i/o routines */ +~ cpp -4 "##c" +~~ cp 6 "#c" +~~ first 10 "i" +^^^^^^^^^ mov ax,00H + push ax + call far ptr isatty_ + pop cx + mov byte ptr _ioflg_,al +; _ioflg[1] = isatty(1); /* set flag for i/o routines */ +^ mov ax,01H + push ax + call far ptr isatty_ + pop cx + mov byte ptr _ioflg_+1,al +; _ioflg[2] = isatty(2); /* set flag for i/o routines */ +^ mov ax,02H + push ax + call far ptr isatty_ + pop cx + mov byte ptr _ioflg_+2,al +; +; Argv = (char **)sbrk((first+1)*sizeof(char *)); +^^ mov ax,word ptr 10[bp] + shl ax,1 + shl ax,1 + add ax,04H + push ax + call far ptr sbrk_ + pop cx + mov word ptr Argv_+2,dx + mov word ptr Argv_,ax +; Argv[0] = ""; +^ mov ax, offset $20000+0 + mov dx,ds + les bx, dword ptr Argv_ + mov es:word ptr 2[bx],dx + mov es:word ptr [bx],ax +; cpp = &Argv[Argc = first]; +^ mov cx,word ptr 10[bp] + mov word ptr Argc_,cx + shl cx,1 + shl cx,1 + mov ax, word ptr Argv_ + mov dx, word ptr Argv_+2 + add ax,cx + + mov word ptr -2[bp],dx + mov word ptr -4[bp],ax +; for (;;) { +^$8: +; while (*cp == ' ' || *cp == '\t') +^$9: + les bx,dword ptr 6[bp] + cmp es:byte ptr [bx],020H + beq $20010 + cmp es:byte ptr [bx],09H + bne $10 +$20010: +; ++cp; +^ inc word ptr 6[bp] + jmp $9 +$10: +; if (*cp == 0) +^; break; + les bx,dword ptr 6[bp] + cmp es:byte ptr [bx],0 + beq $7 +;#ifdef REDIR +; { +^^^^^^^^^^^^^^^^^^^^^ +^^^^^; *cpp++ = cp; +^ mov ax,word ptr 6[bp] + mov dx,word ptr 8[bp] + les bx,dword ptr -4[bp] + mov es:word ptr 2[bx],dx + mov es:word ptr [bx],ax + add word ptr -4[bp],4 +; Argc++; +^ inc word ptr Argc_ +; if (sbrk(sizeof(char *)) == (char *)-1) { +^ mov ax,04H + push ax + call far ptr sbrk_ + pop cx + cmp dx,0ffffH + jne $20011 + cmp ax,0ffffH +$20011: + bne $11 +; write(2, "Too many args.", 14); +^ mov ax,0eH + push ax + push ds + mov ax, offset $20000+1 + push ax + mov ax,02H + push ax + call far ptr write_ + add sp,8 +; _exit(200); +^ mov ax,0c8H + push ax + call far ptr _exit_ + pop cx +; } +^; while (*++cp) +$11: +^$12: + inc word ptr 6[bp] + les bx,dword ptr 6[bp] + cmp es:byte ptr [bx],0 + beq $13 +; if (*cp == ' ' || *cp == '\t') { +^ mov al,es:byte ptr [bx] + cmp al,020H + beq $20012 + cmp al,09H + bne $14 +$20012: +; *cp++ = 0; +^ mov es:byte ptr [bx],00H + inc word ptr 6[bp] +; break; +^ jmp $13 +; } +^; } +$14: + jmp $12 +$13: +^; } +^$6: + jmp $8 +$7: +; *cpp = 0; +^ les bx,dword ptr -4[bp] + mov es:word ptr 2[bx],00H + mov es:word ptr [bx],00H +; main(Argc,Argv); +^ push word ptr Argv_+2 + push word ptr Argv_ + push word ptr Argc_ + call far ptr main_ + add sp,6 +; exit(0); +^ mov ax,00H + push ax + call far ptr exit_ + pop cx +;} +^$20013: +ifdef $20008 + pop si +endif +ifdef $20007 + pop di +endif +ifdef $20009 + mov sp,bp + pop bp +endif + ret +$20006 = -4 +$20009 equ 1 +Croot_ endp +$5: +dataseg segment word public 'data' +$20000 db 0,84,111,111,32,109 + db 97,110,121,32,97,114 + db 103,115,46,0 +dataseg ends +; +;#ifdef REDIR +; +;exit(code) +;{ +# 95 +^| $16 + public exit_ +exit_ proc far +ifdef $20018 + push bp + mov bp,sp +endif +ifdef $20015 + add sp,$20015 +endif +ifdef $20016 + push di +endif +ifdef $20017 + push si +endif +; (*cls_)(); +~~ code 6 "i" +^ call dword ptr cls__ +; _exit(code); +^ push word ptr 6[bp] + call far ptr _exit_ + pop cx +;} +^$20019: +ifdef $20017 + pop si +endif +ifdef $20016 + pop di +endif +ifdef $20018 + mov sp,bp + pop bp +endif + ret +$20018 equ 1 +exit_ endp +$16: +; +| +~ exit_ . "{i" +~ main_ . "{i" +~ _exit_ . "{i" +~ write_ . "{i" +~ isatty_ . "{i" +~ sbrk_ . "{#c" +~ Croot_ . "{i" +~ _ioflg_ . "[0c" +~ cls__ . "#{i" +~ noper_ . "{i" + bss Argc_:word,2 +~ Argc Argc_ "i" + bss Argv_:word,4 +~ Argv Argv_ "##c" + extrn main_:far + extrn _exit_:far + extrn write_:far + extrn sbrk_:far + extrn isatty_:far +codeseg ends +dataseg segment word public 'data' + extrn _ioflg_:word +dataseg ends + end + croot.c +/* Copyright (C) 1981,1982, 1983 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" + +static char **Argv; +static int Argc; + +noper() +{ + return 0; +} + +int (*cls_)() = noper; +extern char _ioflg[]; + +Croot(cp, first) +register char *cp; +{ + register char **cpp; + char *sbrk(); +#ifdef REDIR + register int k; + register char *fname; +#endif + + _ioflg[0] = isatty(0); /* set flag for i/o routines */ + _ioflg[1] = isatty(1); /* set flag for i/o routines */ + _ioflg[2] = isatty(2); /* set flag for i/o routines */ + + Argv = (char **)sbrk((first+1)*sizeof(char *)); + Argv[0] = ""; + cpp = &Argv[Argc = first]; + for (;;) { + while (*cp == ' ' || *cp == '\t') + ++cp; + if (*cp == 0) + break; +#ifdef REDIR + if (*cp == '>') { /* redirect output */ + k = 1; + goto redirect; + } else if (*cp == '<') { /* redirect input */ + k = 0; +redirect: + while (*++cp == ' ' || *cp == '\t') + ; + fname = cp; + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + close(k); + if (k) + k = creat(fname, 0666); + else + k = open(fname, O_RDONLY); + if (k == -1) + redir_err(fname); + } else +#endif + { + *cpp++ = cp; + Argc++; + if (sbrk(sizeof(char *)) == (char *)-1) { + write(2, "Too many args.", 14); + _exit(200); + } + while (*++cp) + if (*cp == ' ' || *cp == '\t') { + *cp++ = 0; + break; + } + } + } + *cpp = 0; + main(Argc,Argv); + exit(0); +} + +#ifdef REDIR +static redir_err(name) +char *name; +{ + char buff[200]; + + strcpy(buff, "Can't open file for redirection: "); + strcat(buff, name); + strcat(buff, "\n"); + write(2, buff, strlen(buff)); + exit(10); +} +#endif + +exit(code) +{ + (*cls_)(); + _exit(code); +} + + crt0.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 +_TEXT segment byte public 'CODE' + public __Corg + assume cs:_TEXT +__Corg label byte + + public __chkstk +__chkstk proc near + ret +__chkstk endp + + public __acrtused +__acrtused proc near + ret +__acrtused endp +_TEXT ends +PROG segment byte public 'CODE' +PROG ends + + +@DATAB segment para public 'DATAB' +@DATAB ends + +_DATA segment word public 'DATA' + db 'Aztec C86 version 4.10a',0 + even + public __Dorg +__Dorg label byte +_DATA ends + +@DATAC segment word public 'DATAC' +@DATAC ends +@DATAI segment word public 'DATAI' +@DATAI ends + +@DATAT segment word public 'DATAT' + public __Dend +__Dend label byte + public __Uorg +__Uorg label byte +@DATAT ends + +@DATAU segment word public 'DATAU' +@DATAU ends + +@DATAV segment word public 'DATAV' + public __Uend +__Uend label byte +@DATAV ends + +_STACK segment para stack 'STACK' +First db 2048 dup (?) +_STACK ends + end +DGROUP group @DATAB,_DATA,@DATAC,@DATAT,_BSS,@DATAV,_STACK + csread.asm +; Copyright (C) 1983, 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef _csread,<,,> +; _csread(fd, char *addr, len) +; read data into code segment + mov bx,fd + push ds +ifdef FARPROC + lds dx,addr +else + mov dx,addr +endif + mov cx,len +ifndef FARPROC + mov ax,cs + mov ds,ax +endif + mov ah,3fH + int 21H + pop ds + jnc ret_ok + mov ds:errno_,ax + mov ax,-1 +ret_ok: + pret + pend _csread + finish + end + ctime.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include + +char * +ctime(clock) +long *clock; +{ + struct tm *tm; + + tm = localtime(clock); + return asctime(tm); +} + dioctl.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef _ioctl, <,,,> +; _ioctl(fd, req, arg[, len]) + mov bx,fd + mov ah,44H + mov al,req + cmp al,0 + je getinfo + cmp al,1 + je setinfo + cmp al,6 + jge getstat + pushds + ldptr dx,arg,ds + mov cx,len + int 21H + popds + jnc xret_ok + mov ds:errno_,ax + mov ax,-1 +xret_ok: + pret +; +doint proc near + int 21H + jnc ret_ok + mov ds:errno_,ax + mov ax,-1 +ret_ok: + ret +doint endp +; +getstat: + call doint + pret +; +getinfo: + call doint + jc err + ldptr bx,arg,es +ifdef LONGPTR + mov es:[bx],dx +else + mov ds:[bx],dx +endif + sub ax,ax +err: + pret +; +setinfo: + ldptr bx,arg,es +ifdef LONGPTR + mov dl,es:[bx] +else + mov dl,ds:[bx] +endif + sub dh,dh + mov bx,fd + call doint + jc err + sub ax,ax + pret + pend _ioctl + finish + end + dos.asm +; Copyright (C) 1983, 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef dos,<,,,,,> +; dos(ax,bx,cx,dx,di,si) + push di + push si +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + mov ax,func + test ah,ah + jnz skip + xchg ah,al +skip: + mov bx,bxval + mov cx,cxval + mov dx,dxval + mov di,dival + mov si,sival + int 21H + jnc ret_ok + mov errno_,ax + mov ax,-1 +ret_ok: + pop si + pop di + pret + pend dos + finish + end + dosdir.c +#include "model.h" + +#define SETDMA 26 +#define SRCHFIR 0x4e +#define SRCHNXT 0x4f + +char * +scdir(pat) +char *pat; +{ + register char *cp, *np; + char *index(); + static int code = SRCHFIR; + static char nambuf[64], *tail; + static struct { + char reserve[21]; + char attr; + long mtime; + long fsize; + char name[13]; + } srchbuf; + + if (code == SRCHFIR) { + if (index(pat, '*') == 0 && index(pat, '?') == 0) { + +/* This code was taken out and new code put in to handle the case of + scdir("hello.c") where hello.c does not exist. 3/10/88 +*/ +#if 0 + code = 0; + return pat; +#endif + if (access(pat, 0) == -1) { + code = SRCHFIR; + return (char *)0; + } else { + code = 0; + return pat; + } + } + strncpy(nambuf, pat, 64); + for (cp = tail = nambuf ; cp < &nambuf[64] && *cp ; ++cp) + if ((tail == nambuf && *cp == ':') || *cp == '/' || *cp == '\\') + tail = cp+1; + } + +#ifdef _LARGEDATA + bdosx(SETDMA, &srchbuf); + if (code == 0 || dosx(code, 0, -1, pat) == -1) { +#else + bdos(SETDMA, &srchbuf); + if (code == 0 || dos(code, 0, -1, pat) == -1) { +#endif + code = SRCHFIR; + return (char *)0; + } + code = SRCHNXT; + + np = tail; + cp = srchbuf.name; + while (*np++ = tolower(*cp++)) + ; + return nambuf; +} + + + + dostime.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +codeseg segment byte public "code" +days dw -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333 +codeseg ends + procdef dostime, <> + push es + push si +; + mov ah,2aH + int 21h + ldptr bx,arg,es + sub cx,1900 +ifndef LONGPTR + mov ds:word ptr 10[bx],cx ;year - 1900 +else + mov es:word ptr 10[bx],cx ;year - 1900 +endif + sub ah,ah + mov al,dh + dec al +ifndef LONGPTR + mov ds:word ptr 8[bx],ax ;month +else + mov es:word ptr 8[bx],ax ;month +endif + mov al,dl +ifndef LONGPTR + mov ds:word ptr 6[bx],ax ;day of month +else + mov es:word ptr 6[bx],ax ;day of month +endif +; + mov ah,2cH + int 21H + ldptr bx,arg,es + sub ah,ah + mov al,ch +ifndef LONGPTR + mov ds:word ptr 4[bx],ax ;hour + mov al,cl + mov ds:word ptr 2[bx],ax ;minute + mov al,dh + mov ds:word ptr [bx],ax ;seconds + mov al,dl + mov ds:word ptr 18[bx],ax ;1/100 seconds +; + sub ax,ax + mov si,ds:word ptr 8[bx] + cmp si,2 + jb noleap + test ds:byte ptr 10[bx],3 + jnz noleap + inc ax +noleap: + shl si,1 + add ax,cs:days[si] + add ax,ds:word ptr 6[bx] + mov ds:word ptr 14[bx],ax ;day of year +; + mov si,ds:word ptr 10[bx] +else + mov es:word ptr 4[bx],ax ;hour + mov al,cl + mov es:word ptr 2[bx],ax ;minute + mov al,dh + mov es:word ptr [bx],ax ;seconds + mov al,dl + mov es:word ptr 18[bx],ax ;1/100 seconds +; + sub ax,ax + mov si,es:word ptr 8[bx] + cmp si,2 + jb noleap + test es:byte ptr 10[bx],3 + jnz noleap + inc ax +noleap: + shl si,1 + add ax,cs:days[si] + add ax,es:word ptr 6[bx] + mov es:word ptr 14[bx],ax ;day of year +; + mov si,es:word ptr 10[bx] +endif + add ax,si + dec si + shr si,1 + shr si,1 + add ax,si + inc ax + sub dx,dx + mov cx,7 + div cx +ifndef LONGPTR + mov ds:word ptr 12[bx],dx ;day of week +; + mov ds:word ptr 16[bx],0 ;say no D.S.T. for now +else + mov es:word ptr 12[bx],dx ;day of week +; + mov es:word ptr 16[bx],0 ;say no D.S.T. for now +endif + pop si + pop es + pret + pend dostime + finish + end + dosx.asm +; Copyright (C) 1983, 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef dosx,<,,,,,,> +; dosx(ax,bx,cx,dx,es,di,si) + push di + push si +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + push ds + mov ax,func + test ah,ah + jnz skip + xchg ah,al +skip: + mov bx,bxval + mov cx,cxval + mov dx,dxval + mov di,dival + mov si,sival + push dsval + pop ds + int 21H + pop ds + jnc ret_ok + mov errno_,ax + mov ax,-1 +ret_ok: + pop si + pop di + pret + pend dosx + finish + end + dup.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef dup,<> +; dup(ofd) : duplicate file descriptor +; if ok, returns new fd. if error, returns -1. + mov ah,45h +dupx: + mov bx,ofd + int 21H + jnc ret_ok + mov errno_,ax + mov ax,-1 +ret_ok: + pret + pend dup +; + procdef fdup,<,> +; fdup(ofd, nfd): force dup of ofd into nfd +; If nfd is open it will be closed. +; if ok, returns nfd; if error, returns -1 + mov cx,nfd + mov ah,46h + jmp dupx + pend fdup + finish + end + exec.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + +ifdef FARPROC + extrn _sigfix_:far +else + extrn _sigfix_:near +endif +; +e_magic equ 0 +e_used equ 2 ;number of bytes used in final sector of file +e_pages equ 4 ;size of file in 512-byte pages +e_nreloc equ 6 ;number relocation table items +e_hsize equ 8 ;size of header in 16-byte paragraphs +e_min equ 10 ;minimum # of para required above program +e_max equ 12 ;maximum # of para " " " +e_ss equ 14 ;offset of stack segment in load module +e_sp equ 16 ;initial SP value +e_csum equ 18 ;negative sum of all words in the file +e_ip equ 20 ;starting IP for program +e_cs equ 22 ; " CS " +e_freloc equ 24 ;offset of first relocation item +e_ovly equ 26 ;overlay number + +; +ldrsize equ 1024 +header equ ldrsize-30 +reloc equ 26 +startad equ 0 +; +dataseg segment word public 'data' + extrn _PSP_:word +dataseg ends +; +;exec(fd,cline,fcb1,fcb2,header) +; NOTE: This function never returns, even if the exec +; fails. +; + procdef exec,<,,,,> +; +; copy cmd line and fcb's into PSP +; +load proc far ;so returns are far + push ds + call _sigfix_ ;restore int 22,23 vectors + mov es,ds:_PSP_ ;fetch segment of PSP + ldptr si,cline,ds + mov di,80h + mov cx,64 +rep movsw ;copy command line + ldptr si,fcb1,ds + mov di,5ch + mov cx,8 +rep movsw ;copy fcb1 + ldptr si,fcb2,ds + mov cx,8 +rep movsw ;copy fcb2 +; + mov bx,0ffffh ;ask for all of memory + mov ah,4ah + int 21h + mov ah,4ah ;then ask for what we can get + int 21h +; + mov dx,fd ;file handle + ldptr si,head,ds ;exe header from file + cmp ds:word ptr [si+e_magic],5a4dh ;check magic # + je exefile + + mov bp,bx ;compute new SP + cmp bp,4096 ;check size of segment + jbe smallstk + mov bp,4096 +smallstk: + mov cx,4 + shl bp,cl ;new SP +; + mov cx,es + add bx,cx ;end of our segment + sub bx,8 ;get 128 bytes for loader and stack + mov es,bx + pop si ; get old ds value back + mov ss,bx + mov sp,128 + push si ; push old ds on stack for later use +; + mov cx,cs + mov ds,cx + mov si,offset com_loader + sub di,di + mov cx,offset com_ldend + sub cx,si +rep movsb +; + mov bx,dx ;handle into bx for io calls + sub cx,cx + sub dx,dx + mov ax,4200H + int 21H ;rewind file +; + mov dx,100H ;address to read data into + lea cx,[bp-256] ;byte count to read in + pop ds + mov ax,ds:_PSP_ ;segment of PSP + mov ds,ax + mov es,ax + push ss + sub ax,ax + push ax + mov ah,3fH + ret +; +; this block of code is moved to the top of available memory +; and jumped to with the registers for a read call setup +; +com_loader: + int 21h + jnc ok + mov ax,4cfeh + int 21h +ok: + mov ah,3eH + int 21h ;close the file + mov ax,ds + mov ss,ax + mov sp,bp + push ax ;push new cs + mov ax,100h + push ax ;push new ip + ret +com_ldend: +; +; +exefile: + mov cx,es + add bx,cx ;end of our segment + sub bx,ldrsize/16 ;get mem for loader, header, and stack + mov es,bx + mov di,header + mov cx,13 +rep movsw ;copy 26 byte file header +; + pop si ; get old ds value + mov ss,bx + mov sp,header + push si ; push old ds value on new stack for later use +; + mov cx,cs + mov ds,cx + mov si,offset exe_loader + sub di,di + mov cx,offset exe_ldend + sub cx,si +rep movsb +; + pop ds + mov ax,ds:_PSP_ ;segment of PSP + push ax ;ES, DS value for program + add ax,10h + mov ds,ax ;place to load program + mov bp,ax + mov bx,dx ;get handle into bx for int 21h +; + mov di,header + mov dx,ss:e_hsize[di] ;compute offset of program + sub ax,ax + mov cl,4 +lshift: + shl dx,1 + rcl ax,1 + loop lshift + mov cx,ax + mov ax,4200H + int 21h ;lseek to load module + jc punt +; + mov si,ss:e_pages[di] + mov cl,5 + shl si,cl ;# paragraphs in file + sub si,ss:e_hsize[di] ;now, # para in program +; + push ss ;CS for loader + sub ax,ax + push ax ;IP for loader + ret ;far return to code at top of mem +; +; this code is moved to the top of our segment and jumped to +; with the following registers setup: +; bx - file handle of program +; ds, bp - where to load the program +; di - points to the exe header +; si - # para to read in +; PSP address pushed onto stack +; +exe_loader: + mov ah,3fH + mov cx,0fff0h ;read as much as possible at once + cmp si,0fffh ;check how much is left to read + ja cx_ok + mov cl,4 ;if less, then compute remaining + shl si,cl + mov cx,si + mov si,0fffh +cx_ok: + sub dx,dx + int 21h + jnc read_ok +punt: + mov ax,4cfeh + int 21h +read_ok: + test ax,ax + jz load_done + mov ax,ds + add ax,0fffh + mov ds,ax + sub si,0fffh + ja exe_loader +; +load_done: + mov ax,cs + mov ds,ax + cmp word ptr e_nreloc[di],0 + jz reloc_done + mov dx,e_freloc[di] + sub cx,cx + mov ax,4200H + int 21H ;lseek to relocation info + jc punt +relocate: + lea dx,reloc[di] + mov cx,4 + mov ah,3fH + int 21H + jc punt + cmp ax,4 + jne punt + mov si,reloc[di] + mov ax,reloc+2[di] + add ax,bp + mov es,ax + add es:[si],bp + dec word ptr e_nreloc[di] + jnz relocate +reloc_done: + mov ah,3eH + int 21h ;close file + add e_ss[di],bp ;relocate stack segment + add e_cs[di],bp ;relocate starting CS + pop ax ;get PSP address before changing stack + mov ss,e_ss[di] + mov sp,e_sp[di] + mov ds,ax + mov es,ax + jmp cs:dword ptr e_ip[di] +exe_ldend: +load endp + pend exec + finish + end + execl.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execl(path, args) +char *path, *args; +{ + return execv(path, &args); +} + execlp.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execlp(name, args) +char *name, *args; +{ + return execvp(name, &args); +} + + execv.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +#define EXEMAGIC 0x5a4d + +struct exehead { /* MS-dos .exe file header */ + int e_magic; + int e_used; /* number of bytes used in final sector of file */ + int e_pages; /* size of file in 512-byte pages */ + int e_nreloc; /* number relocation table items */ + int e_hsize; /* size of header in 16-byte paragraphs */ + int e_min; /* minimum # of para required above program */ + int e_max; /* maximum # of para " " " */ + unsigned e_ss; /* offset of stack segment in load module */ + unsigned e_sp; /* initial SP value */ + unsigned e_csum; /* negative sum of all words in the file */ + unsigned e_ip; /* starting IP for program */ + unsigned e_cs; /* " CS " */ + int e_freloc; /* offset of first relocation item */ + int e_ovly; /* overlay number */ +}; + +execv(path, argv) +char *path, **argv; +{ + register char *cp, *xp; + int i, fd; + char buffer[130]; + char fcb1[16], fcb2[16]; + struct exehead header; + + if ((fd = open(path,0)) == -1) + return -1; + if (read(fd, &header, sizeof header) != sizeof header) + header.e_magic = 0; + + cp = buffer+1; + i = 1; + if (*argv) { + ++argv; /* skip arg0, used for unix (tm) compatibility */ + while (xp = *argv++) { + if (i == 1) + fcbinit(xp, fcb1); + else if (i == 2) + fcbinit(xp, fcb2); + *cp++ = ' '; + while (*xp) { + if (cp >= buffer+128) + goto done; + *cp++ = *xp++; + } + ++i; + } + } +done: + buffer[0] = cp - (buffer+1); + return exec(fd, buffer, fcb1, fcb2, &header); +} + + execvp.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +execvp(name, argv) +char *name, **argv; +{ + register char *cp, *xp; + char *getenv(), path[64]; + + tryexec("", name, argv); + if ((cp = getenv("PATH")) != 0) { + while (*cp) { + xp = path; + while (*cp) { + if (*cp == ';') { + ++cp; + break; + } + *xp++ = *cp++; + } + *xp = 0; + if (path[0] != 0) + tryexec(path, name, argv); + } + } + return -1; +} + +static +tryexec(dir, name, argv) +char *dir, *name, **argv; +{ + char newname[64]; + register char *cp; + char *strchr(), *strrchr(); + + strcpy(newname, dir); + if (((cp = strchr(newname, '/')) || (cp = strchr(newname, '\\'))) + && *(cp+1) != 0) + strcat(newname, "/"); + strcat(newname, name); + if (strchr(name, '.') == 0) { + strcat(newname, ".com"); + execv(newname, argv); + strcpy(strrchr(newname,'.'), ".exe"); + } + execv(newname, argv); +} + fcbinit.asm +;Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef fcbinit, <,> + pushds + push di + push si +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,jname + ldptr di,fcb + mov ax,2900H ; issue parse filename call + int 21H + and ax,0ffH + cmp es:byte ptr 1[di],' ' + jne nameok + mov ax,-1 +nameok: + pop si + pop di + popds + pret + pend fcbinit + finish + end + fexec.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' +param equ this word +env dw ? +cline dw ?,? +fcb1 dw ?,? +fcb2 dw ?,? + extrn errno_:word +dataseg ends + assume ds:dataseg +save_ss dw 0 +save_sp dw 0 + procdef fexec,<,,,,> +; char *fexec(name,env,cline,fcb1,fcb2) +; + push si + push di + pushf + push [030H] + push [02EH] + push ds + push es + mov cs:save_ss,ss + mov cs:save_sp,sp +; +; set up parameter block for exec call +; + mov ax,enva + mov env,ax +ifndef LONGPTR + mov ax,ds + mov es,ax +endif + ldptr ax,clinea,es + mov cline,ax + mov cline+2,es + ldptr ax,fcb1a,es + mov fcb1,ax + mov fcb1+2,es + ldptr ax,fcb2a,es + mov fcb2,ax + mov fcb2+2,es +; + mov ax,ds + mov es,ax + mov bx,offset param + ldptr dx,filname,ds ;name of file to exec + mov ax,04b00H + int 21h + mov ss,cs:save_ss + mov sp,cs:save_sp + pop es + pop ds + jnc noerror + mov errno_,ax + mov ax,-1 + jmp short done +noerror: + sub ax,ax +done: + pop [02EH] + pop [030H] + popf + pop di + pop si + pret + pend fexec + finish + end + fexecl.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +fexecl(path, args) +char *path, *args; +{ + return fexecv(path, &args); +} + fexecv.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ + +fexecv(path, argv) +char *path, **argv; +{ + register char *cp, *xp; + int i; + char buffer[130]; + char fcb1[16], fcb2[16]; + + cp = buffer+1; + i = 1; + fcbinit(".", fcb1); /* initialize fcb's, in case no args */ + fcbinit(".", fcb2); + if (*argv) { + ++argv; /* skip arg0, used for unix (tm) compatibility */ + while (xp = *argv++) { + if (i == 1) + fcbinit(xp, fcb1); + else if (i == 2) + fcbinit(xp, fcb2); + *cp++ = ' '; + while (*xp) { + if (cp >= buffer+127) + goto done; + *cp++ = *xp++; + } + ++i; + } + } +done: + buffer[0] = cp - (buffer+1); + *cp = '\r'; /* add CR to make some dos commands happy */ + return fexec(path, 0, buffer, fcb1, fcb2); +} + + filelock.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn errno_:word +dataseg ends + procdef filelock, <,,,> + push si + push di + mov ah,5ch + mov al,byte ptr flag + mov bx,fd + mov cx,word ptr pos+2 + mov dx,word ptr pos + mov si,word ptr len+2 + mov di,word ptr len + int 21h + pop di + pop si + jnc retok + mov ds:errno_,ax + mov ax,-1 + pret +retok: + sub ax,ax + pret + pend filelock + finish + end + foo +makefile +access.c +asctime.c +bdos.asm +bdosx.asm +chmod.asm +clk.asm +clock.asm +croot.asm +croot.c +crt0.asm +csread.asm +ctime.c +dioctl.asm +dos.asm +dosdir.c +dostime.asm +dosx.asm +dup.asm +exec.asm +execl.c +execlp.c +execv.c +execvp.c +fcbinit.asm +fexec.asm +fexecl.c +fexecv.c +filelock.asm +foo +ftime.asm +getcwd.c +getenv.asm +io.asm +ioctl.c +isatty.asm +lbegin.asm +lbrk.asm +lmalloc.asm +localtim.c +lsbrk.asm +mkdir.asm +mon.c +monitor.c +open.c +profil.c +sbegin.asm +sigfix.asm +sighand.asm +ssbrk.asm +stat.c +stkover.c +stksiz.c +sys.asm +syserr.c +system.c +time.asm +ttyio.c +utime.c +wait.asm + ftime.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef ftime,<,,,> +; +;long ftime(get/set, fd, [long newtime]) +; + mov ah,57h + mov al,get + mov bx,fd + mov cx,newt1 + mov dx,newt2 + int 21h + jnc retok + mov errno_,ax + mov ax,-1 + mov dx,ax + pret +retok: + test get,1 + jz gettime + sub dx,dx + mov cx,dx +gettime: + mov ax,cx + pret + pend ftime + finish + end + getcwd.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char * +getcwd(buf, size) +char *buf; +{ + char *malloc(); + int allflag = 0; + + if (buf == 0) { + if ((buf = malloc(size)) == 0) + return 0; + allflag = 1; + } + if (_sys(0x47,buf,0) == -1) { + if (allflag) + free(buf); + return 0; + } + return buf; +} + getenv.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + ifndef LONGPTR +retbuf db 256 dup (?) + endif + extrn _PSP_:word +dataseg ends + assume ds:dataseg + procdef getenv, <> +; char *getenv(name) +; char *name; +; + push ds + push si + push di +ifndef LONGPTR + mov bx,ds + mov es,bx +endif + cld + ldptr bx,jname,es + mov ds,ds:_PSP_ ;fetch segment of PSP + mov ds,ds:[2cH] ;get environment segment + sub si,si +envloop: + lodsb + test al,al + jz nostring + sub di,di +cmploop: + cmp al,'=' + jne notaneq + sub al,al +notaneq: + cmp al,es:[bx][di] + jne next + test al,al + je foundit + inc di + lodsb + test al,al + jne cmploop + jmp envloop +next: + lodsb + test al,al + jne next + jmp envloop +; +foundit: +ifndef LONGPTR +; +; copy string to local buffer, so we can return a 16-bit pointer to it. +; + mov di,offset retbuf + mov cx,255 +cpyloop: + lodsb + stosb + test al,al + loopnz cpyloop + sub al,al + stosb ;guarantee null termination + mov ax,offset retbuf + test ax,ax + jmp short done +; +nostring: + sub ax,ax +done: +else + mov dx,ds + mov ax,si + jmp short done + +nostring: + sub ax,ax + sub dx,dx + +done: +endif + pop di + pop si + pop ds + pret + pend getenv + finish + end + io.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + +ifdef FARPROC + extrn __tty_rd_:far,__tty_wr_:far +else + extrn __tty_rd_:near,__tty_wr_:near +endif + +dataseg segment para public 'data' + extrn errno_:word + public _ioflg_ +_ioflg_ db 20 dup (0) + public _ttrd_, _ttwr_ + +ifdef FARPROC +_ttrd_ dd __tty_rd_ +else +_ttrd_ dw offset __tty_rd_ +endif + +ifdef FARPROC +_ttwr_ dd __tty_wr_ +else +_ttwr_ dw offset __tty_wr_ +endif +dataseg ends + + assume ds:dataseg +; + procdef _read, <,,> + mov ah,3fH + mov bx,rdfd + jmp short use_dos + pend _read +; + procdef _write, <,,> + mov ah,40H + mov bx,wrfd + jmp short use_dos + pend _write +; + procdef read, <,,> + ;read_(fd, buffer, length) + ;char *buffer; int length; + + mov ah,3fH + jmp short iocommon + pend read +; + procdef write, <,,> + ;write(fd, buffer, length) + ;char *buffer; int length; + mov ah,40H +iocommon: + mov bx,fd + cmp _ioflg_[bx],0 + jz use_dos + pop bp + cmp ah,03fH + je readit + jmp _ttwr_ +readit: + jmp _ttrd_ +; +use_dos: + pushds + ldptr dx,buffer,ds + mov cx,len + int 21H + popds + jnc io_ok + mov errno_,ax + mov ax,-1 +io_ok: + pret + pend write +; + procdef close, <> + ;close(fd) + mov ah,3eH + mov bx,ffd + int 21H + jnc cls_ok + mov errno_,ax + mov ax,-1 + pret +cls_ok: + sub ax,ax + pret + pend close +; + procdef lseek, <,,,> + ;long lseek(fd, pos, how) + ;long pos; + mov ah,42H + mov al,how + mov dx,pos1 + mov cx,pos2 + mov bx,fffd + int 21H + jnc lsk_ok + mov errno_,ax + mov ax,-1 + mov dx,ax +lsk_ok: + pret + pend lseek +; + procdef unlink,<> + ;unlink(name) + pushds + mov ah,41H + ldptr dx,namea,ds + int 21H + popds + jnc unl_ok + mov errno_,ax + mov ax,-1 + pret +unl_ok: + sub ax,ax + pret + pend unlink +; + procdef rename, <,> + ;rename(old, new) + push di + pushds + mov ah,56H + ldptr dx,old,ds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,new,es + int 21H + popds + pop di + jnc rnm_ok + mov errno_,ax + mov ax,-1 + pret +rnm_ok: + sub ax,ax + pret + pend rename + finish + end + ioctl.c +/* Copyright (C) 1984, 1985 by Manx Software Systems */ +#include "errno.h" +#include "sgtty.h" + +#define TIME 10 /* number of iterations of raw_rd loop */ +#define MIN 1 /* minimum number of chars returned from read */ + +extern char _ioflg[]; +extern int (*_ttrd)(); +extern int (*_ttwr)(); +extern char _Eol; +extern int _TTrem; +extern int __tty_rd(), __tty_wr(), _write(); + +static struct sgttyb Tty_ctl = { '\b', '\x18', CRMOD|ECHO }; +static int raw_rd(), cr_wr(); +static int ioflags, myflags, ttyfd; + +ioctl(fd, cmd, arg) +struct sgttyb *arg; +{ + int flags; + + if (_ioflg[fd] == 0) { + errno = ENOTTY; + return -1; + } + switch (cmd) { + case TIOCGETP: + *arg = Tty_ctl; + break; + case TIOCSETP: + if (ttyfd == 0) { + if (_ioflg[2]) + ttyfd = 2; + else if ((ttyfd = _sys(0x3d02,"/dev/con",0)) == -1) + return -1; + } + if (ioflags == 0) { + _ioctl(ttyfd, 0, &ioflags); + ioflags &= 0xff; + } + Tty_ctl = *arg; + if ((myflags = Tty_ctl.sg_flags) & RAW) + myflags = RAW; + _ttwr = _write; + _Eol = '\r'; + if (myflags&CRMOD) { + _Eol = '\n'; + _ttwr = __tty_wr; + } + if (myflags&(RAW|CBREAK)) { + _TTrem = 0; /* clear out input buffer */ + _ttrd = raw_rd; + ioflags |= 0x20; /* turn on dos's raw flag */ + _ioctl(ttyfd, 1, &ioflags); + } else { + ioflags &= ~0x20; /* turn off dos's raw flag */ + _ioctl(ttyfd, 1, &ioflags); + _ttrd = __tty_rd; + } + break; + } + return 0; +} + +raw_rd(fd, buff, len) +register char *buff; +{ + int i; + register int count; + + for (count = 0 ; count < len ; ) { + for (i = TIME ; i-- ; ) + if (_ioctl(ttyfd, 6) != 0) + goto have_char; + if (count < MIN) + continue; + break; +have_char: + _read(ttyfd, buff, 1); + if (*buff == '\r') + *buff = _Eol; + if (myflags&ECHO) + (*_ttwr)(ttyfd, buff, 1); + ++buff; + ++count; + } + return count; +} + isatty.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef isatty, <> +; isatty(fd) + mov bx,fd + mov ax,4400H + int 21H + jc not_tty ;error, then not a tty + test dl,80h ;is the channel a device? + jz not_tty ;no, ... + test dl,3 ;is it console input or output + jz not_tty ;no, ... + mov ax,1 ;yes, the channel is a tty + pret +not_tty: + sub ax,ax + pret + pend isatty + finish + end + lbegin.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +codeseg segment para public 'code' + public $MEMRY + public _mbot_, _sbot_, _mtop_,_lowwater_ +dataseg segment para public 'data' +$MEMRY dw -1 + dw -1 + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 +_mbot_ dw 0,0 +_sbot_ dw 0,0 +_mtop_ dw 0,0 +_lowwater_ dw -1 + public _PSP_ +_PSP_ dw 0 + extrn _HEAPSIZ_:word,_STKSIZ_:word + extrn _STKLOW_:word,_STKRED_:word + extrn _Uorg_:byte,_Uend_:byte +bad8087 db "8087/80287 is required!",13,10,'$' +dataseg ends + +exitad dw 0 +exitcs dw 0 + + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg +ifdef FARPROC + extrn Croot_:far, $fltinit:far +else + extrn Croot_:near, $fltinit:near +endif + public $begin + public _exit_ +$begin proc far + mov bp,dataseg + test bp,bp + jnz notcom + mov al,253 ; This CAN'T be a com file + jmp exits +notcom: + mov exitcs,ds + mov es,bp + mov es:_PSP_,ds + mov bp,offset _Uend_ ; stack starts at Uend + add bp,15 ; round up to next paragraph + rcr bp,1 + mov cl,3 ; and convert to paragraph form + shr bp,cl + and bp,01fffh + mov dx,es ; add in datasegment base paragraph + add bp,dx + mov bx,es:_STKRED_ + shr bx,cl ;compute (2*STKRED)/16 note: cl==3 + cmp bx,es:_STKSIZ_ ;allocate either 2*STKRED or STKSIZ + jae ok1 + mov bx,es:_STKSIZ_ ;whichever is bigger +ok1: + cmp bx,1000h ; stack can't be bigger than 64K + jb ok2 + mov bx,1000h +ok2: + mov dx,bx + mov cl,4 + shl bx,cl + cli + mov ss,bp + mov sp,bx + sti +; + add dx,bp + inc dx + mov es:$MEMRY+2,dx ; and save as bottom of heap + mov es:$MEMRY,0 + mov es:_mbot_+2,dx ; and save as bottom of heap + mov es:_mbot_,0 +; now adjust heap size if necessary + mov bx,es:_HEAPSIZ_ + add bx,es:$MEMRY+2 ; add in base paragraph of heap + mov es:_mtop_+2,bx ; and save as top of heap + mov es:_mtop_,0 + mov si,ds + sub bx,si ; get size of total program in paragraphs + mov bp,es + mov es,si ; point es at PSP + mov ah,4ah + int 21h ; SETBLOCK to raise or lower allocation + jnc didheap + mov al,254 + jmp exits +didheap: + mov es,bp ; restore es to point at dataseg +; + cld +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + mov es,[2cH] ;get enviroment segment + sub di,di + mov cx,7fffH +arglook: + mov ah,es:byte ptr [di] + cmp ah,'=' ;look for null named env. string + je found_args + test ah,ah + jz no_args +repne scasb ;look for null byte + jz arglook +no_args: + mov si,ds + mov es,si + mov si,081h + mov di,080h + mov cl,[80h] + sub ch,ch + jcxz nomov +rep movsb +nomov: + sub al,al + stosb + mov ax,1 + mov di,080h + jmp short mov_args +; +found_args: + sub ax,ax + stosb ;zap and skip over '=' +mov_args: + push ax ; first arg # for Croot + push es + push di ; argp argument for Croot + mov es,bp + mov ds,bp ;set DS, now DS, SS, ES are equal + mov _dsval_,ds + mov _csval_,cs + mov ax,_STKRED_ + mov _sbot_,ax + call $fltinit + jc no_8087 + call Croot_ ;Croot(argp, first) + jmp short exits +; +no_8087: + mov ah,9 ;dos print message + mov dx,offset bad8087 + int 21h ;tell the user about it + mov al,253 + jmp short exits + +_exit_: + pop ax + pop ax ;fetch return code +ifdef FARPROC + pop ax +endif +exits: + mov ah,4cH + int 21H + jmp dword ptr exitad +$begin endp + +retip dw 0 +retcs dw 0 + + public $dbgentry +$dbgentry proc far + pop cs:retip + pop cs:retcs ; save return address into debugger + pop ds ;set DS + call caller + jmp dword ptr cs:retip ; return to debugger +$dbgentry endp + +caller proc + push di ;CS value of local function + push si ;IP value call local function + db 0cbH ;far return instruction +caller endp + +codeseg ends + end $begin + lbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + largecode + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn _mtop_:word + extrn errno_:word + extrn _PSP_:word +dataseg ends + assume ds:dataseg +; +; lsbrk(size): bump by size paragraphs +; + procdef lsbrk,<> + + mov es,_PSP_ + mov ah,4ah ; set block + int 21h + mov bx,word ptr size_in_para + jc bad_status + mov ax,bx + jmp return +bad_status: + mov ax,0 +return: + pret + pend lsbrk +; + lmalloc.asm +; Copyright 1987 Manx Software Systems, Inc. All rights reserved. +;:ts=8 + include lmacros.h + + procdef lmalloc,<> + mov ax,word ptr asize + mov dx,word ptr asize+2 + test dx,dx + js badalloc + add ax,15 + adc dx,0 + mov cx,4 +rshift: + shr dx,1 + rcr ax,1 + loop rshift + test dx,dx + jnz badalloc + mov bx,ax + mov ah,48H + int 21h + jc badalloc + mov dx,ax + mov ax,0 + jmp short lmret +; +badalloc: + mov ax,0 + mov dx,ax +lmret: + pret + pend lmalloc + + procdef lfree,<> + push es + mov es,word ptr areaptr+2 + mov ah,49h + int 21h + jnc other_return + mov ax,-1 + jmp exit +other_return: + xor ax,ax +exit: + pop es + pret + pend lfree + + procdef lrealloc,<,> + + mov ax,word ptr count + mov dx,word ptr count+2 + mov cx,4 + +right_shift: + shr dx,1 + rcr ax,1 + loop right_shift + mov bx,ax + mov ah,4ah + mov es,word ptr area_ptr+2 + int 21h + jc failure + mov ax,word ptr area_ptr + mov dx,word ptr area_ptr+2 +return: + pret +failure: + xor ax,ax + xor dx,dx + jmp return + pend lrealloc + + finish + end + localtim.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include + +struct tm * +gmtime(clock) +long *clock; +{ + struct tm *localtime(); + + return localtime(clock); +} + +struct tm * +localtime(clock) +long *clock; +{ + union { + long l; + unsigned u[2]; + } un; + static struct tm tm; + static int days[12] = { + -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333 + }; + + un.l = *clock; + tm.tm_sec = (un.u[0]&31) * 2; + tm.tm_min = (un.u[0]>>5) & 63; + tm.tm_hour = (un.u[0]>>11) & 31; + tm.tm_mday = un.u[1] & 31; + tm.tm_mon = ((un.u[1]>>5) & 15) - 1; + tm.tm_year = ((un.u[1]>>9) & 127) + 80; + tm.tm_yday = days[tm.tm_mon] + tm.tm_mday + + (tm.tm_mon > 1 && (tm.tm_year&3) == 0); + tm.tm_wday = (tm.tm_yday + tm.tm_year + ((tm.tm_year-1)>>2) + 1) % 7; + return &tm; +} + lsbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn _mtop_:word + extrn errno_:word + extrn _PSP_:word +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + push si + mov ax,$MEMRY ; convert $MEMRY to 20-bit physical address + mov dx,$MEMRY+2 + mov si,ax + mov di,dx + mov cx,4 + rol dx,cl + mov bx,dx + and bx,0fff0h + and dx,0fh + add ax,bx + adc dx,0 + mov bx,siz ; load and check sign of size + cmp bx,0 + jge notneg + sub ax,bx + sbb dx,0 + js brk_error ; mustn't go negative + jmp canon +notneg: + add ax,bx + adc dx,0 + test dx,0fff0h + jnz brk_error ; mustn't overflow 20-bits +canon: + ror dx,cl + mov bx,ax + and ax,0fh + shr bx,cl + and bx,0fffh + or dx,bx + push dx + push ax + call brk_ + add sp,4 + test ax,ax + jnz brk_error + mov ax,si ;return original value of the break + mov dx,di + pop si + pop di + pret +brk_error: + pop si + pop di + mov dx,ax + pret + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<,> + push di + push si + mov ax,addr + inc ax + and al,-2 + mov dx,aseg + mov bx,ax ; convert to canonical pointer + mov cx,4 + shr bx,cl + and bx,0fffh + and ax,0fh + add dx,bx + cmp dx,_mtop_+2 + ja getstore + jne brk_ok2 + cmp ax,_mtop_ + jnb getstore +brk_ok2: + cmp dx,$MEMRY+2 + ja brk_ok3 + jne chkunder + cmp ax,$MEMRY + jnb brk_ok3 +chkunder: + cmp dx,_mbot_+2 + jb brk_ov + jne getstore + cmp ax,_mbot_ + jb brk_ov +getstore: +; going to do a SETBLOCK call + push ax + mov bx,dx + test ax,ax + jz nobump + inc bx +nobump: + add bx,63 ;bump to nearest 1k increment + and bx,0ffc0h ;and round + push es + push bx + mov cx,_PSP_ + mov es,cx ;set segment for SETBLOCK call + sub bx,cx ;and adjust length appropriately + mov ah,04ah + int 21h ;SETBLOCK + pop bx + pop es + pop ax + jc brk_ov ; couldn't do it, so punt + mov _mtop_+2,bx + mov _mtop_,0 +brk_ok3: + mov $MEMRY,ax + mov $MEMRY+2,dx + sub ax,ax + pop si + pop di + pret +; invalid request +brk_ov: + mov errno_,-4 + mov ax,-1 + test ax,ax + pop si + pop di + pret + pend brk + finish + end + mkdir.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + procdef mkdir,<> +; char *mkdir(name) +; char *name; +; + mov ah,39h +dircommon: + pushds + ldptr dx,namea,ds + int 21h + popds + mov ax,0 + jnc ok + mov errno_,ax + mov ax,-1 +ok: + pret + pend mkdir +; + procdef rmdir,<> + mov ah,3aH + jmp dircommon + pend rmdir +; + procdef chdir,<> + mov ah,3bH + jmp dircommon + pend chdir + finish + end + mon.c + +#include + +short _mon_off; +unsigned _speed = 0; +long _ticks=0; +extern int errno; +extern int _Corg(), _Cend(); + +#define high(x) ((unsigned long)(x)) +#define low(x) ((unsigned long)(x) & 0x0000ffffl) +#define canon(x) (int (*)())(((high(x) >> 12)&0x000fffffl) + low(x)) + +long _ptrdiff(); + +static struct { + short pockets; + short byte_pock; + long lowpc; + long highpc; + int speed; + long time; +} mon_head; + +void _profil(); + +short _monitor (lowpc, highpc, buffer, pockets, nfunc) +int (*lowpc)(), (*highpc)(); +unsigned int *buffer; +int pockets, nfunc; +{ + register int i; + static short pro_flag; + static unsigned int *buff_add, oldsig; + unsigned long tot_bytes, left_over, org; + unsigned int bytes, scale; + int exit(); + FILE *fopen(), *fp; + int (*slowpc)(); + +/* + * offset = lowpc; + * tot_bytes = highpc - lowpc + * range mod pockets = bytes left over + * if (bytes left over) + * pockets * (bytes in range +1) > range + */ + + if (pro_flag) + { + + /*check to see if profiling was turned off by overflow*/ + + if (_mon_off) { + printf ("Bucket number %d overflowed\n", _mon_off); + _mon_off = 0; + } + else + _clkrest(); + + pro_flag = 0; + mon_head.time = _ticks; + if ((fp = fopen ("mon.out", "w")) == NULL) + return (errno); + if ((fwrite (&mon_head, sizeof(mon_head), 1, fp)) != 1) { + printf("\nfunction monitor: error trying to write header data\n"); + fclose (fp); + return(errno); + } + for (i=0; i 121) { + _speed = 9861; + mon_head.speed = 121; + } else if (sp <= 0) { + _speed = 0; + mon_head.speed = 18; + } else { + _speed = DIVSOR / sp; + mon_head.speed = sp; + } +} + monitor.c +short monitor (lowpc, highpc, buffer, pockets, nfunc) +int (*lowpc)(), (*highpc)(); +unsigned int *buffer; +int pockets, nfunc; +{ + return _monitor(lowpc,highpc,buffer,pockets,nfunc); +} + open.c +/* Copyright (C) 1982 1983 1984 by Manx Software Systems */ +#include "errno.h" +#include "fcntl.h" + +extern int errno; +extern char _ioflg[]; + +creat(name, mode) +char *name; +{ + return open(name, O_WRONLY|O_TRUNC|O_CREAT, mode); +} + +open(name, flag, mode) +char *name; +{ + register int fd, m; + + m = 0x3d00 | (flag&0x00f3); + if ((flag&O_TRUNC) != 0) + m = 0x3c00; + + if ((fd = _sys(m,name,0)) == -1) { + if ((flag&O_CREAT) != 0) + fd = _sys(0x3c,name,0); + } else if ((flag&O_EXCL) != 0) { + close(fd); + errno = EEXIST; + return -1; + } + if (fd >= 0) { + if (flag&O_APPEND) + (void)lseek(fd, 0L, 2); + _ioflg[fd] = isatty(fd); /* set flag for i/o routines */ + } + return fd; +} + profil.c +void profil (buff, bufsiz, offset, scale) +char *buff; +int bufsiz; +int (*offset)(); +int scale; +{ + + _profil(buff, bufsiz, offset, scale); + + return; +} + sbegin.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +codeseg segment word public 'code' + public $MEMRY + public _mbot_, _sbot_, _mtop_,_lowwater_ +dataseg segment word public 'data' + extrn _Uorg_:byte,_Uend_:byte +$MEMRY dw offset _Uend_ + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 +_mbot_ dw 0 +_sbot_ dw 0 +_mtop_ dw 0 +_lowwater_ dw -1 + public _PSP_ +_PSP_ dw 0 + extrn _STKSIZ_:word,_HEAPSIZ_:word + extrn _STKLOW_:word,_STKRED_:word +bad8087 db "8087/80287 is required!",13,10,'$' +dataseg ends + +exitad dw 0 +exitcs dw 0 + + assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg +ifdef FARPROC + extrn Croot_:far, $fltinit:far +else + extrn Croot_:near, $fltinit:near +endif + public $begin + public _exit_ +$begin proc far + mov bp,dataseg + test bp,bp + jnz notcom + mov bp,ds +notcom: + mov exitcs,ds + mov bx,[2] ;get top segment + sub bx,bp ;compute size of Data seg + cmp bx,4096 ;check if greater than 64K + jbe smallseg + lea bx,[bp+4096] ;end address of segment (paragraphs) + mov ax,es + sub bx,ax ;compute length of segment + mov ah,4aH ;SETBLOCK system call + int 21H + mov bx,4096 +smallseg: + mov es,bp + mov es:_PSP_,ds + mov cl,4 + shl bx,cl + cmp es:_STKLOW_,0 + je setstk ;stack goes above heap + mov ax,es:_STKRED_ ;stack goes below heap + shl ax,1 ;allow at least twice the RED zone size + mov bx,es:_STKSIZ_ + shl bx,cl ;compute requested stack size + cmp bx,ax ;but don't allow too little + ja sizeok + mov bx,ax +sizeok: + add bx, offset _Uend_ +setstk: + cli + mov ss,bp + mov sp,bx + sti +; + test bx,bx + jnz oksav + mov bx,0ffffh +oksav: + mov es:_mtop_,bx +; now adjust heap size if necessary + cmp es:_STKLOW_,0 ; can't do it unless heap above stack + je heapdone + mov si,es:_HEAPSIZ_ + mov ax,bx + inc ax + mov es:$MEMRY,ax ; start of heap for later + shl si,cl + add bx,si + jnc heapok + mov bx,0ffffh +heapok: + mov es:_mtop_,bx ; and save as _mtop_ + add bx,15 + shr bx,cl ; convert to paragraph form + mov ax,es + add bx,ax ; calculate paragraph address of last byte + mov ax,ds ; now take the paragrph form and + sub bx,ax ;compute length of segment + mov bp,es ;save ES + mov es,ax + mov ah,4aH ;SETBLOCK system call + int 21H + jnc heapdone + mov al,254 + jmp exits +heapdone: + mov es,bp ;restore ES + cld +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + mov es,[2cH] ;get enviroment segment + sub di,di + mov cx,7fffH +arglook: + mov ah,es:byte ptr [di] + cmp ah,'=' ;look for null named env. string + je found_args + test ah,ah + jz no_args +repne scasb ;look for null byte + jz arglook +no_args: + mov cl,[80H] + sub ch,ch + mov si,81H + mov ax,1 + jmp short mov_args +; +found_args: + sub ax,ax + stosb ;zap and skip over '=' + mov si,di + mov di,es + mov ds,di +mov_args: + push ax ;first arg # for Croot + mov es,bp ;reload ES with our real dataseg + mov di,es:$MEMRY + push di ;argp for Croot + jcxz cpy_done +cpy_args: ;copy argument string to work buffer + lodsb + test al,al + jz cpy_done + stosb + loop cpy_args +cpy_done: + sub al,al + stosb ;null terminate string + mov ds,bp ;set DS, now DS, SS, ES are equal + inc di + and di,0fffeH ;adjust to word boundary + mov $MEMRY,di ;save memory allocation info for sbrk() + mov _mbot_,di + mov _sbot_,offset _Uend_ + cmp _STKLOW_,0 + jnz nostk + mov _sbot_,di +nostk: + mov ax,_sbot_ + add ax,_STKRED_ + mov _sbot_,ax + mov _dsval_,ds + mov _csval_,cs + call $fltinit + jc no_8087 + call Croot_ ;Croot(argp, first) + jmp short exits +; +no_8087: + mov ah,9 ;dos print message + mov dx,offset bad8087 + int 21h ;tell the user about it + mov al,253 + jmp short exits + +_exit_: + pop ax + pop ax ;fetch return code +ifdef FARPROC + pop ax +endif +exits: + mov ah,4cH + int 21H + jmp dword ptr exitad +$begin endp + +retip dw 0 +retcs dw 0 + + public $dbgentry +$dbgentry proc far + pop cs:retip + pop cs:retcs ; save return address into debugger + pop ds ;set DS + call caller + jmp dword ptr cs:retip ; return to debugger +$dbgentry endp + +caller proc + push di ;CS value of local function + push si ;IP value call local function + db 0cbH ;far return instruction +caller endp + +codeseg ends + end $begin + sigfix.asm +; Copyright (C) 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' + public _brkvec_ +_brkvec_ dw 0,0 +dataseg ends + + assume ds:dataseg +; +; This routine is used by exec (used by execl, execv, etc.) +; to reset any signal handlers which have been setup. +; + procdef _sigfix + cmp _brkvec_+2,0 + je brk_ok + push ds + lds dx,dword ptr _brkvec_ + mov ax,2523H ;restore old cntl-break handler + int 21H + pop ds +brk_ok: + pret + pend _sigfix + + finish + end + sighand.asm +; Copyright (C) 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' + extrn _PSP_:word + extrn _brkvec_:word + extrn _sigfuns_:word +ifdef FARPROC + bss temp:word,4 ;used for far call to handler +endif +saveds dw 0 +dataseg ends + +ourds dw 0 + + assume ds:dataseg +; + procdef _sig_setup + mov ourds,ds + cmp _brkvec_+2,0 + jne have_brk + push ds + mov ax,3523H ;get cntl-break (cntl-c) handler + int 21H + mov _brkvec_,bx + mov _brkvec_+2,es + mov dx,offset brk_handler + mov ax,cs + mov ds,ax + mov ax,2523H ;set new cntl-break handler + int 21H + pop ds +have_brk: + pret + pend _sig_setup + +brk_handler proc far + push ds + mov ds,ourds +ifdef FARPROC + cmp _sigfuns_+2,0 + jne chk_ignore + cmp _sigfuns_,0 + jne chk_ignore +else + cmp _sigfuns_,0 + jne chk_ignore +endif + + pop saveds ;get ds from the stack + push _brkvec_+2 + push _brkvec_ + mov ds,saveds + ret + +chk_ignore: +ifdef FARPROC + cmp _sigfuns_,1 + jne not_ignore + cmp _sigfuns_+2,0 + je ignore +not_ignore: +else + cmp _sigfuns_,1 + je ignore +endif + cld + push es + push ax + push bx + mov ax,sp + mov bx,ss + mov es,_PSP_ + mov ss,es:[30h] ;get our last ss:sp from place + mov sp,es:[2eh] ;where DOS saves it + push ax + push bx + push cx + push dx + push si + push di + mov ax,1 ;signal #1 + push ax +ifdef FARPROC + mov ax,_sigfuns_+2 + mov temp+2,ax + mov ax,_sigfuns_ + mov temp,ax + mov _sigfuns_,0 ;set SIG_DFL + mov _sigfuns_+2,0 + sti + call dword ptr temp +else + mov ax,_sigfuns_ + mov _sigfuns_,0 ;set SIG_DFL + sti + call ax +endif + pop ax ;throw away argument + pop di + pop si + pop dx + pop cx + pop bx + pop ax + mov ss,bx ;restore to system stack + mov sp,ax + pop bx + pop ax + pop es + +ignore: + pop ds + iret +brk_handler endp + finish + end + ssbrk.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h +dataseg segment word public 'data' + extrn $MEMRY:word + extrn _mbot_:word, _sbot_:word + extrn _mtop_:word + extrn errno_:word + extrn _STKLOW_:word + extrn _STKRED_:word + extrn _PSP_:word +dataseg ends + assume ds:dataseg +; +; sbrk(size): return address of current top & bump by size bytes +; + procdef sbrk,<> + push di + mov ax,siz + mov di,$MEMRY + test ax,ax + jge addok + sub di,ax + jc invalid + jmp short dobrk +addok: + add ax,di + jc invalid +dobrk: + push ax + call brk_ + pop cx + test ax,ax + jnz brk_error + mov ax,di ;return original value of the break +brk_error: + pop di + test ax,ax ;set flags for C + pret +invalid: + mov errno_,-8 + mov ax,-1 + jmp brk_error + pend sbrk +; +; brk(addr): set current top address to addr +; returns 0 if ok, -1 if error +; + procdef brk,<> + mov ax,addr + inc ax + and al,-2 + cmp ax,_mbot_ + jb brk_ov + cmp _STKLOW_,0 + jne abovestk + mov bx,sp + sub bx,_STKRED_ + cmp ax,bx + jae brk_ov + mov $MEMRY,ax ;new value is good so save it away + add ax,_STKRED_ + mov _sbot_,ax ;save as new value for safety check +brk_ok2: + sub ax,ax + pret +;heap is above stack +abovestk: + cmp ax,_mtop_ + ja getstore + cmp ax,$MEMRY + jb getstore + mov $MEMRY,ax ;new value is good so save it away + jmp brk_ok2 +; going to do a SETBLOCK call +getstore: + push ax + mov bx,ax + mov cx,4 + shr bx,cl + and bx,0fffh + add bx,65 ;bump to nearest 1k increment + and bx,0ffc0h ;and round + push bx + push es + mov cx,ds + add bx,cx ;get actual paragraph address + mov es,_PSP_ + sub bx,_PSP_ + mov ah,04ah + int 21h ;SETBLOCK + pop es + pop bx + pop ax + jc brk_ov ; couldn't do it, so punt + mov $MEMRY,ax + test bx,0e000h + jnz brk_ov + mov cx,4 + shl bx,cl + mov _mtop_,bx + sub ax,ax + pret +; invalid request +brk_ov: + mov errno_,-8 + mov ax,-1 + test ax,ax + pret + pend brk +; +; rsvstk(size): set safety margin for stack +; this will make sure that at least size +; bytes of stack below the current level remain. +; + procdef rsvstk,<> + mov ax,sp + sub ax,stksize + mov _STKRED_,ax + pret + pend rsvstk + finish + end + stat.c +#include + +stat(path, buf) +char *path; register struct stat *buf; +{ + struct { + char rsvd[21]; + char attr; + long time; + long size; + char name[13]; + } sbuf; + + _sys(0x1a,&sbuf); + if (_sys(0x4e,path,~ST_VLABEL) == -1) + return -1; + buf->st_attr = sbuf.attr; + buf->st_mtime = sbuf.time; + buf->st_size = sbuf.size; + return 0; +} + + stkover.c + +_stkover() +{ + write(2, "STACK OVERFLOW, INCREASE STACK SIZE\n", 36); + _exit(100); +} + stksiz.c +#if sizeof(char *) == 4 +int _STKSIZ = 8192/16; /* (in paragraphs) (large data model) */ +int _STKRED = 1024; /* size of RED zone (in bytes) */ +#else +int _STKSIZ = 4096/16; /* (in paragraphs) */ +int _STKRED = 2048; /* size of RED zone (in bytes) */ +#endif + +int _HEAPSIZ = 4096/16; /* (in paragraphs) */ +int _STKLOW = 0; /* default is stack above heap (small only) */ + +/* +NOTE: The RED zone is used for stack saftey checking. With stack above heap, +the heap will not be allowed to get within STKRED bytes of the current value +of the SP, if limit checking is enabled (see the cc +b option), SP isn't +allowed any closer than STKRED bytes to the top of the heap. If stack below +heap and limit checking is enabled, SP isn't allowed any closer than STKRED +bytes to _Utop. Minimum stack size = 2*_STKRED. Minimum value for STKRED +should be about 256 bytes. This allows some margin to issue DOS calls and +allow interrupt handlers to execute. (Some people think that this should +be > 1k.) */ + sys.asm +;Copyright (C) 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + assume ds:dataseg + + procdef _sys,<,,> + mov ax,func + test ah,ah + jnz valok + xchg ah,al +valok: + cmp ah,10 + jb simple +; + push si + pushds + push es + cmp ah,47H ;check for getcwd call + jne not_cwd + mov dx,arg2 ;load drive # into DX + ldptr si,arg,ds + jmp short issue +not_cwd: + mov cx,arg2 + ldptr dx,arg,ds +issue: + int 21H + mov dx,es + pop es + popds + jnc noerror + mov errno_,ax + mov ax,-1 + mov dx,ax +noerror: + pop si + pret +; +simple: + mov dx,word ptr arg + int 21H + and ax,0ffH + pret + pend _sys + finish + end + syserr.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char *sys_errlist[] = { + /* MsDos error codes */ + "No error", + "Invalid function number", + "File not found", + "Path not found", + "Too many open files", + "Access denied", + "Bad file handle", + "Memory control blocks destroyed", + "Insufficient memory", + "Invalid memory block address", + "Invalid environment", + "Invalid format", + "Invalid access code", + "Invalid data", + "", + "Invalid drive", + "Attempt to remove the current directory", + "Not same device", + "No more files", + + /* additional codes for Aztec C */ + "File exists", + "Not a console device", + /* math library */ + "Result too large", + "Argument out of domain" +}; + +int sys_nerr = sizeof (sys_errlist) / sizeof (char *); + system.c +/* Copyright (C) 1984 by Manx Software Systems */ + +static int swt_char; + +system(cmd) +char *cmd; +{ + register char *prog; + char *getenv(); + char buffer[130]; + +#asm + mov ax,3700h ;ask dos for current switch character + int 21h + sub dh,dh + mov swt_char_,dx +#endasm + if ((prog = getenv("COMSPEC")) == 0) + prog = "/command.com"; + sprintf(buffer+1, "%cC %.123s\r", swt_char, cmd); + buffer[0] = strlen(buffer+1) - 1; + if (fexec(prog,0,buffer,(char *)0,(char *)0) == -1) + return -1; + return wait(); +} + time.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef time,<> ;time_t time(time_t *tloc) +; if tloc!=0 then time is also stored there +; + mov ah,2aH + int 21h + sub cx,1980 + mov ax,cx + mov cl,9 + shl ax,cl + and dh,15 + and dl,31 + mov cl,3 + shl dl,cl + shr dx,cl + or ax,dx + push ax ;save across system call +; + mov ah,2cH + int 21H + mov ax,cx + and ah,31 + and al,63 + and dh,63 + shr dh,1 ;divide seconds by two + shl al,1 ;move minutes over 2 bits + shl al,1 + mov cl,3 ;now move minutes & hours over 3 bits + shl ax,cl + or al,dh ;or the seconds/2 into the bottom 5 bits +; + pop dx ;restore the date info as the high word + ldptr bx,tloc,es ;get tloc +ifdef LONGPTR + mov cx,es + or cx,bx +else + test bx,bx +endif + jz done +ifdef LONGPTR + mov es:[bx],ax + mov es:2[bx],dx +else + mov ds:[bx],ax + mov ds:2[bx],dx +endif +done: + pret + pend time + finish + end + ttyio.c +/* Copyright (C) 1983, 1984 by Manx Software Systems */ +#include "errno.h" + +extern int errno; + +char _Eol = '\n'; +int _TTrem; /* # of bytes remaining in tty buffer */ + +__tty_rd(fd,buff,len) +char *buff; +{ + static char buffer[260], *bp; + register int l; + + if ((l = _TTrem) == 0) { + if ((l = _read(fd, buffer, 260)) != 0 && buffer[l-1]=='\n') { + --l; + buffer[l-1] = _Eol; + } + bp = buffer; + _TTrem = l; + } + if (l > len) + l = len; + if (l) + movmem(bp, buff, l); + bp += l; + _TTrem -= l; + return l; +} + +__tty_wr(fd, buff, len) +char *buff; +{ + register int count; + register char *cp; + static char crbuf = '\r'; + + cp = buff; + for (count = len ; count-- ; ) { + if (*cp++ == '\n') { + _write(fd, buff, cp-buff); + _write(fd, &crbuf, 1); + buff = cp; + } + } + if (cp != buff) + _write(fd, buff, cp-buff); + return len; +} + utime.c +/* Copyright (C) 1984 by Manx Software Systems */ + +struct utimbuf { + long actime; /* access time (not used on Msdos) */ + long modtime; /* modification time */ +}; + +utime(path, times) +char *path; register struct utimbuf *times; +{ + long time(), ftime(); + register int fd, r; + + if ((fd = open(path, 0)) == -1) + return -1; + r = ftime(1, fd, times ? times->modtime : time(0)); + close(fd); + return r; +} + wait.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef wait + mov ah,4dh + int 21h + jnc noerr + neg ax +noerr: + pret + pend wait + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/G.ARC b/Manx Aztec C86 v42b/ARC/G.ARC new file mode 100644 index 0000000..de6bbee --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/G.ARC @@ -0,0 +1,876 @@ + makefile +# Copyright (C) Manx Software Systems, Inc. 1987. All rights reserved. + +# Note: the object files below are in the correct order for linking, +# thus the OBJ macro should be changed with caution. If you are in doubt, +# use the ORD utility to build a correctly ordered list. + +OBJ=mode.o circ.o lin.o point.o address.o scr_call.o + +CC=cc +AS=as +MODEL= +AMODEL=0 + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +$(DIR)g$(MODEL).lib: $(OBJ) + del $(DIR)g$(MODEL).lib + lb $(DIR)g$(MODEL).lib $(OBJ) + @echo graphics done + address.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 +dataseg segment word public 'data' + + public $address + +$address equ this word ;/* vertical address table */ + dw 7920+8192 + dw 7920 + dw 7840+8192 + dw 7840 + dw 7760+8192 + dw 7760 + dw 7680+8192 + dw 7680 + dw 7600+8192 + dw 7600 + dw 7520+8192 + dw 7520 + dw 7440+8192 + dw 7440 + dw 7360+8192 + dw 7360 + dw 7280+8192 + dw 7280 + dw 7200+8192 + dw 7200 + dw 7120+8192 + dw 7120 + dw 7040+8192 + dw 7040 + dw 6960+8192 + dw 6960 + dw 6880+8192 + dw 6880 + dw 6800+8192 + dw 6800 + dw 6720+8192 + dw 6720 + dw 6640+8192 + dw 6640 + dw 6560+8192 + dw 6560 + dw 6480+8192 + dw 6480 + dw 6400+8192 + dw 6400 + dw 6320+8192 + dw 6320 + dw 6240+8192 + dw 6240 + dw 6160+8192 + dw 6160 + dw 6080+8192 + dw 6080 + dw 6000+8192 + dw 6000 + dw 5920+8192 + dw 5920 + dw 5840+8192 + dw 5840 + dw 5760+8192 + dw 5760 + dw 5680+8192 + dw 5680 + dw 5600+8192 + dw 5600 + dw 5520+8192 + dw 5520 + dw 5440+8192 + dw 5440 + dw 5360+8192 + dw 5360 + dw 5280+8192 + dw 5280 + dw 5200+8192 + dw 5200 + dw 5120+8192 + dw 5120 + dw 5040+8192 + dw 5040 + dw 4960+8192 + dw 4960 + dw 4880+8192 + dw 4880 + dw 4800+8192 + dw 4800 + dw 4720+8192 + dw 4720 + dw 4640+8192 + dw 4640 + dw 4560+8192 + dw 4560 + dw 4480+8192 + dw 4480 + dw 4400+8192 + dw 4400 + dw 4320+8192 + dw 4320 + dw 4240+8192 + dw 4240 + dw 4160+8192 + dw 4160 + dw 4080+8192 + dw 4080 + dw 4000+8192 + dw 4000 + dw 3920+8192 + dw 3920 + dw 3840+8192 + dw 3840 + dw 3760+8192 + dw 3760 + dw 3680+8192 + dw 3680 + dw 3600+8192 + dw 3600 + dw 3520+8192 + dw 3520 + dw 3440+8192 + dw 3440 + dw 3360+8192 + dw 3360 + dw 3280+8192 + dw 3280 + dw 3200+8192 + dw 3200 + dw 3120+8192 + dw 3120 + dw 3040+8192 + dw 3040 + dw 2960+8192 + dw 2960 + dw 2880+8192 + dw 2880 + dw 2800+8192 + dw 2800 + dw 2720+8192 + dw 2720 + dw 2640+8192 + dw 2640 + dw 2560+8192 + dw 2560 + dw 2480+8192 + dw 2480 + dw 2400+8192 + dw 2400 + dw 2320+8192 + dw 2320 + dw 2240+8192 + dw 2240 + dw 2160+8192 + dw 2160 + dw 2080+8192 + dw 2080 + dw 2000+8192 + dw 2000 + dw 1920+8192 + dw 1920 + dw 1840+8192 + dw 1840 + dw 1760+8192 + dw 1760 + dw 1680+8192 + dw 1680 + dw 1600+8192 + dw 1600 + dw 1520+8192 + dw 1520 + dw 1440+8192 + dw 1440 + dw 1360+8192 + dw 1360 + dw 1280+8192 + dw 1280 + dw 1200+8192 + dw 1200 + dw 1120+8192 + dw 1120 + dw 1040+8192 + dw 1040 + dw 960+8192 + dw 960 + dw 880+8192 + dw 880 + dw 800+8192 + dw 800 + dw 720+8192 + dw 720 + dw 640+8192 + dw 640 + dw 560+8192 + dw 560 + dw 480+8192 + dw 480 + dw 400+8192 + dw 400 + dw 320+8192 + dw 320 + dw 240+8192 + dw 240 + dw 160+8192 + dw 160 + dw 80+8192 + dw 80 + dw 0+8192 + dw 0 + +dataseg ends + end + circ.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + +aldx dw 0 +aldy dw 0 + + public _yaspect_,_xaspect_ +_yaspect_ dw 5 +_xaspect_ dw 6 + +scale dw 1024 +scale2 dw 512 + + +aspect dw 0 ;function computed aspect (scaled) +invasp dw 0 ;reciprocal of aspect (scaled too) + +xorg dw 0 +yorg dw 0 +radius dw 0 + +dataseg ends + + assume ds:dataseg +;-------------------------------------------------------- +;procedure circle(x,y,radius) +; +;draws a circle at center (x,y) with aspect ratio +;yaspect/xaspect; radius in column units +; +;Dan Lee 7/1/1982 SourceWare +;Modified from DDJ May '83 for CI C-86 by Davin 6/22/1983 +;remodified for Aztec C86, 6/84 +; +;-------------------------------------------------------- +ifdef FARPROC + extrn $inline:far,$pnt:far +else + extrn $inline:near,$pnt:near +endif + procdef set_asp,<,> + ;set_asp (x_aspect, y_aspect); + mov ax, x_asp + mov [_xaspect_],ax + mov ax, y_asp + mov [_yaspect_],ax + pret + pend set_asp + + procdef circle,<<_xorg,word>,<_yorg,word>,> + + mov cx,_xorg + mov [xorg],cx + mov dx,_yorg + mov [yorg],dx + mov ax,irad + pop bp + push es + push si + push di ;save register variables + or ax,ax + jnz okrad + jmp single +okrad: mov [radius],ax + mov ax,_yaspect_ ;get yaspect + mul [scale] ;ax=yaspect*scale + shl ax,1 + div _xaspect_ ;ax=(yaspect*scale)/xaspect + inc ax + shr ax,1 + mov [aspect],ax ;store aspect*scale + mov ax,_xaspect_ ;get xaspect in ax + mul [scale] ;ax=xaspect*scale + shl ax,1 + div _yaspect_ ;ax=(xaspect*scale)/yaspect + inc ax + shr ax,1 + mov [invasp],ax ;store inv aspect*scale +; +; Plot 0 to 45 degrees. +; Increase y by one unit and +; decrease x by TAN units*inv aspect ratio. +; + mov ax,[radius] ;get radius for initial x + mul [scale] ;ax=radius*scale + xor di,di ;zero initial y value + +nlp1: push ax ;save lo word x*scale + push dx ;save hi word x*scale + add ax,[scale2] + adc dx,0 + div [scale] + mov [aldx],ax ; aldx,aldy are old relative coord's + mov [aldy],di + pop dx + pop ax + +lp1: push ax ;save lo word x*scale + push dx ;save hi word x*scale + add ax,[scale2] + adc dx,0 + div [scale] + mov bx,ax ;bx=1st quad x + add ax,[xorg] ;add x origin + + push bp + push di ;relative y-coord + push bx ;relative x-coord + mov bp,sp + mov bx,[yorg] ;get y origin + sub bx,di ;and sub y to plot + call pnt1 + pop cx ;1st quad x val + pop di + mov [aldx],cx + mov [aldy],di + pop bp + +;cx = 1st quad x, di = 1st quad y + inc di ;get new y + mov ax,di ;ax=y + mul [invasp] ;ax=y*inv aspect*scale + div cx ;ax=TAN*inv aspect*scale + xor dx,dx ;zero remainder + mov si,ax ;si=TAN*inv aspect*scale + div [invasp] ;ax=TAN + cmp ax,1 ;TAN=1? + pop dx ;dx=hi word x*scale + pop ax ;ax=lo word x*scale + jae part2 ;yes, go to next sector + neg si ;to decrement x + add ax,si ;new x value + adc dx,-1 ;hi word carry + jmp short lp1 ;plot new point +; +; Plot 45 to 90 degrees. +; Decrease x by one unit and +; increase y by COT units*aspect ratio. +; +part2: mov ax,di ;get next y to plot + mul [scale] ;dx:ax=y*scale + mov di,cx ;di=last x value + dec di ;next x to plot +lp2: push ax ;save lo word y*scale + push dx ;save hi word y*scale + add ax,[scale2] ;'one-half' + adc dx,0 + div [scale] ;ax=y + mov bx,ax ;bx=1st quad y co-ord + + add ax,[yorg] ;add y origin + mov cx,[xorg] ;cx=x origin + add cx,di ;x to plot + + push bp + push bx + push di + mov bp,sp + mov bx,ax + mov ax,cx + call pnt2 + pop di + pop bx + mov [aldx],di + mov [aldy],bx + pop bp + + or di,di ;90 degrees? + js exit ;yes, exit + dec di ;get new x + mov ax,di ;ax=x + imul [aspect] ;ax=x*aspect*scale + idiv bx ;ax=COT*aspect*scale + mov si,ax ;si=change in y + pop dx ;dx=hi word y*scale + pop ax ;ax=lo word y*scale + xor bx,bx + or si,si ;for sign check + jns skp ;positive + mov bx,-1 ;negative carry +skp: add ax,si ;ax=new x value + adc dx,bx + jmp short lp2 ;plot next point + +exit: add sp,4 ;release parms + jmp alldone + +pnt1 proc near +;bp points to rel x coord and bp+2 points to rel y coord +;abs coords of point are in ax,bx + + mov si,[aldx] + add si,[xorg] ;si is old abs x + mov di,[yorg] + mov cx,[aldy] + sub di,cx ;di is old abs y + + call $goinline ;write 1st quad point + sub ax,word ptr [bp] ;get 2nd quad x+origin + sub ax,word ptr [bp] + sub si,[aldx] + sub si,[aldx] + call $goinline ;write 2nd quad point + add bx,word ptr 2[bp] ;get 3rd quad y+origin + add bx,word ptr 2[bp] + add di,[aldy] + add di,[aldy] + call $goinline ;write 3rd quad point + add ax,word ptr [bp] + add ax,word ptr [bp] ;get 4th quad x+origin + add si,[aldx] + add si,[aldx] + call $goinline ;plot 4th quad point + ret +pnt1 endp + +pnt2 proc near + mov si,[aldx] + add si,[xorg] + mov di,[yorg] + add di,[aldy] + + call $goinline ;write 1st quad point + sub ax,word ptr [bp] ;get 2nd quad x+origin + sub ax,word ptr [bp] + sub si,[aldx] + sub si,[aldx] + call $goinline ;write 2nd quad point + sub bx,word ptr 2[bp] ;get 3rd quad y+origin + sub bx,word ptr 2[bp] + sub di,[aldy] + sub di,[aldy] + call $goinline ;write 3rd quad point + add ax,word ptr [bp] + add ax,word ptr [bp] ;get 4th quad x+origin + add si,[aldx] + add si,[aldx] + call $goinline ;plot 4th quad point + ret +pnt2 endp + +single: + mov si,cx + mov di,dx + call $pnt +alldone: + pop di + pop si + pop es + ret + +$goinline proc near + push ax + push bx + push si + push di + call $inline ;pops es,di,si + pop di + pop si + pop bx + pop ax + ret +$goinline endp + + pend circle + finish + end + lin.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + + extrn _oldx_:word, _oldy_:word + +deltax dw 0 +deltay dw 0 +yincr dw 0 + +dataseg ends + assume ds:dataseg +ifdef FARPROC + extrn $pnt:far +else + extrn $pnt:near +endif + + public $inline +$inline proc + cmp si,ax + jbe noxchg + xchg si,ax + xchg di,bx +noxchg: + jne novert + jmp vertical +novert: + sub ax,si + mov [deltax],ax + sub bx,di + jnz nohoriz + jmp horizontal +nohoriz: + mov cx,1 + jns notneg + neg cx + neg bx +notneg: mov [yincr],cx + mov [deltay],bx + cmp ax,bx + jg case2 + + mov dx,[deltax] + shl dx,1 + mov bx,dx + mov ax,[deltay] + shl ax,1 + sub bx,ax + mov ax,dx + sub ax,[deltax] + + mov cx,[deltay] +lp1: dec cx + js done + call $pnt + add di,[yincr] + cmp ax,0 + jl incr1 + inc si + add ax,bx + jmp short lp1 +incr1: + add ax,dx + jmp short lp1 + +case2: + + mov dx,[deltay] + shl dx,1 ;dx <- 2 * deltay + mov bx,dx + mov ax,[deltax] + shl ax,1 + sub bx,ax ;bx <- 2*deltay - 2 * deltax + mov ax,dx + sub ax,[deltax] ;ax <- 2*deltay - deltax + + mov cx,[deltax] +lp2: dec cx + js done + call $pnt + inc si + cmp ax,0 + jl incr2 + add di,[yincr] + add ax,bx + jmp short lp2 +incr2: + add ax,dx + jmp short lp2 + +vertical: ;si = xval, di,bx = yvals + cmp di,bx + jle yorder + xchg bx,di +yorder: + sub bx,di +vplot: + call $pnt + inc di + dec bx + jns vplot + jmp short done + +horizontal: ;ax=deltax, si,di = start point + call $pnt + inc si + dec ax + jns horizontal + ;jmp short done + +done: + ret +$inline endp + + procdef lineto,<,> + + ; lineto (dest_x, dest_y); + push si + push di + push es + mov si,[_oldx_] + mov di,[_oldy_] + mov ax,xdest + mov bx,ydest + mov [_oldx_],ax + mov [_oldy_],bx + call $inline ;pops si,di,es before returning + pop es + pop di + pop si + pret + pend lineto + + procdef line,<,,,> + ; line (src_x, src_y, dest_x, dest_y); + push si + push di + push es + mov si,srcx + mov di,srcy + mov ax,ddstx + mov bx,ddsty + mov [_oldx_],ax + mov [_oldy_],bx + call $inline + pop es + pop di + pop si + pret + pend line + finish + end + mode.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ + +extern int _maxx; +extern int _xaspect, _yaspect; +extern char _color; +extern int _plotf,_plottbl[]; + +mode (val) +{ + switch (val) { + case 'l': case 'L': case 3: + scr_call (3); + break; + case 'm': case 'M': case 4: + _plotf = _plottbl[0]; + _xaspect = 6; + _yaspect = 5; + _maxx = 319; + scr_call (4); + break; + case 'h': case 'H': case 6: + _plotf = _plottbl[1]; + _xaspect = 4; + _yaspect = 1; + _maxx = 639; + scr_call (6); + break; + default: + if (val < 0 || val > 6) + return; + scr_call (val); + break; + } +} + +color (c) +{ + switch (c) { + case 'w': case 'W': case 'y': case 'Y': case 3: + _color = 3; + break; + case 'm': case 'M': case 'r': case 'R': case 2: + _color = 2; + break; + case 'c': case 'C': case 'g': case 'G': case 1: + _color = 1; + break; + default: + _color = 0; + break; + } +} + +palette (c) +{ + if (c) + scr_call (11 << 8,1<<8 | 1,0,0); + else + scr_call (11 << 8,1<<8 | 0,0,0); +} + +ground (c) +{ + scr_call (11 << 8, 0 << 8 | c,0,0); +} + point.asm +; Copyright (C) 1984 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + + extrn $address:word + public _oldx_,_oldy_,_color_,_maxx_ + _oldx_ dw 0 + _oldy_ dw 0 + _color_ db 1 + _maxx_ dw 320 + public _plotf_, _plottbl_ + public mid,ultra + public clrmsk,colmsk + +clrmsk db 00111111b,11001111b,11110011b,11111100b + ;/* clrmsk for point mode 0 */ + +onmask db 10000000b,1000000b,100000b,10000b,1000b,100b,10b,1b +offmask db 01111111b,10111111b,11011111b,11101111b + db 11110111b,11111011b,11111101b,11111110b + +colmsk db 0,0,0,0 ;/* color_ masks */ + db 1000000b,10000b,100b,1 + db 10000000b,100000b,1000b,10b + db 11000000b,110000b,1100b,11b + +_plottbl_ dw offset mid ;medium res + dw offset ultra ;high res + +_plotf_ dw offset ptquit + +dataseg ends + assume ds:dataseg,cs:codeseg + + public $pnt +$pnt proc + cmp si,[_maxx_] ;si=x,di=y does not set oldx & oldy + ja quit + cmp si,0 + jb quit + cmp di,199 + ja quit + cmp di,0 + jnb $pnt3 + jmp quit +$pnt3: + push ax + push bx + mov bl,[_color_] ;entry #3 si=x,di=y no clipping ! +$pnt4: + mov bh,0 +;entry #5 si=x,di=y,bx=color_ +; +$pnt5: mov ax,0b800h ; set es to point to hires segment + mov es,ax + push di + shl di,1 ;mult y*2 (addr table is 2 bytes wide) + jmp [_plotf_] ;jmp to ptquit, mid or ultra + +mid: push si + + mov di,$address[di] ;get vert address from table + + mov ax,si ;save x in si + + and si,3 + shr ax,1 ;divide by 4 (4 dots per byte) + shr ax,1 + + add di,ax ;get addr of byte on screen + + sal bl,1 ; color_ table is 4 by 4 so mult color_ * 4 + sal bl,1 + mov bl,colmsk[si+bx] + mov al,clrmsk[si] + and es:[di],al + or es:[di],bl + pop si +ptquit: pop di + pop bx + pop ax +quit: + ret + +ultra: mov di,$address[di] + mov ax,si + push si + and si,7 + shr ax,1 + shr ax,1 + shr ax,1 + add di,ax + or bl,bl + jz black + mov al,onmask[si] + or es:[di],al + pop si + jmp short ptquit +black: mov al,offmask[si] + and es:[di],al + pop si + jmp short ptquit + + + procdef point,<,> + + push si + push di + push es + mov si,xcoord + mov di,ycoord + + mov [_oldx_],si ;si=x,di=y sets oldx and oldy + mov [_oldy_],di + call $pnt + + pop es + pop di + pop si + pret + pend point + finish + end + scr_call.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +; +; scr_call(ax,bx,cx,dx) - issue int 10 with ax,... set to args +; +; + procdef scr_call,<,,,> + push si + push di + mov ax,aax + mov bx,bbx + mov cx,ccx + mov dx,ddx + int 10h + pop di + pop si + pret + pend scr_call + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/MATH.ARC b/Manx Aztec C86 v42b/ARC/MATH.ARC new file mode 100644 index 0000000..4ee0306 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/MATH.ARC @@ -0,0 +1,5754 @@ + makefile +OBJ=asin.o atan.o exp.o fabs.o floor.o log.o pow.o random.o\ + sin.o sinh.o sqrt.o tan.o tanh.o atof.o ftoa.o\ + fpst.o frexp.o fsubs.o sqrt87s.o frexp87s.o fsubs87s.o + +OBJ87=asin87.o atan87.o exp87.o fabs87.o floor87.o log87.o pow87.o random87.o\ + exp1087.o sin87.o sinh87.o sqrt87.o tan87.o tanh87.o atof87.o ftoa87.o\ + fmod87.o chk87.o frexp87.o isnan.o fpst.o fsubs87.o + +CC=cc +AS=as +MODEL= +AMODEL=0 + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +bld bldlc bldld bldl: $(OBJ) + @echo math done + +bld87 bld87lc bld87ld bld87l: $(OBJ87) + @echo math87 done + +atof87.o: atof.asm + $(AS) -dMODEL=$(AMODEL) -dINLINE atof.asm -o $@ + sqz $@ + +ftoa87.o: ftoa.asm + $(AS) -dMODEL=$(AMODEL) -dINLINE ftoa.asm -o $@ + sqz $@ + +asin87.o: asin.c + $(CC) +$(MODEL) -n +e asin.c -o $@ + sqz $@ +fabs87.o: fabs.c + $(CC) +$(MODEL) -n +e fabs.c -o $@ + sqz $@ +floor87.o: floor.c + $(CC) +$(MODEL) -n +e floor.c -o $@ + sqz $@ +pow87.o: pow.c + $(CC) +$(MODEL) -n +e pow.c -o $@ + sqz $@ +random87.o: random.c + $(CC) +$(MODEL) -n +e random.c -o $@ + sqz $@ +sinh87.o: sinh.c + $(CC) +$(MODEL) -n +e sinh.c -o $@ + sqz $@ +sqrt87.o: sqrt.c + $(CC) +$(MODEL) -n +e sqrt.c -o $@ + sqz $@ +tanh87.o: tanh.c + $(CC) +$(MODEL) -n +e tanh.c -o $@ + sqz $@ + + asin.c +#include "math.h" +#include "errno.h" + +static double arcsine(); + +double asin(x) +double x; +{ + return arcsine(x,0); +} + +double acos(x) +double x; +{ + return arcsine(x,1); +} + +#define P1 -0.27368494524164255994e+2 +#define P2 +0.57208227877891731407e+2 +#define P3 -0.39688862997504877339e+2 +#define P4 +0.10152522233806463645e+2 +#define P5 -0.69674573447350646411 +#define Q0 -0.16421096714498560795e+3 +#define Q1 +0.41714430248260412556e+3 +#define Q2 -0.38186303361750149284e+3 +#define Q3 +0.15095270841030604719e+3 +#define Q4 -0.23823859153670238830e+2 + +#define P(g) ((((P5*g P4)*g P3)*g P2)*g P1) +#define Q(g) (((((g Q4)*g Q3)*g Q2)*g Q1)*g Q0) + +static double arcsine(x,flg) +double x; +{ + double y, g, r; + register int i; + extern int errno; + static double a[2] = { 0.0, 0.78539816339744830962 }; + static double b[2] = { 1.57079632679489661923, 0.78539816339744830962 }; + + y = fabs(x); + i = flg; + if (y < 2.3e-10) + r = y; + else { + if (y > 0.5) { + i = 1-i; + if (y > 1.0) { + errno = EDOM; + return 0.0; + } + g = (0.5-y)+0.5; + g = ldexp(g,-1); + y = sqrt(g); + y = -(y+y); + } else + g = y*y; + r = y + y* + ((P(g)*g) + /Q(g)); + } + if (flg) { + if (x < 0.0) + r = (b[i] + r) + b[i]; + else + r = (a[i] - r) + a[i]; + } else { + r = (a[i] + r) + a[i]; + if (x < 0.0) + r = -r; + } + return r; +} + atan.c +#include "math.h" +#include "errno.h" + +#ifdef MPU8086 +#define MAXEXP 1024 +#define MINEXP -1023 +#else +#define MAXEXP 504 +#define MINEXP -512 +#endif + +#define PI 3.14159265358979323846 +#define PIov2 1.57079632679489661923 + +double atan2(v,u) +double u,v; +{ + double f, frexp(); + int vexp, uexp; + extern int flterr; + extern int errno; + + if (u == 0.0) { + if (v == 0.0) { + errno = EDOM; + return 0.0; + } else if (v > 0.0 ) + return PIov2; + return -PIov2; + } + + frexp(v, &vexp); + frexp(u, &uexp); + if (vexp-uexp > MAXEXP-3) /* overflow */ + f = PIov2; + else { + if (vexp-uexp < MINEXP+3) /* underflow */ + f = 0.0; + else + f = atan(fabs(v/u)); + if (u < 0.0) + f = PI - f; + } + if (v < 0.0) + f = -f; + return f; +} + +#define P0 -0.13688768894191926929e+2 +#define P1 -0.20505855195861651981e+2 +#define P2 -0.84946240351320683534e+1 +#define P3 -0.83758299368150059274e+0 +#define Q0 +0.41066306682575781263e+2 +#define Q1 +0.86157349597130242515e+2 +#define Q2 +0.59578436142597344465e+2 +#define Q3 +0.15024001160028576121e+2 + +#define P(g) (((P3*g P2)*g P1)*g P0) +#define Q(g) ((((g Q3)*g Q2)*g Q1)*g Q0) + +double atan(x) +double x; +{ + double f, r, g; + int n; + static double Avals[4] = { + 0.0, + 0.52359877559829887308, + 1.57079632679489661923, + 1.04719755119659774615 + }; + + n = 0; + f = fabs(x); + if (f > 1.0) { + f = 1.0/f; + n = 2; + } + if (f > 0.26794919243112270647) { + f = (((0.73205080756887729353*f - 0.5) - 0.5) + f) / + (1.73205080756887729353 + f); + ++n; + } + if (fabs(f) < 2.3e-10) + r = f; + else { + g = f*f; + r = f + f * + ((P(g)*g) + /Q(g)); + } + if (n > 1) + r = -r; + r += Avals[n]; + if (x < 0.0) + r = -r; + return r; +} + atan87.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + +EDOM equ 22 + +dataseg segment public byte 'data' + extrn errno_:word +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + + assume cs:codeseg,ds:dataseg + +;double atan(x) +;double x; + + procdef atan,<> + sub sp,2 + fld qword ptr xx ;load x + ftst ; see if x is negative + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + xor bx,bx + sahf + ja skip3 + fchs ; make it positive + mov bx,1 ; but remember the sign +skip3: + fld1 ; load a one + fcomp ; x should be < 1.0 + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + xor cx,cx + sahf + ja skip4 + mov cx,1 + fld1 ;load a one + fdivr ; x = 1.0 / x +skip4: + fld1 + fpatan ; compute the arctan + test cx,1 + jz skip1 + mov word ptr -2[bp],-1 + fild word ptr -2[bp] + fldpi ; load pi + fscale ;compute pi / 2 + fxch ;get scale factor back on top + fstp st(0) ;and discard + fsubr ; x = pi/2 - x +skip1: + test bx,1 + jz nosign + fchs +nosign: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + fwait + add sp,2 + pret + pend atan + + + procdef atan2,<,> + sub sp,2 + fld qword ptr y ;load y + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnz ok1 +; +; y is zero, if x is zero also, error +; + fld qword ptr x ;load x + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnz okx + mov errno_,EDOM +zerores: + fstp st(0) ;clear stack + fstp st(0) + fldz ;answer is zero + jmp exit +okx: + mov bx,0 + ja notneg ; x < 0 + mov bx,1 +notneg: + fstp st(0) + fstp st(0) ; answer is +/- pi/2 + mov word ptr -2[bp],-1 + fild word ptr -2[bp] + fldpi + fscale + fxch + fstp st(0) + test bx,1 + jz oksign + fchs +oksign: + jmp exit +ok1: +; +; x and y are both non zero, but x must be < y +; + mov bx,word ptr x+6 + xor bx,word ptr y+6 + fabs ; y = fabs(y) + fld qword ptr x + fabs ; x = fabs(x) + fxch + fcom st(1) + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + xor cx,cx + sahf + jz zerores + ja nodiv + fxch + mov cx,1 +nodiv: + fpatan ; compute the arctangent + test cx,cx + jz noadjust + mov word ptr -2[bp],-1 + fild word ptr -2[bp] + fldpi + fscale + fxch + fstp st(0) + fsubr ; res = pi/2 - res +noadjust: + test bx,8000h ; should result be negative + jz notnegr + fchs +notnegr: + test word ptr y+6,8000h ; y < 0 ? + jz exit + test word ptr x+6,8000h ; x < 0 too? + jz addpi + fldpi + fsub ; x -= pi + jmp exit +addpi: + fldpi + fadd +exit: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + fwait + add sp,2 + pret + pend atan2 + finish + end + atof.asm +; Copyright Manx Software Systems, Inc. 1983-1987. All rights reserved. +; +;double +;atof(cp) +;register char *cp; + include lmacros.h + +IFDEF LONGPTR +cp equ es:byte ptr [di] +getes macro + mov es,ss:word ptr acp[2] + endm + +ELSE + +cp equ byte ptr [di] +getes macro +; + endm +ENDIF + +zero dw 0,0,0,0 +ten dw 0,0,0,4024h + +ifdef STATRES +dataseg segment public word 'data' +result db 8 dup (?) +dataseg ends + + assume ds:dataseg +endif + + procdef atof,<> + sub sp,4 + push di + push si +;{ +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,acp,es +; double acc; +; int msign, esign, dpflg; +; int i, dexp; +msign equ byte ptr -1[bp] +esign equ byte ptr -2[bp] ;these two aren't active at the same time +dpflg equ byte ptr -2[bp] +temp equ word ptr -4[bp] + +; while (*cp == ' ' || *cp == '\t') +; ++cp; +skiploop: + mov al,cp + cmp al,' ' + je skipbl + cmp al,9 + jne skipdone +skipbl: + inc di + jmp skiploop +skipdone: +; if (*cp == '-') { + cmp al,45 + jne $3 +; ++cp; + inc di +; msign = 1; + mov msign,1 + jmp short $4 +; } else { +$3: +; msign = 0; + mov msign,0 +; if (*cp == '+') +; ++cp; + cmp al,43 + jne $4 + inc di +; } +$4: +; dpflg = dexp = 0; + mov si,0 + mov dpflg,0 +; for (acc = zero ; ; ++cp) { +ifdef INLINE + fldz +else + mov bx, offset zero + call $dldpcs +endif +$6: +; if (isdigit(*cp)) { + getes + mov al,cp + cmp al,'0' + jb $9 + cmp al,'9' + ja $9 +; acc *= ten; +ifdef INLINE + fmul cs:qword ptr ten +else + mov bx, offset ten + call $dldscs + call $dml +endif +; acc += *cp - '0'; +ifndef INLINE + call $dswap +endif + getes + mov al,cp + cbw + add ax,-48 +ifdef INLINE + mov temp,ax + fild temp + fadd +else + call $itod + call $dad +endif +; if (dpflg) +; --dexp; + cmp dpflg,0 + je $11 + dec si + jmp short $11 +; } else if (*cp == '.') { +$9: + cmp al,'.' + jne $8 +; if (dpflg) +; break; + cmp dpflg,0 + jne $8 +; dpflg = 1; + mov dpflg,1 +; } else +; break; +$11: +; } + inc di + jmp $6 +$8: +; if (*cp == 'e' || *cp == 'E') { + cmp al,101 + je $15 + cmp al,69 + jne $14 +$15: +; ++cp; + inc di +; if (*cp == '-') { + cmp cp,45 + jne $16 +; ++cp; + inc di +; esign = 1; + mov esign,1 + jmp short $17 +; } else { +$16: +; esign = 0; + mov esign,0 +; if (*cp == '+') +; ++cp; + cmp cp,43 + jne $17 + inc di +; } +$17: +; for ( i = 0 ; isdigit(*cp) ; i = i*10 + *cp++ - '0' ) + sub ax,ax + mov cx,10 + jmp short $20 +$19: + mul cx + mov dx,ax + mov al,cp + inc di + cbw + add ax,dx + add ax,-48 +$20: + mov bl,cp + cmp bl,'0' + jb $21 + cmp bl,'9' + jbe $19 +; ; +$21: +; if (esign) +; i = -i; + cmp esign,0 + je $22 + neg ax +$22: +; dexp += i; + add si,ax +; } +; if (dexp < 0) { +$14: +ifndef INLINE + mov bx, offset ten + call $dldscs +endif + test si,si + jns $23 +; while (dexp++) +$24: +; acc /= ten; +ifdef INLINE + fdiv cs:qword ptr ten +else + call $ddv +endif + inc si + jnz $24 + jmp short $26 +; } else if (dexp > 0) { +$23: + jz $26 +; while (dexp--) +$28: +; acc *= ten; +ifdef INLINE + fmul cs:qword ptr ten +else + call $dml +endif + dec si + jnz $28 +; } +$26: +; if (msign) +; acc = -acc; + cmp msign,0 + je $30 +ifdef INLINE + fchs +else + call $dng +endif +; return acc; +$30: +ifdef STATRES +ifdef INLINE + fstp qword ptr result +else + mov bx,offset result + call $dstds +endif + mov ax,offset result + mov dx,ds +endif + pop si + pop di + mov sp,bp + pret +;} + pend atof +ifndef INLINE +ifdef FARPROC + extrn $dad:far,$dml:far,$ddv:far + extrn $dng:far,$dswap:far,$itod:far + extrn $dldpcs:far,$dldscs:far,$dstds:far +else + extrn $dad:near,$dml:near,$ddv:near + extrn $dng:near,$dswap:near,$itod:near + extrn $dldpcs:near,$dldscs:near,$dstds:near +endif +endif + finish + end + chk87.asm +;Copyright (C) Manx Software Systems, Inc. 1987. All rights reserved. +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' + public chop_ctl, round_ctl, rdown_ctl +chop_ctl dw 0fbfH ;control word for Chop mode +round_ctl dw 03bfH ;control word for Round nearest mode +rdown_ctl dw 07bfh ;control word for Round Down mode +mess db "8087/80287 is absent or not functional!" + db 10 ; newline +MESSLEN equ 40 +dataseg ends + + public $maxdigit ; this must be in CODESEG +$maxdigit dw 16 ;maximum # of digits for ftoa() to produce. + + assume ds:dataseg + public _chk87_, $fltinit +$fltinit proc +_chk87_: + push bp + mov bp,sp + sub sp,2 + fninit + fnstcw word ptr -2[bp] + mov cx,50 +w1loop: loop w1loop ; wait for a while + and word ptr -2[bp],01f3fh ; clear unused bits + cmp word ptr -2[bp],0033fh ; is 8087 there? + jnz notthere ; no, return error to caller + fstsw word ptr -2[bp] + mov cx,50 +w2loop: loop w2loop ; wait for a while + test word ptr -2[bp],0b8bfh ; all status bits should be off + jz ok_8087 ; 8087 is there!! +notthere: + stc ;bad status, no 8087 present + jmp short exit +ok_8087: + ;note: the carry is cleared by the test instr. above + fldcw word ptr round_ctl ;set initial control +exit: + mov sp,bp + pop bp + ret +$fltinit endp + + finish + end + exp.c +#include "math.h" +#include "errno.h" + +#define P0 0.25000000000000000000e+0 +#define P1 0.75753180159422776666e-2 +#define P2 0.31555192765684646356e-4 +#define Q0 0.50000000000000000000e+0 +#define Q1 0.56817302698551221787e-1 +#define Q2 0.63121894374398503557e-3 +#define Q3 0.75104028399870046114e-6 + +#define P(z) ((P2*z + P1)*z + P0) +#define Q(z) (((Q3*z + Q2)*z + Q1)*z + Q0) + +#define EPS 2.710505e-20 + +double +exp(x) +double x; +{ + int n; + double xn, g, r, z; + extern int errno; + + if (x > LOGHUGE) { + errno = ERANGE; + return HUGE_VAL; + } + if (x < LOGTINY) { + errno = ERANGE; + return 0.0; + } + if (fabs(x) < EPS) + return 1.0; + n = z = x * 1.4426950408889634074; + if (n < 0) + --n; + if (z-n >= 0.5) + ++n; + xn = n; + g = ((x - xn*0.693359375)) + xn*2.1219444005469058277e-4; + z = g*g; + r = P(z)*g; + r = 0.5 + r/(Q(z)-r); + return ldexp(r,n+1); +} + exp1087.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + +log10e db 016h,055h,0b5h,0bbh,0b1h,06bh,02h,040h + +ifdef FARPROC + extrn exp_:far +else + extrn exp_:near +endif + + assume cs:codeseg,ds:dataseg + +;double exp10 (x) +;double x; + + procdef exp10,<> + fld qword ptr x + fmul cs:qword ptr log10e + sub sp,8 + mov bx,sp + fstp ss:qword ptr [bx] + fwait + call exp_ + add sp,8 + pret + pend exp10 + finish + end + exp87.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + +ERANGE equ 21 + +dataseg segment para public 'data' + extrn errno_:word,chop_ctl:word,round_ctl:word +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + + assume cs:codeseg,ds:dataseg + +huge db 020H,062H,010H,058H,039H,02EH,086H,040H +tiny db 080H,049H,0CH,02H,02BH,023H,086H,0C0H +plus5 db 00H,00H,00H,00H,00H,00H,0E0H,03FH ; +0.5 +minus5 db 00H,00H,00H,00H,00H,00H,0E0H,0BFH ; -0.5 + +;double exp(x) +;double x; + + procdef exp,<> + sub sp,6 + fld qword ptr x ; load input value + fcom cs:qword ptr huge ; must be less than or equal to LOGHUGE + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + ja badval + fcom cs:qword ptr tiny ; must be >= LOGTINY + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jae goodval +badval: + mov errno_,ERANGE ; range error + fstp st(0) ; get rid of original number + fldz ; result is zero + jmp exit +goodval: + fldln2 ; load log(e) 2 + fdiv ; x = x / (log(e) 2) + fld st(0) ; make a copy of x/(log(e) 2 + ftst ; check for number < 0 + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + mov bx,offset plus5 ;default rounding is +0.5 + jnc roundup + mov bx,offset minus5 ;otherwise -0.5 +roundup: + fadd cs:qword ptr [bx] ;add round + fldcw word ptr chop_ctl + fistp word ptr -6[bp] ; n = x + (x < 0)?-0.5:0.5 + fldcw word ptr round_ctl + fild word ptr -6[bp] ; reload n + fsub ; x = x - n + mov word ptr -4[bp],0 ; flag = 0 + ftst ; x < 0 + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnc notneg + fchs ; x = -x + mov word ptr -4[bp],1 ;flag = 1; +notneg: + f2xm1 ; x = 2**x - 1 + fld1 ; load one + fadd ; x = x + 1 (i.e. 2**x) + cmp word ptr -4[bp],0 ; if (flag) + je noinvert + fld1 ; load one + fdivr ; x = 1.0/x +noinvert: + fild word ptr -6[bp] ; reload n + fxch ; get x back on top + fscale ; x = x * 2**n + fxch ; get n back on top + fstp st(0) ; and discard it (this keeps stack clean) +exit: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,6 + pret + pend exp + finish + end + fabs.c +#ifdef MPU68K +#define SIGN 0 +#else +#define SIGN 7 +#endif + +double +fabs(dou) +double dou; +{ + register char *cp; + + cp = (char *)&dou; + cp[SIGN] &= 0x7f; + return dou; +} + floor.c +#include "math.h" + +double floor(d) +double d; +{ + if (d < 0.0) + return -ceil(-d); + modf(d, &d); + return d; +} + +double ceil(d) +double d; +{ + if (d < 0.0) + return -floor(-d); + if (modf(d, &d) > 0.0) + ++d; + return d; +} + fmod87.asm +; Copyright Manx Software Systems, Inc. 1983, 1987 +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + assume ds:dataseg + + procdef fmod, <,> +; +; double fmod(doud,denom) +; + sub sp,2 + fld qword ptr denom + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnz divok + fstp st(0) + fld qword ptr doub + jmp exit +divok: + fabs + fld qword ptr doub + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + xor bx,bx + sahf + jnc notneg + mov bx,1 + fabs +notneg: + fprem + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jz done + fcom st(1) + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + ja notneg +done: + fxch + fstp st(0) + test bx,bx + jz exit + fchs +exit: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,2 + pret + pend fmod + finish + end + fpst.asm +; Copyright (C) 1983 by Manx Software Systems + include lmacros.h + + internal $FPSTI + + intrdef $fprds ;preinc or predec a single float using ds:bx + mov cx,ds + mov es,cx + jmp short fpr + + intrdef $fprss ;preinc or predec a single float using ss:bx + mov cx,ss + mov es,cx + jmp short fpr + + intrdef $fpres ;preinc or predec a single float using es:bx +fpr: + push bx + push es + call $itod + pop es + pop bx + push bx + push es + call $fldses + call $dad + pop es + pop bx + call $fstes + ret + + intrdef $fpsds ;postinc or postdec a single float using ds:bx + mov cx,ds + mov es,cx + jmp short fps + + intrdef $fpsss ;postinc or postdec a single float using ss:bx + mov cx,ss + mov es,cx + jmp short fps + + intrdef $fpses ;postinc or postdec a single float using es:bx +fps: + push bx + push es + call $itod + pop es + pop bx + push bx + push es + call $fldses + call $dswap + call $dpsh + call $dad + call $dpop + pop es + pop bx + call $fstes + call $dswap + ret + + intrdef $dprds ;preinc or predec a double float using ds:bx + mov cx,ds + mov es,cx + jmp short dpr + + intrdef $dprss ;preinc or predec a double float using ss:bx + mov cx,ss + mov es,cx + jmp short dpr + + intrdef $dpres ;preinc or predec a double float using es:bx +dpr: + push bx + push es + call $itod + pop es + pop bx + push bx + push es + call $dldses + call $dad + pop es + pop bx + call $dstes + ret + + intrdef $dpsds ;postinc or postdec a double float using ds:bx + mov cx,ds + mov es,cx + jmp short dps + + intrdef $dpsss ;postinc or postdec a double float using ss:bx + mov cx,ss + mov es,cx + jmp short dps + + intrdef $dpses ;postinc or postdec a double float using es:bx +dps: + push bx + push es + call $itod + pop es + pop bx + push bx + push es + call $dldses + call $dswap + call $dpsh + call $dad + call $dpop + pop es + pop bx + call $dstes + call $dswap + ret + +; +ifdef FARPROC + extrn $itod:far,$dad:far,$dpsh:far,$dpop:far,$dswap:far + extrn $fldses:far,$fstes:far,$dldses:far,$dstes:far +else + extrn $itod:near,$dad:near,$dpsh:near,$dpop:near,$dswap:near + extrn $fldses:near,$fstes:near,$dldses:near,$dstes:near +endif +$FPSTI endp + finish + end + frexp.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -10 -8 -6 -4 -2 0 +; |grd + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + include lmacros.h +dataseg segment word public 'data' + dw 5 dup (?) +temp dw ? + extrn flprm:word,flsec:word + extrn flterr_:word +dataseg ends + assume ds:dataseg + +ifdef FARPROC + extrn $dldpss:far, $dst:far, $itod:far + extrn $dad:far, $dsb:far, $isnan:far +else + extrn $dldpss:near, $dst:near, $itod:near + extrn $dad:near, $dsb:near, $isnan:near +endif + + procdef _isnan,<> + lea bx,word ptr ddd ;compute address of first argument + call $dldpss ;load it into the float primary + call $isnan + pret + pend _isnan + + procdef frexp, <,> +; +; frexp(d, &i) +; returns 0 <= x < 1 +; such that: d = x * 2^i + lea bx,word ptr d ;compute address of first argument + call $dldpss ;load it into the float primary + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz fr_nzero + ldptr bx,i,es ;get pointer +ifndef LONGPTR + mov ds:word ptr [bx],0 +else + mov es:word ptr [bx],0 +endif + pret +fr_nzero: + sub ax,1022 + mov word ptr -2[bx],1022 + ldptr bx,i,es ;get pointer +ifndef LONGPTR + mov ds:word ptr [bx],ax +else + mov es:word ptr [bx],ax +endif + pret + pend frexp +; +; ldexp(d, i) +; returns x = d * 2^i + procdef ldexp, <,> + lea bx,word ptr dou ;compute address of first argument + call $dldpss ;load it into the float primary + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jz ld_zero + add ax,ii ;add i to exponent + js ld_underflow + cmp ax,2048 + jl ld_ret + mov flterr_,UNDER_FLOW + mov ax,2047 +ld_ret: + mov word ptr -2[bx],ax +ld_zero: + pret +; +ld_underflow: + mov flterr_,UNDER_FLOW + sub ax,ax + jmp ld_ret + pend ldexp +; +; modf(d, dptr) +; returns fractional part of d, and +; stores integral part into *dptr + procdef modf,<,> + push di + push si + push ds + lea bx,word ptr doubl ;compute address of first argument + call $dldpss ;load it into the float primary + std + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz mf_nzero + ldptr bx,dptr,es ;get pointer + call $dst +mf_return: + cld + pop ds + pop si + pop di + pret +mf_nzero: + mov di,ds + mov es,di + mov si,bx + mov di,offset temp + mov cx,6 ;save value for fraction part later +rep movsw + sub ax,1023 + jns int_notzero + mov ax,0 + call $itod + jmp get_fraction +int_notzero: + cmp ax,52 + jna mf_frac + ;fraction is zero + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + sub ax,ax + call $itod + jmp mf_return +mf_frac: + sub di,di + mov cx,ax + mov ax,4 +mf_count: + sub cx,ax + jbe mf_cdone + dec di + mov ax,8 + jmp mf_count +mf_cdone: + jcxz no_shift + neg cx + mov al,byte ptr -3[bx][di] + shr al,cl + shl al,cl + mov byte ptr -3[bx][di],al +no_shift: + dec di +zap_loop: + cmp di,-8 + jle get_fraction + mov byte ptr -3[bx][di],0 + dec di + jmp zap_loop +get_fraction: + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + std + pop ds + push ds + mov di,flprm + xchg di,flsec + mov flprm,di + mov si,ds + mov es,si + mov si,offset temp + mov cx,6 ;restore original value +rep movsw + call $dsb ;compute fractional part + jmp mf_return + pend modf + finish + end + frexp87.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; +; floating point system error codes: +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + include lmacros.h + +dataseg segment word public 'data' +status dw ? +result db 8 dup (?) + extrn chop_ctl:word, round_ctl:word +dataseg ends + assume ds:dataseg + + procdef frexp,<,> +; +; frexp(d, &i) +; returns 0 <= x < 1 +; such that: d = x * 2^i + fld1 + fchs + fld qword ptr d + ftst + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + jz zero + fxtract + fxch + fsub st,st(2) + ldptr bx,i,es +ifdef LONGPTR + fistp es:word ptr [bx] +else + fistp word ptr [bx] +endif + fscale + fxch + fstp st(0) +ifdef STATRES + jmp exit +else + pret +endif +zero: + ldptr bx,i,es +ifdef LONGPTR + mov es:word ptr [bx],0 +else + mov word ptr [bx],0 +endif + fstp st(0) + fstp st(0) + fldz +ifdef STATRES +exit: + fstp qword ptr result + fwait + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + pret + pend frexp +; +; ldexp(d, i) +; returns x = d * 2^i + procdef ldexp, <,> + fild word ptr ii + fld qword ptr dou + fscale + fxch + fstp st(0) +ifdef STATRES + fstp qword ptr result + fwait + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + pret + pend ldexp +; +; modf(d, dptr) +; returns fractional part of d, and +; stores integral part into *dptr + procdef modf, <,> + fld qword ptr doub + fld st(0) + fldcw word ptr chop_ctl + frndint + fldcw word ptr round_ctl + ldptr bx,dptr,es +ifdef LONGPTR + fst es:qword ptr [bx] +else + fst qword ptr [bx] +endif + fsub +ifdef STATRES + fstp qword ptr result + fwait + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + pret + pend modf + finish + end + frexp87s.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -10 -8 -6 -4 -2 0 +; |grd + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + include lmacros.h +dataseg segment word public 'data' + dw 5 dup (?) +temp dw ? + extrn flprm:word,flsec:word + extrn flterr_:word +status dw ? + extrn $flt_inx:word,chop_ctl:word, round_ctl:word +dataseg ends + assume ds:dataseg + +ifdef FARPROC + extrn $dldpss:far, $dst:far, $itod:far + extrn $dad:far, $dsb:far, $isnan:far +else + extrn $dldpss:near, $dst:near, $itod:near + extrn $dad:near, $dsb:near, $isnan:near +endif + + procdef _isnan,<> + lea bx,word ptr ddd ;compute address of first argument + call $dldpss ;load it into the float primary + call $isnan + pret + pend _isnan + + procdef frexp, <,> +; +; frexp(d, &i) +; returns 0 <= x < 1 +; such that: d = x * 2^i + cmp $flt_inx,0 + jnz $frexp87 + lea bx,word ptr d ;compute address of first argument + call $dldpss ;load it into the float primary + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz fr_nzero + ldptr bx,i,es ;get pointer +ifdef LONGPTR + mov es:word ptr [bx],0 +else + mov ds:word ptr [bx],0 +endif + pret +fr_nzero: + sub ax,1022 + mov word ptr -2[bx],1022 + ldptr bx,i,es ;get pointer +ifdef LONGPTR + mov es:word ptr [bx],ax +else + mov ds:word ptr [bx],ax +endif + pret +$frexp87: + fld1 + fchs + fld qword ptr d + ftst + fstsw status + fwait + mov ah,byte ptr status+1 + sahf + je zero + fxtract + fxch + fsub st,st(2) + ldptr bx,i,es +ifdef LONGPTR + fistp es:word ptr [bx] +else + fistp ds:word ptr [bx] +endif + fscale + fxch + fstp st(0) + fwait + pret +zero: + fstp st(0) + fstp st(0) + fldz + ldptr bx,i,es +ifdef LONGPTR + mov es:word ptr [bx],0 +else + mov ds:word ptr [bx],0 +endif + pret + pend frexp +; +; ldexp(d, i) +; returns x = d * 2^i + procdef ldexp, <,> + cmp $flt_inx,0 + jnz $ldexp87 + lea bx,word ptr dou ;compute address of first argument + call $dldpss ;load it into the float primary + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jz ld_zero + add ax,ii ;add i to exponent + js ld_underflow + cmp ax,2048 + jl ld_ret + mov flterr_,UNDER_FLOW + mov ax,2047 +ld_ret: + mov word ptr -2[bx],ax +ld_zero: + pret +; +ld_underflow: + mov flterr_,UNDER_FLOW + sub ax,ax + jmp ld_ret +$ldexp87: + fild word ptr ii + fld qword ptr dou + fscale + fxch + fstp st(0) + pret + pend ldexp +; +; modf(d, dptr) +; returns fractional part of d, and +; stores integral part into *dptr + procdef modf,<,> + cmp $flt_inx,0 + jz modf_soft + fld qword ptr doubl + fld st(0) + fldcw chop_ctl + frndint + ldptr bx,dptr,es + fldcw round_ctl +ifdef LONGPTR + fst es:qword ptr [bx] +else + fst ds:qword ptr [bx] +endif + fsub + pret + +modf_soft: + push di + push si + push ds + lea bx,word ptr doubl ;compute address of first argument + call $dldpss ;load it into the float primary + std + mov bx,flprm + mov ax,word ptr -2[bx] ;fetch current exponent value + test ax,ax + jnz mf_nzero + ldptr bx,dptr,es ;get pointer + call $dst +mf_return: + cld + pop ds + pop si + pop di + pret +mf_nzero: + mov di,ds + mov es,di + mov si,bx + mov di,offset temp + mov cx,6 ;save value for fraction part later +rep movsw + sub ax,1023 + jns int_notzero + mov ax,0 + call $itod + jmp get_fraction +int_notzero: + cmp ax,52 + jna mf_frac + ;fraction is zero + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + sub ax,ax + call $itod + jmp mf_return +mf_frac: + sub di,di + mov cx,ax + mov ax,4 +mf_count: + sub cx,ax + jbe mf_cdone + dec di + mov ax,8 + jmp mf_count +mf_cdone: + jcxz no_shift + neg cx + mov al,byte ptr -3[bx][di] + shr al,cl + shl al,cl + mov byte ptr -3[bx][di],al +no_shift: + dec di +zap_loop: + cmp di,-8 + jle get_fraction + mov byte ptr -3[bx][di],0 + dec di + jmp zap_loop +get_fraction: + ldptr bx,dptr,es ;get pointer + call $dst ;store integer part away + std + pop ds + push ds + mov di,flprm + xchg di,flsec + mov flprm,di + mov si,ds + mov es,si + mov si,offset temp + mov cx,6 ;restore original value +rep movsw + call $dsb ;compute fractional part + jmp mf_return + pend modf + finish + end + fsubs.asm +ifndef INTERNAL +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 +; the psuedo accumlators are formated as follows: +; -12 -10 -8 -6 -4 -2 0 +; |guard digits + LS ----- fraction ---- MS | exp | sign +; +; floating point system error codes: + include lmacros.h +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; +dataseg segment word public 'data' + public flprm,flsec + public flterr_ +flterr_ dw 0 +flprm dw acc1 +flsec dw acc2 +YU dw ? +VEE dw ? + dw 5 dup (?) +acc1 dw 7 dup (?) +acc2 dw ? +; +;work area for divide and multiply routines +; + dw 4 dup (?) +temp dw 4 dup (?) +loop_count db 0 ;iterations left (for divide) +lcnt1 db 0 ;# iter. for this word of quotient +dataseg ends + assume ds:dataseg + + + internal $floats + +endif + + public $maxdigit ; this must be in CODESEG +$maxdigit dw 16 ;maximum # of digits for ftoa() to produce. + + intrdef $isnan + sub ax,ax + ret + + intrdef $fldpds ;load single float into primary accum using ds:bx +ifndef LONGPTR + intrdef $fldp +endif + push di + mov di,ds + mov es,di + mov di,flprm + jmp short fload + + intrdef $fldpss ;load single float into primary accum using ss:bx + push di + mov di,ss + mov es,di + mov di,flprm + jmp short fload + + intrdef $fldpes ;load single float into primary accum using es:bx +ifdef LONGPTR + intrdef $fldp +endif + push di + mov di,flprm +fload: + push si + mov ax,es:2[bx] ;get exponent/sign word of number + mov byte ptr [di],ah ;save sign + mov dh,al ;save fraction bits + shl ax,1 ;get LS bit of exponent + xchg ah,al + and ax,0ffH + jnz fld_nz + push ds + mov ax,ds + mov es,ax + jmp loadzero +fld_nz: + sub ax,127 ;adjust from excess 127 notation + add ax,1023 ;put into excess 1023 notation + mov word ptr -2[di],ax ;and save + or dh,80H ;turn "hidden" bit back on + mov dl,es:byte ptr 1[bx] + mov ah,es:byte ptr [bx] + sub al,al + shr dx,1 ;shift fraction into same position as a double + rcr ax,1 + shr dx,1 + rcr ax,1 + shr dx,1 + rcr ax,1 + mov word ptr -4[di],dx + mov word ptr -6[di],ax + sub ax,ax + mov word ptr -8[di],ax + mov word ptr -10[di],ax + mov word ptr -12[di],ax + pop si + pop di + ret + + intrdef $fldsds ;load single float into secondary accum using ds:bx +ifndef LONGPTR + intrdef $flds +endif + push di + mov di,ds + mov es,di + mov di,flsec + jmp short fload + + intrdef $fldsss ;load single float into secondary accum using ss:bx + push di + mov di,ss + mov es,di + mov di,flsec + jmp short fload + + intrdef $fldses ;load single float into secondary accum using es:bx +ifdef LONGPTR + intrdef $flds +endif + push di + mov di,flsec + jmp short fload + + intrdef $fstds ; store single float from primary using ds:bx +ifndef LONGPTR + intrdef $fst +endif + mov cx,ds + mov es,cx + jmp short dofst + + intrdef $fstss ; store single float from primary using ss:bx + mov cx,ss + mov es,cx + jmp short dofst + + intrdef $fstes ;store single float from primary using es:bx +ifdef LONGPTR + intrdef $fst +endif +dofst: + push di + push si + push bx + call dornd + pop di + mov si,flprm + mov ax,-2[si] ;get exponent + test ax,ax + jnz fst_nzero + mov es:word ptr [di],0 + mov es:word ptr 2[di],0 + pop si + pop di + ret +fst_nzero: + sub ax,1023 ;switch from excess 1023 notation + add ax,127 ;into excess 127 notation + mov dx,-4[si] + mov bx,-6[si] + add bx,10H ;round number + adc dx,0 + shl bx,1 ;move number back into proper position + rcl dx,1 + shl bx,1 + rcl dx,1 + test dx,dx + js fix_exp + shl bx,1 + rcl dx,1 + jmp short fst_merge +fix_exp: + inc ax ;adjust exponent +fst_merge: + mov cl,7 + shl ax,cl + mov cl,[si] ;get sign + and cl,80H + or ah,cl ;merge sign and exponent + and dh,7fH ;clear "hidden" bit + or al,dh ;merge with sign/exponent + mov es:word ptr 2[di],ax + mov es:byte ptr 1[di],dl + mov es:byte ptr [di],bh + pop si + pop di + ret +; + intrdef $fstsds ; store single float from secondary using ds:bx +ifndef LONGPTR + intrdef $fsts +endif + mov cx,ds + mov es,cx + jmp short dofsts + + intrdef $fstsss ; store single float fromn secondary using ss:bx + mov cx,ss + mov es,cx + jmp short dofsts + + intrdef $fstses ; store single float from secondary using es:bx +ifdef LONGPTR + intrdef $fsts +endif +dofsts: + mov ax,flprm + xchg ax,flsec + mov flprm,ax +ifdef FARPROC + call far ptr $fstes +else + call $fstes +endif + mov ax,flprm + xchg ax,flsec + mov flprm,ax + ret + + intrdef $dldpds ; load double float in primary using ds:bxS +ifndef LONGPTR + intrdef $dldp +endif + mov cx,ds + mov es,cx + jmp short dodldp + + intrdef $dldpss ; load double float in primary using ss:bx + mov cx,ss + mov es,cx + jmp short dodldp + + intrdef $dldpcs ; load double float in primary using cs:bx +ifndef FARPROC + mov cx,cs + mov es,cx +else + mov cx,bx + mov bx,sp + mov bx,ss:2[bx] + xchg cx,bx + mov es,cx +endif + jmp short dodldp + + intrdef $dldpes ;load double float in primary using es:bx +ifdef LONGPTR + intrdef $dldp +endif +dodldp: + push di + mov di,flprm +dload: + push si + lea si,6[bx] +dload2: + push ds + mov cx,es ;swap the segment registers + mov dx,ds + mov es,dx + mov ds,cx + std + lods word ptr [si];get first two bytes of number + mov es:byte ptr [di],ah ;save sign + mov dh,al ;save top nibble of fraction + mov cl,4 + shr ax,cl + and ax,7ffH ;isolate exponent + jz loadzero + sub di,2 + stos word ptr [di] + and dh,15 ;isolate fraction + or dh,10H ;put back "hidden" bit + mov es:byte ptr 1[di],dh + mov cx,6 + inc si +rep movs byte ptr [di], byte ptr [si] + mov al,0 + stosb ;clear guard bytes + stosb + stosb + cld + pop ds + pop si + pop di + ret +loadzero: + std + sub ax,ax + mov cx,7 +rep stos word ptr [di] + cld + pop ds + pop si + pop di + ret + + intrdef $dldsds ; load double float in secondary using ds:bx +ifndef LONGPTR + intrdef $dlds +endif + mov cx,ds + mov es,cx + jmp dolds + + intrdef $dldsss ; load double float in secondary using ss:bx + mov cx,ss + mov es,cx + jmp dolds + + intrdef $dldscs ; load double float in secondary using cs:bx +ifndef FARPROC + mov cx,cs + mov es,cx +else + mov cx,bx + mov bx,sp + mov bx,ss:2[bx] + xchg cx,bx + mov es,cx +endif + jmp dolds + + intrdef $dldses ; load double float in secondary using es:bx +ifdef LONGPTR + intrdef $dlds +endif +dolds: + push di + mov di,flsec + jmp short dload + + intrdef $dstds ; store double float from primary using ds:bx +ifndef LONGPTR + intrdef $dst +endif + mov cx,ds + mov es,cx + jmp short dodst + + intrdef $dstss ; store double float from primary using ss:bx + mov cx,ss + mov es,cx + jmp short dodst + + intrdef $dstes ; store double float from primary using es:bx +ifdef LONGPTR + intrdef $dst +endif +dodst: + std + push di + push si + push bx ;save address + call dornd ;round fraction to 7 bytes + pop di ;restore address + add di,6 + mov si,flprm + mov dl,[si] ;get sign + and dl,80H + sub si,2 + lods word ptr [si];get exponent + mov cl,4 + shl ax,cl + or ah,dl ;merge sign and exponent + mov dl,1[si] + and dl,15 ;clear "hidden" bit + or al,dl ;merge with sign/exponent + stos word ptr [di] + mov cx,6 + inc di +rep movs byte ptr [di], byte ptr [si] + cld + pop si + pop di + ret + + intrdef $dstsds ; store double float from secondary using ds:bx +ifndef LONGPTR + intrdef $dsts +endif + mov cx,ds + mov es,cx + jmp short dodsts + + intrdef $dstsss ; store double float from secondary using ss:bx + mov cx,ss + mov es,cx + jmp short dodsts + + intrdef $dstses ; store double float from secondary using es:bx +ifdef LONGPTR + intrdef $dsts +endif +dodsts: + mov ax,flprm + xchg ax,flsec + mov flprm,ax +ifdef FARPROC + call far ptr $dstes +else + call $dstes +endif + mov ax,flprm + xchg ax,flsec + mov flprm,ax + ret + + intrdef $dpshs ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack + mov bx,ss + mov es,bx + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back + jmp near ptr dodsts +; + intrdef $dpsh ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack + mov bx,ss + mov es,bx + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back + jmp near ptr dodst +; + intrdef $dpopp ;pop double float into secondary accum + push bx + push es + mov bx,ss + mov es,bx + mov bx,sp + add bx,FPTRSIZE+4 ;address of data to load +ifdef FARPROC + call far ptr $dldpes +else + call $dldpes +endif + + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dpop ;pop double float into secondary accum + push bx + push es + mov bx,ss + mov es,bx + mov bx,sp + add bx,FPTRSIZE+4 ;address of data to load +ifdef FARPROC + call far ptr $dldses +else + call $dldses +endif + pop es + pop bx + ret 8 ;return and de-allocate space + + intrdef $dlip ;load double immediate primary + push bp + mov bp,sp +ifdef FARPROC + les bx,2[bp] +else + mov bx,cs + mov es,bx + mov bx,2[bp] +endif + add 2[bp],8 ;skip over double constant in code + pop bp + jmp dodldp + + intrdef $dlis ;load double immediate secondary + push bp + mov bp,sp +ifdef FARPROC + les bx,2[bp] +else + mov bx,cs + mov es,bx + mov bx,2[bp] +endif + add 2[bp],8 ;skip over double constant in code + pop bp + jmp dolds + + intrdef $dswap ;exchange primary and secondary + mov ax,flsec + xchg ax,flprm + mov flsec,ax + ret + + intrdef $dng ;negate primary + mov bx,flprm + cmp -2[bx],0 + je no_flip + xor byte ptr [bx],80H ;flip sign +no_flip: + ret + + intrdef $dtst ;test if primary is zero + mov bx,flprm + cmp word ptr -2[bx],0 + jne true + sub ax,ax + ret +true: + sub ax,ax + inc ax + ret + + intrdef $dcmp ;compare primary and secondary + push di + push si + std + mov si,flprm + mov di,ds + mov es,di + mov di,flsec + mov al,byte ptr [si] + test al,al ;is primary negative + js dcneg +; primary is positive + xor al,byte ptr [di] ;check if signs the same + js p_gt_s ;differ then p > s + jmp short docomp +dcneg: + ;primary is negative + xor al,byte ptr [di] ;check if signs the same + js p_lt_s ;differ the p < s + xchg di,si ;both negative reverse sense of test +docomp: + sub di,2 ;back up to exponent + sub si,2 + mov cx,5 ;test exponent + 4 words of fraction +repe cmps acc1, es:acc2 + jb p_lt_s + ja p_gt_s + ;return 0 if p == s + xor ax,ax + jmp short cmp_return + ;return 0 if p == s +p_lt_s: ;return < 0 if p < s + xor ax,ax + dec ax + jmp short cmp_return +; +p_gt_s: ; > 0 if p > s + xor ax,ax + inc ax +cmp_return: + pop si + pop di + cld + ret + + intrdef $dsb ;subtract secondary from primary + mov bx,flsec + xor byte ptr [bx],80H ;flip sign of secondary + ;and fall thru into add routine + + intrdef $dad ;add secondary to primary + pushf + push bp + push si + push di + std + mov si,flprm + mov di,ds + mov es,di + mov di,flsec + mov cx,word ptr -2[si] ;get exponent of primary + sub cx,word ptr -2[di] ;compute magnitude difference + jae order_ok + xchg si,di ;make largest number primary + mov flprm,si + mov flsec,di + neg cx ;fix exponent difference +order_ok: + cmp cx,64 ;see if numbers overlap + jna add_ok ;no overlap just return largest number + pop di + pop si + pop bp + popf + ret +add_ok: + lea si,-3[di] + mov di,offset temp+7 + sub al,al +cx_check: + cmp cx,8 ;more than a byte to shift ? + jb shift_it ;no, then shift remaining part over + stos byte ptr [di] + sub cx,8 + jmp cx_check +shift_it: + sub dl,dl +shift_loop: + mov ah,dl + lods byte ptr [si] + mov dl,al + shr ax,cl + stos byte ptr [di] + cmp di,offset temp-2 + jae shift_loop +; + mov si,flprm + mov di,flsec + mov cx,5 ;load up for loops below + mov al,byte ptr [di] + xor al,byte ptr [si] + jns signs_same + test byte ptr [di],80H ;check which is negative + jnz sub_s_from_p +; +; subtract primary from secondary +; + clc + mov bx,0 +sub_loop_1: + mov ax,temp-2[bx] + sbb ax,word ptr -12[bx][si] + mov word ptr -12[bx][si],ax + inc bx + inc bx + loop sub_loop_1 + jmp short check_sign +; +; subtract secondary from primary +; +sub_s_from_p: + clc + mov bx,0 +sub_loop_2: + mov ax,temp-2[bx] + sbb word ptr -12[bx][si],ax + inc bx + inc bx + loop sub_loop_2 +check_sign: + mov byte ptr [si],0 ;mark result as positive + jnb do_normalize + mov byte ptr [si],0FFH ;mark result as negative + clc + mov bx,0 + mov cx,5 +neg_loop: + mov ax,0 + sbb ax,word ptr -12[bx][si] + mov word ptr -12[bx][si],ax + inc bx + inc bx + loop neg_loop + jmp short do_normalize +; +; signs of numbers are the same just add them together +; +signs_same: + clc + mov bx,0 +add_loop: + mov ax,temp-2[bx] + adc word ptr -12[bx][si],ax + inc bx + inc bx + loop add_loop +;;; jmp short do_normalize ;fall through +; +; normalize number such that first byte of number is >= 0x10 +; and < 0x20 +; +do_normalize: + mov si,flprm + lea bp,-12[si] +norm: + lea bx,-3[si] + mov dx,word ptr -2[si] ;get exponent +byte_loop: + cmp byte ptr [bx],0 + jne bskip_done + dec bx + sub dx,8 + cmp bx,bp + jae byte_loop +; +; number is zero +; +zero_result: + mov di,ds + mov es,di + mov di,flprm + sub ax,ax + mov cx,7 +rep stos word ptr [di] + pop di + pop si + pop bp + popf + ret + +bskip_done: + sub cx,cx + lea di,-3[si] + mov ah,byte ptr [bx] + dec bx + cmp ah,20H + jnb too_big +; + mov al,byte ptr [bx] + mov ch,al +left_count: + cmp ah,10H + jae move_left + shl ax,1 + inc cl + dec dx + jmp left_count +move_left: + mov [di],ah + dec di + dec bx + cmp bx,bp + jb clear_tail + mov ah,ch + mov al,byte ptr [bx] + mov ch,al + shl ax,cl + jmp move_left +; +; +too_big: + mov al,ah + sub ah,ah + mov ch,al +right_count: + inc cl + inc dx + shr ax,1 + cmp al,20H + jnb right_count +move_right: + stos byte ptr [di] + cmp bx,bp + jb clear_tail + mov ah,ch + mov al,byte ptr [bx] + dec bx + mov ch,al + shr ax,cl + jmp move_right +; +clear_tail: + mov cx,di + sub cx,bp + inc cx + jcxz norm_done + sub al,al +rep stos byte ptr [di] +; +norm_done: +; +; overflow/underflow checking needs to be done here +; + cmp dx,0 + jg no_under + mov flterr_,UNDER_FLOW + mov word ptr -2[si],1 + jmp short clr_fraction +no_under: + cmp dx,2048 + jl no_over + mov flterr_,OVER_FLOW + mov word ptr -2[si],2047 +clr_fraction: + mov word ptr -4[si],1000H + lea di,-6[si] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp fault_handler +no_over: + mov word ptr -2[si],dx ;save new value of exponent + pop di + pop si + pop bp + popf + ret +; + intrdef $ddv + ;double floating divide (primary = primary/secondary) + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov bp,flprm + mov bx,flsec + mov ax,ds:-2[bp] + test ax,ax + jnz not_zero + jmp zero_result +not_zero: + mov dx,-2[bx] + test dx,dx + jnz div_ok + mov flterr_,DIV_BY_ZERO + jmp fault_handler +div_ok: + sub ax,dx + add ax,1019 ;exp = Ep - Es + mov ds:-2[bp],ax + mov al,byte ptr [bx] + xor ds:byte ptr [bp],al +; + mov ax,-6[bx] ;check if easy divide case + or ax,-8[bx] + or ax,-10[bx] + jnz hard_div +; + mov si,-4[bx] + lea di,ds:-4[bp] + mov cx,4 + mov dx,[di] + cmp dx,si + jb ediv_loop + shl si,1 + inc ds:word ptr -2[bp] ;adjust exponent +ediv_loop: + mov ax,-2[di] + div si + stos word ptr [di] + loop ediv_loop + sub ax,ax ;this IS the correct way + div si + stos word ptr [di] + jmp do_normalize +; +hard_div: + lea si,ds:-4[bp] + lea di,-4[bx] + mov cx,4 +repe cmps acc1, es:acc2 + jne do_div +; numbers are the same so answer is 1 + add ds:word ptr -2[bp],4 ;adjust exponent + lea di,ds:-4[bp] + mov ax,1000H + stos es:acc1 + sub ax,ax + stos es:acc1 + stos es:acc1 + stos es:acc1 + mov si,bp + mov dx,word ptr -2[si] + jmp norm_done +; +do_div: + mov ds:word ptr -12[bp],0 + mov ax,ds:-10[bp] + mov dx,ds:-8[bp] + mov si,ds:-6[bp] + mov di,ds:-4[bp] + jb dont_shift + inc ds:word ptr -2[bp] ;fix exponent + shr di,1 + rcr si,1 + rcr dx,1 + rcr ax,1 +dont_shift: + sub cx,cx + sub bp,4 + mov loop_count,4 +bdiv_loop: + mov lcnt1,16 +div_loop: + shl cx,1 + shl ax,1 + rcl dx,1 + rcl si,1 + rcl di,1 + sub ax,word ptr -10[bx] + sbb dx,word ptr -8[bx] + sbb si,word ptr -6[bx] + sbb di,word ptr -4[bx] + js zero_bit +one_bit: + inc cx ;set bit in quotient + dec lcnt1 + jnz div_loop + mov ds:word ptr [bp],cx + sub bp,2 + sub cx,cx + dec loop_count + jnz bdiv_loop + jmp do_normalize +; +bzero_loop: + mov lcnt1,16 +zero_loop: + shl cx,1 + shl ax,1 + rcl dx,1 + rcl si,1 + rcl di,1 + add ax,word ptr -10[bx] + adc dx,word ptr -8[bx] + adc si,word ptr -6[bx] + adc di,word ptr -4[bx] + jns one_bit +zero_bit: + dec lcnt1 + jnz zero_loop + mov ds:word ptr [bp],cx + sub bp,2 + sub cx,cx + dec loop_count + jnz bzero_loop + jmp do_normalize +; +; + intrdef $dml + ;double floating multiply (primary = primary * secondary) + pushf + push bp + push si + push di + std + mov si,flprm + mov bx,flsec + mov ax,-2[si] + test ax,ax + jnz prm_not_zero + jmp zero_result +prm_not_zero: + mov dx,-2[bx] + test dx,dx + jnz alt_not_zero + jmp zero_result +alt_not_zero: + add ax,dx + sub ax,1019 + mov -2[si],ax + mov al,byte ptr [bx] + xor byte ptr [si],al + sub ax,ax + mov cx,8 + mov di,ds + mov es,di + mov di,offset temp+6 +rep stos word ptr [di] ;clear result +; + mov cx,-10[bx] + jcxz skip1 + mov ax,-6[si] + test ax,ax + jz skip13 + mul cx + mov temp-2,dx +skip13: + mov ax,-4[si] + test ax,ax + jz skip1 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 +skip1: + mov cx,-8[bx] + jcxz skip2 + mov ax,-8[si] + test ax,ax + jz skip22 + mul cx + add temp-2,dx + adc temp,0 + adc temp+2,0 +skip22: + mov ax,-6[si] + test ax,ax + jz skip23 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 +skip23: + mov ax,-4[si] + test ax,ax + jz skip2 + mul cx + add temp,ax + adc temp+2,dx + adc temp+4,0 +skip2: + mov cx,-6[bx] + jcxz skip3 + mov ax,-10[si] + test ax,ax + jz skip3x + mul cx + add temp-2,dx + adc temp,0 + adc temp+2,0 + adc temp+4,0 +skip3x: + mov ax,-8[si] + test ax,ax + jz skip31 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 + adc temp+4,0 +skip31: + mov ax,-6[si] + test ax,ax + jz skip32 + mul cx + add temp,ax + adc temp+2,dx + adc temp+4,0 +skip32: + mov ax,-4[si] + test ax,ax + jz skip3 + mul cx + add temp+2,ax + adc temp+4,dx + adc temp+6,0 +skip3: + mov cx,-4[bx] + jcxz skip4 + mov ax,-10[si] + test ax,ax + jz skip41 + mul cx + add temp-2,ax + adc temp,dx + adc temp+2,0 + adc temp+4,0 + adc temp+6,0 +skip41: + mov ax,-8[si] + test ax,ax + jz skip42 + mul cx + add temp,ax + adc temp+2,dx + adc temp+4,0 + adc temp+6,0 +skip42: + mov ax,-6[si] + test ax,ax + jz skip43 + mul cx + add temp+2,ax + adc temp+4,dx + adc temp+6,0 +skip43: + mov ax,-4[si] + test ax,ax + jz skip4 + mul cx + add temp+4,ax + adc temp+6,dx +skip4: + lea di,-4[si] + mov si,offset temp+6 + mov cx,5 +rep movs word ptr [di], word ptr [si] + jmp do_normalize +; + intrdef $utod + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov di,flprm + mov byte ptr [di],0 ;make sign positive + mov word ptr -2[di],1023+12 ;set exponent + sub di,4 + stos word ptr [di] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp do_normalize +; + intrdef $itod + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov di,flprm + mov byte ptr [di],0 ;make sign positive + mov word ptr -2[di],1023+12 ;set exponent + test ax,ax + jns pos_int + neg ax + mov byte ptr [di],80H ;make sign negative +pos_int: + sub di,4 + stos word ptr [di] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp do_normalize +; +dornd proc near + ; round the number in the primary accumulator + mov di,flprm + mov ax,word ptr -12[di] + mov word ptr -12[di],0 + cmp byte ptr -10[di],80H + mov byte ptr -10[di],0 + jb rndexit + jne round_up + test ax,ax + jnz round_up + or byte ptr -9[di],1 ;round up on even, down on odd + ret +round_up: + add byte ptr -9[di],1 + adc word ptr -8[di],0 + adc word ptr -6[di],0 + adc word ptr -4[di],0 + cmp byte ptr -3[di],20h + jb rndexit + inc word ptr -2[di] ;bump exponent + shr word ptr -4[di],1 ;and re-normalize number + rcr word ptr -6[di],1 + rcr word ptr -8[di],1 + rcr word ptr -10[di],1 +rndexit: + ret +dornd endp +; + intrdef $xtod + mov cx,1 + jmp short xxtod + + intrdef $ul2d + mov cx,0 +xxtod: + pushf + push bp + push si + push di + std + mov di,ds + mov es,di + mov di,flprm + mov byte ptr [di],0 ;make sign positive + mov word ptr -2[di],1023+28 ;set exponent + test cx,cx + jz pos_long + test dx,dx + jns pos_long + neg dx + neg ax + sbb dx,0 + mov byte ptr [di],80H ;make sign negative +pos_long: + sub di,4 + xchg ax,dx + stos word ptr [di] + xchg ax,dx + stos word ptr [di] + sub ax,ax + stos word ptr [di] + stos word ptr [di] + stos word ptr [di] + jmp do_normalize +; + intrdef $dtou + intrdef $dtoi + intrdef $dtox + push si + push di + mov si,flprm + sub ax,ax + mov temp,ax + mov temp+2,ax + mov temp+4,ax + mov temp+6,ax + mov ax,word ptr -2[si] + sub ax,1023 + js d2x_zero + cmp ax,54 + jae d2x_zero + mov di,ds + mov es,di + mov di,offset temp + sub bx,bx + mov cx,ax + mov ax,4 +d2x_count: + sub cx,ax + jbe d2x_cdone + dec bx + mov ax,8 + jmp d2x_count +d2x_cdone: + mov dl,byte ptr -3[si][bx] + mov byte ptr [di],dl + inc di + inc bx + jle d2x_cdone + neg cx + mov ax,temp + mov dx,temp+2 + mov bx,temp+4 + jcxz d2x_nshift +d2x_shift: + shr bx,1 + rcr dx,1 + rcr ax,1 + loop d2x_shift +d2x_nshift: + test byte ptr [si],80H + jz d2x_ret + neg dx + neg ax + sbb dx,0 +d2x_ret: + pop di + pop si + ret + +d2x_zero: + sub ax,ax + sub dx,dx + pop di + pop si + ret + + intrdef $dstat ; save floating state in buf es:bx + push si + push di + mov di,bx + mov si, offset flterr_ ; get start of data area + mov cx, offset lcnt1+1 ; get end of data area + sub cx, si ; get size +rep movs byte ptr [di], byte ptr [si] ; save floating state + pop di + pop si + ret + + intrdef $drest ; restore floating state from buf es:bx + push si + push di + push ds + mov dx,ds ; swap segment registers + mov cx,es + mov ds,cx + mov es,dx + mov si,bx + mov di, offset flterr_ ; get start of data area + mov cx, offset lcnt1+1 ; get end of data area + sub cx, di ; get size +rep movs byte ptr [di], byte ptr [si] ; restore floating state + pop ds + pop di + pop si + ret + +; +; +fault_handler: + pop di + pop si + pop bp + popf + ret +; +ifndef INTERNAL +$floats endp + finish + end +endif + fsubs87.asm +ifndef INTERNAL +; Copyright (C) 1983 by Manx Software Systems +; page 54,130 +; :ts=8 +; floating point system error codes: + include lmacros.h +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; + internal $floats + +dataseg segment word public 'data' + public flterr_ +flterr_ dw 0 +second db 8 dup (?) +work dw 4 dup (?) +status dw 0 + extrn chop_ctl:word, round_ctl:word, rdown_ctl:word +dataseg ends + assume ds:dataseg +ifdef FARPROC +frame equ 4 +else +frame equ 2 +endif + +endif + +ifdef INTERNAL +; +; In the table 0 -- number is valid +; 1 -- number is +/- NAN +; 2 -- number is +/- infinity +; 3 -- number is +/- unnormal +; 4 -- number is +/- denormal +; 5 -- register is marked empty + +oktab db 3,1,3,1,0,2,0,2,0,5,0,5,4,5,4,5 + + intrdef $isnan + push bp + mov bp,sp + sub sp,2 + fxam + fstsw word ptr -2[bp] + fwait + mov bl,byte ptr -1[bp] + and bl,047h + test bl,40h + jz noc3 + or bl,08h +noc3: + and bx,0fh ; mask to get c3 c2 c1 and c0 bits + mov al,cs:byte ptr oktab[bx] + cbw + test ax,ax + mov sp,bp + pop bp + ret +endif + + intrdef $fldpds ;load single float into primary accum +ifndef LONGPTR + intrdef $fldp +endif + finit + fld ds:dword ptr[bx] + ret + + intrdef $fldpss ;load single float into primary accum + finit + fld ss:dword ptr[bx] + ret + + intrdef $fldpes +ifdef LONGPTR + intrdef $fldp ;load single float into primary accum +endif + finit + fld es:dword ptr[bx] + ret + + intrdef $fldsds ;load single float into secondary accum +ifndef LONGPTR + intrdef $flds +endif + fld ds:dword ptr[bx] + fstp qword ptr second + ret + + intrdef $fldsss ;load single float into secondary accum + fld ss:dword ptr[bx] + fstp qword ptr second + ret + + intrdef $fldses +ifdef LONGPTR + intrdef $flds ;load single float into secondary accum +endif + fld es:dword ptr[bx] + fstp qword ptr second + ret + + intrdef $fstds ;store single at addr in BX +ifndef LONGPTR + intrdef $fst +endif + fst ds:dword ptr[bx] + fwait + ret + + intrdef $fstss ;store single at addr in BX + fst ss:dword ptr[bx] + fwait + ret + + intrdef $fstes +ifdef LONGPTR + intrdef $fst ;store single at addr in BX +endif + fst es:dword ptr[bx] + fwait + ret + + intrdef $fstsds ;store single at addr in BX +ifndef LONGPTR + intrdef $fsts +endif + fld qword ptr second + fstp ds:dword ptr[bx] + fwait + ret + + intrdef $fstsss ;store single at addr in BX + fld qword ptr second + fstp ss:dword ptr[bx] + fwait + ret + + intrdef $fstses +ifdef LONGPTR + intrdef $fsts ;store single at addr in BX +endif + fld qword ptr second + fstp es:dword ptr[bx] + fwait + ret + + intrdef $dldpds ;load double float into primary accum +ifndef LONGPTR + intrdef $dldp +endif + finit + fld ds:qword ptr[bx] + ret + + intrdef $dldpss ;load double float into primary accum + finit + fld ss:qword ptr[bx] + ret + + intrdef $dldpcs ;load double float into primary accum + finit +ifndef FARPROC + fld cs:qword ptr[bx] +else + mov cx,bx + mov bx,sp + mov bx,ss:2[bx] + xchg cx,bx + mov es,cx + fld es:qword ptr[bx] +endif + ret + + intrdef $dldpes +ifdef LONGPTR + intrdef $dldp ;load double float into primary accum +endif + finit + fld es:qword ptr[bx] + ret + + intrdef $dldsds +ifndef LONGPTR + intrdef $dlds +endif + push di + push si + push ds + mov cx,ds + mov es,cx + jmp dodldsx + + intrdef $dldsss + mov cx,ss + mov es,cx + jmp dodlds + + intrdef $dldscs +ifndef FARPROC + mov cx,cs + mov es,cx +else + mov cx,bx + mov bx,sp + mov bx,ss:2[bx] ; gat code segment of calling routine + xchg cx,bx + mov es,cx +endif + jmp dodlds + + intrdef $dldses +ifdef LONGPTR + intrdef $dlds ;load double float into secondary accum +endif +dodlds: + push di + push si + push ds + mov di,ds + mov si,es + mov ds,si + mov es,di +dodldsx: + mov di,offset second + mov si,bx + mov cx,4 +rep movsw + pop ds + pop si + pop di + ret + + intrdef $dstds ;store double at addr in BX +ifndef LONGPTR + intrdef $dst +endif + fst ds:qword ptr[bx] + fwait + ret + + intrdef $dstss ;store double at addr in BX + fst ss:qword ptr[bx] + fwait + ret + + intrdef $dstes +ifdef LONGPTR + intrdef $dst ;store double at addr in BX +endif + fst es:qword ptr[bx] + fwait + ret + + intrdef $dstsds ;store double at addr in BX +ifndef LONGPTR + intrdef $dsts +endif + fld qword ptr second + fstp ds:qword ptr[bx] + fwait + ret + + intrdef $dstsss ;store double at addr in BX + fld qword ptr second + fstp ss:qword ptr[bx] + fwait + ret + + intrdef $dstses +ifdef LONGPTR + intrdef $dsts +endif + fld qword ptr second + fstp es:qword ptr[bx] + fwait + ret + + intrdef $dlip ;load double immediate primary + pop bx +ifdef FARPROC + pop es + finit + fld es:qword ptr [bx] + add bx,8 + push es + push bx + ret +else + finit + fld cs:qword ptr[bx] + add bx,8 + jmp bx +endif +; + intrdef $dlis ;load double immediate secondary + pop bx +ifdef FARPROC + pop dx +endif + push di + push si + mov di,ds + mov es,di + mov di,offset second + mov si,bx ;get return addr + mov cx,4 +ifdef FARPROC + push ds + mov ds,dx +lis_lp: ;8086 doesn't handle double prefixes + movs word ptr [di], word ptr [si] +else +lis_lp: ;8086 doesn't handle double prefixes + movs word ptr [di], cs:word ptr [si] +endif + loop lis_lp + mov bx,si +ifdef FARPROC + pop ds +endif + pop si + pop di +ifdef FARPROC + push dx + push bx + ret +else + jmp bx +endif + + intrdef $dpsh ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back + jmp $dstss + + intrdef $dpshs ;push double float onto the stack + ;from the primary accumulator + pop ax ;fetch return address +ifdef FARPROC + pop dx +endif + sub sp,8 ;make room for double on stack + mov bx,sp ;address of place to store +ifdef FARPROC + push dx +endif + push ax ;put return address back + jmp $dstsss + + intrdef $dpopp ;pop double float into secondary accum + push bx + push es + mov bx,sp + add bx,frame+4 ;address of data to load + call $dldpss + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dpop ;pop double float into secondary accum + push bx + push es + mov bx,sp + add bx,frame+4 ;address of data to load + call $dldsss + pop es + pop bx + ret 8 ;return and de-allocate space +; + intrdef $dswap ;exchange primary and secondary + fld qword ptr second + fxch + fstp qword ptr second + fwait + ret +; + intrdef $dng ;negate primary + fchs + ret +; + intrdef $dtst ;test if primary is zero + ftst + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + jne ltrue + sub ax,ax + ret +ltrue: + sub ax,ax + inc ax + ret +; + intrdef $dcmp ;compare primary and secondary + fcom qword ptr second + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + jb lp_lt_s + ja lp_gt_s + ;return 0 if p == s + xor ax,ax + ret + ;return 0 if p == s +lp_lt_s: ;return < 0 if p < s + xor ax,ax + dec ax + ret +; +lp_gt_s: ; > 0 if p > s + xor ax,ax + inc ax + ret +; + intrdef $dsb ;subtract secondary from primary + fsub qword ptr second + ret +; + intrdef $dad ;add secondary to primary + fadd qword ptr second + ret +; + intrdef $ddv + ;double floating divide (primary = primary/secondary) + fdiv qword ptr second + ret +; + intrdef $dml + ;double floating multiply (primary = primary * secondary) + fmul qword ptr second + ret +; + intrdef $utod + mov work,ax + mov work+2,0 + fild dword ptr work + ret +; + intrdef $itod + mov work,ax + finit + fild word ptr work + ret +; + intrdef $ul2d + mov work,ax + mov work+2,dx + mov work+4,0 + mov work+6,0 + finit + fild qword ptr work + ret +; + intrdef $xtod + mov work,ax + mov work+2,dx + finit + fild dword ptr work + ret +; + intrdef $dtou + intrdef $dtoi + intrdef $dtox + fldcw word ptr chop_ctl + fld st(0) + fistp qword ptr work + fldcw word ptr round_ctl + fwait + mov ax,work + mov dx,work+2 + ret + + intrdef $dstat ; save floating state in buf es:bx + push si + push di + push ds + mov di,bx + mov si,offset flterr_ ;get start of data + mov cx,offset status+2 ;get end of data + sub cx,si ;get size + add bx,cx ;save end +rep movs byte ptr [di], byte ptr [si] ; save data + mov cx,es + mov ds,cx + esc 101110b,[bx] ; save floating state (acts like finit) + wait + esc 101100b,[bx] ; restore floating state + pop ds + pop di + pop si + ret + + intrdef $drest ; restore floating state from buf es:bx + push si + push di + push ds + mov si,bx + mov cx,es ; swap segment registers + mov dx,ds + mov es,dx + mov ds,cx + mov di,offset flterr_ ;get start of data + mov cx,offset status+2 ;get end of data + sub cx,di ;get size + add bx,cx ;save end +rep movs byte ptr [di], byte ptr [si] ; save data + esc 101100b,[bx] ; restore floating state + wait + pop ds + pop di + pop si + ret + +ifndef INTERNAL +$floats endp + finish + end +endif + fsubs87s.asm +; Copyright (C) 1983 by Manx Software Systems +; page 54,130 +; :ts=8 +; floating point system error codes: + include lmacros.h + + internal $floats + +UNDER_FLOW equ 1 +OVER_FLOW equ 2 +DIV_BY_ZERO equ 3 +; +codeseg segment para public 'code' + public flprm,flsec + public flterr_ +dataseg segment para public 'data' + public $flt_inx, chop_ctl, round_ctl, rdown_ctl +$flt_inx dw 0 ; 8087/software emulation switch index +flterr_ dw 0 +second db 8 dup (?) +work dw 4 dup (?) +status dw 0 +flprm dw acc1 +flsec dw acc2 +YU dw ? +VEE dw ? + dw 5 dup (?) +acc1 dw 7 dup (?) +acc2 dw ? +; +;work area for divide and multiply routines +; + dw 4 dup (?) +temp dw 4 dup (?) +loop_count db 0 ;iterations left (for divide) +lcnt1 db 0 ;# iter. for this word of quotient +chop_ctl dw 0fbfH ;control word for Chop mode +round_ctl dw 03bfH ;control word for Round nearest mode +rdown_ctl dw 07bfh ;control word for Round Down mode + +dataseg ends + + assume ds:dataseg + +ifdef FARPROC +frame equ 4 +CALLSZ equ 5 +else +frame equ 2 +CALLSZ equ 3 +endif + +$flttb87 equ this word ; 8087 hardware indirection table + dw $isnan87 + dw $fldses87 + dw $fldpes87 + dw $fstes87 + dw $fstses87 + dw $dlis87 + dw $dldses87 + dw $dlip87 + dw $dldpes87 + dw $dstes87 + dw $dstses87 + dw $dpsh87 + dw $dpshs87 + dw $dpop87 + dw $dpopp87 + dw $dswap87 + dw $dng87 + dw $dtst87 + dw $dcmp87 + dw $dsb87 + dw $dad87 + dw $ddv87 + dw $dml87 + dw $utod87 + dw $itod87 + dw $xtod87 + dw $ul2d87 + dw $dtoi87 + dw $dstat87 + dw $drest87 + dw $fldsss87 + dw $fldsds87 + dw $fldpss87 + dw $fldpds87 + dw $fstss87 + dw $fstds87 + dw $fstsss87 + dw $fstsds87 + dw $dldsss87 + dw $dldsds87 + dw $dldpss87 + dw $dldpds87 + dw $dstss87 + dw $dstds87 + dw $dstsss87 + dw $dstsds87 + dw $dldpcs87 + dw $dldscs87 + +dataseg segment word public 'data' +$flttb equ this word ; initial indirection table +$isnantb dw $isnan86 +$fldsestb dw $fldses86 +$fldpestb dw $fldpes86 +$fstestb dw $fstes86 +$fstsestb dw $fstses86 +$dlistb dw $dlis86 +$dldsestb dw $dldses86 +$dliptb dw $dlip86 +$dldpestb dw $dldpes86 +$dstestb dw $dstes86 +$dstsestb dw $dstses86 +$dpshtb dw $dpsh86 +$dpshstb dw $dpshs86 +$dpoptb dw $dpop86 +$dpopptb dw $dpopp86 +$dswaptb dw $dswap86 +$dngtb dw $dng86 +$dtsttb dw $dtst86 +$dcmptb dw $dcmp86 +$dsbtb dw $dsb86 +$dadtb dw $dad86 +$ddvtb dw $ddv86 +$dmltb dw $dml86 +$utodtb dw $utod86 +$itodtb dw $itod86 +$xtodtb dw $xtod86 +$ul2dtb dw $ul2d86 +$dtoitb dw $dtoi86 +$dstattb dw $dstat86 +$dresttb dw $drest86 +$fldssstb dw $fldsss86 +$fldsdstb dw $fldsds86 +$fldpsstb dw $fldpss86 +$fldpdstb dw $fldpds86 +$fstsstb dw $fstss86 +$fstdstb dw $fstds86 +$fstssstb dw $fstsss86 +$fstsdstb dw $fstsds86 +$dldssstb dw $dldsss86 +$dldsdstb dw $dldsds86 +$dldpsstb dw $dldpss86 +$dldpdstb dw $dldpds86 +$dstsstb dw $dstss86 +$dstdstb dw $dstds86 +$dstssstb dw $dstsss86 +$dstsdstb dw $dstsds86 +$dldpcstb dw $dldpcs86 +$dldscstb dw $dldscs86 +dataseg ends + + +SIZFLTTB equ 48 + + intrdef $fltinit +; test for 8087/80287 and install new vector table if present + push si + push di + push es + mov ds:status,0 + esc 28,bx ; finit (initialize 8087) + xor cx,cx + esc 15,ds:status ; fstcw + mov cx,50 +w1loop: loop w1loop ; wait for a while + and status,01f3fh ; clear unused bits + cmp status,0033fh ; is 8087 there? + jnz no_8087 ; no, use software emulation + wait + esc 47,status ; fstsw status + mov cx,50 +w2loop: loop w2loop ; wait for a while + test ds:status,0b8bfh ; all status bits should be off + jnz no_8087 ; bad status, assume not there + mov si,offset $flttb87 ; 8087 is there! + mov $flt_inx,2 ; set index for outside routines + mov ax,ds + mov es,ax + mov di,cs + mov ds,di + mov di,offset $flttb ; get pointer to indirection table + mov cx,SIZFLTTB + cld +rep movsw ; and overwrite it with new table + mov ds,ax + fldcw word ptr round_ctl ;set initial control + +no_8087: + pop es + pop di + pop si + clc ;return OK status + ret + + intrdef $isnan + jmp $isnantb + + intrdef $fldses +ifdef LONGPTR + intrdef $flds ;load single float into secondary accum +endif + jmp $fldsestb + + intrdef $fldsss ;load single float into secondary accum + jmp $fldssstb + + intrdef $fldsds ;load single float into secondary accum +ifndef LONGPTR + intrdef $flds +endif + jmp $fldsdstb +; + intrdef $fldpes +ifdef LONGPTR + intrdef $fldp ;load single float into primary accum +endif + jmp $fldpestb +; + intrdef $fldpss ;load single float into primary accum + jmp $fldpsstb +; + intrdef $fldpds ;load single float into primary accum +ifndef LONGPTR + intrdef $fldp +endif + jmp $fldpdstb +; + intrdef $fstes +ifdef LONGPTR + intrdef $fst ;store single at addr in BX +endif + jmp $fstestb +; + intrdef $fstses +ifdef LONGPTR + intrdef $fsts ;store single at addr in BX +endif + jmp $fstsestb +; + intrdef $fstss ;store single at addr in BX + jmp $fstsstb +; + intrdef $fstds ;store single at addr in BX +ifndef LONGPTR + intrdef $fst +endif + jmp $fstdstb + + intrdef $fstsss ;store single at addr in BX + jmp $fstssstb +; + intrdef $fstsds ;store single at addr in BX +ifndef LONGPTR + intrdef $fsts +endif + jmp $fstsdstb +; + intrdef $dlis ;load double immediate secondary + jmp $dlistb +; + intrdef $dldsss + jmp $dldssstb + + intrdef $dldscs + jmp $dldscstb + + intrdef $dldsds +ifndef LONGPTR + intrdef $dlds +endif + jmp $dldsdstb + + intrdef $dldses +ifdef LONGPTR + intrdef $dlds ;load double float into secondary accum +endif + jmp $dldsestb +; + intrdef $dlip ;load double immediate primary + jmp $dliptb +; + intrdef $dldpss ;load double float into primary accum + jmp $dldpsstb + + intrdef $dldpcs ;load double float into primary accum + jmp $dldpcstb + + intrdef $dldpds ;load double float into primary accum +ifndef LONGPTR + intrdef $dldp +endif + jmp $dldpdstb + + intrdef $dldpes +ifdef LONGPTR + intrdef $dldp ;load double float into primary accum +endif + jmp $dldpestb +; + intrdef $dstses +ifdef LONGPTR + intrdef $dsts +endif + jmp $dstsestb + + intrdef $dstes +ifdef LONGPTR + intrdef $dst ;store double at addr in BX +endif + jmp $dstestb + + intrdef $dstss ;store double at addr in BX + jmp $dstsstb + + intrdef $dstds ;store double at addr in BX +ifndef LONGPTR + intrdef $dst +endif + jmp $dstdstb + + intrdef $dstsss ;store double at addr in BX + jmp $dstssstb + + intrdef $dstsds ;store double at addr in BX +ifndef LONGPTR + intrdef $dsts +endif + jmp $dstsdstb + + intrdef $dpsh ;push double float onto the stack + ;from the primary accumulator + jmp $dpshtb +; + intrdef $dpshs ;push double float onto the stack + ;from the secondary accumulator + jmp $dpshstb + + intrdef $dpopp ;pop double float into primary accum + jmp $dpopptb +; + intrdef $dpop ;pop double float into secondary accum + jmp $dpoptb +; + intrdef $dswap ;exchange primary and secondary + jmp $dswaptb +; + intrdef $dng ;negate primary + jmp $dngtb +; + intrdef $dtst ;test if primary is zero + jmp $dtsttb +; + intrdef $dcmp ;compare primary and secondary + jmp $dcmptb +; + intrdef $dsb ;subtract secondary from primary + jmp $dsbtb +; + intrdef $dad ;add secondary to primary + jmp $dadtb +; + intrdef $ddv + ;double floating divide (primary = primary/secondary) + jmp $ddvtb +; + intrdef $dml + ;double floating multiply (primary = primary * secondary) + jmp $dmltb +; + intrdef $utod + jmp $utodtb +; + intrdef $itod + jmp $itodtb +; + intrdef $xtod + jmp $xtodtb +; + intrdef $ul2d + jmp $ul2dtb +; + intrdef $dtou + intrdef $dtoi + intrdef $dtox + jmp $dtoitb + + intrdef $dstat + jmp $dstattb + + intrdef $drest + jmp $dresttb + +INTERNAL equ 1 + purge intrdef +intrdef macro pname +pname&86 label near + endm + include fsubs.asm + purge intrdef +intrdef macro pname +pname&87 label near + endm + include fsubs87.asm + purge intrdef +intrdef macro pname + public pname +ifdef FARPROC + pname label far +else + pname label near +endif + endm +$floats endp + finish + end + ftoa.asm +; Copyright (C) 1984 by Manx Software Systems +; + include lmacros.h +; +;static double rounding[] = { +rounding equ this word +; 5.0e+0, + db 00H,00H,00H,00H,00H,00H,014H,040H +; 0.5e+0, + db 00H,00H,00H,00H,00H,00H,0e0H,03fH +; 0.5e-1, + db 09aH,099H,099H,099H,099H,099H,0a9H,03fH +; 0.5e-2, + db 07bH,014H,0aeH,047H,0e1H,07aH,074H,03fH +; 0.5e-3, + db 0fcH,0a9H,0f1H,0d2H,04dH,062H,040H,03fH +; 0.5e-4, + db 02dH,043H,01cH,0ebH,0e2H,036H,0aH,03fH +; 0.5e-5, + db 0f1H,068H,0e3H,088H,0b5H,0f8H,0d4H,03eH +; 0.5e-6, + db 08dH,0edH,0b5H,0a0H,0f7H,0c6H,0a0H,03eH +; 0.5e-7, + db 048H,0afH,0bcH,09aH,0f2H,0d7H,06aH,03eH +; 0.5e-8, + db 03aH,08cH,030H,0e2H,08eH,079H,035H,03eH +; 0.5e-9, + db 095H,0d6H,026H,0e8H,0bH,02eH,01H,03eH +; 0.5e-10, + db 0bbH,0bdH,0d7H,0d9H,0dfH,07cH,0cbH,03dH +; 0.5e-11, + db 095H,064H,079H,0e1H,07fH,0fdH,095H,03dH +; 0.5e-12, + db 011H,0eaH,02dH,081H,099H,097H,061H,03dH +; 0.5e-13, + db 082H,076H,049H,068H,0c2H,025H,02cH,03dH +; 0.5e-14, + db 09bH,02bH,0a1H,086H,09bH,084H,0f6H,03cH +; 0.5e-15, + db 016H,056H,0e7H,09eH,0afH,03H,0c2H,03cH +; 0.5e-16, +; db 0bcH,089H,0d8H,097H,0b2H,0d2H,08cH,03cH +; 0.5e-17, +; db 097H,0d4H,046H,046H,0f5H,0eH,057H,03cH +; 0.5e-18, +; db 0acH,043H,0d2H,0d1H,05dH,072H,022H,03cH +;}; + +ten dw 0,0,0,4024h +zero dw 0,0,0,0 +; 1, +one db 00H,00H,00H,00H,00H,00H,0f0H,03fH +; 2, + db 00H,00H,00H,00H,00H,00H,00H,040H +; 3, + db 00H,00H,00H,00H,00H,00H,08H,040H +; 4, + db 00H,00H,00H,00H,00H,00H,010H,040H +; 5, + db 00H,00H,00H,00H,00H,00H,014H,040H +; 6, + db 00H,00H,00H,00H,00H,00H,018H,040H +; 7, + db 00H,00H,00H,00H,00H,00H,01cH,040H +; 8, + db 00H,00H,00H,00H,00H,00H,020H,040H +; 9 + db 00H,00H,00H,00H,00H,00H,022H,040H + + extrn $maxdigit:word ;this item is in CODESEG. + +ifdef INLINE +dataseg segment word public 'data' + extrn chop_ctl:word, round_ctl:word +status dw 0 + +dataseg ends + assume ds:dataseg +endif + +IFDEF LONGPTR +buffer equ es:byte ptr [di] +getes macro + mov es,word ptr abuf[2] + endm +ELSE + +buffer equ byte ptr [di] +getes macro +; + endm +ENDIF +; +;ftoa(number, abuf, maxwidth, flag) +;double number; register char *abuf; + procdef ftoa, <,,,> + add sp,-8 + push di + push si + mov di,word ptr abuf ;load offset word of buffer +;{ +; register int i; +; int exp, digit, decpos, ndig; +; +; ndig = maxwidth+1; + mov ax,maxwidth + inc ax + mov word ptr -8[bp],ax +; exp = 0; + mov word ptr -2[bp],0 +ifdef INLINE + fld qword ptr number +else + lea bx,number + call $dldpss +endif + call $isnan + je notnan + mov cx,ax + mov al,'?' + cmp cx,1 + beq outrange + mov al,'*' + cmp cx,3 + je iszero + cmp cx,4 + je iszero + jmp outrange +iszero: +ifdef INLINE + fstp st(0) ; discard number + fldz +else + mov bx, offset zero + call $dldpcs +endif +notnan: +; if (number < 0.0) { +ifdef INLINE + ftst + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + je $4 + jnc $3 +else + mov bx, offset zero + call $dldscs + call $dcmp + je $4 ;skip scaling if zero + jge $3 +endif +; number = -number; +ifdef INLINE + fchs +else + call $dng +endif +; *buffer++ = '-'; + getes + mov buffer,'-' + inc di +; } +$3: +; if (number > 0.0) { +; while (number < 1.0) { +$5: +ifdef INLINE + fld1 + fcomp + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + jbe $6 +else + mov bx, offset one + call $dldscs + call $dcmp + jge $6 +endif +; number *= 10.0; +ifdef INLINE + fmul qword ptr ten +else + mov bx,offset ten + call $dldscs + call $dml +endif +; --exp; + dec word ptr -2[bp] +; } + jmp $5 +$6: +; while (number >= 10.0) { +ifdef INLINE +$7: + fcom qword ptr ten + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + jb $8 + fdiv qword ptr ten +else + mov bx,offset ten + call $dldscs +$7: + call $dcmp + jl $8 +; number /= 10.0; + call $ddv +endif +; ++exp; + inc word ptr -2[bp] +; } + jmp $7 +$8: +; } +; +; if (flag == 2) { /* 'g' format */ +$4: + mov ax,flag + cmp ax,2 + jne $9 +; ndig = maxwidth; + mov ax,maxwidth + mov word ptr -8[bp],ax +; if (exp < -4 || exp >= maxwidth) +; flag = 0; /* switch to 'e' format */ + mov ax,word ptr -2[bp] + cmp ax,-4 + jl $11 + cmp ax,maxwidth + jl $10 +$11: + mov flag,0 +$10: + jmp $12 +; } else if (flag == 1) /* 'f' format */ +; ndig += exp; +$9: + cmp al,1 + jne $13 + mov ax,word ptr -2[bp] + add word ptr -8[bp],ax +; +; if (ndig >= 0) { +$13: +$12: + mov bx,word ptr -8[bp] + test bx,bx + jl $14 +; if ((number += round[ndig>MAXDIGIT?MAXDIGIT:ndig]) >= 10.0) { +IFDEF FARPROC + mov ax,es ; save es into ax + mov cx,seg $maxdigit + mov es,cx + cmp bx,es:$maxdigit +ELSE + cmp bx,$maxdigit +ENDIF + jle $16 +IFDEF FARPROC + mov bx,seg $maxdigit + mov es,bx + mov bx,es:$maxdigit +ELSE + mov bx,$maxdigit +ENDIF + +$16: +IFDEF FARPROC + mov es,ax ; resotre es +ENDIF + mov cx,3 + shl bx,cl +ifdef INLINE + fadd qword ptr rounding[bx] + fcom qword ptr ten + fstsw word ptr status + fwait + mov ah,byte ptr status+1 + sahf + jb $15 + fstp st(0) + fld1 +else + add bx,offset rounding + call $dldscs + call $dad + mov bx,offset ten + call $dldscs + call $dcmp + jl $15 +; number = 1.0; + mov bx, offset one + call $dldpcs +endif +; ++exp; + inc word ptr -2[bp] +; if (flag) +; ++ndig; + cmp flag,0 + je $18 + inc word ptr -8[bp] +; } +$18: +; } +$15: +; +; if (flag) { +$14: + cmp flag,0 + je $19 +; if (exp < 0) { + mov ax,word ptr -2[bp] + test ax,ax + jge $20 +; *buffer++ = '0'; + getes + mov buffer,'0' + inc di +; *buffer++ = '.'; + mov buffer,'.' + inc di +; i = -exp - 1; + not ax + mov cx,ax +; if (ndig <= 0) +; i = maxwidth; + cmp word ptr -8[bp],0 + jg $21 + mov cx,maxwidth +$21: +; while (i--) +; *buffer++ = '0'; + jcxz $23 + mov al,'0' +rep stosb +$23: +; decpos = 0; + sub ax,ax +; } else { + jmp short $25 +$20: +; decpos = exp+1; +; } + mov ax,word ptr -2[bp] + inc ax + jmp short $25 +; } else { +$19: +; decpos = 1; + mov ax,1 +; } +$25: + mov word ptr -6[bp],ax +ifdef INLINE + fldcw word ptr chop_ctl +endif +; +; if (ndig > 0) { + cmp word ptr -8[bp],0 + jle $28 +; for (i = 0 ; ; ++i) { + mov si,0 + jmp short $27 +$26: + inc si +$27: +; if (i < MAXDIGIT) { +IFDEF FARPROC + mov cx,es ; save es + mov ax,seg $maxdigit + mov es,ax + cmp si,es:$maxdigit + mov es,cx ; resotre es +ELSE + cmp si,$maxdigit +ENDIF + jge $29 +; digit = (int)number; +ifdef INLINE + fist word ptr status + fwait + mov ax,status +else + call $dtoi + push ax +endif +; *buffer++ = digit+'0'; + getes + add al,'0' + stosb +; number = (number - digit) * 10.0; +ifdef INLINE + fild word ptr status + fsub + fmul qword ptr ten +else + pop bx + dec bx + js no_subtract + mov cl,3 + shl bx,cl + add bx,offset one + call $dldscs + call $dsb +no_subtract: + mov bx, offset ten + call $dldscs + call $dml +endif + jmp short $30 +; } else +$29: +; *buffer++ = '0'; + getes + mov buffer,'0' + inc di +$30: +; if (--ndig == 0) +; break; + dec word ptr -8[bp] + jz $28 +; if (decpos && --decpos == 0) +; *buffer++ = '.'; + mov ax,word ptr -6[bp] + test ax,ax + jz $26 + dec ax + mov word ptr -6[bp],ax + jnz $26 + getes + mov buffer,'.' + inc di +; } + jmp $26 +; } +$28: +ifdef INLINE + fldcw word ptr round_ctl + fstp st(0) ; get rid of the value, we're done with it +endif + getes +; +; if (!flag) { + cmp flag,0 + jne $32 +; *buffer++ = 'e'; + mov buffer,'e' + inc di +; if (exp < 0) { +; exp = -exp; +; *buffer++ = '-'; + mov al,'+' + cmp word ptr -2[bp],0 + jge $33 + neg word ptr -2[bp] + mov al,'-' +; } else +; *buffer++ = '+'; +$33: + stosb +; if (exp >= 100) { + mov ax,word ptr -2[bp] + cmp ax,100 + jl $35 +; *buffer++ = exp/100 + '0'; + mov cx,100 + cwd + idiv cx + add al,'0' + stosb +; exp %= 100; + mov ax,dx +; } +; *buffer++ = exp/10 + '0'; +$35: + mov cx,10 + cwd + idiv cx + add al,'0' + stosb +; *buffer++ = exp%10 + '0'; + mov ax,dx + add al,'0' + stosb +; } +; *buffer = 0; +$32: + mov buffer,0 +;} + pop si + pop di + mov sp,bp + pret + +outrange: + mov cx,maxwidth + jcxz $32 +rep stosb + jmp $32 +; +ifdef FARPROC + extrn $isnan:far +else + extrn $isnan:near +endif + +ifndef INLINE +ifdef FARPROC + extrn $dad:far,$dsb:far,$dml:far,$ddv:far + extrn $dldpcs:far,$dldpss:far,$dldscs:far + extrn $dcmp:far,$dng:far,$dswap:far,$utod:far,$dtoi:far +else + extrn $dad:near,$dsb:near,$dml:near,$ddv:near + extrn $dldpcs:near,$dldpss:near,$dldscs:near + extrn $dcmp:near,$dng:near,$dswap:near,$utod:near,$dtoi:near +endif +endif + pend ftoa + finish + end + isnan.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + + procdef _isnan,<> + fld qword ptr x + call $isnan + pret + pend _isnan + +; +; In the table 0 -- number is valid +; 1 -- number is +/- NAN +; 2 -- number is +/- infinity +; 3 -- number is +/- unnormal +; 4 -- number is +/- denormal +; 5 -- register is marked empty + +oktab db 3,1,3,1,0,2,0,2,0,5,0,5,4,5,4,5 + + public $isnan +$isnan proc + push bp + mov bp,sp + sub sp,2 + fxam + fstsw word ptr -2[bp] + fwait + mov bl,byte ptr -1[bp] + and bl,047h + test bl,40h + jz noc3 + or bl,08h +noc3: + and bx,0fh ; mask to get c3 c2 c1 and c0 bits + mov al,cs:byte ptr oktab[bx] + cbw + test ax,ax + mov sp,bp + pop bp + ret +$isnan endp + finish + end + log.c +#include "math.h" +#include "errno.h" + +double log10(x) +double x; +{ + return log(x)*0.43429448190325182765; +} + +#define A0 -0.64124943423745581147e+2 +#define A1 +0.16383943563021534222e+2 +#define A2 -0.78956112887491257267e+0 +#define A(w) ((A2*w A1)*w A0) + +#define B0 -0.76949932108494879777e+3 +#define B1 +0.31203222091924532844e+3 +#define B2 -0.35667977739034646171e+2 +#define B(w) (((w B2)*w B1)*w B0) + +#define C0 0.70710678118654752440 +#define C1 0.693359375 +#define C2 -2.121944400546905827679e-4 + +double log(x) +double x; +{ + double Rz, f, z, w, znum, zden, xn; + int n; + extern int errno; + + if (x <= 0.0) { + errno = EDOM; + return -HUGE_VAL; + } + f = frexp(x, &n); + if (f > C0) { + znum = (znum = f-0.5) - 0.5; /* the assignment prevents const. eval */ + zden = f*0.5 + 0.5; + } else { + --n; + znum = f - 0.5; + zden = znum*0.5 + 0.5; + } + z = znum/zden; + w = z*z; +/* the lines below are split up to allow expansion of A(w) and B(w) */ + Rz = z + z * (w * + A(w) + /B(w)); + xn = n; + return (xn*C2 + Rz) + xn*C1; +} + log87.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + +EDOM equ 22 + +;/****************************** log10 ***************************** +; Using the 8087/80287, calculate log, base 10, of x using +; the formula: +; log x = log 2 . log x +; 10 10 2 +;*/ + +neghuge db 099h,0bbh,0adh,058h,0f1h,0dch,0efh,0ffh +botval db 0cdh,03bh,07fh,066h,09eh,0a0h,0e6h,03fh +topval db 01ah,062h,0c0h,0cch,0b0h,0afh,0f4h,03fh + + assume cs:codeseg,ds:dataseg + +dataseg segment public byte 'data' + extrn errno_:word +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + +;double log10 (x) +;double x; +; + procdef log10,<> + sub sp,2 + fld qword ptr x + ftst + fstsw word ptr -2[bp] + mov ah,byte ptr -1[bp] + sahf + jz badval + jnc okval +badval: + mov errno_,EDOM + fstp st(0) + fld cs:qword ptr neghuge + jmp exit +okval: + fldlg2 + fxch st(1) + fld cs:qword ptr botval + fcomp + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnae default + fld cs:qword ptr topval + fcomp + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnb default + fld1 + fsub + fyl2xp1 + jmp exit +default: + fyl2x +exit: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,2 + pret + pend log10 + + +;/****************************** log ***************************** +; Using the 8087/80287, calculate log, base e, of x using +; the formula: +; log x = log 2 . log x +; e e 2 +;*/ + +;double log (x) +;double x; + + procdef log,<> + sub sp,2 + fld qword ptr xx + ftst + fstsw word ptr -2[bp] + mov ah,byte ptr -1[bp] + sahf + jz badval1 + jnc okval1 +badval1: + mov errno_,EDOM + fstp st(0) + fld cs:qword ptr neghuge + jmp exit1 +okval1: + fldln2 + fxch st(1) + fld cs:qword ptr botval + fcomp + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnae default1 + fld cs:qword ptr topval + fcomp + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnb default1 + fld1 + fsub + fyl2xp1 + jmp exit1 +default1: + fyl2x +exit1: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,2 + pret + pend log + finish + end + pow.c +#include "math.h" +#include "errno.h" + +double pow(a,b) +double a,b; +{ + double answer; + extern int errno; + register long count; + char sign, inverse; + + if (a == 0) { + if (b <= 0) +domain: errno = EDOM; + return 0.0; + } + if (b == 0) + return 1.0; /* anything raised to 0 is 1 */ + inverse = sign = 0; + if (modf(b,&answer) == 0) { + if (answer < 0) + inverse = 1, answer = -answer; + if ((count = answer) == answer) { + for (answer = 1.0 ; count ; count >>= 1, a *= a) + if ((int)count & 1) + answer *= a; + if (inverse) + answer = 1.0/answer; + return answer; + } + if (a < 0) + sign = 1, a = -a; + if ((count&1) == 0) + sign = 0; /* number is even so sign is positive */ + + } else if (a < 0) + goto domain; + + answer = exp(log(a)*b); + return sign ? -answer : answer; +} + random.c +/* + * Random number generator - + * adapted from the FORTRAN version + * in "Software Manual for the Elementary Functions" + * by W.J. Cody, Jr and William Waite. + */ +double ran() +{ + static long int iy = 100001; + + iy *= 125; + iy -= (iy/2796203) * 2796203; + return (double) iy/ 2796203.0; +} + +double randl(x) +double x; +{ + double exp(); + + return exp(x*ran()); +} + sin.c +#include "math.h" +#include "errno.h" + +double cos(x) +double x; +{ + double sincos(); + + return sincos(x, fabs(x) + 1.57079632679489661923, 0); +} + +double sin(x) +double x; +{ + double sincos(); + + if (x < 0.0) + return sincos(x,-x,1); + else + return sincos(x,x,0); +} + +#define R1 -0.16666666666666665052e+00 +#define R2 +0.83333333333331650314e-02 +#define R3 -0.19841269841201840457e-03 +#define R4 +0.27557319210152756119e-05 +#define R5 -0.25052106798274584544e-07 +#define R6 +0.16058936490371589114e-09 +#define R7 -0.76429178068910467734e-12 +#define R8 +0.27204790957888846175e-14 + +#define YMAX 6.7465e09 + +static double sincos(x,y,sgn) +double x,y; +{ + double f, xn, g; + extern int errno; + + if (y >= YMAX) { + errno = ERANGE; + return 0.0; + } + if (modf(y * 0.31830988618379067154, &xn) >= 0.5) + ++xn; + if ((int)xn & 1) + sgn = !sgn; + if (fabs(x) != y) + xn -= 0.5; + g = modf(fabs(x), &x); /* break into fraction and integer parts */ + f = ((x - xn*(3217.0/1024)) + g) - xn*-8.9089102067615373566e-6; + if (fabs(f) > 2.3283e-10) { + g = f*f; + f = (((((((R8*g R7)*g R6)*g R5)*g + R4)*g R3)*g R2)*g R1)*g*f+f; + } + if (sgn) + f = -f; + return f; +} + sin87.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + +EDOM equ 22 +ERANGE equ 21 + +highval db 000h,066h,067h,0d0h,03dh,0ebh,0cfh,043h ; 4.6e+18 + + assume cs:codeseg,ds:dataseg + +dataseg segment public byte 'data' + extrn errno_:word +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + +;double cos (x) +;double x; + + procdef cos,<> + sub sp,2 + fld qword ptr x + fabs ;y = fabs(x) + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jz zeroval + jc badval ;if this is true y is not a number + fcom cs:qword ptr highval + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jb goodval ;y must be < 4.6e+18 +badval: + mov errno_,ERANGE + fstp st(0) ;clean up the stack + fldz ;result is zero + jmp exit +zeroval: + fstp st(0) ;clean up the stack + fld1 ;result is one + jmp exit +goodval: + fstp st(0) ;get rid of y + fld qword ptr x ; reload x + mov ax,1 + call near ptr __sincos +exit: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,2 + pret + pend cos + +;double sin (x) +;double (x); + + procdef sin,<> + sub sp,2 + fld qword ptr xx + fabs ; y = fabs(x) + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jz zeroval1 + jc badval1 ; y is not a number + fcom cs:qword ptr highval + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jb good1 ;y must be < 4.6e+18 +badval1: + mov errno_,ERANGE +zeroval1: + fstp st(0) ;clean up stack + fldz ;result is zero + jmp exit1 +good1: + fstp st(0) ;clean up the stack + fld qword ptr xx ; reload xx + xor ax,ax + call near ptr __sincos +exit1: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,2 + pret + pend sin + +__sincos proc near + push bp + mov bp,sp + sub sp,2 + mov cx,ax ; save flag + ftst ; set the status flags + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + xor dx,dx ; positive sign flag + sahf + ja sk_pos ; j if both bits zero (number is positive) + mov dx,1 ; negative sign flag +sk_pos: + mov word ptr -2[bp],-2 ; divide by 4 exponent + fild word ptr -2[bp] ; put exponent on stack + fldpi ; put pi on stack + fscale ; pi/4 + fxch ; put -2 before pi/4 + fstp st(0) ; and discard scale factor + fxch ; swap pi/4 and x (put x back on stack top) + fprem ; find which octant x lies in y = x/(pi/4) + fstsw word ptr -2[bp] + fabs ; x = fabs(x) + fwait + mov al,byte ptr -1[bp] + xor bx,bx + test al,1 ; using least significant 3 bits of quotient + jz ok1 ; determine which octant of unit circle x is in + or bx,4 +ok1: + test al,2 + jz ok2 + or bx,1 +ok2: + test al,64 + jz ok3 + or bx,2 +ok3: + cmp cx,1 + jnz noadjust + mov dx,0 + add bx,2 +noadjust: + test bx,1 + jz skip1 ; j if bit not set (not odd number) + fsub ; x = (pi/4) - x + jmp test_it +skip1: + fxch ; get p/4 on top + fstp st(0) ; and discard it +test_it: + ftst ; is x zero now? + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnz doit + fstp st(0) ; pop x clean up stack + fld1 ; answer is one + jmp exit2 +doit: + fptan ; compute partial tangent x/y x on top y in st1 +; +exit2: + mov ax,bx + and ax,3 + cmp ax,2 + jz noexch + cmp ax,1 + jz noexch + fxch ; swap x and y +noexch: + fxch + fld st(1) ; save a copy of x + fmul st,st(0) ; compute x ^ 2 + fxch + fmul st,st(0) ; compute y ^ 2 + fadd ; (x ^ 2) + (y ^ 2) + fsqrt ; sqrt (x ^ 2 + y ^ 2) + fdiv ; x / sqrt(x ^ 2 + y ^ 2) +; +; see if the sign needs to be changed +; + shr bx,1 + shr bx,1 + and bx,1 + cmp bx,dx + jz alldone + fchs ; x = - x +alldone: + fwait + add sp,2 + pop bp + ret +__sincos endp + finish + end + sinh.c +#include "math.h" +#include "errno.h" + +extern int errno; + +#define P0 -0.35181283430177117881e+6 +#define P1 -0.11563521196851768270e+5 +#define P2 -0.16375798202630751372e+3 +#define P3 -0.78966127417357099479e+0 +#define Q0 -0.21108770058106271242e+7 +#define Q1 +0.36162723109421836460e+5 +#define Q2 -0.27773523119650701667e+3 + +#define PS(x) (((P3*x P2)*x P1)*x P0) +#define QS(x) (((x Q2)*x Q1)*x Q0) + +double sinh(x) +double x; +{ + double y, w, z; + int sign; + + y = x; + sign = 0; + if (x < 0.0) { + y = -x; + sign = 1; + } + if (y > 1.0) { + w = y - 0.6931610107421875000; + if (w > LOGHUGE) { + errno = ERANGE; + z = HUGE_VAL; + } else { + z = exp(w); + if (w < 19.95) + z -= 0.24999308500451499336 / z; + z += 0.13830277879601902638e-4 * z; + } + if (sign) + z = -z; + } else if (y < 2.3e-10) + z = x; + else { + z = x*x; + z = x + x * + (z*(PS(z) + /QS(z))); + } + return z; +} + +double cosh(x) +double x; +{ + double y, w, z; + + y = fabs(x); + if (y > 1.0) { + w = y - 0.6931610107421875000; + if (w > LOGHUGE) { + errno = ERANGE; + return HUGE_VAL; + } + z = exp(w); + if (w < 19.95) + z += 0.24999308500451499336 / z; + z += 0.13830277879601902638e-4 * z; + } else { + z = exp(y); + z = z*0.5 + 0.5/z; + } + return z; +} + sqrt.c +#include "math.h" +#include "errno.h" + +double sqrt(x) +double x; +{ + double f, y; + int n; + extern int errno; + + if (x == 0.0) + return x; + if (x < 0.0) { + errno = EDOM; + return 0.0; + } + f = frexp(x, &n); + y = 0.41731 + 0.59016 * f; + y = (y + f/y); + y = ldexp(y,-2) + f/y; /* fast calculation of y2 */ + y = ldexp(y + f/y, -1); + y = ldexp(y + f/y, -1); + + if (n&1) { + y *= 0.70710678118654752440; + ++n; + } + return ldexp(y,n/2); +} + sqrt87.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h + +dataseg segment word public 'data' + extrn errno_:word +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + assume ds:dataseg + +ERANGE equ -20 +EDOM equ -21 + + procdef sqrt, <> +; +; double sqrt(d) +; + sub sp,2 + fld qword ptr doub + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnc sqrt_ok + fchs + mov errno_,EDOM +sqrt_ok: + fsqrt +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif + fwait +endif + add sp,2 + pret + pend sqrt + finish + end + sqrt87s.asm +; Copyright Manx Software Systems, Inc. 1985, 1987 + include lmacros.h +dataseg segment para public 'data' +status dw ? + extrn chop_ctl:word, round_ctl:word + extrn errno_:word + extrn $flt_inx:word +dataseg ends + assume ds:dataseg +; +;double sqrt(x) +;double x; + procdef sqrt, <> + lea bx,ss:word ptr doub + call $dldpss + mov cx,$flt_inx + or cx,cx + jz $sqrt86 +; +; + +ERANGE equ -20 +EDOM equ -21 + +$sqrt87: + fld qword ptr doub + ftst + fstsw status + fwait + mov ah,byte ptr status+1 + sahf + jnb sqrt_ok + fchs + mov errno_,EDOM +sqrt_ok: + fsqrt + pret +; +$sqrt86: +; +;{ +; double f, y; +; int n; +; extern int errno; + add sp,$2 + push di + push si +; +; if (x == 0.0) +; return x; + mov bx,offset zero + call $dldscs + call $dcmp + jne $3 + lea bx,ss:word ptr doub + call $dldpss + jmp return +; if (x < 0.0) { +$3: + lea bx,ss:word ptr doub + call $dldpss + mov bx,offset zero + call $dldscs + call $dcmp + jge $4 +; errno = EDOM; + mov word ptr errno_,22 +; return 0.0; + mov bx,offset zero + call $dldpcs + jmp return +; } +; f = frexp(x, &n); +$4: + lea ax,word ptr -18[bp] +ifdef LONGPTR + push ss +endif + push ax + lea bx,ss:word ptr doub + call $dldpss + call $dpsh + call frexp_ +ifdef LONGPTR + add sp,12 +else + add sp,10 +endif + lea bx,word ptr -8[bp] + call $dstss +; y = 0.41731 + 0.59016 * f; + lea bx,word ptr -8[bp] + call $dldpss + mov bx, offset xcons1 + call $dldscs + call $dml + mov bx,offset xcons2 + call $dldscs + call $dad + lea bx,word ptr -16[bp] + call $dstss +; y = (y + f/y); + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + lea bx,word ptr -16[bp] + call $dldsss + call $dad + lea bx,word ptr -16[bp] + call $dstss +; y = ldexp(y,-2) + f/y; /* fast calculation of y2 */ + mov ax,-2 + push ax + lea bx,word ptr -16[bp] + call $dldpss + call $dpsh + call ldexp_ + add sp,10 + call $dpsh + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + call $dpop + call $dad + lea bx,word ptr -16[bp] + call $dstss +; y = ldexp(y + f/y, -1); + mov ax,-1 + push ax + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + lea bx,word ptr -16[bp] + call $dldsss + call $dad + call $dpsh + call ldexp_ + add sp,10 + lea bx,word ptr -16[bp] + call $dstss +; y = ldexp(y + f/y, -1); + mov ax,-1 + push ax + lea bx,word ptr -8[bp] + call $dldpss + lea bx,word ptr -16[bp] + call $dldsss + call $ddv + lea bx,word ptr -16[bp] + call $dldsss + call $dad + call $dpsh + call ldexp_ + add sp,10 + lea bx,word ptr -16[bp] + call $dstss +; +; if (n&1) { + mov ax,word ptr -18[bp] + test ax,1 + jeq $5 +; y *= 0.70710678118654752440; + lea bx,word ptr -16[bp] + call $dldpss + mov bx,offset xcons3 + call $dldscs + call $dml + lea bx,word ptr -16[bp] + call $dstss +; ++n; + inc word ptr -18[bp] +; } +; return ldexp(y,n/2); +$5: + mov ax,word ptr -18[bp] + mov cx,2 + cwd + idiv cx + push ax + lea bx,word ptr -16[bp] + call $dldpss + call $dpsh + call ldexp_ + add sp,10 +return: + pop si + pop di + mov sp,bp + pop bp + ret +;} +$2 = -18 + pend sqrt +; +zero dw 0,0,0,0 +xcons1 db 018H,09H,06dH,039H,097H,0e2H,0e2H,03fH +xcons2 db 0f7H,0ccH,092H,00H,035H,0b5H,0daH,03fH +xcons3 db 0cdH,03bH,07fH,066H,09eH,0a0H,0e6H,03fH +ifdef FARPROC + extrn frexp_:far + extrn ldexp_:far + extrn $dad:far,$dsb:far,$dml:far,$ddv:far + extrn $dldpss:far,$dldpcs:far,$dldscs:far,$dldsss:far,$dstss:far + extrn $dcmp:far,$dtst:far + extrn $dpsh:far,$dpopp:far,$dpop:far,$dng:far,$dswap:far + extrn $itod:far,$utod:far,$xtod:far + extrn $dtoi:far,$dtou:far,$dtox:far +else + extrn frexp_:near + extrn ldexp_:near + extrn $dad:near,$dsb:near,$dml:near,$ddv:near + extrn $dldpss:near,$dldpcs:near,$dldscs:near,$dldsss:near,$dstss:near + extrn $dcmp:near,$dtst:near + extrn $dpsh:near,$dpopp:near,$dpop:near,$dng:near,$dswap:near + extrn $itod:near,$utod:near,$xtod:near + extrn $dtoi:near,$dtou:near,$dtox:near +endif +dataseg segment para public 'data' + extrn errno_:word +dataseg ends + finish + end + tan.c +#include "math.h" +#include "errno.h" + +extern int errno; + +static double tansub(); + +#if MPU8080 || MPUZ80 || MPU6502 +#define TOOSMALL (1.0/HUGE_VAL) +#else +#define TOOSMALL TINY_VAL +#endif + +double cotan(x) +double x; +{ + double y; + + y = fabs(x); + if (y < TOOSMALL) { + errno = ERANGE; + if (x < 0.0) + return -HUGE_VAL; + else + return HUGE_VAL; + } + return tansub(x,y,2); +} + +double tan(x) +double x; +{ + return tansub(x, fabs(x), 0); +} + +#define P1 -0.13338350006421960681e+0 +#define P2 +0.34248878235890589960e-2 +#define P3 -0.17861707342254426711e-4 +#define Q0 +1.0 +#define Q1 -0.46671683339755294240e+0 +#define Q2 +0.25663832289440112864e-1 +#define Q3 -0.31181531907010027307e-3 +#define Q4 +0.49819433993786512270e-6 + +#define P(f,g) (((P3*g P2)*g P1)*g*f + f) +#define Q(g) ((((Q4*g Q3)*g Q2)*g Q1)*g Q0) + +#define YMAX 6.74652e09 + +static double tansub(x, y, flag) +double x,y; +{ + double f, g, xn; + double xnum, xden; + + if (y > YMAX) { + errno = ERANGE; + return 0.0; + } + if (fabs(modf(x*0.63661977236758134308, &xn)) >= 0.5) + xn += (x < 0.0) ? -1.0 : 1.0; + f = modf(x, &g); + f = ((g - xn*(3217.0/2048)) + f) - xn*-4.454455103380768678308e-6; + if (fabs(f) < 2.33e-10) { + xnum = f; + xden = 1.0; + } else { + g = f*f; + xnum = P(f,g); + xden = Q(g); + } + flag |= ((int)xn & 1); + switch (flag) { + case 1: /* A: tan, xn odd */ + xnum = -xnum; + case 2: /* B: cotan, xn even */ + return xden/xnum; + + case 3: /* C: cotan, xn odd */ + xnum = -xnum; + case 0: /* D: tan, xn even */ + return xnum/xden; + } + return 0.0; +} + tan87.asm +;:ts=8 Copyright Manx Software Systems, Inc. 1986 + include lmacros.h + +ERANGE equ 21 +EDOM equ 22 + +highval db 000h,066h,067h,0d0h,03dh,0ebh,0cfh,043h ; 4.6e+18 +one dw 0,0,0,3ff0h ; 1.0 +zero dw 0,0,0,0 ; 0.0 + +dataseg segment public byte 'data' + extrn errno_:word +ifdef STATRES +result db 8 dup (?) +endif +dataseg ends + + assume cs:codeseg,ds:dataseg + +;double cotan(x) +;double x; + + procdef cotan,<> + sub sp,2 + push word ptr errno_ + mov ax,0 + mov word ptr errno_,ax + mov ax,word ptr xx+6 + push ax + mov ax,word ptr xx+4 + push ax + mov ax,word ptr xx+2 + push ax + mov ax,word ptr xx + push ax + call tan_ + add sp,8 + cmp errno_,0 + jz okres + pop cx ;get old errno off stack + fldz ;answer is zero + jmp exit1 +okres: + pop word ptr errno_ ;restore old errno +ifdef STATRES + mov bx,ax +ifdef LONGPTR + mov ds,dx + fld es:qword ptr [bx] +else + fld qword ptr [bx] +endif +endif + ftst + fstsw word ptr -2 [bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnz oktan + mov word ptr errno_,EDOM ;domain error + jmp exit1 +oktan: + fld1 ; load a one + fdivr ; cotan(x) = 1 / tan(x) +exit1: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + fwait + add sp,2 + pret + pend cotan + +;double tan (x) +;double x; + + procdef tan,<> + sub sp,2 + fld qword ptr x ;load x + fld st(0) ;get a copy of x + fabs + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jz zeroval + jc badval ; value is not a number + fcom cs:qword ptr highval + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jb goodval +badval: + mov errno_,ERANGE +zeroval: + fstp st(0) ; get rid of fabs(x) + fstp st(0) ; get rid of x + fldz + jmp exit +goodval: + fstp st(0) ; get rid of fabs(x) + fldz + fcomp + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + xor dx,dx ; clear sign flag + sahf + jb sk_pos + mov dx,1 ;sign is negative +sk_pos: + mov word ptr -2[bp],-2 ; divide by 4 exponent + fild word ptr -2[bp] + fldpi + fscale ; compute pi/4 + fxch ; put -2 before pi/4 + fstp st(0) ; and discard (clean up stack) + fxch ; get x back on stack top + fprem ; figure out the octant of the result + fstsw word ptr -2[bp] + fwait + fabs ; make x absolute + mov al,byte ptr -1[bp] + cbw + xor bx,bx + test ax,1 + jnz ok1 + or bx,4 +ok1: + test ax,2 + jnz ok2 + or bx,1 +ok2: + test ax,64 + jnz ok3 + or bx,2 +ok3: + test bx,1 + jnz noadjust + fsub ; pi/4 - x + jmp do_it +noadjust: + ftst + fstsw word ptr -2[bp] + fwait + mov ah,byte ptr -1[bp] + sahf + jnz do_it + fstp st(0) ; discard x + fld1 ; result is one + jmp nochk +; +do_it: + fptan ; take the tangent x on top y in st1 +; +nochk: + mov ax,bx ; does the fraction need inversion? + and ax,3 + cmp ax,1 + jz noswap + cmp ax,2 + jz noswap + fxch +noswap: + shr bx,1 ; do we need to change the sign? + and bx,1 + cmp bx,dx + jnz nosign + fchs +nosign: + fdivr ; finish the tangent calculation +exit: +ifdef STATRES + fstp qword ptr result + mov ax,offset result +ifdef LONGPTR + mov dx,ds +endif +endif + fwait + add sp,2 + pret + pend tan + finish + end + tanh.c +#include "math.h" + +#define P0 -0.16134119023996228053e+4 +#define P1 -0.99225929672236083313e+2 +#define P2 -0.96437492777225469787e+0 +#define Q0 +0.48402357071988688686e+4 +#define Q1 +0.22337720718962312926e+4 +#define Q2 +0.11274474380534949335e+3 + +#define gP(g) (((P2*g P1)*g P0)*g) +#define Q(g) (((g Q2)*g Q1)*g Q0) + +double tanh(x) +double x; +{ + double f,g,r; + + f = fabs(x); + if (f > 25.3) + r = 1.0; + else if (f > 0.54930614433405484570) { + r = 0.5 - 1.0/(exp(f+f)+1.0); + r += r; + } else if (f < 2.3e-10) + r = f; + else { + g = f*f; + r = f + f* + (gP(g) + /Q(g)); + } + if (x < 0.0) + r = -r; + return r; +} + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/MCH86.ARC b/Manx Aztec C86 v42b/ARC/MCH86.ARC new file mode 100644 index 0000000..18096c1 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/MCH86.ARC @@ -0,0 +1,2227 @@ + makefile + +OBJ=csav.o farcall.o fcall.o index.o lsubs.o memccpy.o memchr.o memcmp.o\ + memcpy.o memset.o movblock.o movmem.o peek.o pointers.o port.o ptradd.o\ + ptrdiff.o rindex.o segread.o setjmp.o setmem.o strcat.o strchr.o strcmp.o\ + strcpy.o strlen.o strncpy.o strrchr.o swapmem.o sysint.o toupper.o\ + cswit.o clswit.o fptrs.o fltstub.o strstr.o stricmp.o strlwr.o strrev.o + +CC=cc +AS=as +MODEL= +AMODEL=0 +DIR= + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +bld: $(OBJ) cswt.o olsubs.o + @echo mch86 done + +bldlc bldl bldld: $(OBJ) + @echo mch86 done + +$(DIR)$(MODEL)rom.o: rom.asm + $(AS) -dMODEL=$(AMODEL) rom.asm -o $@ + +ovly: $(DIR)ovld.o $(DIR)ovldpath.o $(DIR)ovbgn.o + @echo overlay done + +ovlyl ovlyld ovlylc: + @echo overlays supported only in small model + +$(DIR)ovld.o: ovloader.c + $(CC) +$(MODEL) -n ovloader.c -o $@ +$(DIR)ovldpath.o: ovloader.c + $(CC) +$(MODEL) -n -DDOS20 ovloader.c -o $@ +$(DIR)ovbgn.o: ovbgn.asm + $(AS) -dMODEL=$(AMODEL) ovbgn.asm -o $@ + clswit.asm +; Copyright (C) 1983, 85 by Manx Software Systems +; :ts=8 + include lmacros.h + public $clswt + +$clswt proc + pop bx ; get address of table +ifdef FARPROC + pop es +endif + push di + push si + mov si,bx ; save base address + dec cx + mov di,cx ; save number of entries in di +ltop: +ifdef FARPROC + cmp ax,es:word ptr [bx] + jne notit + cmp dx,es:word ptr 2[bx] + je found +else + cmp ax,cs:word ptr [bx] + jne notit + cmp dx,cs:word ptr 2[bx] + je found +endif +notit: + add bx,4 + loop ltop +found: + shl di,1 + shl di,1 ; adjust di for length of values + add di,si ; di now points at array of labels + sub bx,si ; find which entry matched + shr bx,1 ; divide by 2 to get offset to label +ifdef FARPROC + mov ax,es:word ptr [di][bx] ; get address to return to + pop si + pop di + push es + push ax + ret +else + mov ax,cs:word ptr [di][bx] ; get address to return to + pop si + pop di + jmp ax +endif +$clswt endp + finish + end + csav.asm +; Copyright (C) 1983 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment para public 'data' + extrn _sbot_:word + extrn _lowwater_:word +dataseg ends + assume ds:dataseg,cs:codeseg +ifdef FARPROC + extrn _stkover_:far +else + extrn _stkover_:near +endif + extrn $begin:far + dw near ptr $begin + public $csav, $cret +$csav proc + pop bx +ifdef FARPROC + pop dx +endif + push bp + mov bp,sp + add sp,ax + cmp sp,bp ;check for wrap around + ja stackfault + cmp sp,word ptr _sbot_ ;or moving into the RED zone + jb stackfault + cmp sp,word ptr _lowwater_ + ja nodeeper + mov word ptr _lowwater_,sp +nodeeper: + push di + push si +ifdef FARPROC + push cs + mov ax,offset $cret + push ax + push dx + push bx + ret +else + call bx +endif +$csav endp + +$cret proc + pop si + pop di + mov sp,bp + pop bp + ret +$cret endp + +stackfault: + mov sp,bp ;put stack back the way it was + jmp _stkover_ + finish + end + cswit.asm +; Copyright (C) 1983, 85 by Manx Software Systems +; :ts=8 + include lmacros.h + public $cswt + +$cswt proc +ifndef FARPROC + pop bx ; get address of table + push di +ifndef LONGPTR + push es +endif + mov di,cs + mov es,di + mov di,bx ; make di to point to table of values + mov bx,cx ; save number of entries in bx + shl bx,1 ; adjusted for size of an entry + cld +repne scasw ; find the right entry + mov cx,es:word ptr -4[di][bx] ; pick up target address +ifndef LONGPTR + pop es +endif + pop di + jmp cx ; jump there +endif +$cswt endp + finish + end + cswt.asm +; Copyright (C) 1983, 85 by Manx Software Systems +; :ts=8 + include lmacros.h + ifdef FARPROC +data equ word ptr es:[bx] +addr equ word ptr es:2[bx] +dflt equ word ptr es:[bx] + else +data equ word ptr cs:[bx] +addr equ word ptr cs:2[bx] +dflt equ word ptr cs:[bx] + endif +slot equ 4 + public $swt + +$swt proc + pop bx +ifdef FARPROC +ifndef LONGPTR + mov dx,es +endif + pop es + push es +endif + mov cx,data + add bx,2 + jcxz eswt +swtloop: + cmp ax,data + je found + add bx,slot + loop swtloop +eswt: + push dflt +ifdef FARPROC +ifndef LONGPTR + mov es,dx +endif +endif + ret +found: + push addr +ifdef FARPROC +ifndef LONGPTR + mov es,dx +endif +endif + ret +$swt endp + finish + end + farcall.asm +; :ts=8 +;Copyright (C) 1983, 85 by Manx Software Systems + include lmacros.h + procdef farcall, <, , > + push si + push di + push ds + push es +; + ldptr bx,srcregs,ds + mov ax,[bx] + push 2[bx] ;save BX value for later + mov cx,4[bx] + mov dx,6[bx] + mov si,8[bx] + mov di,10[bx] + mov es,14[bx] + mov ds,12[bx] ;trash DS last + pop bx ;now get value for BX + push bp + call where + pop bp + push ds ;save returned DS + push bx ;save returned BX + mov ds,-6[bp] ;fetch C's data seg, for small model + ldptr bx,dstregs,ds + mov [bx],ax + pop 2[bx] ;value returned in BX + mov 4[bx],cx + mov 6[bx],dx + mov 8[bx],si + mov 10[bx],di + pop 12[bx] ;value returned in DS + mov 14[bx],es + pop es + pop ds + pop di + pop si + pop bp + pushf + pop ax + ret + pend farcall + finish + end + fcall.asm +; Copyright (C) 1985 by Manx Software Systems +; :ts=8 + largecode +codeseg segment byte public 'code' + assume cs:codeseg + public $fcall +$fcall proc far + push dx + push ax + ret +$fcall endp +codeseg ends + end + fltstub.asm +; Copyright (C) 1987 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + + public $fltinit +$fltinit proc + clc ;all OK + ret +$fltinit endp + finish + end + fptrs.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h + assume ds:dataseg + + internal $fptrs +; +; $hdiff ; subtract (and compare) huge pointers in ax:dx cx:bx +; + intrdef $hdiff + push si + sub dx,bx + sbb si,si + mov bx,cx + mov cx,4 +sloop: shl dx,1 + rcl si,1 + loop sloop + add ax,dx + adc si,0 + sub ax,bx + sbb si,0 + mov dx,si + pop si + cmp dx,0 + jnz doret + cmp ax,0 + jz outnow +outclear: + clc + ret +doret: + jgt outclear + stc +outnow: + ret + + intrdef $hadd ; add hugeptr in cx:bx with long in ax:dx + push si + push di + mov si,cx + mov cx,4 + xor di,di +addloop: + shl bx,1 + rcl di,1 + loop addloop + add bx,si + adc di,0 + add ax,bx + adc di,dx + mov cx,4 + mov dx,ax + and ax,0fh +canon: + shr di,1 + rcr dx,1 + loop canon + pop di + pop si + ret + + intrdef $hinx ;add hugeptr in cx:bx to long in ax:dx and put in es:bx + push si + push di + mov si,cx + mov cx,4 + xor di,di +xddloop: + shl bx,1 + rcl di,1 + loop xddloop + add bx,si + adc di,0 + add bx,ax + adc di,dx + mov cx,4 + mov ax,bx + and bx,0fh +xcanon: + shr di,1 + rcr ax,1 + loop xcanon + mov es,ax + pop di + pop si + ret + +$fptrs endp + finish + end + index.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef index, <,> + cld + push si + pushds + ldptr si,arg,ds + mov bl,val +lookloop: + lodsb + test al,al + jz notfound + cmp al,bl + jne lookloop + retptrr si,ds + dec ax + popds + pop si + pret +notfound: + retnull + popds + pop si + pret + pend index + finish + end + lsubs.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + internal $longs +; + intrdef $ldv +;long divide (primary = primary/secondary) + push di + sub di,di ;mark result as positive + test dx,dx + jns prim_ok + neg dx + neg ax + sbb dx,0 + inc di ;mark as negative +prim_ok: + test bx,bx + jns sec_ok + neg bx + neg cx + sbb bx,0 + xor di,1 ;flip sign of result +sec_ok: + call comdivide +chksign: + test di,di + jz posres + neg dx + neg ax + sbb dx,0 +posres: + pop di + ret +; + intrdef $lrm +;long remainder (primary = primary%secondary) + push di + mov di,0 ;mark result as positive + test dx,dx + jns rprim_ok + neg dx + neg ax + sbb dx,0 + inc di ;mark as negative +rprim_ok: + test bx,bx + jns rsec_ok + neg bx + neg cx + sbb bx,0 +rsec_ok: + call comdivide + mov ax,cx + mov dx,bx + jmp chksign +; + intrdef $lum +;unsigned long remainder (primary = primary%secondary) + call comdivide + mov ax,cx + mov dx,bx + ret +; + intrdef $lud +;unsigned long divide (primary = primary/secondary) + ifdef FARPROC + call comdivide + ret + endif + +; fall thru into common divide routine if not large code model +; +comdivide proc near ; divide (dx,ax) by (bx,cx): +; returns quotient in (dx,ax) +; remainder in (bx,cx) +; + test bx,bx ;check for easy case + jnz hardldv + cmp cx,dx + ja veryeasy + push ax + mov ax,dx + sub dx,dx + div cx + mov bx,ax ;save high word of quotient + pop ax + div cx + mov cx,dx ;save remainder + mov dx,bx + sub bx,bx + ret +veryeasy: + div cx + mov cx,dx ;save remainder + mov dx,bx ;bx is already zero if we are here + ret +hardldv: + push di + push si + mov si,cx ;copy divisor (bx,cx) into (di,si) + mov di,bx + push dx ;save dividend for remainder calculation + push ax + + test bh,bh + jz shiftit + mov cl,ch ;shift bx,cx right 8 bits + mov ch,bl + mov bl,bh + mov al,ah ;shift dx,ax right 8 bits + mov ah,dl + mov dl,dh + sub dh,dh +shiftit: + shr dx,1 + rcr ax,1 + shr bl,1 + rcr cx,1 + test bl,bl + jnz shiftit + + div cx ;guess at quotient (may off by 1) + mov cx,ax + ; compute remainder = dividend - divisor*quotient + mul si + mov bx,dx + push ax ;save low half + mov ax,cx + mul di + add bx,ax + jnc normal_path + dec cx + pop ax ; delete top element off the stack + mov ax,cx + mul di + mov bx,ax ; save the answer into bx + mov ax,cx + mul si + add bx,dx + mov es,cx ; es now contains the answer of the divide + mov cx,ax +; bx:cx now contains result * quotient + pop ax + pop dx + sub cx,ax + sbb bx,dx + not cx + not bx + add cx,1 + adc bx,0 + mov ax,es + jmp answer_ok +normal_path: + mov dx,bx ;high half + mov ax,cx ;restore quotient to ax for return + + pop bx ;low half of divisor*quotient + pop cx ;low half of dividend + sub cx,bx + pop bx ;high half of dividend + sbb bx,dx + jnc answer_ok ;if we get a borrow, answer was too big + add cx,si ;so adjust the remainder + adc bx,di + dec ax ;and the quotient +answer_ok: + sub dx,dx + pop si + pop di + ret +comdivide endp +$longs endp + finish + end + memccpy.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memccpy,<,,,> + push si + push di + pushds + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,s1 + ldptr si,s2 + mov bl,char + mov cx,lim + jcxz cpydone +cpyloop: + lodsb + stosb + cmp al,bl + jz cpyfnd + loop cpyloop + jmp short cpydone +cpyfnd: + retptrr di,es + popds + pop di + pop si + pret +cpydone: + retnull + popds + pop di + pop si + pret + pend memccpy + finish + end + memchr.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef memchr,<,,> + push di +ifdef LONGPTR + mov ax,ds + mov es,ax +endif + cld + ldptr di,area + mov al,char + mov cx,lim + jcxz notfound +repne scasb + jne notfound + dec di + retptrr di,es + pop di + pret +notfound: + retnull + pop di + pret + pend memchr + finish + end + memcmp.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memcmp,<,,> + push si + push di + pushds + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,dest + ldptr di,src + mov cx,lim + jcxz done +repe cmpsb + mov ax,0 + ja greater + je done + dec ax +done: + popds + pop di + pop si + pret +greater: + inc ax + jmp done + pend memcmp + finish + end + memcpy.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memcpy,<,,> + push si + push di + pushds + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,s1 + ldptr si,s2 + mov cx,lim + mov dx,cx + shr cx,1 + jcxz chk_odd +rep movsw +chk_odd: + test dl,1 + jz done + movsb +done: + retptrm s1 + popds + pop di + pop si + pret + pend memcpy + finish + end + memset.asm +; Copyright (C) 1984, 1985 by Manx Software Systems, Inc. +; :ts=8 + include lmacros.h + procdef memset,<,,> + push di + cld +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,area + mov al,char + mov ah,al + mov cx,lim + mov dx,cx + shr cx,1 + jcxz nowords +rep stosw +nowords: + test dl,1 + jz done + stosb +done: + retptrm area + pop di + pret + pend memset + finish + end + movblock.asm +;Copyright (C) 1983, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef movblock,<,,> + push di + push si + push ds + push es + pushf + cld + mov cx,len + les di,dest + lds si,src + cmp cx,4 + jne not_int + cli +not_int: + test cx,cx + jnz not_mov_all + mov cx,8000H + jmp short movwords +not_mov_all: + mov dx,cx + shr cx,1 + jz mv_skip +movwords: +rep movsw +mv_skip: + test dl,1 + jz done + movsb +done: + popf + pop es + pop ds + pop si + pop di + pret + pend movblock + finish + end + movmem.asm +;Copyright (C) 1984, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef movmem,<,,> + pushf + cld + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,arg1 + ldptr di,arg2 + mov cx,len + mov ax,es + mov dx,ds + cmp ax,dx + jne move_forward + cmp di,si + je done + jb move_forward + std + add di,cx + add si,cx + dec di + dec si + test cl,1 + jz nobyte + movsb +nobyte: + dec di + dec si + jmp short domove +; +move_forward: + test cl,1 + jz domove + movsb +domove: + shr cx,1 + jz done +rep movsw +done: + cld + popds + pop di + pop si + popf + pret + pend movmem + finish + end + olsubs.asm +; Copyright (C) 1983 1984 by Manx Software Systems +; :ts=8 +codeseg segment para public 'code' + assume cs:codeseg + public $olongs +$olongs proc near +; + public $lng ;negate primary +$lng: + neg dx + neg ax + sbb dx,0 + ret +; + public $lcmp ;compare primary and secondary +$lcmp: + cmp dx,bx + jne cmpdone + cmp ax,cx + je cmpdone + ja p_gt_s + sub ax,ax + dec ax + stc + ret +p_gt_s: + sub ax,ax + inc ax +cmpdone: + ret +; + public $lad ;add secondary to primary +$lad: + add ax,cx + adc dx,bx + ret +; + public $lsb ;subtract secondary from primary +$lsb: + sub ax,cx + sbb dx,bx + ret +; + public $lan ;and primary with secondary +$lan: + and ax,cx + and dx,bx + ret +; + public $lor ;or primary with secondary +$lor: + or ax,cx + or dx,bx + ret +; + public $lxr ;exclusive or primary with secondary +$lxr: + xor ax,cx + xor dx,bx + ret +; + public $lcm ;complement primary +$lcm: + not ax + not dx + ret +; + public $lls ;shift primary left by secondary +$lls: + and cl,03fH ;restrict to 63 bits + jz lsdone +lsloop: + shl ax,1 + rcl dx,1 + loop lsloop +lsdone: + ret +; + public $lrs ;right shift primary by secondary bits +$lrs: + and cl,03fH ;restrict to 63 bits + jz rsdone +rsloop: + sar dx,1 + rcr ax,1 + loop rsloop +rsdone: + ret +; + public $lur ;unsigned right shift primary by secondary bits +$lur: + and cl,03fH ;restrict to 63 bits + jz ursdone +ursloop: + shr dx,1 + rcr ax,1 + loop ursloop +ursdone: + ret +; + public $lml +$lml: ;long multiply (primary = primary * secondary) + push ax ;save low word + push dx ;save high word + mul bx + mov bx,ax ;keep partial product + pop ax ;get high word + mul cx + add bx,ax ;add to partial product + pop ax ;get low word + mul cx + add dx,bx ;add in partial products + ret +; +$olongs endp +codeseg ends + end + ovbgn.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems +codeseg segment para public 'code' +dataseg segment para public 'data' +save_si dw 0 +save_di dw 0 +save_sp dw 0 +save_bp dw 0 +save_ret dw 0 + extrn _Uorg_:word, _Uend_:word +dataseg ends + assume cs:codeseg,ds:dataseg + extrn ovmain_:near + public $ovbgn +$ovbgn proc near + pop save_ret + pop cx ;throw away overlay name + mov save_sp,sp + mov save_bp,bp + mov save_si,si + mov save_di,di + cld + mov di,offset _Uorg_ ;clear uninitialized data + mov cx,offset _Uend_ + sub cx,di + shr cx,1 + jz nobss + sub ax,ax +rep stosw +nobss: + call ovmain_ +; +; fall through into ovexit code +; + public ovexit_ +ovexit_: + mov bp,save_bp + mov sp,save_sp + mov si,save_si + mov di,save_di + push cx ;fake argument to replace overlay name + jmp save_ret +$ovbgn endp +codeseg ends + end $ovbgn + ovloader.c +/* Copyright (C) 1984 by Manx Software Systems */ + +#define OV_MAGIC 0xf2 + +struct ovrheader { /* overlay header header */ + short o_magic; + unsigned short o_corg; + unsigned short o_csize; + unsigned short o_dorg; + unsigned short o_dsize; + unsigned short o_bss; + unsigned short o_entry; +}; + +static char *ovname; + +#asm + public ovloader_ +ovloader_ proc near + mov bx,sp + mov ax,word ptr 2[bx] + mov ovname_,ax + call _ovld_ + jmp ax +ovloader_ endp +#endasm + +static +_ovld() +{ + int fd, flag; + register char *cp, *xp; + auto struct ovrheader hdr; + char *getenv(), path[64]; + extern char *_mbot, _Cend[], _Uend[]; + +#ifdef DOS20 + if ((cp = getenv("PATH")) == 0) + cp = ""; + xp = path; + for (;;) { + strcpy(xp, ovname); + strcat(path, ".ovr"); + if ((fd = open(path, 0)) != -1) + break; + do { + if (*cp == 0) + loadabort(10); + xp = path; + while (*cp) { + if (*cp == ';') { + ++cp; + break; + } + *xp++ = *cp++; + } + *xp = 0; + } while (path[0] == 0); + } + +#else + strcpy(path, ovname); + strcat(path, ".ovr"); + if ((fd = open(path, 0)) == -1) + loadabort(10); +#endif + + if (read(fd, &hdr, sizeof hdr) != sizeof hdr) + loadabort(20); + + /* safety check overlay header */ + if (hdr.o_magic != OV_MAGIC) + loadabort(30); + if (_mbot < hdr.o_dorg+hdr.o_dsize+hdr.o_bss) + loadabort(40); + if (_Cend > hdr.o_corg || _Uend > hdr.o_dorg) + loadabort(60); + + if (_csread(fd, hdr.o_corg, hdr.o_csize) < hdr.o_csize + || read(fd, hdr.o_dorg, hdr.o_dsize) < hdr.o_dsize) + loadabort(50); + close(fd); + return hdr.o_entry; +} + +static +loadabort(code) +{ + char buffer[80]; + + sprintf(buffer, "Error %d loading overlay: %s$", code, ovname); + bdos(9, buffer); + exit(100); +} + peek.asm +;Copyright (C) 1983, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + procdef peekw,<> + push ds + lds bx,addr + mov ax,ds:[bx] + pop ds + pret + pend peekw +; + entrdef peekb + procdef peek,<> + push ds + lds bx,addr1 + mov al,ds:[bx] + and ax,0ffH + pop ds + pret + pend peek +; + procdef pokew,<,> + push ds + mov ax,val + lds bx,addr2 + mov ds:[bx],ax + pop ds + pret + pend pokew +; + entrdef poke + procdef pokeb,<,> + push ds + mov al,val1 + lds bx,addr3 + mov ds:[bx],al + pop ds + pret + pend pokeb + finish + end + pointers.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h + assume ds:dataseg +; +; ptrtoabs(lptr): convert pointer to 20-bit physical address +; + procdef ptrtoabs,<,> + mov ax,lptr + mov dx,llptr + mov cx,4 + rol dx,cl + mov bx,dx + and bx,0fff0h + and dx,0fh + add ax,bx + adc dx,0 + pret + pend ptrtoabs +; +; abstoptr(laddr): convert 20-bit physical address to pointer +; + procdef abstoptr,<,> + mov ax,laddr + mov dx,lladdr + and dx,0fh + mov bx,ax + mov cx,4 + ror dx,cl + shr bx,cl + and bx,0fffh + or dx,bx + and ax,0fh + pret + pend abstoptr + finish + end + port.asm +;Copyright (C) 1983, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h + entrdef inport + procdef inportb,<> + mov dx,port + in al,dx + and ax,0ffH + pret + pend inportb +; + procdef inportw,<> + mov dx,port1 + in ax,dx + pret + pend inportw +; + entrdef outport + procdef outportb,<,> + mov dx,port2 + mov al,val + out dx,al + pret + pend outportb +; + procdef outportw,<,> + mov dx,port3 + mov ax,val1 + out dx,ax + pret + pend outportw + finish + end + ptradd.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h +; +;char *_ptradd(lptr, long): return lptr+long +; + procdef _ptradd,<,,,> + mov ax,segm + sub dx,dx + mov cx,4 +sloop: shl ax,1 + rcl dx,1 + loop sloop + add ax,offs + adc dx,0 + add ax,incrl + adc dx,incrh + mov bx,ax + mov cx,4 +sloop2: shr dx,1 + rcr ax,1 + loop sloop2 + mov dx,ax + mov ax,bx + and ax,15 + mov bx,dx + pret + pend _ptradd + finish + end + ptrdiff.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h +; +; long _ptrdiff(lptr1, lptr2): return long pointer difference +; + procdef _ptrdiff,<,,,> + mov ax,seg1 + sub ax,seg2 + sbb dx,dx + mov cx,4 +sloop: shl ax,1 + rcl dx,1 + loop sloop + add ax,off1 + adc dx,0 + sub ax,off2 + sbb dx,0 + mov bx,dx + pret + pend _ptrdiff + finish + end + rindex.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef rindex, <,> + pushf + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,string,es + mov dx,di ;save for later + sub ax,ax + mov cx,7fffH +repne scasb + mov cx,di + sub cx,dx ;compute length of string + dec di ;backup to null byte + mov al,chr ;get byte to look for + std ;now go backwards +repne scasb + je found + retnull + pop di + popf + pret +found: + retptrr di,es + inc ax + pop di + popf + pret + pend rindex + finish + end + rom.asm +; Copyright (C) 1984, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h +; +; If you want your stack at a fixed place, you may remove the +; "bss cstack..." statement below and change the "mov sp,cstack..." +; to load SP with the value you desire. Note that the setup of +; SS may need to be changed also. If the program is small data +; model, then SS must be equal to DS or pointers to automatic +; variables won't work. +; +; Otherwise, stacksize should be set according to your program's +; requirements. +stacksize equ 2048 +; +; dataseg is the data segment address (as a paragraph #) +; this is picked from the -D option of the linker +; +;Dseg equ 040H ;physical addr 0x400, just above the int vectors + +dataseg segment word public 'data' + bss cstack:byte,stacksize + public $MEMRY +$MEMRY dw -1 + dw -1 + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 + public _mbot_, _sbot_ +_mbot_ dw 0 + dw 0 +_sbot_ dw 0 + dw 0 +; +; The variable is used with csav and cret only. Therefore if you do not +; compile the the +c option or +b option you do not need this. +; + public _lowwater_ +_lowwater_ dw -1 + extrn _Dorg_:byte,_Dend_:byte + extrn _Uorg_:byte,_Uend_:byte +dataseg ends + extrn _Corg_:byte,_Cend_:byte + +ifdef FARPROC + extrn main_:far, $fltinit:far +else + extrn main_:near, $fltinit:near +endif + + public $begin +$begin proc far + cli + cld +; +; Compute where initialzed data starts (@ next para after code) +; + mov ax,offset _Cend_+15 + mov cl,4 + shr ax,cl + add ax,seg _Cend_ + mov ds,ax ;place where data is in rom + mov bx,dataseg ;place where data is to go in ram + mov es,bx +; +; Note: For hardware reasons the instruction which loads SS should +; be immediatly followed by the load of SP. +; + mov ss,bx + mov sp,offset cstack+stacksize +; +; copy Init data from rom to ram + mov di,0 + mov cx,offset _Dend_ + inc cx + shr cx,1 + jcxz nocopy + mov si,0 +rep movsw +nocopy: +; +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + assume ds:dataseg,es:dataseg + + mov ds,bx ;set DS, now DS, SS, ES are equal + mov di,$MEMRY + inc di + and di,0fffeH ;adjust to word boundary + mov $MEMRY,di ;save memory allocation info for sbrk() + mov $MEMRY+2,ds + mov _mbot_,di + mov _mbot_+2,ds + mov _sbot_,0ffffH ;this is the heap limit for sbrk() + mov _sbot_+2,0fff0h + mov _dsval_,ds + mov _csval_,cs ;this is of dubious value in large code + sti + call $fltinit ;setup floating point software/hardware + jnc flt_ok + hlt ;program needs 8087 and one wasn't found +flt_ok: + jmp main_ ;main shouldn't return in ROM based system +$begin endp +codeseg ends + end $begin + segread.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef segread,<> +ifdef LONGPTR + mov cx,es + ldptr bx,segs,es +ifdef FARPROC + mov ax,4[bp] + mov es:[bx],ax +else + mov es:[bx],cs +endif + mov es:2[bx],ss + mov es:4[bx],ds + mov es:6[bx],cx + +else + + mov bx,segs +ifdef FARPROC + mov ax,4[bp] + mov [bx],ax +else + mov [bx],cs +endif + mov 2[bx],ss + mov 4[bx],ds + mov 6[bx],es + +endif + pret + pend segread + finish + end + setjmp.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef setjmp,<> + pushds + ldptr bx,jmpbuf,ds + lea ax,jmpbuf + mov [bx],ax + mov ax,0[bp] ;get caller's BP + mov 2[bx],ax + mov 4[bx],si + mov 6[bx],di + mov ax,2[bp] ;caller's IP + mov 8[bx],ax +ifdef FARPROC + mov ax,4[bp] ;caller's CS + mov 10[bx],ax +endif + sub ax,ax + popds + pret + pend setjmp +; + procdef longjmp,<,> + mov ax,retval +ifndef LONGPTR + mov bx,ds + mov es,bx +endif + ldptr bx,jbuf,es + mov sp,es:[bx] + mov bp,es:2[bx] + mov si,es:4[bx] + mov di,es:6[bx] + test ax,ax + jnz ax_ok + inc ax +ax_ok: +ifdef FARPROC + jmp es:dword ptr 8[bx] +else + jmp es:word ptr 8[bx] +endif + pend longjmp + finish + end + setmem.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef setmem,<,,> + pushf + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,src,es + mov cx,len + mov al,val + mov ah,al + mov dx,cx + shr cx,1 + jz skip +rep stosw +skip: + test dl,1 + jz done + stosb +done: + pop di + popf + pret + pend setmem + finish + end + strcat.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef strcat,<,> + mov dx,7fffH + jmp short catcommon + pend strcat + + procdef strncat,<,,> + mov dx,len +catcommon: + cld + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + sub ax,ax + mov cx,7fffH +repne scasb ;find end of destination string + dec di ;backup to null byte + ldptr si,str2 + mov cx,dx +cpyloop: + lodsb + stosb + test al,al + loopnz cpyloop + jz nul_ok + sub al,al ;guarantee that string is nul terminated + stosb +nul_ok: + popds + pop di + pop si + retptrm str1 + pret + pend strncat + finish + end + strchr.asm +; :ts=8 +;Copyright (C) 1985 by Manx Software Systems + include lmacros.h + procdef strchr, <,> + cld + push si + pushds + ldptr si,arg,ds + mov bl,val +lookloop: + lodsb + cmp al,bl + je found + test al,al + jnz lookloop + retnull + popds + pop si + pret +found: + retptrr si,ds + dec ax + popds + pop si + pret + pend strchr + finish + end + strcmp.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef strcmp,<,> + cld + push si + push di + pushds + ldptr si,s1 +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,s2 +cmploop: + lodsw + scasw + jne word_notequal + test al,al + jz equal + test ah,ah + jnz cmploop + jmp short equal + pend strcmp + + procdef strncmp,<,,> + mov cx,len + mov dx,cx + shr cx,1 ;# of times through word loop + cld + push si + push di + pushds + ldptr si,str1 +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str2 + jcxz words_equal +ncmploop: + lodsw + scasw + jne word_notequal + test al,al + jz equal + test ah,ah + loopnz ncmploop + jz equal +words_equal: + test dl,1 + jz equal + cmpsb + jne notequal +equal: + sub ax,ax +done: + popds + pop di + pop si + pret +word_notequal: + sub di,2 ;back up to first byte in word + scasb ;and redo the compare a byte at a time + jne notequal + test al,al ;if end of string, this was a false mismatch + jz equal + mov al,ah ;get second byte + scasb ;this must be not equal, since the words aren't equal +notequal: + sbb ax,ax + js done ;if -1 then s1s2 + jmp done + + pend strncmp + finish + end + strcpy.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef strcpy,<,> + cld + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str2 + mov cx,0ffffH + mov al,0 +repne scasb + not cx ;real length of string + ldptr di,str1 + ldptr si,str2 + shr cx,1 + jcxz nowords +rep movsw + +nowords: + jnc nobyte + movsb +nobyte: + popds + pop di + pop si + retptrm str1 + pret + pend strcpy + finish + end + stricmp.asm +; :ts=8 +;Copyright (C) 1988 by Manx Software Systems + + include lmacros.h + procdef stricmp,<,> + push si + push di + pushds + sub ah,ah + sub bh,bh + + ldptr si,s1 + ldptr di,s2 +cmploop: + lodsb +; convert al to lower case if needed + cmp al,'A' + jl skip + cmp al,'Z' + jg skip + add al,'a'-'A' +skip: +ifdef LONGPTR + mov bl,byte ptr es:[di] +else + mov bl,byte ptr [di] +endif + inc di +; convert bl to lower case if needed + cmp bl,'A' + jl skip2 + cmp bl,'Z' + jg skip2 + add bl,'a'-'A' +skip2: +; Now "compare bytes" + cmp al,bl + jne word_notequal + test al,al + jnz cmploop + +equal: + popds + pop di + pop si + pret +word_notequal: + sub al,bl + popds + pop di + pop si + pret + pend stricmp + + finish + end + strlen.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef strlen,<> + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + mov bx,di ;save for later + sub ax,ax + mov cx,7fffH +repne scasb + mov ax,di + sub ax,bx ;compute length of string + dec ax + pop di + pret + pend strlen + finish + end + strlwr.c +#include + +strlwr(string) +unsigned char *string; +{ + register unsigned char *place; + place = string; + while ( *place ) { + *place = tolower(*place); + place ++; + } + return string; +} + + strncpy.asm +; :ts=8 +;Copyright (C) 1983, 1985 by Manx Software Systems + include lmacros.h + procdef strncpy,<,,> + cld + push si + push di + pushds + mov cx,len +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,str1 + ldptr si,str2 + jcxz cpydone +cpyloop: + lodsb + test al,al + jz zerofill + stosb + loop cpyloop + jmp short cpydone +zerofill: +rep stosb +cpydone: + popds + pop di + pop si + retptrm str1 + pret + pend strncpy + finish + end + strrchr.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef strrchr, <,> + pushf + cld + push di +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr di,string,es + mov dx,di ;save for later + sub ax,ax + mov cx,7fffH +repne scasb + mov cx,di + sub cx,dx ;compute length of string + dec di ;backup to null byte + mov al,chr ;get byte to look for + std ;now go backwards +repne scasb + je found + retnull + pop di + popf + pret +found: + retptrr di,es + inc ax + pop di + popf + pret + pend strrchr + finish + end + strrev.asm +; :ts=8 +;Copyright (C) 1988 by Manx Software Systems + include lmacros.h +ifdef FARPROC + extrn strlen_:far +else + extrn strlen_:near +endif + procdef strrev,<> + + push si + pushds + +ifdef LONGPTR + mov ax,word ptr string+2 + push ax +endif + mov si,word ptr string + push si + call strlen_ +ifdef LONGPTR + add sp,4 + mov ds,word ptr string+2 +else + pop cx +endif + add ax,si + dec ax + mov bx,ax +; si should point to start of string +; bx should point to rear of string + + jmp loop_test +again: +; swap word ptr by [si] and word ptr by [di] + mov dl,byte ptr [si] + mov cl,byte ptr [bx] + + mov byte ptr [si],cl + mov byte ptr [bx],dl + + inc si + dec bx +loop_test: + cmp si,bx + jb again + + mov ax,word ptr string +ifdef LONGPTR + mov dx,word ptr string+2 +endif + popds + pop si + pret + pend strrev +codeseg ends + end + strstr.asm +; :ts=8 +;Copyright (C) 1988 by Manx Software Systems + + include lmacros.h + +ifndef FARPROC + extrn strncmp_:near + extrn strlen_:near +else + extrn strncmp_:far + extrn strlen_:far +endif + + procdef strstr,<,> + + push si + push di + pushds + + ldptr si,s2,es + + +ifdef LONGPTR + mov di,es + push es +endif + push si + + call strlen_ + +ifdef LONGPTR + add sp,4 + mov es,di +else + pop cx +endif + mov di,ax + + ldptr bx,s1,ds + +; bx pointer to first string ( offset only ) +; si pointer to second string ( offset only ) +; di length of second string ( offset only ) + + jmp test_condition +top_of_loop: + +; save bx + push bx + + push di +ifdef LONGPTR + push ds +endif + push bx +ifdef LONGPTR + push es +endif + push si + + call strncmp_ + +ifdef LONGPTR + add sp,10 + mov es,word ptr s2+2 +else + add sp,6 +endif + +; restore bx + pop bx + + test ax,ax + jz return_succ + + inc bx + +test_condition: + cmp byte ptr [bx],0 + jne top_of_loop + +exit_failure: + +ifdef LONGPTR + xor dx,dx +endif + xor ax,ax + jmp final_exit +return_succ: + mov ax,bx +ifdef LONGPTR + mov dx,word ptr s1+2 +endif +final_exit: + popds + pop di + pop si + pret + pend strstr + + finish + end + swapmem.asm +; :ts=8 +;Copyright (C) 1984 by Manx Software Systems + include lmacros.h + procdef swapmem,<,,> + push si + push di + pushds +ifndef LONGPTR + mov di,ds + mov es,di +endif + ldptr si,str1 + ldptr di,str2 + mov cx,len + jcxz done +ifdef LONGPTR + mov ax,ds + mov dx,es + cmp ax,dx + jne swaploop +endif + cmp di,si + je done +swaploop: + mov al,es:[di] + xchg al,ds:[si] + stosb + inc si + loop swaploop +done: + popds + pop di + pop si + pret + pend swapmem + finish + end + sysint.asm +; :ts=8 +;Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef sysint,<,,> + sub sp,14 + push si + push di + push es + push ds +; +; build instruction sequence on the stack to issue int +; and restore ss:sp to value before int. +; Note: All this is because some handlers don't restore ss and sp. +; + mov byte ptr -10[bp],0cdH ;int xx + mov al,num + mov byte ptr -9[bp],al + mov word ptr -8[bp],0cd8cH ;mov bp,cs + mov word ptr -6[bp],0d58eH ;mov ss,bp + mov byte ptr -4[bp],0bcH ;mov sp,xx + mov ax,sp + sub ax,6 + mov word ptr -3[bp],ax + mov byte ptr -1[bp],0cbH ;retf + mov word ptr -12[bp],ss ;set up pointer to above code + lea ax,-10[bp] + mov word ptr -14[bp],ax +; + ldptr bx,sregs,ds + mov ax,[bx] + push 2[bx] ;value to go into BX + mov cx,4[bx] + mov dx,6[bx] + mov si,8[bx] + mov di,10[bx] + mov es,14[bx] + mov ds,12[bx] + pop bx + push bp + call ss:dword ptr -14[bp] + pop bp + push ds ;save values so we have working registers + push bx + ldptr bx,dregs,ds +ifdef LONGPTR + mov [bx],ax + pop 2[bx] ;value returned in BX + mov 4[bx],cx + mov 6[bx],dx + mov 8[bx],si + mov 10[bx],di + pop 12[bx] ;value returned in DS + mov 14[bx],es + pop ds +else + mov ss:14[bx],es + pop ss:2[bx] ;value returned in BX + pop ss:12[bx] ;value returned in DS + pop ds + mov [bx],ax + mov 4[bx],cx + mov 6[bx],dx + mov 8[bx],si + mov 10[bx],di +endif + pop es + pop di + pop si + pushf + pop ax + add sp,14 + pret + pend sysint + finish + end + toupper.asm +; Copyright (C) 1983 by Manx Software Systems + include lmacros.h + procdef toupper,<> +; + mov al,val1 + sub ah,ah + cmp al,'a' + jl tu_done + cmp al,'z' + jg tu_done + sub al,'a'-'A' +tu_done: + pret + pend toupper +; +; + procdef tolower,<> +; + mov al,val2 + sub ah,ah + cmp al,'A' + jl skip + cmp al,'Z' + jg skip + add al,'a'-'A' +skip: + pret + pend tolower + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/MISC.ARC b/Manx Aztec C86 v42b/ARC/MISC.ARC new file mode 100644 index 0000000..773f835 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/MISC.ARC @@ -0,0 +1,1615 @@ + abort.c +#include + +void abort(void) +{ + raise(SIGABRT); + _exit(255); +} + atoi.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include + +atoi(cp) +register char *cp; +{ + register unsigned i; + register sign; + + while (*cp == ' ' || *cp == '\t') + ++cp; + sign = 0; + if ( *cp == '-' ) { + sign = 1; + ++cp; + } else if ( *cp == '+' ) + ++cp; + + for ( i = 0 ; isdigit(*cp) ; ) + i = i*10 + *cp++ - '0'; + return sign ? -i : i; +} + atol.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include + +long +atol(cp) +register char *cp; +{ + long n; + register sign; + + while (*cp == ' ' || *cp == '\t') + ++cp; + sign = 0; + if ( *cp == '-' ) { + sign = 1; + ++cp; + } else if ( *cp == '+' ) + ++cp; + + for ( n = 0 ; isdigit(*cp) ; ) + n = n*10 + *cp++ - '0'; + return sign ? -n : n; +} + calloc.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char *calloc(nelem, size) +unsigned nelem, size; +{ + register unsigned i = nelem*size; + register char *cp, *malloc(); + + if ((cp = malloc(i)) != (char *)0) + setmem(cp, i, 0); + return cp; +} + ctype.c +/* Copyright (C) 1984 by Manx Software Systems */ + +char ctp_[129] = { + 0, /* EOF */ + 0x20, 0x20, 0x20, 0x20, /* nul soh stx etx */ + 0x20, 0x20, 0x20, 0x20, /* eot enq ack bel */ + 0x20, 0x30, 0x30, 0x30, /* bs ht nl vt */ + 0x30, 0x30, 0x20, 0x20, /* ff cr so si */ + 0x20, 0x20, 0x20, 0x20, /* dle dc1 dc2 dc3 */ + 0x20, 0x20, 0x20, 0x20, /* dc4 nak syn etb */ + 0x20, 0x20, 0x20, 0x20, /* can em sub esc */ + 0x20, 0x20, 0x20, 0x20, /* fs gs rs us */ + 0x90, 0x40, 0x40, 0x40, /* sp ! " # */ + 0x40, 0x40, 0x40, 0x40, /* $ % & ' */ + 0x40, 0x40, 0x40, 0x40, /* ( ) * + */ + 0x40, 0x40, 0x40, 0x40, /* , - . / */ + 0x0C, 0x0C, 0x0C, 0x0C, /* 0 1 2 3 */ + 0x0C, 0x0C, 0x0C, 0x0C, /* 4 5 6 7 */ + 0x0C, 0x0C, 0x40, 0x40, /* 8 9 : ; */ + 0x40, 0x40, 0x40, 0x40, /* < = > ? */ + 0x40, 0x09, 0x09, 0x09, /* @ A B C */ + 0x09, 0x09, 0x09, 0x01, /* D E F G */ + 0x01, 0x01, 0x01, 0x01, /* H I J K */ + 0x01, 0x01, 0x01, 0x01, /* L M N O */ + 0x01, 0x01, 0x01, 0x01, /* P Q R S */ + 0x01, 0x01, 0x01, 0x01, /* T U V W */ + 0x01, 0x01, 0x01, 0x40, /* X Y Z [ */ + 0x40, 0x40, 0x40, 0x40, /* \ ] ^ _ */ + 0x40, 0x0A, 0x0A, 0x0A, /* ` a b c */ + 0x0A, 0x0A, 0x0A, 0x02, /* d e f g */ + 0x02, 0x02, 0x02, 0x02, /* h i j k */ + 0x02, 0x02, 0x02, 0x02, /* l m n o */ + 0x02, 0x02, 0x02, 0x02, /* p q r s */ + 0x02, 0x02, 0x02, 0x02, /* t u v w */ + 0x02, 0x02, 0x02, 0x40, /* x y z { */ + 0x40, 0x40, 0x40, 0x20, /* | } ~ del */ +} ; + format.asm +; Copyright (C) Manx Software Systems, Inc. 1987 +; All Rights Reserved. +; :ts=8 + include lmacros.h + +INTSIZE equ 2 +LONGSIZE equ 4 +DBLSIZE equ 8 + +ifdef LONGPTR +loades macro reg,expr + les reg,dword ptr expr + endm + +pushptr macro addr,seg + push seg + push addr + endm +else + +loades macro reg,expr + push ds + pop es + mov reg,word ptr expr + endm + +pushptr macro addr,seg + push addr + endm +endif + +LDBLOPT equ 01H +LONGOPT equ 02H +FAROPT equ 04H +LEFTJUST equ 08H +ALTFORM equ 10H +CASEMAP equ 20H + +CONVCOUNT equ 21 +conversions db 'LlhFNoxXudiscpneEfgG%' +conv_routines dw ldblopt,longopt,shortopt,FARopt,NEARopt + dw octal,hex,upperhex,unsigned,decimal,decimal + dw string,char,pointer,numchar + dw fltformat,cap_fltformat,fltformat,fltformat,cap_fltformat + dw default + +digits db '0123456789abcdef' + +ifndef FLOAT +nofltmsg db ' -lm first',0 +endif + +charcount equ word ptr -2[bp] +fldwidth equ word ptr -4[bp] +precision equ word ptr -6[bp] +outsize equ word ptr -8[bp] +dsvalue equ word ptr -10[bp] +options equ byte ptr -11[bp] +fillc equ byte ptr -12[bp] +sign equ byte ptr -13[bp] +pos_sign equ byte ptr -14[bp] +buffer equ byte ptr -340[bp] +autosize equ 340 + + procdef format,<, , > + sub sp,autosize + push di + push si +ifdef LONGPTR + mov dsvalue,ds +endif + cld + ldptr si,fmtstr + mov charcount,0 +; +main_loop: + mov options,0 ;reset all conversion flags + lodsb ;get next byte of format string + cmp al,'%' ;is it a conversion character ? + je ispercent ;yes, then perform conversion +default: + test al,al + jz finishup + call emitchar + jmp main_loop +finishup: + mov ax,charcount +ifdef LONGPTR + mov ds,dsvalue +endif + pop si + pop di + mov sp,bp + pret + +ispercent: + mov fillc,' ' + mov pos_sign,0 ;default is no sign char for positive #'s + mov sign,0 ;clear out sign, so %s works right + mov precision,-1 +next_flag: + lodsb ;next byte of format string + cmp al,'-' ;check for left justify flag + jne not_minus + or options,LEFTJUST + jmp short next_flag +not_minus: + cmp al,'+' ;always show sign flag + jne not_plus + mov pos_sign,'+' + jmp short next_flag +not_plus: + cmp al,' ' ;show positive sign with space + jne not_space + cmp pos_sign,0 + jne next_flag + mov pos_sign,' ' + jmp short next_flag +not_space: + cmp al,'#' ;print in alternate form + jne not_alter + or options,ALTFORM + jmp short next_flag +not_alter: + cmp al,'0' ;check for zero fill flag + jne not_zero + mov fillc,'0' + lodsb ;skip over '0' +not_zero: + call do_width + test dx,dx + jns pos_width + neg dx + or options,LEFTJUST +pos_width: + mov fldwidth,dx + cmp al,'.' ;check for precision field + jne no_precision + lodsb ;skip over '.' + call do_width + mov precision,dx +no_precision: + mov di,cs + mov es,di +convert_again: + mov di,offset conversions + mov cx,CONVCOUNT +repne scasb + sub di,offset conversions+1 ;compute index into table + shl di,1 ;scale for proper addressing + jmp word ptr conv_routines[di] ;dispatch handler + + +ldblopt: + or options,LDBLOPT + lodsb + jmp short convert_again +longopt: + or options,LONGOPT +shortopt: ;not needed for 8086 +NEARopt: ;Aztec promotes near ptrs to far ptrs on varargs calls + lodsb + jmp short convert_again +FARopt: + or options,FAROPT + lodsb + jmp short convert_again + +octal: + mov cx,8 ;set base to 8, and unsigned conversion + jmp short intconv +upperhex: + or options,CASEMAP +hex: + mov cx,16 ;set base to 16, and unsigned conversion + jmp short intconv +unsigned: + mov cx,10 ;set base to 10, and unsigned conversion + jmp short intconv +decimal: + mov cx,0ff0aH ;set base (cl) and signed conv flag (ch) +intconv: + loades di,args + mov ax,es:[di] + add di,2 + test options,LONGOPT + jz shortload + mov dx,es:[di] + add di,2 + jmp short signcheck +shortload: + sub dx,dx + test ch,ch + jz nosign + cwd +signcheck: + test ch,ch + jz nosign + mov ch,pos_sign + mov sign,ch + test dx,dx + jns nosign + mov sign,'-' + neg dx + neg ax + sbb dx,0 +nosign: + mov word ptr args,di + cmp precision,0 ;check for default precision + jge prec_ok + mov precision,1 ;set to default of 1 for integer conversions +prec_ok: + + mov ch,0 + mov di,ss + mov es,di + lea di,buffer+20 ;make ES:DI point at end of buffer +digit_loop: + test dx,dx + jnz notyet + test ax,ax + jz digits_done +notyet: sub bx,bx ;clear high word of quotient + cmp cx,dx + ja veryeasy + push ax + mov ax,dx + sub dx,dx + div cx + mov bx,ax ;save high word of quotient + pop ax + div cx + jmp short div_done +veryeasy: + div cx +div_done: + xchg dx,bx ;ax,dx has quotient, bx has remainder + mov bl,cs:digits[bx] + dec di + mov es:byte ptr [di],bl + jmp digit_loop + +digits_done: + test options,ALTFORM ;check for # form of conversion + jz normalform + cmp cl,10 + je normalform ;no effect on decimal conversions + cmp cl,16 + jne nothex + mov sign,'x' ;hex: prefixes output with 0x + jmp short normalform +nothex: + dec di ;octal: prefixes output with 0 + mov es:byte ptr [di],'0' + +normalform: + lea cx,buffer+20 ;get starting address into cx + sub cx,di ;and compute char count into cx + mov ax,precision + sub ax,cx + mov precision,ax + jle output_string + sub fldwidth,ax ;adjust for precision padding to be done + +output_string: + mov outsize,cx ;save for later + cmp sign,0 + jz width_ok + cmp sign,'x' ;hex prefix instead of sign? + jne nothex_prefix + dec fldwidth ;adjust for 0x prefix +nothex_prefix: + dec fldwidth ;adjust for sign character +width_ok: + sub fldwidth,cx ;adjust for characters to be output + jle left_justify + test options,LEFTJUST + jnz left_justify + +; emit leading pad characters for right justified field + + cmp fillc,'0' ;if padding with zeros + jne wpad_loop + call emitsign ;then we must emit sign chars if required +wpad_loop: + mov al,fillc ;emit padding needed to get min field width + call emitchar + dec fldwidth + jg wpad_loop + +left_justify: + call emitsign ;emit sign chars if required + +zpad_loop: ;emit any padding needed because of precision + dec precision + js outchars + mov al,'0' + call emitchar + jmp zpad_loop + +outchars: ;emit the characters generated + dec outsize + js trail_pad + mov al,es:byte ptr [di] + inc di + call emitchar + jmp outchars + +trail_pad: ;emit trailing field width padding + dec fldwidth + js outdone + mov al,' ' ;trailing pad is always space + call emitchar + jmp trail_pad +outdone: + jmp main_loop + +cap_fltformat: + or options,CASEMAP + add al,'a'-'A' ;map convert char to lower case +fltformat: +ifndef FLOAT + add word ptr args,DBLSIZE + mov ax,cs + mov es,ax + mov di,offset nofltmsg + sub fldwidth,size nofltmsg - 1 + jmp outchars +else + +ifdef FARPROC + extrn ftoa_:far +else + extrn ftoa_:near +endif +ifdef LONGPTR + push ds ; save current ds + mov ds,dsvalue ; make sure ds points to dataseg +endif + sub al,'e' + sub ah,ah + push ax + mov ax,precision + test ax,ax ;check for default precision + jns fprec_ok + mov ax,6 ;set to default of 6 for float conversions +fprec_ok: + push ax + lea ax,buffer + pushptr ax,ss + loades bx,args + add word ptr args,DBLSIZE + mov al,pos_sign + mov sign,al + mov ax,es:word ptr 6[bx] + test ax,ax + jns flt_positive + mov sign,'-' + and ah,7fH ;clear sign bit +flt_positive: + push ax + push es:word ptr 4[bx] + push es:word ptr 2[bx] + push es:word ptr [bx] + call ftoa_ + ifdef LONGPTR + add sp,16 + pop ds + else + add sp,14 + endif + mov di,ss + mov es,di + lea di,buffer ;make ES:DI point at buffer + mov al,0 + mov cx,0ffffH +repne scasb + not cx ;length counting nul char + dec cx ;fix so we have correct length + jmp set_buffer +endif + +string: + call get_pointer + push di ;save for output routine + mov al,0 + mov cx,0ffffH +repne scasb + not cx ;length counting nul char + dec cx ;fix so we have correct length + cmp cx,precision + jbe strlen_ok + mov cx,precision ;limit string to precision chars +strlen_ok: + pop di ;get buffer address back + mov precision,0 ;precision already dealt with + jmp output_string + +char: + loades di,args + mov al,es:[di] + add di,2 + mov word ptr args,di + mov buffer,al + mov cx,1 + mov ax,ss + mov es,ax +set_buffer: + lea di,buffer ;get buffer address back + mov precision,0 ;precision already dealt with + jmp output_string + +pointer: + jmp main_loop + +numchar: + call get_pointer + mov ax,charcount + mov es:word ptr [di],ax + test options,LONGOPT + jz nc_done + mov es:word ptr 2[di],0 +nc_done: + jmp main_loop + +emitsign proc near + mov al,sign ;check if sign chars required + test al,al + jz emitreturn + cmp al,'x' ;check for 0x prefix + jne normalsign + mov al,'0' + call emitchar + mov al,'x' +normalsign: + mov sign,0 ;mark sign as already emitted + ;fall through into emitchar routine and return +emitchar: + inc charcount + test options,CASEMAP + jz nocasefix + cmp al,'a' ;check if lowercase alpha + jb nocasefix + cmp al,'z' + ja nocasefix + sub al,'a'-'A' ;map lowercase into uppercase +nocasefix: + push es ;save for routines above +ifdef LONGPTR + mov ds,dsvalue ;restore normal DS for outside function +endif + sub ah,ah + push ax + call result + pop ax ;fix stack +ifdef LONGPTR + mov ds,word ptr fmtstr+2 ;get internal DS back +endif + pop es ;restore +emitreturn: + ret +emitsign endp + +get_pointer proc near + loades di,args +ifndef LONGPTR + test options,FAROPT + jnz load_longptr + mov di,[di] + add word ptr args,2 + ret +load_longptr: +endif + les di,es:dword ptr [di] + add word ptr args,4 + ret +get_pointer endp + +; process a field width or precision specifier + +do_width proc near + cmp al,'*' ;variable field width indicator + jne fixed_width + loades di,args + mov dx,es:[di] + add di,INTSIZE ;bump to next argument + mov word ptr args,di + lodsb ;skip over '*' + ret + +fixed_width: + sub dx,dx + mov ah,0 +pack_digits: + cmp al,'0' ;is character a digit ? + jb pack_done ;no, then we are done. + cmp al,'9' + ja pack_done + sub al,'0' ;put into absolute range 0-9 + shl dx,1 + mov cx,dx ;CX = DX*2 + shl dx,1 ;DX*4 + shl dx,1 ;DX*8 + add dx,cx ;DX*10 + add dx,ax ;accumulate value given + lodsb ;fetch next byte of format string + jmp pack_digits +pack_done: + ret +do_width endp + + pend format + finish + end + lcalloc.c +/* Copyright (C) Manx Software Systems, Inc. 1987. All rights reserved. */ + +huge void * +lcalloc(nelem, size) +unsigned long nelem, size; +{ + huge void *ptr; + huge long *lp; + huge void *lmalloc(); + + size *= nelem; + size = size+3 & ~3; + if ((ptr = lmalloc(size)) != (huge void *)0) { + size >>= 2; + for (lp = ptr ; size ; --size) + *lp++ = 0; + } + return ptr; +} + ldlmallo.c +/* Copyright (C) Manx Software Systems, Inc. 1985-1987. + All rights reserved. */ + +huge void * +lrealloc(area,size) +register char *area; unsigned long size; +{ + char *_realloc(); + + return _realloc(area,size); +} + +huge void * +lmalloc(size) +unsigned long size; +{ + char *_malloc(); + + return _malloc(size); +} + +lfree(p) +huge void *p; +{ + return free(p); +} + ldmalloc.c +/* Copyright (C) Manx Software Systems, Inc. 1985-1987. + All rights reserved. */ + +typedef unsigned long size_t; +char *_ptradd(); +long _ptrdiff(); +#define bump(p,i) ((l_t *)_ptradd((p),(i))) +#define ptrdiff(p1,p2) _ptrdiff(p1,p2) + +typedef struct list { + struct list *next; +} l_t; +static l_t first, *current; +static l_t *endmarker = &first, *restart = &first; +static size_t keep; + +#define INUSE 1 +#define inuse(p) (*(size_t *)(p)&INUSE) +#define markblk(p) (*(size_t *)(p) |= INUSE) +#define unmark(p) (*(size_t *)(p) &= ~INUSE) +#define chain(p) ((l_t *)(*(size_t *)(p) & ~INUSE)) + +#define BLOCK (1024*sizeof(l_t)) /* # of bytes to ask sbrk for */ + +char * +realloc(area,size) +register char *area; unsigned size; +{ + char *_realloc(); + + return _realloc(area,(unsigned long)size); +} + +char * +_realloc(area, size) +register char *area; unsigned long size; +{ + register char *cp, *end; + size_t osize; + char *_malloc(); + huge long *ptr, *orig; + + end = (char *)chain((l_t *)area-1); + if ((osize = ptrdiff(end, area)) > size) { + osize = size; + end = (char *)bump(area, osize); + } + free(area); + if ((cp = _malloc(size)) != 0 && cp != area) { + if (osize < 0xffffL) + movmem(area, cp, osize); + else { + osize = osize+3 >> 2; + orig = (huge long *)area; + for (ptr = (huge long *)cp ; osize ; --osize) + *ptr++ = *orig++; + } + if ((char *)current >= area && (char *)current < end) + *(size_t *)bump(cp, ptrdiff(current,area)) = keep; + } + return cp; +} + +char * +malloc(size) +unsigned size; +{ + char *_malloc(); + + return _malloc((unsigned long)size); +} + +char * +_malloc(size) +unsigned long size; +{ + register l_t *ptr, *temp, *lastfree; + register size_t len; + long times; + char *sbrk(); + + size = ((size+sizeof(l_t)*2-1)/sizeof(l_t))*sizeof(l_t); + if (current == 0) { + first.next = &first; + markblk(&first); + current = &first; + } + for (times = 0, lastfree = ptr = current ; ; ptr = chain(ptr)) { + if (ptr == endmarker) { + if (++times > 1) { + len = BLOCK; + if ((temp = (l_t *)sbrk((int)len)) == (l_t *)-1) + return 0; + if (temp != bump(ptr,(long)sizeof(l_t))) { + /* non-contiguous allocation */ + ptr->next = temp; + markblk(ptr); + len -= sizeof(l_t); + ptr = temp; + } + temp = bump(ptr, len); + ptr->next = temp; + temp->next = &first; /* new end marker */ + markblk(temp); + endmarker = temp; + if (chain(lastfree) == ptr) + ptr = lastfree; + } + } + if (inuse(ptr)) + continue; + lastfree = ptr; + while (!inuse(temp = chain(ptr))) { + ptr->next = temp->next; + if (temp == current) + current = &first; + } + len = ptrdiff(temp,ptr); + if (len >= size) { + if (len > size) { + ptr->next = bump(ptr, size); + keep = *(size_t *)ptr->next; + ptr->next->next = temp; + } + current = ptr->next; + markblk(ptr); + return (char *)(ptr+1); + } + } +} + +free(p) +char *p; +{ + register l_t *ptr; + + ptr = (l_t *)p - 1; + if (!inuse(ptr)) + return -1; + unmark(ptr); + current = ptr; + return 0; +} + lmalloc.c +/* Copyright (C) 1985 by Manx Software Systems, Inc. */ + +#ifdef __LDATA +typedef long size_t; +char *_ptradd(); +long _ptrdiff(); +#define bump(p,i) ((l_t *)_ptradd((p),(long)(i))) +#define ptrdiff(p1,p2) _ptrdiff(p1,p2) +#else +typedef unsigned size_t; +#define bump(p,i) ((l_t *)((char *)(p)+(i))) +#define ptrdiff(p1,p2) (unsigned)((char *)(p1)-(char *)(p2)) +#endif + +typedef struct list { + struct list *next; +} l_t; +static l_t first, *current; +static l_t *endmarker = &first, *restart = &first; +static size_t keep; + +#define INUSE 1 +#define inuse(p) (*(size_t *)(p)&INUSE) +#define markblk(p) (*(size_t *)(p) |= INUSE) +#define unmark(p) (*(size_t *)(p) &= ~INUSE) +#define chain(p) ((l_t *)(*(size_t *)(p) & ~INUSE)) + +#define BLOCK (512*sizeof(l_t)) /* # of bytes to ask sbrk for */ + +char * +realloc(area, size) +register char *area; unsigned size; +{ + register char *cp, *end; + size_t osize; + char *malloc(); + + end = (char *)chain((l_t *)area-1); + if ((osize = ptrdiff(end, area)) > size) { + osize = size; + end = (char *)bump(area, osize); + } + free(area); + if ((cp = malloc(size)) != 0 && cp != area) { + movmem(area, cp, osize); + if ((char *)current >= area && (char *)current < end) + *(size_t *)bump(cp, ptrdiff(current,area)) = keep; + } + return cp; +} + +char * +malloc(size) +unsigned size; +{ + register l_t *ptr, *temp, *lastfree; + register size_t len; + int times; + char *sbrk(); + + size = ((size+sizeof(l_t)*2-1)/sizeof(l_t))*sizeof(l_t); + if (current == 0) { + first.next = &first; + markblk(&first); + current = &first; + } + for (times = 0, lastfree = ptr = current ; ; ptr = chain(ptr)) { + if (ptr == endmarker) { + if (++times > 1) { + len = BLOCK; + if ((temp = (l_t *)sbrk((int)len)) == (l_t *)-1) + return 0; + if (temp != bump(ptr,sizeof(l_t))) { + /* non-contiguous allocation */ + ptr->next = temp; + markblk(ptr); + len -= sizeof(l_t); + ptr = temp; + } + temp = bump(ptr, len); + ptr->next = temp; + temp->next = &first; /* new end marker */ + markblk(temp); + endmarker = temp; + if (chain(lastfree) == ptr) + ptr = lastfree; + } + } + if (inuse(ptr)) + continue; + lastfree = ptr; + while (!inuse(temp = chain(ptr))) + ptr->next = temp->next; + len = ptrdiff(temp,ptr); + if (len >= size) { + if (len > size) { + ptr->next = bump(ptr, size); + keep = *(size_t *)ptr->next; + ptr->next->next = temp; + } + current = ptr->next; + markblk(ptr); + return (char *)(ptr+1); + } + } +} + +free(p) +char *p; +{ + register l_t *ptr; + + ptr = (l_t *)p - 1; + if (!inuse(ptr)) + return -1; + unmark(ptr); + current = ptr; + return 0; +} + makefile +OBJ=atoi.o atol.o calloc.o lcalloc.o ctype.o qsort.o format.o scan.o\ + sprintf.o sscanf.o rand.o abort.o raise.o signal.o sigtable.o +MOBJ=fscan.o fscan87.o fformat.o sprintf.o sscanf.o + +CC=cc +AS=as +MODEL= +AMODEL=0 + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +bld bldlc: $(OBJ) malloc.o + @echo misc done + +bldl bldld: $(OBJ) ldlmallo.o ldmalloc.o + @echo misc done + +math: $(MOBJ) + @echo math misc done + +fformat.o: format.asm + $(AS) -DFLOAT -dMODEL=$(AMODEL) format.asm -o $@ + sqz $@ + +fscan.o: scan.c + $(CC) -DFLOAT +$(MODEL) -n scan.c -o $@ + sqz $@ + +fscan87.o: scan.c + $(CC) -DFLOAT +$(MODEL) -n +e scan.c -o $@ + sqz $@ + +arc: + mkarcv misc.arc size) { + osize = size; + end = (char *)bump(area, osize); + } + free(area); + if ((cp = malloc(size)) != 0 && cp != area) { + movmem(area, cp, osize); + if ((char *)current >= area && (char *)current < end) + *(size_t *)bump(cp, ptrdiff(current,area)) = keep; + } + return cp; +} + +char * +malloc(size) +unsigned size; +{ + register l_t *ptr, *temp, *lastfree; + register size_t len; + int times; + char *sbrk(); + + size = ((size+sizeof(l_t)*2-1)/sizeof(l_t))*sizeof(l_t); + if (current == 0) { + first.next = &first; + markblk(&first); + current = &first; + } + for (times = 0, lastfree = ptr = current ; ; ptr = chain(ptr)) { + if (ptr == endmarker) { + if (++times > 1) { + len = BLOCK; + if ((temp = (l_t *)sbrk((int)len)) == (l_t *)-1) + return 0; + if (temp != bump(ptr,sizeof(l_t))) { + /* non-contiguous allocation */ + ptr->next = temp; + markblk(ptr); + len -= sizeof(l_t); + ptr = temp; + } + temp = bump(ptr, len); + ptr->next = temp; + temp->next = &first; /* new end marker */ + markblk(temp); + endmarker = temp; + if (chain(lastfree) == ptr) + ptr = lastfree; + } + } + if (inuse(ptr)) + continue; + lastfree = ptr; + while (!inuse(temp = chain(ptr))) + ptr->next = temp->next; + len = ptrdiff(temp,ptr); + if (len >= size) { + if (len > size) { + ptr->next = bump(ptr, size); + keep = *(size_t *)ptr->next; + ptr->next->next = temp; + } + current = ptr->next; + markblk(ptr); + return (char *)(ptr+1); + } + } +} + +free(p) +char *p; +{ + register l_t *ptr; + + ptr = (l_t *)p - 1; + if (!inuse(ptr)) + return -1; + unmark(ptr); + current = ptr; + return 0; +} + misc.bld +abort.c +atoi.c +atol.c +calloc.c +ctype.c +format.asm +lcalloc.c +ldlmallo.c +ldmalloc.c +lmalloc.c +makefile +malloc.c +misc.bld +qsort.c +raise.c +rand.c +scan.c +signal.c +sigtable.c +sprintf.c +sscanf.c + qsort.c +/* Copyright (C) 1984 by Manx Software Systems */ + +qsort(base, nel, size, compar) +char *base; unsigned nel, size; int (*compar)(); +{ + register char *i,*j,*x,*r; + auto struct stk { + char *l, *r; + } stack[16]; + struct stk *sp; + +#ifdef __LDATA /* added by R. Sherry Feb. 1 1988 for underflow problem */ + long ptrtoabs(); + void *abstoptr(); + + long good_address; + + good_address = ptrtoabs(base); + good_address -= size *2; /* double it for safety */ + base = abstoptr(good_address); + base += size *2; +#endif + + sp = stack; + r = base + (nel-1)*size; + for (;;) { + do { + x = base + (r-base)/size/2 * size; + i = base; + j = r; + do { + while ((*compar)(i,x) < 0) + i += size; + while ((*compar)(x,j) < 0) + j -= size; + if (i < j) { + swapmem(i, j, size); + if (i == x) + x = j; + else if (j == x) + x = i; + } + if (i <= j) { + i += size; + j -= size; + } + } while (i <= j); + if (j-base < r-i) { + if (i < r) { /* stack request for right partition */ + sp->l = i; + sp->r = r; + ++sp; + } + r = j; /* continue sorting left partition */ + } else { + if (base < j) { /* stack request for left partition */ + sp->l = base; + sp->r = j; + ++sp; + } + base = i; /* continue sorting right partition */ + } + } while (base < r); + + if (sp <= stack) + break; + --sp; + base = sp->l; + r = sp->r; + } +} + raise.c +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#include +#include + +extern void (*_sigfuns[])(int); + +int raise(int sig) +{ + register void (*handler)(int); + + if (sig < _FSTSIG || sig >= _FSTSIG+_NUMSIG) + return -1; + if ((handler = _sigfuns[sig - _FSTSIG]) == SIG_DFL) + _exit(255); + if (handler != SIG_IGN) + (*handler)(sig); + return 0; +} + rand.c +static unsigned long int next = 1; + +/* + * rand() returns a random number in the range of 0 to 32767. + */ +int rand() +{ + next = next * 1103515245 + 12345; + return (unsigned int)(next/65536) % 32768; +} + +/* + * srand() enables you to set the seed value of the rand() function. + */ +void srand(unsigned int seed) +{ + next = seed; +} + scan.c +/* Copyright (C) 1982, 1984 by Manx Software Systems */ +#include + +#ifdef FARMODIFIER +#define FAR far +#else +#define FAR +#endif + +#define EOF -1 + +static int maxwidth; +static int (*gsub)(); +static getnum(), skipblank(), getflt(); + +char *strchr(); + +scanfmt(getsub, fmt, arglist) +int (*getsub)(); register char *fmt; register char *arglist; +{ +#ifdef FLOAT + double atof(); +#endif + long lv; + register int c, count, base, cc; + char suppress, lflag, widflg; +#ifdef FARMODIFIER + char nearfar; +#endif + char FAR *ptr; + auto char tlist[130]; + static char list[] = "ABCDEFabcdef9876543210"; + static char vals[] = { + 10,11,12,13,14,15,10,11,12,13,14,15,9,8,7,6,5,4,3,2,1,0 + }; + + count = 0; + gsub = getsub; + while (c = *fmt++) { + if (c == '%') { + widflg = lflag = suppress = 0; +#ifdef FARMODIFIER + nearfar = 0; +#endif + maxwidth = 127; + if (*fmt == '*') { + ++fmt; + suppress = 1; + } + if (isdigit(*fmt)) { + maxwidth = 0; + do { + maxwidth = maxwidth*10 + *fmt - '0'; + } while (isdigit(*++fmt)); + widflg = 1; + } + +again: + switch (cc = *fmt++) { + case 'l': + lflag = 1; + goto again; + case 'h': /* specify short (for compatibility) */ + lflag = 0; + goto again; +#ifdef FARMODIFIER + case 'N': + nearfar = 0; + goto again; + case 'F': + nearfar = 1; + goto again; +#endif + + case '%': + c = '%'; + goto matchit; + case 'D': + lflag = 1; + case 'u': + case 'd': + decimal: + c = 12; + base = 10; + goto getval; + + case 'X': + lflag = 1; + case 'x': + c = 0; + base = 16; + goto getval; + + case 'O': + lflag = 1; + case 'o': + c = 14; + base = 8; + getval: + if (skipblank()) + goto stopscan; + if (getnum(&list[c], &vals[c], base, &lv) == 0) + goto stopscan; + if (!suppress) { +#ifdef FARMODIFIER + if (nearfar) { + ptr = *(void FAR **)arglist; + arglist += sizeof(void FAR *); + } else +#endif + { + ptr = *(void **)arglist; + arglist += sizeof(void *); + } + if (lflag) + *(long FAR *)ptr = lv; + else + *(int FAR *)ptr = lv; + ++count; + } + break; + +#ifdef FLOAT + case 'e': + case 'f': + if (skipblank()) + goto stopscan; + if (getflt(tlist)) + goto stopscan; + if (!suppress) { +#ifdef FARMODIFIER + if (nearfar) { + ptr = *(void FAR **)arglist; + arglist += sizeof(void FAR *); + } else +#endif + { + ptr = *(void **)arglist; + arglist += sizeof(void *); + } + if (lflag) + *(double FAR *)ptr = atof(tlist); + else + *(float FAR *)ptr = atof(tlist); + ++count; + } + break; +#endif + case '[': + lflag = 0; + if (*fmt == '^' || *fmt == '~') { + ++fmt; + lflag = 1; + } + +/* Fix so match [] will work. */ +/* Base is dead, therefor we can use it. R. Sherry 3/10/88 */ + for (base = 0 ; (cc = *fmt++) != ']' ; ) + tlist[base++] = cc; + tlist[base] = 0; + goto string; + case 's': + lflag = 1; + tlist[0] = ' '; + tlist[1] = '\t'; + tlist[2] = '\n'; + tlist[3] = 0; + string: + if (skipblank()) + goto stopscan; + charstring: + if (!suppress) { +#ifdef FARMODIFIER + if (nearfar) { + ptr = *(void FAR **)arglist; + arglist += sizeof(void FAR *); + } else +#endif + { + ptr = *(void **)arglist; + arglist += sizeof(void *); + } + } + widflg = 0; + while (maxwidth--) { + if ((c = (*gsub)(0)) == EOF) + break; + if (lflag ? (strchr(tlist,c)!=0) : (strchr(tlist,c)==0)) { + (*gsub)(1); /* unget last character */ + break; + } + if (!suppress) + *ptr++ = c; + widflg = 1; + } + if (!widflg) + goto stopscan; + if (!suppress) { + if (cc != 'c') + *ptr = 0; + ++count; + } + break; + + case 'c': + if (!widflg) + maxwidth = 1; + tlist[0] = 0; + lflag = 1; + goto charstring; + } + } else if (isspace(c)) { + if (skipblank()) + goto stopscan; + } else { +matchit: + if ((*gsub)(0) != c) { + (*gsub)(1); + goto stopscan; + } + } + } + +stopscan: + if (count == 0) { + if ((*gsub)(0) == EOF) + return EOF; + (*gsub)(1); + } + return count; +} + +static +skipblank() +{ + while (isspace((*gsub)(0))) + ; + if ((*gsub)(1) == EOF) + return EOF; + return 0; +} + +#ifdef FLOAT +static +getflt(buffer) +char *buffer; +{ + register char *cp; + register int c; + char decpt, sign, exp; + + sign = exp = decpt = 0; + + for (cp = buffer ; maxwidth-- ; *cp++ = c) { + c = (*gsub)(0); + if (!isdigit(c)) { + if (!decpt && c == '.') + decpt = 1; + else if (!exp && (c == 'e' || c == 'E') && cp != buffer) { + sign = 0; + exp = decpt = 1; + continue; + } else if (sign || (c != '-' && c != '+')) { + (*gsub)(1); + break; + } + } + sign = 1; + } + *cp = 0; + return cp==buffer; +} +#endif + +static +getnum(list, values, base, valp) +char *list; char *values; long *valp; +{ + register char *cp; + register int c, cnt; + long val; + int sign; + + if (maxwidth <= 0) + return 0L; + val = cnt = sign = 0; + if ((c = (*gsub)(0)) == '-') { + sign = 1; + ++cnt; + } else if (c == '+') + ++cnt; + else + (*gsub)(1); + + for ( ; cnt < maxwidth ; ++cnt) { + if ((cp = strchr(list, c = (*gsub)(0))) == 0) { + if (base == 16 && val == 0 && (c=='x' || c=='X')) + continue; + (*gsub)(1); + break; + } + val *= base; + val += values[cp-list]; + } + if (sign) + *valp = -val; + else + *valp = val; + return cnt; +} + signal.c +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ +#include +#include + +extern void (*_sigfuns[])(int); +static char setup; + +void (*signal(register int sig, void (*func)(int)))(int) +{ + register void (*retval)(int); + + if (!setup) { + _sig_setup(); + setup = 1; + } + if ((sig -= _FSTSIG) < 0 || sig >= _NUMSIG) { + errno = EINVAL; + return SIG_ERR; + } + retval = _sigfuns[sig]; + _sigfuns[sig] = func; + return retval; +} + sigtable.c +#include +void (*_sigfuns[_NUMSIG])(int)={0}; + sprintf.c +/* Copyright (C) 1982 by Manx Software Systems */ +static char *buff; + +sprintf(str,fmt,args) +char *str, *fmt; unsigned args; +{ + int spsub(); + register int i; + + buff = str; + i = format(spsub,fmt,&args); + *buff = 0; + return i; +} + +static +spsub(c) +{ + return (*buff++ = c)&0xff; +} + + sscanf.c +/* Copyright (C) 1983 by Manx Software Systems */ +static char *scnstr; +static char quit; + +sscanf(string, fmt, arg) +char *string, *fmt; int *arg; +{ + int sgetc(); + + scnstr = string; + quit = 0; + return scanfmt(sgetc, fmt, &arg); +} + +static +sgetc(what) +{ + if (what == 0) { + if (*scnstr) + return *scnstr++ & 255; + quit = 1; + } else { + if (!quit) + return *--scnstr & 255; + } + return -1; +} + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/ROM.ASM b/Manx Aztec C86 v42b/ARC/ROM.ASM new file mode 100644 index 0000000..0e414f8 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/ROM.ASM @@ -0,0 +1,117 @@ +; Copyright (C) 1984, 1985 by Manx Software Systems +; :ts=8 + include lmacros.h +; +; If you want your stack at a fixed place, you may remove the +; "bss cstack..." statement below and change the "mov sp,cstack..." +; to load SP with the value you desire. Note that the setup of +; SS may need to be changed also. If the program is small data +; model, then SS must be equal to DS or pointers to automatic +; variables won't work. +; +; Otherwise, stacksize should be set according to your program's +; requirements. +stacksize equ 2048 +; +; dataseg is the data segment address (as a paragraph #) +; this is picked from the -D option of the linker +; +;Dseg equ 040H ;physical addr 0x400, just above the int vectors + +dataseg segment word public 'data' + bss cstack:byte,stacksize + public $MEMRY +$MEMRY dw -1 + dw -1 + public errno_ +errno_ dw 0 + public _dsval_,_csval_ +_dsval_ dw 0 +_csval_ dw 0 + public _mbot_, _sbot_ +_mbot_ dw 0 + dw 0 +_sbot_ dw 0 + dw 0 +; +; The variable is used with csav and cret only. Therefore if you do not +; compile the the +c option or +b option you do not need this. +; + public _lowwater_ +_lowwater_ dw -1 + extrn _Dorg_:byte,_Dend_:byte + extrn _Uorg_:byte,_Uend_:byte +dataseg ends + extrn _Corg_:byte,_Cend_:byte + +ifdef FARPROC + extrn main_:far, $fltinit:far +else + extrn main_:near, $fltinit:near +endif + + public $begin +$begin proc far + cli + cld +; +; Compute where initialzed data starts (@ next para after code) +; + mov ax,offset _Cend_+15 + mov cl,4 + shr ax,cl + add ax,seg _Cend_ + mov ds,ax ;place where data is in rom + mov bx,dataseg ;place where data is to go in ram + mov es,bx +; +; Note: For hardware reasons the instruction which loads SS should +; be immediatly followed by the load of SP. +; + mov ss,bx + mov sp,offset cstack+stacksize +; +; copy Init data from rom to ram + mov di,0 + mov cx,offset _Dend_ + inc cx + shr cx,1 + jcxz nocopy + mov si,0 +rep movsw +nocopy: +; +; clear uninitialized data + mov di,offset _Uorg_ + mov cx,offset _Uend_ + sub cx,di + inc cx + shr cx,1 + jcxz noclear + sub ax,ax +rep stosw +noclear: +; + assume ds:dataseg,es:dataseg + + mov ds,bx ;set DS, now DS, SS, ES are equal + mov di,$MEMRY + inc di + and di,0fffeH ;adjust to word boundary + mov $MEMRY,di ;save memory allocation info for sbrk() + mov $MEMRY+2,ds + mov _mbot_,di + mov _mbot_+2,ds + mov _sbot_,0ffffH ;this is the heap limit for sbrk() + mov _sbot_+2,0fff0h + mov _dsval_,ds + mov _csval_,cs ;this is of dubious value in large code + sti + call $fltinit ;setup floating point software/hardware + jnc flt_ok + hlt ;program needs 8087 and one wasn't found +flt_ok: + jmp main_ ;main shouldn't return in ROM based system +$begin endp +codeseg ends + end $begin diff --git a/Manx Aztec C86 v42b/ARC/S.ARC b/Manx Aztec C86 v42b/ARC/S.ARC new file mode 100644 index 0000000..0cf7dec --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/S.ARC @@ -0,0 +1,424 @@ + makefile +# Copyright (C) Manx Software Systems, Inc. 1987. All rights reserved. + +# Note: the object files below are in the correct order for linking, +# thus the OBJ macro should be changed with caution. If you are in doubt, +# use the ORD utility to build a correctly ordered list. + +OBJ=cio.o scr_cdel.o scr_cins.o scr_clea.o scr_echo.o scr_eol.o\ + scr_eos.o scr_getc.o scr_home.o scr_inve.o scr_ldel.o scr_lins.o\ + scr_curs.o scr_loc.o scr_putc.o scr_call.o + +CC=cc +AS=as +MODEL= +AMODEL=0 + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +$(DIR)s$(MODEL).lib: $(OBJ) + del $(DIR)s$(MODEL).lib + lb $(DIR)s$(MODEL).lib $(OBJ) + @echo screen done + cio.c +extern int _attrib; + +static cputc(chr) +register int chr; +{ + scr_putc(chr); + + if (chr == '\n') + scr_putc('\r'); +} + +scr_puts(str) +register char *str; +{ + while(*str) + cputc(*str++); + + cputc('\n'); +} + +scr_printf(fmt,args) +register char *fmt; +unsigned args; +{ + format(cputc,fmt,&args); +} + +scr_setatr(back,frg,intens,blink) +register int back, frg; +register int intens, blink; +{ + register char tmp; + + tmp = _attrib; + _attrib = (back << 4) | frg; + + if (blink) + _attrib |= 128; + else + _attrib &= 127; + + if (intens) + _attrib |= 8; + else + _attrib &= 247; + + _attrib &= 255; + return(tmp); +} + +scr_getatr() +{ + return(_attrib); +} + +scr_resatr(atr) +register int atr; +{ + register char tmp; + + tmp = _attrib; + _attrib = atr; + return(tmp); +} + scr_call.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 + include lmacros.h +; +; scr_call(ax,bx,cx,dx) - issue int 10 with ax,... set to args +; +; + procdef scr_call,<,,,> + push si + push di + mov ax,aax + mov bx,bbx + mov cx,ccx + mov dx,ddx + int 10h + pop di + pop si + pret + pend scr_call + finish + end + scr_cdel.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * delete the char. at the cursor and put blank at end of line + */ + +#define max_width 80 + +extern int _attrib; + +scr_cdelete() +{ + register unsigned ch, x; + int lin, col; + + scr_loc(&lin, &col); + for (x = col ; x < max_width-1 ; ++x) { + scr_curs(lin, x+1); + ch = scr_call(0x0800,0,0,0); /* read out current char */ + scr_curs(lin, x); + scr_call(0x0900 | (ch&255), ch>>8, 1, 0); /* and shift over */ + } + scr_curs(lin, max_width-1); + scr_call(0x920, _attrib, 1, 0); /* put a blank at end of line */ + scr_curs(lin, col); + return(0); +} + scr_cins.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * insert a space at the cursor and delete the char. at end of line + */ + +#define max_width 80 +extern int _attrib; + +scr_cinsert() +{ + register unsigned ch, z; + int lin, col; + + scr_loc(&lin, &col); + for (z = max_width - 1 ; z > col ; --z) { + scr_curs(lin, z-1); + ch = scr_call(0x0800,0,0,0); /* read out current char */ + scr_curs(lin, z); + scr_call(0x0900 | (ch&255), ch>>8, 1, 0); /* and move it right */ + } + scr_curs(lin, col); + scr_call(0x920,_attrib,1,0); + return(0); +} + scr_clea.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Clears the screen and homes the cursor + */ + +#define max_width 80 +#define max_y 25 + +extern int _attrib; + +scr_clear() +{ + scr_home(); + scr_call(0x920,_attrib,(max_width * max_y),0); + return(0); +} + scr_curs.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Moves cursor to line lin, position pos + */ + +#define max_width 80 + +scr_curs(lin, col) +register int lin, col; +{ + if (col >= max_width) + col = max_width - 1; + if (lin >= 25) + lin = 24; + scr_call(0x200, 0, 0, (lin << 8) | col); + return(0); +} + scr_echo.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * if flg is zero disable echoing of characters + */ + +extern int _echo; + +scr_echo(flg) +int flg; +{ + _echo = flg; + return(0); +} + scr_eol.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Clear to the end of line + */ + +extern int _attrib; + +scr_eol() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x920, _attrib, 80-col, 0); + return(0); +} + scr_eos.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * clear to end of screen + */ + +extern int _attrib; + +scr_eos() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x920, _attrib, (80-col)+((24-lin)*80), 0); + return(0); +} + scr_getc.asm +; Copyright (C) 1985 by Manx Software Systems +; :ts=8 + include lmacros.h +dataseg segment word public 'data' + public _echo_ +_echo_ db 0,0 +dataseg ends + assume ds:dataseg +ifdef FARPROC + extrn scr_putc_:far +else + extrn scr_putc_:near +endif +; +; scr_getc() - issue int 16 to get keyboard value +; returns normal ASCII chars as their value (0-127) +; special chars are in the range 128 - 255 +; cntl-break is returned as -2 +; + procdef scr_getc + mov ah,0 + int 16h + call mapchar + cmp _echo_,0 + jz no_echo + cmp ax,128 + jae no_echo + push ax + call scr_putc_ + pop ax +no_echo: + pret + pend scr_getc +; +; scr_poll() - polls keyboard for a character +; returns -1 for no character +; otherwise returns the character as above +; Note: this doesn't remove the char from the buffer +; + procdef scr_poll + mov ah,1 + int 16h + jnz mapit + mov ax,-1 + pret +mapit: + call mapchar + pret + pend scr_poll +; +mapchar proc near + test al,al + jz special + sub ah,ah + ret +special: + xchg al,ah + test al,al + jz ctl_brk + cmp al,3 + jne not_nul + sub ax,ax + ret +not_nul: + or al,80H + ret +ctl_brk: + mov ax,-2 + ret +mapchar endp +; + finish + end + scr_home.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Homes the cursor (0, 0) + */ + +scr_home() +{ + scr_curs(0, 0); + return(0); +} + scr_inve.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * if flg is zero turn on inverse + */ + +extern int _attrib; + +scr_invers(flg) +int flg; +{ + _attrib = flg ? 0x70 : 0x07; + return(0); +} + scr_ldel.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Deletes line at lin, blank lines at bottom + */ + +extern int _attrib; + +scr_ldelete() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x600 | 1, _attrib<<8, lin<<8, (24<<8) | 79); + scr_curs(lin, 0); + return(0); +} + scr_lins.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * Inserts blank lines at lin, pushing rest down + */ + +extern int _attrib; + +scr_linsert() +{ + int lin, col; + + scr_loc(&lin, &col); + scr_call(0x700 | 1, _attrib<<8, lin<<8, (24<<8) | 79); + scr_curs(lin, 0); + return(0); +} + scr_loc.asm +; Copyright (C) 1984 by Manx Software Systems +; :ts=8 +; +; scr_loc(lin, col) - place the location of the cursor in line and column +; + include lmacros.h +; + procdef scr_loc,<,> +; + pushds + mov ah,3 + mov bh,0 + int 10h ; find the location of cursor + ldptr bx,lin,ds ; move address of line into bx + mov 0[bx],dh ; move cursor location into memory + mov byte ptr 1[bx],0 + ldptr bx,col,ds ; move addres of col. into bx + mov 0[bx],dl ; move cursor location into memory + mov byte ptr 1[bx],0 + popds + pret + pend scr_loc + finish + end + scr_putc.c +/* Copyright (C) 1984 by Manx Software Systems, Inc. */ +/* + * display the character at the cursor + */ + +int _attrib = 0x07; + +scr_putc(c) +register int c; +{ + c &= 255; + if (c >= 0x20) + scr_call(0x0900 | c, _attrib,1,0); + scr_call(0x0e00 | c, _attrib); + return c; +} + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/STDIO.ARC b/Manx Aztec C86 v42b/ARC/STDIO.ARC new file mode 100644 index 0000000..52a71c7 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/STDIO.ARC @@ -0,0 +1,743 @@ + makefile +OBJ=agetc.o aputc.o fdopen.o fgets.o fopen.o fprintf.o fputs.o fread.o\ + fscanf.o fseek.o fwrite.o getbuff.o getc.o getchar.o gets.o getw.o\ + mktemp.o perror.o printf.o putc.o putchar.o puterr.o puts.o putw.o\ + scanf.o setbuf.o tmpfile.o tmpnam.o ungetc.o assert.o + +MOBJ=fprintf.o fscanf.o printf.o scanf.o + +CC=cc +AS=as +MODEL= +AMODEL=0 + +.c.o: + $(CC) +$(MODEL) -n $*.c -o $@ + sqz $@ + +.asm.o: + $(AS) -dMODEL=$(AMODEL) $*.asm -o $@ + sqz $@ + +bld bldl bldld bldlc: $(OBJ) + @echo stdio done + +math: $(MOBJ) + @echo math stdio done + agetc.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +int _agetc_mask = 0xff; + +agetc(ptr) +register FILE *ptr; +{ + register int c; + +top: + if ((c = getc(ptr)) != EOF) { + switch (c &= _agetc_mask) { + case 0x1a: + ptr->_flags |= _EOF; + return EOF; + case '\r': + case 0: + goto top; + } + } + return c; +} + aputc.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +aputc(c,ptr) +register int c; register FILE *ptr; +{ + if (c == '\n') + if (putc('\r',ptr) == EOF) + return EOF; + return putc(c,ptr); +} + + assert.c +#include + +void _assert(char *expr, char *filename, unsigned int linenumber) +{ + fprintf(stderr, "Assert(%s) failed at line %u in file %s.\n", + expr, linenumber, filename); + abort(); +} + fdopen.c +/* Copyright (C) 1984 by Manx Software Systems */ +#include "stdio.h" + +FILE * +fdopen(fd,mode) +char *mode; +{ + register FILE *fp; + FILE *newstream(); + + if ((fp = newstream()) == NULL) + return NULL; + fp->_unit = fd; + fp->_flags = _BUSY; + return fp; +} + + fgets.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +char *fgets(s, n, fp) +char *s; FILE *fp; +{ + register c; + register char *cp; + + cp = s; + while (--n > 0 && (c = agetc(fp)) != EOF) { + *cp++ = c; + if (c == '\n') + break; + } + *cp = 0; + if (c == EOF && cp == s) + return NULL; + return(s); +} + fopen.c +/* Copyright (C) 1981,1982,1983,1984 by Manx Software Systems */ +#include "stdio.h" +#include "fcntl.h" +#include "errno.h" + +extern int errno; + +static struct modes { + char fmode[3]; + int omode; +} modes[] = { + "r", O_RDONLY, + "r+", O_RDWR, + "w", (O_WRONLY|O_CREAT|O_TRUNC), + "w+", (O_RDWR|O_CREAT|O_TRUNC), + "a", (O_WRONLY|O_CREAT|O_APPEND), + "a+", (O_RDWR|O_CREAT|O_APPEND), + "x", (O_WRONLY|O_CREAT|O_EXCL), + "x+", (O_RDWR|O_CREAT|O_EXCL), + "", 0, +}; + +FILE * +fopen(name,mode) +char *name,*mode; +{ + register FILE *fp; + FILE *newstream(), *freopen(); + + if ((fp = newstream()) == NULL) + return NULL; + return freopen(name, mode, fp); +} + +FILE * +freopen(name, mode, fp) +char *name,*mode; FILE *fp; +{ + register struct modes *mp; + register int fd; + + fclose(fp); + + for (mp = modes ; ; ++mp) { + if (*mp->fmode == 0) { + errno = EINVAL; + return NULL; + } + if (strcmp(mp->fmode, mode) == 0) + break; + } + +/* + Don't try to optimize the next 3 lines. Since _unit is a char, + assigning to it in the if statement will cause the -1 test to fail + on unsigned char machines. +*/ + if ((fd = open(name, mp->omode)) == -1) + return (NULL); + fp->_unit = fd; + fp->_flags = _BUSY; + return fp; +} + + fprintf.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +static FILE *Stream; + +fprintf(stream,fmt,args) +FILE *stream; char *fmt; unsigned args; +{ + int fpsub(); + + Stream = stream; + return format(fpsub,fmt,&args); +} + +static +fpsub(c) +{ + return aputc(c,Stream); +} + fputs.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +fputs(s,fp) +register char *s; +FILE *fp; +{ + while ( *s ) + if (aputc(*s++,fp) == EOF) + return(EOF); + return 0; +} + fread.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +fread(buffer,size,number,stream) +register char *buffer; unsigned size; int number; +FILE *stream; +{ + int total; + register int c,i; + + for ( total = 0 ; total < number ; ++total ) { + for ( i = size ; i ; --i ) { + if ( (c = getc(stream)) == EOF ) + return total; + *buffer++ = c; + } + } + return total; +} + fscanf.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +static gchar(); +static int scnlast; +static FILE *scnfp; + +fscanf(fp, fmt, args) +FILE *fp; char *fmt; int *args; +{ + int gchar(); + + scnfp = fp; + scnlast = 0; + return scanfmt(gchar, fmt, &args); +} + +static gchar(what) +{ + if (what == 0) { + if (feof(scnfp)) + scnlast = EOF; + else + scnlast = agetc(scnfp); + } else + scnlast = ungetc(scnlast, scnfp); + return scnlast; +} + + fseek.c +/* Copyright (c) 1981, 1982 by Manx Software Systems */ +#include "stdio.h" + +fseek(fp,pos,mode) +register FILE *fp; +long pos; +{ + register int i; + long curpos, lseek(); + + fp->_flags &= ~_EOF; + if (fp->_flags & _DIRTY) { + if (flsh_(fp,-1)) + return EOF; + } else if (mode == 1 && fp->_bp) + pos -= fp->_bend - fp->_bp; + fp->_bp = fp->_bend = NULL; + if (lseek(fp->_unit, pos, mode) < 0) + return EOF; + return 0; +} + +long ftell(fp) +register FILE *fp; +{ + long pos, lseek(); + + pos = lseek(fp->_unit, 0L, 1); /* find out where we are */ + if (fp->_flags & _DIRTY) + pos += fp->_bp - fp->_buff; + else if (fp->_bp) + pos -= fp->_bend - fp->_bp; + return pos; +} + fwrite.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +fwrite(buffer,size,number,stream) +register char *buffer; unsigned size,number; +FILE *stream; +{ + register unsigned i,max; + + max = size * number; + for ( i = 0 ; i < max ; ++i ) { + if ( putc(*buffer++,stream) == EOF ) + return 0; + } + return number; +} + + getbuff.c +/* Copyright (C) 1983 by Manx Software Systems */ +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +FILE Cbuffs[MAXSTREAM] = { + { 0,0,0, _BUSY,0,0,1 }, + { 0,0,0, _BUSY,1,0,1 }, + { 0,0,0, _BUSY,2,0,1 }, + { 0,0,0, _BUSY,3,0,1 }, + { 0,0,0, _BUSY,4,0,1 }, +}; + +FILE * +newstream() +{ + register FILE *fp; + + fp = Cbuffs; + while (fp->_flags) + if (++fp >= &Cbuffs[MAXSTREAM]) + return NULL; + return fp; +} + +getbuff(ptr) +register FILE *ptr; +{ + char *buffer, *malloc(); + + if (isatty(ptr->_unit)) { +smlbuff: + ptr->_buflen = 1; + ptr->_buff = &ptr->_bytbuf; + return; + } + if ((buffer = malloc(BUFSIZ)) == NULL) + goto smlbuff; + ptr->_buflen = BUFSIZ; + ptr->_flags |= _ALLBUF; + ptr->_buff = buffer; + return; +} + + getc.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +getc(ptr) +register FILE *ptr; +{ + register int len; + + if (ptr->_bp >= ptr->_bend) { + if (ptr->_flags&(_EOF|_IOERR)) + return EOF; + ptr->_flags &= ~_DIRTY; + if (ptr->_buff == NULL) + getbuff(ptr); + if ((len = read(ptr->_unit,ptr->_buff,ptr->_buflen)) <= 0) { + ptr->_flags |= len==0 ? _EOF : _IOERR; + return EOF; + } + ptr->_bend = (ptr->_bp = ptr->_buff) + len; + } + return *ptr->_bp++ & 255; +} + getchar.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +#undef getchar + +getchar() +{ + return agetc(stdin); +} + gets.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +#undef getchar + +char *gets(line) +char *line; +{ + register char *cp; + register int i; + + cp = line; + while ((i = getchar()) != EOF && i != '\n') + *cp++ = i; + *cp = 0; + if (i == EOF && cp == line) + return NULL; + return line; +} + getw.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +getw(stream) +FILE *stream; +{ + register int x1,x2; + + if ((x1 = getc(stream)) == EOF || (x2 = getc(stream)) == EOF) + return EOF; + return (x2<<8) | x1; +} + mktemp.c +#ifdef DOS11 +#include +#endif + +char * +mktemp(template) +char *template; +{ + register char *cp; + register unsigned val; + extern unsigned _dsval; +#ifdef DOS11 + int file; +#endif + + cp = template; + cp += strlen(cp); + for (val = _dsval ; ; ) + if (*--cp == 'X') { + *cp = val%10 + '0'; + val /= 10; + } else if (*cp != '.') + break; + + if (*++cp == '.') /* allow for "abcd.XXX" type file names */ + ++cp; + if (*cp != 0) { + *cp = 'A'; +#ifdef DOS11 + while ((file = open(template, O_RDONLY)) >= 0) { + close(file); +#else + while (access(template, 0) == 0) { +#endif + if (*cp == 'Z') { + *template = 0; + break; + } + ++*cp; + } + } else { +#ifdef DOS11 + if ((file = open(template, O_RDONLY)) >= 0) { + close(file); +#else + if (access(template, 0) == 0) { +#endif + *template = 0; + } + } + return template; +} + perror.c +#include +#include + +perror (s) +char *s; +{ + if (errno < 0 || errno > sys_nerr) + return -1; + if (s) + fprintf (stderr, "%s: ", s); + fprintf (stderr, "%s\n", sys_errlist[errno]); + return 0; +} + printf.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ + +printf(fmt,args) +char *fmt; unsigned args; +{ + extern int putchar(); + + format(putchar,fmt,&args); +} + putc.c +/* Copyright (C) 1981,1982,1983,1984 by Manx Software Systems */ +#include "stdio.h" + +putc(c,ptr) +int c; register FILE *ptr; +{ + if (ptr->_bp >= ptr->_bend) + return flsh_(ptr,c&0xff); + return (*ptr->_bp++ = c) & 0xff; +} + +static closall() /* called by exit to close any open files */ +{ + register FILE *fp; + + for ( fp = Cbuffs ; fp < Cbuffs+MAXSTREAM ; ) + fclose(fp++); +} + +fclose(ptr) +register FILE *ptr; +{ + register int err; + + err = 0; + if (!ptr) + return -1; + if ( ptr->_flags ) { + if (ptr->_flags&_DIRTY) /* if modifed flush buffer */ + err = flsh_(ptr,-1); + err |= close(ptr->_unit); + if (ptr->_flags&_ALLBUF) + free(ptr->_buff); + if (ptr->_flags&_TEMP) { /* temp file, delete it */ + unlink(ptr->_tmpname); + free(ptr->_tmpname); + } + } + + ptr->_buff = + ptr->_bend = /* nothing in buffer */ + ptr->_bp = 0; + ptr->_flags = 0; + return err; +} + +flsh_(ptr,data) +register FILE *ptr; +{ + register int size; + extern int (*cls_)(); + + cls_ = closall; + if (ptr->_flags & _IOERR) + return EOF; + if (ptr->_flags & _DIRTY) { + size = ptr->_bp - ptr->_buff; + if (write(ptr->_unit, ptr->_buff, size) != size) { +ioerr: + ptr->_flags |= _IOERR; + ptr->_bend = ptr->_bp = NULL; + return EOF; + } + } + if (data == -1) { + ptr->_flags &= ~_DIRTY; + ptr->_bend = ptr->_bp = NULL; + return 0; + } + if (ptr->_buff == NULL) + getbuff(ptr); + if (ptr->_buflen == 1) { /* unbuffered I/O */ + if (write(ptr->_unit, &data, 1) != 1) + goto ioerr; + return data; + } + ptr->_bp = ptr->_buff; + ptr->_bend = ptr->_buff + ptr->_buflen; + ptr->_flags |= _DIRTY; + return (*ptr->_bp++ = data) & 0xff; +} + putchar.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +#undef putchar + +putchar(c) +{ + return aputc(c,stdout); +} + puterr.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +puterr(c) +{ + return aputc(c, stderr); +} + puts.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ + +puts(str) +register char *str; +{ + while (*str) + if (putchar(*str++) == -1) + return -1; + return putchar('\n'); +} + putw.c +/* Copyright (C) 1981,1982 by Manx Software Systems */ +#include "stdio.h" + +putw(w,stream) +register unsigned w; +FILE *stream; +{ + if ( putc(w,stream) < 0 ) + return EOF; + else if ( putc((w>>8),stream) < 0 ) + return EOF; + return w; +} + scanf.c +/* Copyright (C) 1982 by Manx Software Systems */ +#include "stdio.h" + +static gchar(); + +static int scnlast; + +scanf(fmt, args) +char *fmt; int *args; +{ + int gchar(); + + scnlast = 0; + return scanfmt(gchar, fmt, &args); +} + +static gchar(what) +{ + if (what == 0) { + if (feof(stdin)) + scnlast = EOF; + else + scnlast = agetc(stdin); + } else + scnlast = ungetc(scnlast, stdin); + return scnlast; +} + + setbuf.c +/* Copyright (C) 1981,1982 by Manx Software Systems and Thomas Fenwick */ +#include "stdio.h" + +setbuf(stream, buffer) +register FILE *stream; char *buffer; +{ + if (stream->_buff) + return; + if (buffer) { + stream->_buff = buffer; + stream->_buflen = BUFSIZ; + } else { + stream->_buff = &stream->_bytbuf; + stream->_buflen = 1; + } +} + + tmpfile.c +#include + +/* returns a pointer for a temp file which is automatically deleted + when the program exits; the file is opened for update */ + +FILE * +tmpfile () +{ + register char *cp; + register FILE *fp; + char *tmpnam(), *malloc(); + + cp = tmpnam (NULL); + if ( (fp = fopen (cp, "w+")) == NULL ) + perror (cp); + else { + if ((fp->_tmpname = malloc(strlen(cp)+1)) == NULL) { + fclose(fp); + unlink(cp); + return NULL; + } + strcpy(fp->_tmpname,cp); + fp->_flags |= _TEMP; + } + return fp; +} + + tmpnam.c +#include + +static char work[] = "AAAAA"; + +char * +tmpnam(s) +char *s; +{ + static char tmpbuf[L_tmpnam]; + register char *cp; + + if (s == NULL) + s = tmpbuf; + for (;;) { + strcpy(s,P_tmpdir); + strcat(s,work); + strcat(s,"XXX.XXX"); + for (cp = work ; *cp ; ++cp) + if (*cp == 'Z') + *cp = 'A'; + else { + ++*cp; + break; + } + if (mktemp(s)) + break; + } + return s; +} + ungetc.c +/* Copyright (c) 1981, 1982 by Manx Software Systems */ +#include "stdio.h" + +ungetc(c,ptr) +int c; register FILE *ptr; +{ + if (c == EOF || ptr->_bp <= ptr->_buff) + return EOF; + *--ptr->_bp = c; + return c; +} + + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/ARC/TERM.ARC b/Manx Aztec C86 v42b/ARC/TERM.ARC new file mode 100644 index 0000000..cafb230 --- /dev/null +++ b/Manx Aztec C86 v42b/ARC/TERM.ARC @@ -0,0 +1,322 @@ + term.mk +OBJ=term.o pcio.o + +term.exe: $(OBJ) + ln -o term.exe $(OBJ) -ls -lc + term.c +#define XOFF 0x13 +#define XON 0x11 + +main(argc, argv) +char **argv; +{ + register int speed, channel; + + printf("Manx term 4.10a (Use F1 to exit)\n"); + channel = 1; + if (argc > 1 && argv[1][0]=='-') { + channel = argv[1][1] - '0'; + if (channel < 1 || channel > 2) { + printf("Invalid unit #.\n"); + printf("Usage: term [-1 | -2] [speed]\n"); + exit(1); + } + --argc; + ++argv; + } + + speed = 0; + if (argc > 1) + speed = atoi(argv[1]); + term(speed, channel); + comrest(); +} + +#undef putchar + +putchar(c) +{ + scr_putc(c); + if (c == '\n') + scr_putc('\r'); + return c; +} + +#define INQSIZ 256 /* these sizes must be powers of two */ +#define OUTQSIZ 16 + +unsigned char inqh, inqt, outqh, outqt; +unsigned char inpq[INQSIZ], outq[OUTQSIZ]; +int inqcnt; +char mode, stopped, xoffsent; + +term(speed, channel) +{ + /* + * Inpq is the queue of characters from the com line, waiting to go to + * the console. Outq is from the console, waiting to go to the com line + */ + register int c, row; + + cominit(speed, channel); + for (;;) { + if (scr_poll() != -1) { + c = scr_getc(); + if (c == (59|0x80)) /* check for F1 to exit */ + return c; + if (c == (83|0x80)) + c = 0x7f; /* map DEL key to ascii DEL */ + outq[outqh] = c; + outqh = outqh+1 & OUTQSIZ-1; + } + + if (inqh != inqt) { + c = inpq[inqt] & 0x7f; /* strip parity */ + ++inqt; + --inqcnt; + switch (mode) { + case 1: + mode = 0; + switch (c) { +#ifdef DOWNLOAD + case 02: case 03: /* initiate upload/download sequence */ + download(); + continue; +#endif + case 'Q': /* insert a blank @ cursor pos */ + scr_cinsert(); + continue; + case 'W': /* delete the char @ cursor pos */ + scr_cdelete(); + continue; + case 'E': /* insert a blank line @ cursor pos */ + scr_linsert(); + continue; + case 'R': /* delete the line @ cursor pos */ + scr_ldelete(); + continue; + case 'T': /* clear to end of line */ + scr_eol(); + continue; + case '*': /* home cursor & clear screen */ + scr_clear(); + continue; + case '=': /* cursor move sequence */ + mode = 2; + continue; + } + /* fall thru into normal character processing */ + + case 0: + if (c == 0x1b) + mode = 1; + else if (c == 032) + scr_clear(); + else + scr_putc(c); + break; + + case 2: /* row character for cursor move */ + row = c - 32; + mode = 3; + continue; + + case 3: /* column character for cursor move */ + c -= 32; + scr_curs(row, c); + mode = 0; + continue; + } + } + + if (inqcnt > 200 && !stopped) { + if (comput(XOFF) == 0) + stopped = xoffsent = 1; + } else if (xoffsent && inqcnt < 30) { + if (comput(XON) == 0) + stopped = xoffsent = 0; + } else if (outqt != outqh && comput(outq[outqt]) == 0) { + stopped = 0; + outqt = outqt+1 & OUTQSIZ-1; + } + } +} + pcio.asm +;:ts=8 +; +; IBM PC Support routines +; + include lmacros.h + +dataseg segment word public 'data' +BASE equ 3f8H + +DATA dw BASE+0 ;data register +INTENAB dw BASE+1 ;interrupt enable +DIVLAT dw BASE+0 ;divisor latch (least sig. byte) +INTID dw BASE+2 ;interrupt identification +LINECTL dw BASE+3 ;line control +MODCTL dw BASE+4 ;modem control +LINSTAT dw BASE+5 ;line status +MODSTAT dw BASE+6 ;modem status + +INTNUM db 12 ;COM1 interrupt vector # +INTMASK db 10H ;bit mask for 8259. +INTCTL equ 20h ;8259 control register +INTCHIP equ 21h ;8259 mask register + +extrn inqh_:byte, inqt_:byte, inqcnt_:word +extrn inpq_:byte + +vec_save dd ? +intr_reg db ? +intr_chp db ? +dataseg ends + + + assume ds:dataseg + +data_add dw ? ;codesegment variable for location of dataseg in 'C' + + procdef comput,<> + mov dx,LINSTAT + in al,dx + and ax,20H ;is the transmitter ready? + jz notready ;not yet + mov bx,sp + mov al,byte ptr outvalue + mov dx,DATA + out dx,al ;output the data + sub ax,ax + pret +notready: + mov ax,-1 + pret + pend comput + + procdef cominit,<,> + cmp channel,1 + je skipfix +; +; we are using SERIAL2, adjust I/O ports, and Int vectors +; + mov bx,offset DATA + mov al,2 +fixloop: + mov byte ptr 1[bx],al + add bx,2 + cmp bx,offset MODSTAT + jbe fixloop + dec INTNUM ;serial2 uses IRQ3 + shr INTMASK,1 + +skipfix: + mov data_add,ds ;mov 'C' dataseg address to var. + push es + mov ah,35h ;ask DOS for current int vector + mov al,INTNUM + int 21h + mov word ptr vec_save,bx + mov word ptr vec_save+2,es + mov ah,25h ;ask DOS to set new int vector + mov al,INTNUM + push ds + mov dx,cs + mov ds,dx + mov dx,offset intsr ;addr of interupt service in DS:DX + int 21h + pop ds + pop es + + mov dx,INTENAB ;get contents of interupt enable reg. + in al,dx + mov intr_reg,al ;sav contents of interupt enable reg. + mov al,0 ;disable interupts for now + out dx,al + mov dx,INTCHIP ;get contents of interupt chip + in al,dx + mov intr_chp,al ;sav contents of interupt chip + mov cl,INTMASK + not cl + and al,cl + out dx,al ;turn on interupt chip + + cmp speed,0 + je nosetup + + mov al,80H + mov dx,LINECTL + out dx,al + mov ax,0c200H + mov dx,1 ;dividend = 0x1c200 + div speed ;compute baud rate divisor + mov dx,DIVLAT + out dx,al ;setup com port to given baud rate + mov al,ah + inc dx ;second byte of divisor latch + out dx,al +nosetup: + mov al,03H ;set 8 data, 1 stop, no parity + mov dx,LINECTL + out dx,al + inc dx + mov al,0bh ;turn on DTR, RTS and enable ints + out dx,al + mov al,020h ;send EOI to 8259 + out INTCTL,al + mov dx,DATA + in al,dx ;just in case one was waiting for us + mov dx,INTENAB ;now turn on 8250 interupts + mov al,01H ;enable data ready intr. + out dx,al + pret + pend cominit + + procdef comrest + mov al,intr_reg + mov dx,INTENAB + out dx,al + mov al,intr_chp + mov dx,INTCHIP + out dx,al +; + push ds + mov ah,25h ;ask DOS to restore old int vector + mov al,INTNUM + lds dx,vec_save + int 21H + pop ds + pret + pend comrest + + public intsr +intsr proc far + push ds + push ax + push dx + push bx + mov ds,data_add + mov dx,DATA + in al,dx ;yes, get the byte + sub bx,bx + mov bl,inqh_ + mov byte ptr inpq_[bx],al ;mov char. into cue + inc bl ;increment cue head will wrap at 255 + cmp bl,inqt_ + je no_overflow + mov inqh_,bl + inc inqcnt_ +no_overflow: +; + mov al,020h ;send EOI to 8259 + out INTCTL,al + pop bx + pop dx + pop ax + pop ds + iret +intsr endp + + finish + end + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/AZTEC.BAT b/Manx Aztec C86 v42b/AZTEC.BAT new file mode 100644 index 0000000..714129a --- /dev/null +++ b/Manx Aztec C86 v42b/AZTEC.BAT @@ -0,0 +1,12 @@ +@echo off +if "%CLIB%" == "" goto START +goto END + + This is a modified version of the AZTEC Batch which should + run on either a floppy or a hard drive... + +:START +set CLIB=\AZTECC86\LIB\; +set INCLUDE=\AZTECC86\INCLUDE\; +set PATH=\AZTECC86\BIN;%PATH%; +:END diff --git a/Manx Aztec C86 v42b/Aztec C86 Command Prompt.lnk b/Manx Aztec C86 v42b/Aztec C86 Command Prompt.lnk new file mode 100644 index 0000000..0753ca2 Binary files /dev/null and b/Manx Aztec C86 v42b/Aztec C86 Command Prompt.lnk differ diff --git a/Manx Aztec C86 v42b/BIN/ARCV.COM b/Manx Aztec C86 v42b/BIN/ARCV.COM new file mode 100644 index 0000000..080ddd8 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/ARCV.COM differ diff --git a/Manx Aztec C86 v42b/BIN/AS.EXE b/Manx Aztec C86 v42b/BIN/AS.EXE new file mode 100644 index 0000000..12af38b Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/AS.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/AZ2OMF.EXE b/Manx Aztec C86 v42b/BIN/AZ2OMF.EXE new file mode 100644 index 0000000..133dbaf Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/AZ2OMF.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/C.EXE b/Manx Aztec C86 v42b/BIN/C.EXE new file mode 100644 index 0000000..e3b1af7 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/C.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/CC.EXE b/Manx Aztec C86 v42b/BIN/CC.EXE new file mode 100644 index 0000000..19dcdc1 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CC.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/CGEN.EXE b/Manx Aztec C86 v42b/BIN/CGEN.EXE new file mode 100644 index 0000000..ea7a44b Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CGEN.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/CNM.EXE b/Manx Aztec C86 v42b/BIN/CNM.EXE new file mode 100644 index 0000000..2bfeb48 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CNM.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/CPP.EXE b/Manx Aztec C86 v42b/BIN/CPP.EXE new file mode 100644 index 0000000..bc9808b Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CPP.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/CRC.EXE b/Manx Aztec C86 v42b/BIN/CRC.EXE new file mode 100644 index 0000000..c9235d0 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CRC.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/CTAGS.COM b/Manx Aztec C86 v42b/BIN/CTAGS.COM new file mode 100644 index 0000000..c894470 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CTAGS.COM differ diff --git a/Manx Aztec C86 v42b/BIN/CTOENG.COM b/Manx Aztec C86 v42b/BIN/CTOENG.COM new file mode 100644 index 0000000..4a31e41 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/CTOENG.COM differ diff --git a/Manx Aztec C86 v42b/BIN/DB.EXE b/Manx Aztec C86 v42b/BIN/DB.EXE new file mode 100644 index 0000000..93842bf Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/DB.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/DBGMAP.EXE b/Manx Aztec C86 v42b/BIN/DBGMAP.EXE new file mode 100644 index 0000000..7f58cf6 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/DBGMAP.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/DIFF.EXE b/Manx Aztec C86 v42b/BIN/DIFF.EXE new file mode 100644 index 0000000..6844be2 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/DIFF.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/ENGTOC.COM b/Manx Aztec C86 v42b/BIN/ENGTOC.COM new file mode 100644 index 0000000..81c47b7 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/ENGTOC.COM differ diff --git a/Manx Aztec C86 v42b/BIN/GREP.EXE b/Manx Aztec C86 v42b/BIN/GREP.EXE new file mode 100644 index 0000000..8809640 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/GREP.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/HD.COM b/Manx Aztec C86 v42b/BIN/HD.COM new file mode 100644 index 0000000..00b913b Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/HD.COM differ diff --git a/Manx Aztec C86 v42b/BIN/HEX86.EXE b/Manx Aztec C86 v42b/BIN/HEX86.EXE new file mode 100644 index 0000000..0fcaefe Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/HEX86.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/INITSDB.COM b/Manx Aztec C86 v42b/BIN/INITSDB.COM new file mode 100644 index 0000000..a9ac377 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/INITSDB.COM differ diff --git a/Manx Aztec C86 v42b/BIN/INSTALL.COM b/Manx Aztec C86 v42b/BIN/INSTALL.COM new file mode 100644 index 0000000..d7b1396 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/INSTALL.COM differ diff --git a/Manx Aztec C86 v42b/BIN/LB.EXE b/Manx Aztec C86 v42b/BIN/LB.EXE new file mode 100644 index 0000000..6951443 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/LB.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/LN.EXE b/Manx Aztec C86 v42b/BIN/LN.EXE new file mode 100644 index 0000000..c8fafd6 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/LN.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/LS.COM b/Manx Aztec C86 v42b/BIN/LS.COM new file mode 100644 index 0000000..b51c4a6 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/LS.COM differ diff --git a/Manx Aztec C86 v42b/BIN/MAKE.EXE b/Manx Aztec C86 v42b/BIN/MAKE.EXE new file mode 100644 index 0000000..de7a09a Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/MAKE.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/OBD.EXE b/Manx Aztec C86 v42b/BIN/OBD.EXE new file mode 100644 index 0000000..cdc7f4d Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/OBD.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/OBJ.EXE b/Manx Aztec C86 v42b/BIN/OBJ.EXE new file mode 100644 index 0000000..0b8c4de Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/OBJ.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/OBJI.EXE b/Manx Aztec C86 v42b/BIN/OBJI.EXE new file mode 100644 index 0000000..46b84e4 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/OBJI.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/OMFDMP.EXE b/Manx Aztec C86 v42b/BIN/OMFDMP.EXE new file mode 100644 index 0000000..05d80ce Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/OMFDMP.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/ORD.EXE b/Manx Aztec C86 v42b/BIN/ORD.EXE new file mode 100644 index 0000000..a397e89 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/ORD.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/PROF.EXE b/Manx Aztec C86 v42b/BIN/PROF.EXE new file mode 100644 index 0000000..7e68ffe Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/PROF.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/PROTO.EXE b/Manx Aztec C86 v42b/BIN/PROTO.EXE new file mode 100644 index 0000000..534cd57 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/PROTO.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/RM.EXE b/Manx Aztec C86 v42b/BIN/RM.EXE new file mode 100644 index 0000000..460f31c Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/RM.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/SDB.EXE b/Manx Aztec C86 v42b/BIN/SDB.EXE new file mode 100644 index 0000000..4d03559 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/SDB.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/SQZ.EXE b/Manx Aztec C86 v42b/BIN/SQZ.EXE new file mode 100644 index 0000000..6ed9470 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/SQZ.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/TERM.EXE b/Manx Aztec C86 v42b/BIN/TERM.EXE new file mode 100644 index 0000000..acbee34 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/TERM.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/Z.EXE b/Manx Aztec C86 v42b/BIN/Z.EXE new file mode 100644 index 0000000..e307732 Binary files /dev/null and b/Manx Aztec C86 v42b/BIN/Z.EXE differ diff --git a/Manx Aztec C86 v42b/BIN/rm.c b/Manx Aztec C86 v42b/BIN/rm.c new file mode 100644 index 0000000..bb718e7 --- /dev/null +++ b/Manx Aztec C86 v42b/BIN/rm.c @@ -0,0 +1,13 @@ +#include +#include + +main(int argc, char **argv) +{ + + if (argc > 1) { + unlink(argv[1]); + } + + exit(0); + +} \ No newline at end of file diff --git a/Manx Aztec C86 v42b/CRCLIST b/Manx Aztec C86 v42b/CRCLIST new file mode 100644 index 0000000..9809e46 --- /dev/null +++ b/Manx Aztec C86 v42b/CRCLIST @@ -0,0 +1,108 @@ +arcv.com: crc=495a +as.exe: crc=a3ee +assert.h: crc=bf7e +build.arc: crc=c424 +c.exe: crc=d6c9 +c.lib: crc=265b +c86.lib: crc=7fda +cc.exe: crc=7004 +cgen.exe: crc=97ff +cl.lib: crc=f2f6 +clc.lib: crc=e39f +cld.lib: crc=c049 +cnm.exe: crc=d526 +color.h: crc=de55 +cpm86.arc: crc=5dd7 +cpp.exe: crc=0e57 +crc.exe: crc=80f8 +crt0.obj: crc=d6c2 +ctags.com: crc=79e7 +ctoeng.com: crc=9147 +ctype.h: crc=8342 +db.exe: crc=1c83 +dbg-read.me: crc=c436 +dbgmap.c: crc=5a54 +dbgmap.exe: crc=2ba7 +dbgmap.mak: crc=2cef +diff.exe: crc=d1ca +dioctl.h: crc=90b8 +dos20.arc: crc=c381 +engtoc.com: crc=0d08 +errno.h: crc=014d +exmpl.c: crc=cee0 +fcntl.h: crc=95b9 +float.h: crc=1234 +g.arc: crc=3e60 +g.lib: crc=040c +gl.lib: crc=1ebe +glc.lib: crc=1fde +gld.lib: crc=403f +grep.exe: crc=72d9 +hd.com: crc=fdf3 +hex86.exe: crc=9c02 +initsdb.com: crc=7972 +install.com: crc=2c0f +io.h: crc=3b0f +lb.exe: crc=31fc +lcrom.o: crc=fc29 +ldrom.o: crc=f2b0 +libc.h: crc=012d +limits.h: crc=1c7b +lmacros.h: crc=eb95 +ln.exe: crc=7fec +locale.h: crc=3313 +lrom.o: crc=fc29 +ls.com: crc=7593 +m.lib: crc=67ca +m87.lib: crc=12c9 +m87l.lib: crc=cb9b +m87lc.lib: crc=4eef +m87ld.lib: crc=bac7 +m87s.lib: crc=8a41 +m87sl.lib: crc=9ab3 +m87slc.lib: crc=aec9 +m87sld.lib: crc=c568 +make.exe: crc=9530 +math.arc: crc=c003 +math.h: crc=39ae +mch86.arc: crc=941d +memory.h: crc=e0dd +misc.arc: crc=c805 +ml.lib: crc=e082 +mlc.lib: crc=c28a +mld.lib: crc=f003 +model.h: crc=9339 +obd.exe: crc=6448 +obj.exe: crc=49c2 +ord.exe: crc=90b8 +ovbgn.o: crc=c959 +ovld.o: crc=bfc0 +ovldpath.o: crc=b36d +prof.exe: crc=9031 +proto.exe: crc=c4a7 +read.me: crc=1d4f +rom.asm: crc=418c +rom.o: crc=f2b0 +s.arc: crc=0b60 +s.lib: crc=9721 +sdb.exe: crc=e875 +setjmp.h: crc=cca9 +sgtty.h: crc=070f +signal.h: crc=2087 +sl.lib: crc=fd2c +slc.lib: crc=f5e0 +sld.lib: crc=1b69 +sqz.exe: crc=5071 +stat.h: crc=28b4 +stdarg.h: crc=aee1 +stddef.h: crc=73dd +stdio.arc: crc=5c57 +stdio.h: crc=f090 +stdlib.h: crc=2e8a +stksiz.c: crc=026f +string.h: crc=9d60 +term.arc: crc=66f2 +term.exe: crc=9692 +time.h: crc=1d84 +unpack.bat: crc=9388 +z.exe: crc=8863 diff --git a/Manx Aztec C86 v42b/EXMPL.C b/Manx Aztec C86 v42b/EXMPL.C new file mode 100644 index 0000000..84ac78e --- /dev/null +++ b/Manx Aztec C86 v42b/EXMPL.C @@ -0,0 +1,9 @@ +main() +{ + char buffer[100]; + + printf("Please enter your name: "); + gets(buffer); + printf("Hello %s, welcome to the growing family of AZTEC C users.\n", + buffer); +} diff --git a/Manx Aztec C86 v42b/INCLUDE/ASSERT.H b/Manx Aztec C86 v42b/INCLUDE/ASSERT.H new file mode 100644 index 0000000..ed041aa --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/ASSERT.H @@ -0,0 +1,10 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#ifndef assert +#ifndef NDEBUG +void _assert(char *expr, char *filename, unsigned int lineno); +#define assert(x) if (!(x)) _assert(#x, __FILE__, __LINE__); else; +#else +#define assert(x) +#endif +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/COLOR.H b/Manx Aztec C86 v42b/INCLUDE/COLOR.H new file mode 100644 index 0000000..d67e39a --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/COLOR.H @@ -0,0 +1,13 @@ +#define BLACK 0 +#define BLUE 1 +#define GREEN 2 +#define CYAN 3 +#define RED 4 +#define MAGENTA 5 +#define YELLOW 6 +#define WHITE 7 + +#define BLINK 1 +#define NO_BLINK 0 +#define HIGH 1 +#define LOW 0 diff --git a/Manx Aztec C86 v42b/INCLUDE/CTYPE.H b/Manx Aztec C86 v42b/INCLUDE/CTYPE.H new file mode 100644 index 0000000..b8e2f3b --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/CTYPE.H @@ -0,0 +1,23 @@ +/* Copyright Manx Software Systems, Inc. 1984. All rights reserved */ + +#ifndef __CTP +extern char ctp_[]; + +#define isalpha(x) (ctp_[(x)+1]&0x03) +#define isupper(x) (ctp_[(x)+1]&0x01) +#define islower(x) (ctp_[(x)+1]&0x02) +#define isdigit(x) (ctp_[(x)+1]&0x04) +#define isxdigit(x) (ctp_[(x)+1]&0x08) +#define isalnum(x) (ctp_[(x)+1]&0x07) +#define isspace(x) (ctp_[(x)+1]&0x10) +#define ispunct(x) (ctp_[(x)+1]&0x40) +#define iscntrl(x) (ctp_[(x)+1]&0x20) +#define isprint(x) (ctp_[(x)+1]&0xc7) +#define isgraph(x) (ctp_[(x)+1]&0x47) +#define isascii(x) (((x)&0x80)==0) + +#define toascii(x) ((x)&127) +#define _tolower(x) ((x)|0x20) +#define _toupper(x) ((x)&0x5f) +#define __CTP +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/DIOCTL.H b/Manx Aztec C86 v42b/INCLUDE/DIOCTL.H new file mode 100644 index 0000000..092740d --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/DIOCTL.H @@ -0,0 +1,26 @@ +/* Copyright (C) 1983 by Manx Software Systems */ + +#define TIOCGETP 0 /* read contents of tty control structure */ +#define TIOCSETP 1 /* set contents of tty control structure */ +#define TIOCSETN 1 /* ditto only don't wait for output to flush */ + +/* special codes for MSDOS 2.x only */ +#define TIOCREAD 2 /* read control info from device */ +#define TIOCWRITE 3 /* write control info to device */ +#define TIOCDREAD 4 /* same as 2 but for drives */ +#define TIOCDWRITE 5 /* same as 3 but for drives */ +#define GETISTATUS 6 /* get input status */ +#define GETOSTATUS 7 /* get output status */ + +struct sgttyb { + short sg_flags; /* control flags */ + char sg_erase; /* ignored */ + char sg_kill; /* ignored */ +}; + +/* settings for flags */ +#define RAW 0x20 /* no echo or mapping of input/output BDOS(6) */ + +/* Refer to the MSDOS technical reference for detailed information on + * the remaining flags. + */ diff --git a/Manx Aztec C86 v42b/INCLUDE/ERRNO.H b/Manx Aztec C86 v42b/INCLUDE/ERRNO.H new file mode 100644 index 0000000..2ab0591 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/ERRNO.H @@ -0,0 +1,29 @@ +extern int errno; +extern char *sys_errlist[]; +extern int sys_nerr; + +/* MsDos return codes */ +#define EINVAL 1 +#define ENOENT 2 +#define ENOTDIR 3 +#define EMFILE 4 +#define EACCES 5 +#define EBADF 6 +#define EARENA 7 +#define ENOMEM 8 +#define EFAULT 9 +#define EINVENV 10 +#define EBADFMT 11 +#define EINVACC 12 +#define EINVDAT 13 +#define ENODEV 15 +#define ERMCD 16 +#define EXDEV 17 +#define ENOMORE 18 + +/* additional codes used by Aztec C */ +#define EEXIST 19 +#define ENOTTY 20 +/* used by the math library */ +#define ERANGE 21 +#define EDOM 22 diff --git a/Manx Aztec C86 v42b/INCLUDE/FCNTL.H b/Manx Aztec C86 v42b/INCLUDE/FCNTL.H new file mode 100644 index 0000000..e394bf9 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/FCNTL.H @@ -0,0 +1,13 @@ +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 +#define O_DENYRW 0x10 +#define O_DENYW 0x20 +#define O_DENYR 0x30 +#define O_DENYN 0x40 +#define O_INHER 0x80 +#define O_COMP 0x00 +#define O_CREAT 0x0100 +#define O_TRUNC 0x0200 +#define O_EXCL 0x0400 +#define O_APPEND 0x0800 diff --git a/Manx Aztec C86 v42b/INCLUDE/FLOAT.H b/Manx Aztec C86 v42b/INCLUDE/FLOAT.H new file mode 100644 index 0000000..bbca7eb --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/FLOAT.H @@ -0,0 +1,32 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#define FLT_RADIX 2 +#define FLT_MANT_DIG 24 +#define FLT_EPSILON 1.19209290e-7F +#define FLT_DIG 6 +#define FLT_MIN_EXP -125 +#define FLT_MIN 1.17549435e-38F +#define FLT_MIN_10_EXP -37 +#define FLT_MAX_EXP 128 +#define FLT_MAX 3.40282347e+38F +#define FLT_MAX_10_EXP 38 + +#define DBL_MANT_DIG 53 +#define DBL_EPSILON 2.2204460492503131e-16 +#define DBL_DIG 15 +#define DBL_MIN_EXP -1021 +#define DBL_MIN 2.225073858507201e-308 +#define DBL_MIN_10_EXP -307 +#define DBL_MAX_EXP 1024 +#define DBL_MAX 1.797693134862316e+308 +#define DBL_MAX_10_EXP 308 + +#define LDBL_MANT_DIG 53 +#define LDBL_EPSILON 2.2204460492503131e-16 +#define LDBL_DIG 15 +#define LDBL_MIN_EXP -1021 +#define LDBL_MIN 2.225073858507201e-308 +#define LDBL_MIN_10_EXP -307 +#define LDBL_MAX_EXP 1024 +#define LDBL_MAX 1.797693134862316e+308 +#define LDBL_MAX_10_EXP 308 diff --git a/Manx Aztec C86 v42b/INCLUDE/IO.H b/Manx Aztec C86 v42b/INCLUDE/IO.H new file mode 100644 index 0000000..d78d6a3 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/IO.H @@ -0,0 +1,82 @@ +/* Copyright (C) 1982 by Manx Software Systems */ +/* + * if MAXCHAN is changed then the initialization of chantab in croot.c + * should be adjusted so that it initializes EXACTLY MAXCHAN elements of + * the array. If this is not done, the I/O library may exhibit + * strange behavior. + */ +#define MAXCHAN 11 /* maximum number of I/O channels */ + +/* + * argument to device routines. + * this is a typedef to allow future redeclaration to guarantee + * enough space to store either a pointer or an integer. + */ +typedef char *_arg; + +/* + * device control structure + */ +struct device { + char d_read; + char d_write; + char d_ioctl; /* used by character special devices (eg CON:) */ + char d_seek; /* used by random I/O devices (eg: a file) */ + int (*d_open)(); /* for special open handling */ +}; + +/* + * device table, contains names and pointers to device entries + */ +struct devtabl { + char *d_name; + struct device *d_dev; + _arg d_arg; +}; + +/* + * channel table: relates fd's to devices + */ +struct channel { + char c_read; + char c_write; + char c_ioctl; + char c_seek; + int (*c_close)(); + _arg c_arg; +} ; +extern struct channel chantab[MAXCHAN]; + +struct fcb { + char f_driv; + char f_name[8]; + char f_type[3]; + char f_ext; + char f_resv[2]; + char f_rc; + char f_sydx[16]; + char f_cr; + unsigned f_record; char f_overfl; +}; + +struct fcbtab { + struct fcb fcb; + char offset; + char flags; + char user; +}; + +#define OPNFIL 15 +#define CLSFIL 16 +#define DELFIL 19 +#define READSQ 20 +#define WRITSQ 21 +#define MAKFIL 22 +#define SETDMA 26 +#define GETUSR 32 +#define READRN 33 +#define WRITRN 34 +#define FILSIZ 35 +#define SETREC 36 + +#define Wrkbuf ((char *)0x80) diff --git a/Manx Aztec C86 v42b/INCLUDE/LIBC.H b/Manx Aztec C86 v42b/INCLUDE/LIBC.H new file mode 100644 index 0000000..3775f8e --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/LIBC.H @@ -0,0 +1,49 @@ +/* Copyright (C) 1981, 1982 by Manx Software Systems */ +#define fgetc getc +#define fputc putc + +extern int errno; +#define FLT_FAULT 0 /* vector for floating-point faults */ +extern int (*Sysvec[])(); + +#define NULL (void *)0 +#define EOF -1 +#define BUFSIZ 1024 +#define MAXSTREAM 20 + +#define _BUSY 0x01 +#define _ALLBUF 0x02 +#define _DIRTY 0x04 +#define _EOF 0x08 +#define _IOERR 0x10 +#define _TEMP 0x20 /* temporary file (delete on close) */ + +typedef struct { + char *_bp; /* current position in buffer */ + char *_bend; /* last character in buffer + 1 */ + char *_buff; /* address of buffer */ + char _flags; /* open mode, etc. */ + char _unit; /* token returned by open */ + char _bytbuf; /* single byte buffer for unbuffer streams */ + int _buflen; /* length of buffer */ + char *_tmpname; /* name of file for temporaries */ +} FILE; + +extern FILE Cbuffs[]; +extern char *Stdbufs; /* free list of buffers */ +FILE *fopen(); +long ftell(); + +#define stdin (&Cbuffs[0]) +#define stdout (&Cbuffs[1]) +#define stderr (&Cbuffs[2]) +#define getchar() agetc(stdin) +#define putchar(c) aputc(c, stdout) +#define feof(fp) (((fp)->_flags&_EOF)!=0) +#define ferror(fp) (((fp)->_flags&_IOERR)!=0) +#define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF)) +#define fileno(fp) ((fp)->_unit) +#define fflush(fp) flsh_(fp,-1) + +#define P_tmpdir "" +#define L_tmpnam 40 diff --git a/Manx Aztec C86 v42b/INCLUDE/LIMITS.H b/Manx Aztec C86 v42b/INCLUDE/LIMITS.H new file mode 100644 index 0000000..f92a4f5 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/LIMITS.H @@ -0,0 +1,21 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#ifndef __LIMITS +#define CHAR_BIT 8 +#define SCHAR_MIN -128 +#define SCHAR_MAX 127 +#define CHAR_MIN -128 +#define CHAR_MAX 127 +#define UCHAR_MAX 255 +#define SHRT_MIN 0x8000 +#define SHRT_MAX 0x7fff +#define USHRT_MAX 0xffffU +#define INT_MIN 0x8000 +#define INT_MAX 0x7fff +#define UINT_MAX 0xffffU +#define LONG_MIN 0x80000000L +#define LONG_MAX 0x7fffffffL +#define ULONG_MAX 0xffffffffU + +#define __LIMITS +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/LMACROS.H b/Manx Aztec C86 v42b/INCLUDE/LMACROS.H new file mode 100644 index 0000000..c3686de --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/LMACROS.H @@ -0,0 +1,210 @@ + nlist +; Copyright (C) 1985 by Manx Software Systems, Inc. +; :ts=8 + ifndef MODEL +MODEL equ 0 + endif + if MODEL and 1 + largecode +FARPROC equ 1 +FPTRSIZE equ 4 + else +FPTRSIZE equ 2 + endif + if MODEL and 2 +LONGPTR equ 1 + endif + +;this macro to be used on returning +;restores bp and registers +pret macro +if havbp + pop bp +endif + ret + endm + +internal macro pname + public pname +pname proc + endm + +intrdef macro pname + public pname +ifdef FARPROC + pname label far +else + pname label near +endif + endm + +procdef macro pname, args + public pname&_ +ifdef FARPROC + _arg = 6 + pname&_ proc far +else + _arg = 4 + pname&_ proc near +endif +ifnb + push bp + mov bp,sp + havbp = 1 + decll +else + havbp = 0 +endif + endm + +entrdef macro pname, args + public pname&_ +ifdef FARPROC + _arg = 6 + pname&_: +else + _arg = 4 + pname&_: +endif +ifnb +if havbp + push bp + mov bp,sp +else + error must declare main proc with args, if entry has args +endif + decll +endif + endm + +;this macro equates 'aname' to arg on stack +decl macro aname, type +;;'byte' or anything else +havtyp = 0 +ifidn , + aname equ byte ptr _arg[bp] + _arg = _arg + 2 + havtyp = 1 +endif +ifidn , + aname equ dword ptr _arg[bp] + _arg = _arg + 4 + havtyp = 1 +endif +ifidn , + aname equ qword ptr _arg[bp] + _arg = _arg + 8 + havtyp = 1 +endif +ifidn , + ifdef LONGPTR + aname equ dword ptr _arg[bp] + _arg = _arg + 4 + else + aname equ word ptr _arg[bp] + _arg = _arg + 2 + endif + havtyp = 1 +endif +ifidn , + ifdef FARPROC + aname equ dword ptr _arg[bp] + _arg = _arg + 4 + else + aname equ word ptr _arg[bp] + _arg = _arg + 2 + endif + havtyp = 1 +endif +ifidn , + aname equ word ptr _arg[bp] + _arg = _arg + 2 + havtyp = 1 +endif +ife havtyp + error -- type is unknown. +endif + endm + +;this macro loads an arg pointer into DEST, with optional SEGment +ldptr macro dest, argname, seg +ifdef LONGPTR + ifnb ;;get segment if specified + ifidn , + les dest,argname + else + ifidn , + lds dest,argname + else + mov dest, word ptr argname + mov seg, word ptr argname[2] + endif + endif + else + ifidn , ;;si gets seg in ds + lds si, argname + else + ifidn , ;;or, es:di + les di, argname + else + garbage error: no seg for long pointer + endif + endif + endif +else + mov dest, word ptr argname ;;get the pointer +ENDIF + ENDM + +decll macro list + IRP i, + decl i + ENDM + ENDM + +pend macro pname +pname&_ endp + endm + +retptrm macro src,seg +mov ax, word ptr src +ifdef LONGPTR + mov dx, word ptr src+2 +endif + endm + +retptrr macro src,seg +mov ax,src +ifdef LONGPTR + ifnb + mov dx, seg + endif +endif + endm + +retnull macro +ifdef LONGPTR + sub dx,dx +endif + sub ax,ax + endm + +pushds macro + ifdef LONGPTR + push ds + endif + endm + +popds macro + ifdef LONGPTR + pop ds + endif + endm + +finish macro +codeseg ends + endm + + list +codeseg segment byte public 'code' + assume cs:codeseg diff --git a/Manx Aztec C86 v42b/INCLUDE/LOCALE.H b/Manx Aztec C86 v42b/INCLUDE/LOCALE.H new file mode 100644 index 0000000..2c2fd7d --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/LOCALE.H @@ -0,0 +1,11 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#ifndef LC_ALL +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_NUMERIC 3 +#define LC_TIME 4 + +char *setlocale(int category, const char *locale); +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/MATH.H b/Manx Aztec C86 v42b/INCLUDE/MATH.H new file mode 100644 index 0000000..3bebc80 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/MATH.H @@ -0,0 +1,24 @@ +/* Copyright Manx Software Systems, Inc. 1984. All rights reserved */ + +#ifndef __NOPROTO__ +double sin(double), cos(double), tan(double), cotan(double); +double asin(double), acos(double), atan(double), atan2(double,double); +double ldexp(double,int), frexp(double, int *), modf(double, double *); +double floor(double), ceil(double), fabs(double), fmod(double,double); +double log(double), log10(double), exp(double), sqrt(double); +double pow(double,double), sinh(double), cosh(double), tanh(double); +#else +double sin(), cos(), tan(), cotan(); +double asin(), acos(), atan(), atan2(); +double ldexp(), frexp(), modf(); +double floor(), ceil(), fabs(), fmod(); +double log(), log10(), exp(), sqrt(); +double pow(), sinh(), cosh(), tanh(); +#endif + +#ifndef HUGE_VAL +#define HUGE_VAL 1.79e+308 +#define LOGHUGE 709.778 +#define TINY_VAL 2.2e-308 +#define LOGTINY -708.396 +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/MEMORY.H b/Manx Aztec C86 v42b/INCLUDE/MEMORY.H new file mode 100644 index 0000000..3d8d0c1 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/MEMORY.H @@ -0,0 +1,2 @@ +extern char *memcpy(), *memchr(), *memccpy(), memset(); +extern int memcmp(); diff --git a/Manx Aztec C86 v42b/INCLUDE/MODEL.H b/Manx Aztec C86 v42b/INCLUDE/MODEL.H new file mode 100644 index 0000000..8889f3e --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/MODEL.H @@ -0,0 +1,7 @@ +#if (sizeof(int (*)()) == 4) +#define _LARGECODE +#endif + +#if (sizeof(char *) == 4) +#define _LARGEDATA +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/SETJMP.H b/Manx Aztec C86 v42b/INCLUDE/SETJMP.H new file mode 100644 index 0000000..38e2937 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/SETJMP.H @@ -0,0 +1,9 @@ +/* Copyright Manx Software Systems, Inc. 1984. All rights reserved */ +#ifndef __JBUFSIZE +#define __JBUFSIZE (6*sizeof(char *)) + +typedef char jmp_buf[__JBUFSIZE]; + +int setjmp(jmp_buf env); +void longjmp(jmp_buf env, int val); +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/SGTTY.H b/Manx Aztec C86 v42b/INCLUDE/SGTTY.H new file mode 100644 index 0000000..a2a5cad --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/SGTTY.H @@ -0,0 +1,19 @@ +/* Copyright (C) 1983 by Manx Software Systems */ + +#define TIOCGETP 0 /* read contents of tty control structure */ +#define TIOCSETP 1 /* set contents of tty control structure */ +#define TIOCSETN 1 /* ditto only don't wait for output to flush */ + +struct sgttyb { + char sg_erase; /* ignored */ + char sg_kill; /* ignored */ + short sg_flags; /* control flags */ +}; + +/* settings for flags */ +#define _VALID 0x3a +#define RAW 0x20 /* no echo or mapping of input/output BDOS(6) */ +#define CRMOD 0x10 /* map input CR to NL, output NL to CR LF */ +#define ECHO 0x08 /* ignored unless CBREAK is set */ +#define CBREAK 0x02 /* input using BDOS(1), unless echo off then */ + /* same as RAW */ diff --git a/Manx Aztec C86 v42b/INCLUDE/SIGNAL.H b/Manx Aztec C86 v42b/INCLUDE/SIGNAL.H new file mode 100644 index 0000000..05ee21c --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/SIGNAL.H @@ -0,0 +1,32 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#ifndef _NUMSIG + +#define SIGINT 1 +#define SIGTERM 2 +#define SIGABRT 3 +#define SIGFPE 4 +#define SIGILL 5 +#define SIGSEGV 6 + +#define _NUMSIG 6 +#define _FSTSIG 1 + +#ifndef __NOPROTO__ +#define SIG_DFL ((void (*)(int))0) +#define SIG_IGN ((void (*)(int))1) +#define SIG_ERR ((void (*)(int))-1) + +void (*signal(int sig, void (*func)(int)))(int); +int raise(int sig); + +#else +#define SIG_DFL ((void (*)())0) +#define SIG_IGN ((void (*)())1) +#define SIG_ERR ((void (*)())-1) + +void (*signal())(); +int raise(); +#endif + +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/STAT.H b/Manx Aztec C86 v42b/INCLUDE/STAT.H new file mode 100644 index 0000000..5e10dba --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/STAT.H @@ -0,0 +1,29 @@ +/* Copyright (C) 1984 by Manx Software Systems */ + +struct stat { + char st_attr; + long st_mtime; + long st_size; +}; + +/* settings of the st_attr field */ +#define ST_RDONLY 0x01 /* read only file */ +#define ST_HIDDEN 0x02 /* hidden file */ +#define ST_SYSTEM 0x04 /* system file */ +#define ST_VLABEL 0x08 /* volume label */ +#define ST_DIRECT 0x10 /* file is a sub-directory */ +#define ST_ARCHIV 0x20 /* set when file has been written and closed */ + +/* the format of the st_mtime field is: + < year > < month> < day > < hours > < minutes > < sec/2 > + 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 + 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 + +where: + year is from 0-119 for 1980-2099 + month is 1-12 + day is 1-31 + hours is 0-23 + minutes is 0-59 + sec/2 is 0-29 +*/ diff --git a/Manx Aztec C86 v42b/INCLUDE/STDARG.H b/Manx Aztec C86 v42b/INCLUDE/STDARG.H new file mode 100644 index 0000000..66717a9 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/STDARG.H @@ -0,0 +1,6 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +typedef char *va_list; +#define va_start(ap, parmN) ((ap) = (char *)(&parmN + 1)) +#define va_arg(ap, type) ((ap) += sizeof(type), ((type *)(ap))[-1]) +#define va_end(ap) diff --git a/Manx Aztec C86 v42b/INCLUDE/STDDEF.H b/Manx Aztec C86 v42b/INCLUDE/STDDEF.H new file mode 100644 index 0000000..6e17298 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/STDDEF.H @@ -0,0 +1,14 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#ifndef __DEFS +extern char __offtemp[]; + +typedef int ptrdiff_t; +typedef unsigned int size_t; + +#define NULL ((void *)0) +#define offsetof(type, ident) ((char *)((type *)__offtemp)->ident - __offtemp) + +extern int errno; +#define __DEFS +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/STDIO.H b/Manx Aztec C86 v42b/INCLUDE/STDIO.H new file mode 100644 index 0000000..467dac5 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/STDIO.H @@ -0,0 +1,74 @@ +/* Copyright Manx Software Systems, Inc. 1982-1987. All rights reserved */ + +#ifndef _BUSY + +#define fgetc getc +#define fputc putc +#define NULL ((void *)0) +#define EOF -1 + + +#define BUFSIZ 1024 +#define MAXSTREAM 20 + +#define _BUSY 0x01 +#define _ALLBUF 0x02 +#define _DIRTY 0x04 +#define _EOF 0x08 +#define _IOERR 0x10 +#define _TEMP 0x20 /* temporary file (delete on close) */ + +#define _IOFBF 0x00 +#define _IOLBF 0x40 +#define _IONBF 0x80 + +typedef struct { + char *_bp; /* current position in buffer */ + char *_bend; /* last character in buffer + 1 */ + char *_buff; /* address of buffer */ + char _flags; /* open mode, etc. */ + char _unit; /* token returned by open */ + char _bytbuf; /* single byte buffer for unbuffer streams */ + int _buflen; /* length of buffer */ + char *_tmpname; /* name of file for temporaries */ +} FILE; + +extern FILE Cbuffs[]; + +#ifndef __NOPROTO__ +FILE *fopen(char *name, char *mode); +FILE *freopen(char *name, char *mode, FILE *stream); +FILE *fdopen(int fd, char *mode); +int fseek(FILE *stream, long pos, int whence); +long ftell(FILE *stream); +int remove(const char *filename); +#else +FILE *fopen(), *freopen(), *fdopen(); +long ftell(); +#endif + + +#define stdin (&Cbuffs[0]) +#define stdout (&Cbuffs[1]) +#define stderr (&Cbuffs[2]) +#ifdef MSDOS +#define stdaux (&Cbuffs[3]) +#define stdprt (&Cbuffs[4]) +#endif +#define getchar() agetc(stdin) +#define putchar(c) aputc(c, stdout) +#define feof(fp) (((fp)->_flags&_EOF)!=0) +#define ferror(fp) (((fp)->_flags&_IOERR)!=0) +#define clearerr(fp) ((fp)->_flags &= ~(_IOERR|_EOF)) +#define fileno(fp) ((fp)->_unit) +#define fflush(fp) flsh_(fp,-1) + +#define P_tmpdir "" +#define L_tmpnam 40 + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#define TMP_MAX 26 + +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/STDLIB.H b/Manx Aztec C86 v42b/INCLUDE/STDLIB.H new file mode 100644 index 0000000..bf9394c --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/STDLIB.H @@ -0,0 +1,57 @@ +/* Copyright Manx Software Systems, Inc. 1988. All rights reserved */ + +typedef unsigned int size_t; + +#ifndef __NOPROTO__ +double atof(const char *nptr); +int atoi(const char *nptr); +long int atol(const char *nptr); +double strtod(const char *nptr, char *endptr); +long int strtol(char *nptr, char *endptr, int base); +unsigned long int stroul(char *nptr, char *endptr, int base); +int rand(void); +void srand(unsigned int seed); +void *calloc(size_t nmemb, size_t size); +void *malloc(size_t size); +void *realloc(void *ptr, size_t); +void abort(void); +int atexit(void (*func)(void)); +int exit(int status); +char *getenv(const char *name); +int system(const char *string); +void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); +int abs(int j); + +#else + +double atof(); +int atoi(); +long int atol(); +double strtod(); +long int strtol(); +unsigned long stroul(); +int rand(); +void srand(); +void *calloc(), *malloc(); +void *realloc(), abort(); +int atexit(); +int exit(); +char *getenv(); +int system(); +void *bsearch(); +int abs(); +#endif + + +#if __STDC__ != 1 +char *stricmp(const char *string1, const char *string2); +#ifdef __NOPROTO__ +char *strrev(const char *string1); +char *strlwr(const char *string1); +#else +char *strrev(); +char *strlwr(); +#endif +#endif + diff --git a/Manx Aztec C86 v42b/INCLUDE/STRING.H b/Manx Aztec C86 v42b/INCLUDE/STRING.H new file mode 100644 index 0000000..c05c087 --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/STRING.H @@ -0,0 +1,48 @@ +/* Copyright Manx Software Systems, Inc. 1987. All rights reserved */ + +#ifndef __NOPROTO__ +void *memcpy(void *s1, const void *s2, unsigned int n); +void *memmove(void *s1, const void *s2, unsigned int n); +char *strcpy(char *s1, const char *s2); +char *strncpy(char *s1, const char *s2, unsigned int n); +char *strcat(char *s1, const char *s2); +char *strncat(char *s1, const char *s2, unsigned int n); +int memcmp(const void *s1, const void *s2, unsigned int n); +int strcmp(const char *s1, const char *s2); +int strcoll(const char *s1, const char *s2); +int strncmp(const char *s1, const char *s2, unsigned int n); +unsigned int strxfrm(char *s1, const char *s2, unsigned int n); +void *memchr(const void *s, int c, unsigned int n); +char *strchr(const char *s, int c); +unsigned int strcspn(const char *s1, const char *s2); +char *strpbrk(const char *s1, const char *s2); +char *strrchr(const char *s, int c); +unsigned int strspn(const char *s1, const char *s2); +char *strstr(const char *s1, const char *s2); +char *strtok(char *s1, const char *s2); +void *memset(void *s, int c, unsigned int n); +char *strerror(int errnum); +unsigned int strlen(const char *s); + +#else +void *memcpy(); +void *memmove(); +char *strcpy(); +char *strncpy(); +char *strcat(); +char *strncat(); +int memcmp(); +int strcmp(); +int strncmp(); +void *memchr(); +char *strchr(); +unsigned int strcspn(); +char *strpbrk(); +char *strrchr(); +unsigned int strspn(); +char *strstr(); +char *strtok(); +void *memset(); +char *strerror(); +unsigned int strlen(); +#endif diff --git a/Manx Aztec C86 v42b/INCLUDE/TIME.H b/Manx Aztec C86 v42b/INCLUDE/TIME.H new file mode 100644 index 0000000..9ea9a8c --- /dev/null +++ b/Manx Aztec C86 v42b/INCLUDE/TIME.H @@ -0,0 +1,34 @@ +/* Copyright Manx Software Systems, Inc. 1984-1987. All rights reserved */ + +#ifndef CLK_TCK + +#define CLK_TCK 100 +typedef long time_t; +typedef long clock_t; + +struct tm { + short tm_sec; + short tm_min; + short tm_hour; + short tm_mday; + short tm_mon; + short tm_year; + short tm_wday; + short tm_yday; + short tm_isdst; + short tm_hsec; +}; + +#ifndef __NOPROTO__ +clock_t clock(void); +time_t time(time_t *timer); +struct tm *gmtime(time_t *timer), *localtime(time_t *timer); +char *asctime(struct tm *timeptr), *ctime(time_t *timer); +#else +clock_t clock(); +time_t time(); +struct tm *gmtime(), *localtime(); +char *asctime(), *ctime(); +#endif + +#endif diff --git a/Manx Aztec C86 v42b/LIB/C.LIB b/Manx Aztec C86 v42b/LIB/C.LIB new file mode 100644 index 0000000..0d34841 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/C.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/C86.LIB b/Manx Aztec C86 v42b/LIB/C86.LIB new file mode 100644 index 0000000..46157b2 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/C86.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/CL.LIB b/Manx Aztec C86 v42b/LIB/CL.LIB new file mode 100644 index 0000000..9e2ece9 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/CL.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/CLC.LIB b/Manx Aztec C86 v42b/LIB/CLC.LIB new file mode 100644 index 0000000..10d518b Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/CLC.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/CLD.LIB b/Manx Aztec C86 v42b/LIB/CLD.LIB new file mode 100644 index 0000000..5bf7a73 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/CLD.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/CRT0.OBJ b/Manx Aztec C86 v42b/LIB/CRT0.OBJ new file mode 100644 index 0000000..fe22521 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/CRT0.OBJ differ diff --git a/Manx Aztec C86 v42b/LIB/EXMPL.C b/Manx Aztec C86 v42b/LIB/EXMPL.C new file mode 100644 index 0000000..84ac78e --- /dev/null +++ b/Manx Aztec C86 v42b/LIB/EXMPL.C @@ -0,0 +1,9 @@ +main() +{ + char buffer[100]; + + printf("Please enter your name: "); + gets(buffer); + printf("Hello %s, welcome to the growing family of AZTEC C users.\n", + buffer); +} diff --git a/Manx Aztec C86 v42b/LIB/G.LIB b/Manx Aztec C86 v42b/LIB/G.LIB new file mode 100644 index 0000000..fb90cba Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/G.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/GL.LIB b/Manx Aztec C86 v42b/LIB/GL.LIB new file mode 100644 index 0000000..58ae2fb Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/GL.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/GLC.LIB b/Manx Aztec C86 v42b/LIB/GLC.LIB new file mode 100644 index 0000000..713ebe3 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/GLC.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/GLD.LIB b/Manx Aztec C86 v42b/LIB/GLD.LIB new file mode 100644 index 0000000..d81f2c4 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/GLD.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/LCROM.O b/Manx Aztec C86 v42b/LIB/LCROM.O new file mode 100644 index 0000000..9013a5c Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/LCROM.O differ diff --git a/Manx Aztec C86 v42b/LIB/LDROM.O b/Manx Aztec C86 v42b/LIB/LDROM.O new file mode 100644 index 0000000..16d88bb Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/LDROM.O differ diff --git a/Manx Aztec C86 v42b/LIB/LROM.O b/Manx Aztec C86 v42b/LIB/LROM.O new file mode 100644 index 0000000..9013a5c Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/LROM.O differ diff --git a/Manx Aztec C86 v42b/LIB/M.LIB b/Manx Aztec C86 v42b/LIB/M.LIB new file mode 100644 index 0000000..0bd859b Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87.LIB b/Manx Aztec C86 v42b/LIB/M87.LIB new file mode 100644 index 0000000..dd7a2c4 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87L.LIB b/Manx Aztec C86 v42b/LIB/M87L.LIB new file mode 100644 index 0000000..0b241aa Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87L.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87LC.LIB b/Manx Aztec C86 v42b/LIB/M87LC.LIB new file mode 100644 index 0000000..726144c Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87LC.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87LD.LIB b/Manx Aztec C86 v42b/LIB/M87LD.LIB new file mode 100644 index 0000000..f667920 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87LD.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87S.LIB b/Manx Aztec C86 v42b/LIB/M87S.LIB new file mode 100644 index 0000000..ddb9cc4 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87S.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87SL.LIB b/Manx Aztec C86 v42b/LIB/M87SL.LIB new file mode 100644 index 0000000..8b56938 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87SL.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87SLC.LIB b/Manx Aztec C86 v42b/LIB/M87SLC.LIB new file mode 100644 index 0000000..78bc303 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87SLC.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/M87SLD.LIB b/Manx Aztec C86 v42b/LIB/M87SLD.LIB new file mode 100644 index 0000000..776c0ce Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/M87SLD.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/ML.LIB b/Manx Aztec C86 v42b/LIB/ML.LIB new file mode 100644 index 0000000..59b4631 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/ML.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/MLC.LIB b/Manx Aztec C86 v42b/LIB/MLC.LIB new file mode 100644 index 0000000..14464d7 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/MLC.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/MLD.LIB b/Manx Aztec C86 v42b/LIB/MLD.LIB new file mode 100644 index 0000000..39f9b19 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/MLD.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/OVBGN.O b/Manx Aztec C86 v42b/LIB/OVBGN.O new file mode 100644 index 0000000..c9a4483 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/OVBGN.O differ diff --git a/Manx Aztec C86 v42b/LIB/OVLD.O b/Manx Aztec C86 v42b/LIB/OVLD.O new file mode 100644 index 0000000..7d1c83d Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/OVLD.O differ diff --git a/Manx Aztec C86 v42b/LIB/OVLDPATH.O b/Manx Aztec C86 v42b/LIB/OVLDPATH.O new file mode 100644 index 0000000..bbd2c81 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/OVLDPATH.O differ diff --git a/Manx Aztec C86 v42b/LIB/ROM.O b/Manx Aztec C86 v42b/LIB/ROM.O new file mode 100644 index 0000000..16d88bb Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/ROM.O differ diff --git a/Manx Aztec C86 v42b/LIB/S.LIB b/Manx Aztec C86 v42b/LIB/S.LIB new file mode 100644 index 0000000..440f784 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/S.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/SL.LIB b/Manx Aztec C86 v42b/LIB/SL.LIB new file mode 100644 index 0000000..4c26f3c Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/SL.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/SLC.LIB b/Manx Aztec C86 v42b/LIB/SLC.LIB new file mode 100644 index 0000000..627ecc5 Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/SLC.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/SLD.LIB b/Manx Aztec C86 v42b/LIB/SLD.LIB new file mode 100644 index 0000000..35e8e6e Binary files /dev/null and b/Manx Aztec C86 v42b/LIB/SLD.LIB differ diff --git a/Manx Aztec C86 v42b/LIB/STKSIZ.C b/Manx Aztec C86 v42b/LIB/STKSIZ.C new file mode 100644 index 0000000..e03f327 --- /dev/null +++ b/Manx Aztec C86 v42b/LIB/STKSIZ.C @@ -0,0 +1,21 @@ +#if sizeof(char *) == 4 +int _STKSIZ = 8192/16; /* (in paragraphs) (large data model) */ +int _STKRED = 1024; /* size of RED zone (in bytes) */ +#else +int _STKSIZ = 4096/16; /* (in paragraphs) */ +int _STKRED = 2048; /* size of RED zone (in bytes) */ +#endif + +int _HEAPSIZ = 4096/16; /* (in paragraphs) */ +int _STKLOW = 0; /* default is stack above heap (small only) */ + +/* +NOTE: The RED zone is used for stack saftey checking. With stack above heap, +the heap will not be allowed to get within STKRED bytes of the current value +of the SP, if limit checking is enabled (see the cc +b option), SP isn't +allowed any closer than STKRED bytes to the top of the heap. If stack below +heap and limit checking is enabled, SP isn't allowed any closer than STKRED +bytes to _Utop. Minimum stack size = 2*_STKRED. Minimum value for STKRED +should be about 256 bytes. This allows some margin to issue DOS calls and +allow interrupt handlers to execute. (Some people think that this should +be > 1k.) */ diff --git a/Manx Aztec C86 v42b/MAKEFILE b/Manx Aztec C86 v42b/MAKEFILE new file mode 100644 index 0000000..9ac1daf --- /dev/null +++ b/Manx Aztec C86 v42b/MAKEFILE @@ -0,0 +1,11 @@ +# --------------------------------------------------------------------- +# makefile by bill buckels 1997 +# --------------------------------------------------------------------- + +exmpl.exe: exmpl.o + ln exmpl.o c.lib + rm exmpl.o + @echo All Done! + +exmpl.o: exmpl.c + cc exmpl.c diff --git a/Manx Aztec C86 v42b/README.txt b/Manx Aztec C86 v42b/README.txt new file mode 100644 index 0000000..2a6f07a --- /dev/null +++ b/Manx Aztec C86 v42b/README.txt @@ -0,0 +1,104 @@ + C86 v4.2 README + 9/29/89 + +INSTALLATION: + +Version 4.2b of the Aztec C86 compiler now includes an installation utility. +To perform a full installation, follow these steps: + + - If you haven't already done so, insert disk 1 into a floppy drive. + - Type install + +From this point, follow the installation prompts to complete the installation. +Please note the following approximate hard-disk space requirements: + + Minimum Maximum + Professional Package 800K 1.3MB + Developer Package 970K 1.5MB + Commericial Package 970K 1.8MB + +The minimum configuration omits source-archive files (in the case of the +commercial version), as well as all library files except the small code/ +small data model libraries (all versions). + +The installation utility may also be invokved with the /p (for partial) option +if you wish to install only a portion of the package. For example, if your +original installation did not copy archive files, you may invoke Install with +/p to copy ONLY the archive files. The same may be done for the various +models of libraries. To perform a partial-install, follow these steps: + + - If you haven't already done so, insert disk 1 into a floppy drive. + - Type install /p + +From this point, follow the installation prompts to complete the installation. + +LATE-ADDITIONS TO V4.2B +In addition to the changes listed in the 4.2 release document, the hex86 +utility has also been changed. This version fixes two problems that existed +in the 4.1d version, as well as adding support for Intel extended address +records. One problem with the 4.1d compiler was fixed, as well as early bugs +in obji. + + HEX86 Changes + +HEX86 Bug Fixes: + +1. In previous versions, there was a bug in using the -j option (specify +up to 16 bytes of startup code) and the -e & -o options (even & odd). If +an odd number of bytes was specified with the -j option and -e and -o was +used, the last byte of reset data would be omitted. + +2. Previous versions of hex86 did not always include the last item of +initialized data in the hex file. + +3. Early versions of v4.2 hex86 did not always generate correct checksums for +extended address records. + +4. When extended address records were used, early versions of v4.2 hex86 +placed the jump to $begin at the end of the initialized data segment instead of +at absolute address ffff:0. + +EXTENDED ADDRESS RECORD SUPPORT + +This version now supports Intel extended address records within the +hex file. This allows >64K of data to occur in each file, and also allows +code & data to be placed at different locations, but still be contained within +the same physical file. If extended address records are required, then a +symbol table MUST be generated by the linker, using the -t option. The hex86 +utility needs this file in order for it to correctly locate code & data. Two +command line options enable the extended address record feature: + + -x: This option enables the use of extended address records within the Intel + Hex files generated by hex86. This option may be specified with or + without an explicit segment address. If a segment address is specified + (in hexadecimal), then that address will be the address used in the first + extended address record, and following address records will be + adjusted accordingly. If no address is specified, then the value of + _Corg_ in the program's symbol table will be used. + + Data will follow the code within the hexfile, and no special extended + address record will be emitted for it. If code or data goes past 64K, + an extended address record will be emitted to select a new segment. + + -i: This option is identical to -x, except that a seperate extended address + record will be emitted for initialzed data, with an address of _Dorg_ + (the start of initialized data). An explicit segment for code cannot be + specified with this option, as can be with -x. + + + OBJI Changes + +OBJI Bug Fixes: + +1. Early versions of obji occasionally did not generate a BLKEND record for +the last BLKDEF record within the output file. This would cause the Intel +linker to terminate with a "bad object file" error message. + + COMPILER Changes + +CGEN (Pass 2) Bug fixes: + +1. Version 4.1d of pass 2 of the C compiler did not generate correct code when +dealing with Huge pointers. Specifically, segments were bumped by 1000 decimal +instead of 1000 hex when crossing segment boundaries. + diff --git a/Manx Aztec C86 v42b/SAMPLES/BATCH/BATCH.C b/Manx Aztec C86 v42b/SAMPLES/BATCH/BATCH.C new file mode 100644 index 0000000..bee1151 --- /dev/null +++ b/Manx Aztec C86 v42b/SAMPLES/BATCH/BATCH.C @@ -0,0 +1,451 @@ +/* demo for embedded .BSV files in aztec C */ +/* BATCH.c by bill buckels 1990 */ +/* these files can be created in the THEDRAW or in GWBASIC, etc. */ +/* arrays are encoded using my utility bsaveinc */ + +#include + +unsigned char BATCH000[]={ +255, 32,255, 32,242, 32,193,218,231,196,193,194,197,196,191,225, 32, +179,198, 32,199,220,195, 32,199,220,195, 32,199,220,198, 32,179,197, 32, +179,225, 32,179,199, 32,194,220,195, 32,194,220,195, 32,194,220,195, 32, +194,220,195, 32,194,220,195, 32,194,220,197, 32,179, 32,194, 66, 80, + 32,179,225, 32,179,199, 32,198,220,196, 32,198,220,196, 32,198,220, +198, 32,179, 32,195,219, 32,179,225, 32,179,199, 32,194,220,195, 32, +194,220,195, 32,194,220,195, 32,194,220,195, 32,194,220,202, 32,179, +197, 32,179,225, 32,179,198, 32,199,220,195, 32,199,220,196, 32,194,220, +202, 32,179,197, 32,179,225, 32,179,231, 32,179,194, 32,193,249,194, 32, +179,225, 32,179,197, 32, 66,105,194,108, 32, 66,117, 99,107,101,108, +115, 32, 80,114,111,100,117, 99,116,105,111,110,115, 32, 49, 57,194, 56, +197, 32,179,194, 32,111,194, 32,179,225, 32,179,205, 32, 99,111,112, +121,114,105,116,101, 32, 49, 57, 56, 57,205, 32,179,197, 32,179,225, 32, +179,231, 32,179,194, 32,111,194, 32,179,225, 32,179,231, 32,179,197, 32, +179,225, 32,179,231, 32,179,194, 32,111,194, 32,179,225, 32,193,192, +231,196,193,193,197,196,193,217,234, 32,193,219,219, 32,193,219,231, 32, +193,218,244,196,191,218, 32,179,194, 32,193,218,195,196,191,202, 32, +193,218,207,196,191,193,218,207,196,191, 32,179,218, 32,179,194, 32, +179,194, 66, 80,179,202, 32,179,195, 32,196,196, 18,196,196, 32,193,254, + 32,194,179,207, 32,179, 32,179,218, 32,179,194, 32,193,192,195,196, +193,217,202, 32,193,195,207,196,180,179,203, 32,193,254, 32,193,254, + 32,179, 32,179,218, 32,179, 32,206,186,194, 32,179,195, 32,196,196, + 18,196,196, 32,193,254, 32,194,179,207, 32,179, 32,179,218, 32,179, + 32,206,186,194, 32,193,192,207,196,193,217,193,192,207,196,193,217, + 32,179,218, 32,193,192,244,196,193,217,255, 32,255, 32,239, 32,255, 7, +255, 7,242, 7,239, 96,225, 7, 96,198, 7,219, 3,198, 7,199, 96, +225, 7, 96,199, 7,224, 3,199, 96,225, 7, 96,199, 7,218, 3,198, 7, +199, 96,225, 7, 96,199, 7,214, 3,202, 7,199, 96,225, 7, 96,198, 7, +215, 3,202, 7,199, 96,225, 7, 96,231, 7,199, 96,225, 7, 96,197, 7, +226, 14,199, 96,225, 7, 96,205, 7,205, 14,205, 7,199, 96,225, 7, + 96,231, 7,199, 96,225, 7, 96,231, 7,199, 96,225, 7, 96,231, 7, +199, 96,225, 7,239, 96,234, 7, 4,219, 7, 4,231, 7,246, 96,218, 7, +195, 96,197, 3,202, 96,226, 4,194, 96,218, 7,195, 96,197, 3,202, 96, +210, 4,207, 7, 4,194, 96,218, 7,195, 96,197, 3,202, 96,210, 4, +203, 7,197, 4,194, 96,218, 7,194, 96,206, 3,194, 96,210, 4,207, 7, + 4,194, 96,218, 7,194, 96,206, 3,194, 96,226, 4,194, 96,218, 7, +246, 96,255, 7,255, 7,239, 7, +0}; /* terminator */ + +unsigned char BATCH001[]={ +194, 32,193,201,255,205,202,205,187,197, 32,186,203, 32,204,220,197, 32, +204,220,197, 32,204,220,208, 32,186,197, 32,186,203, 32,206,220,195, 32, +206,220,195, 32,206,220,206, 32,186,197, 32,186,205, 32,196,220,196, 32, +196,220,197, 32,196,220,196, 32,196,220,197, 32,196,220,196, 32,196,220, +206, 32,186,197, 32,186,205, 32,203,220,198, 32,203,220,198, 32,203,220, +207, 32,186,197, 32,186,205, 32,203,220,198, 32,203,220,198, 32,202,220, +208, 32,186,197, 32,186,205, 32,196,220,196, 32,196,220,197, 32,196,220, +196, 32,196,220,197, 32,196,220,214, 32,186,197, 32,186,203, 32,206,220, +195, 32,206,220,195, 32,200,220,212, 32,186,197, 32,186,203, 32,204,220, +197, 32,204,220,197, 32,200,220,212, 32,186,197, 32,193,204,255,205, +202,205,185,197, 32,186,207, 32, 66,105,194,108, 32, 66,117, 99,107, +101,108,115, 32, 80,114,111,100,117, 99,116,105,111,110,115, 32, 49, + 57,194, 56, 32,112,114,101,115,101,110,116,115,212, 32,186,197, 32, +186,207, 32, 79, 98,115,101,114,118, 97,116,105,111,110,115, 32,111, +110, 32, 80, 67, 68, 79, 83, 32, 66, 97,116, 99,104, 32, 80,114,111, + 99,101,194,115,105,110,103,212, 32,186,197, 32,186,212, 32, 79,110, + 32,116,104,101, 32, 73, 66, 77, 32, 80, 67, 32, 97,110,100, 32, 67, +111,109,112, 97,116, 97, 98,108,101,115,216, 32,186,197, 32,193,204, +255,205,202,205,185,197, 32,186,204, 32,200,220,194, 32,204,220,196, 32, +199,220,199, 32,199,220,206, 32,186,197, 32,186,204, 32,200,220,194, 32, +206,220,194, 32,200,220,197, 32,200,220,206, 32,186,197, 32,186,206, 32, +196,220,198, 32,196,220,196, 32,196,220,196, 32,199,220,195, 32,199,220, +208, 32,186,197, 32,186,206, 32,196,220,198, 32,203,220,197, 32,200,220, + 32,200,220,208, 32,186,197, 32,186,206, 32,196,220,198, 32,203,220, +197, 32,196,220, 32,199,220, 32,196,220,208, 32,186,197, 32,186,206, 32, +196,220,198, 32,196,220,196, 32,196,220,196, 32,196,220,194, 32,197,220, +194, 32,196,220,208, 32,186,197, 32,186,204, 32,200,220,194, 32,206,220, +194, 32,198,220,195, 32,195,220,195, 32,198,220,206, 32,186,197, 32, +186,204, 32,200,220,194, 32,204,220,196, 32,198,220,196, 32,193,220, +196, 32,198,220,206, 32,186,197, 32,193,200,255,205,202,205,188,255, 32, +255, 32,229, 32,194, 23,255, 4,204, 4,197, 23, 4,203, 7,238, 1, +208, 7, 4,197, 23, 4,203, 7,240, 1,206, 7, 4,197, 23, 4,205, 7, +238, 1,206, 7, 4,197, 23, 4,205, 7,203, 1,198, 7,203, 1,198, 7, +203, 1,207, 7, 4,197, 23, 4,205, 7,203, 1,198, 7,203, 1,198, 7, +202, 1,208, 7, 4,197, 23, 4,205, 7,230, 1,214, 7, 4,197, 23, + 4,203, 7,234, 1,212, 7, 4,197, 23, 4,203, 7,234, 1,212, 7, + 4,197, 23,255, 4,204, 4,197, 23, 4,255, 71,202, 71, 4,197, 23, + 4,255, 71,202, 71, 4,197, 23, 4,255, 71,202, 71, 4,197, 23,255, 4, +204, 4,197, 23, 4,204, 7,225, 1,199, 7,199, 1,206, 7, 4,197, 23, + 4,204, 7,239, 1,206, 7, 4,197, 23, 4,206, 7,196, 1,198, 7, +225, 1,208, 7, 4,197, 23, 4,206, 7,196, 1,198, 7,225, 1,208, 7, + 4,197, 23, 4,206, 7,196, 1,198, 7,225, 1,208, 7, 4,197, 23, + 4,206, 7,196, 1,198, 7,225, 1,208, 7, 4,197, 23, 4,204, 7, +239, 1,206, 7, 4,197, 23, 4,204, 7,239, 1,206, 7, 4,197, 23, +255, 4,204, 4,195, 23,255, 7,255, 7,226, 7, +0}; /* terminator */ + +unsigned char BATCH002[]={ +194, 32,193,201,255,205,202,205,187,197, 32,186,255, 32,202, 32,186, +197, 32,186,195, 32, 84,104,101, 32, 73, 66, 77, 32, 80, 67, 32,111, +112,101,114, 97,116,105,110,103, 32,115,121,115,116,101,109, 32, 40, + 68, 79, 83, 41, 32,105,115, 32,116,104,101, 32,109,111,115,116, 32, +101,194,102,105, 99,105,101,110,116, 32,119, 97,121, 32,102,111,114, +199, 32,186,197, 32,186,195, 32,116,104,101, 32, 97,118,101,114, 97, +103,101, 32,117,115,101,114, 32,116,111, 32,105,194,115,117,101, 32, +105,110,115,116,114,117, 99,116,105,111,110,115, 32,116,111, 32,116, +104,101, 32,112,114,111, 99,101,194,115,111,114, 44, 32, 98,117,116, + 32,105,116, 32,105,115,196, 32,186,197, 32,186,195, 32, 97,108,115, +111, 32,116,104,101, 32,109,111,115,116, 32,111,118,101,114,108,194,111, +107,101,100, 32,119,104,101,110, 32,105,116, 32, 99,111,109,101,115, + 32,116,105,109,101, 32,102,111,114, 32,109,111,115,116, 32,111,102, + 32,117,115, 32,116,111,201, 32,186,197, 32,186,195, 32, 99,111,110, +115,105,100,101,114, 32,119, 97,121,115, 32, 97,110,100, 32,109,101, + 97,110,115, 32,116,111, 32,112,114,111, 99,101,194,115, 32,111,117, +114, 32,118, 97,114,105,111,117,115, 32, 99,111,109,112,117,116,105, +110,103, 32,116, 97,115,107,115, 46,199, 32,186,197, 32,186,255, 32, +202, 32,186,197, 32,186,195, 32, 65,194,108, 32,116,194,111, 32,111, +102,116,101,110, 32,119,101, 32,111,112,116, 32,102,111,114, 32, 97, + 32,109,101,109,111,114,121, 32,104,111,103, 32,111,102, 32, 97, 32, +102, 97,109,105,108,105, 97,114, 32, 97,194,112,108,105, 99, 97,116, +105,111,110,115,198, 32,186,197, 32,186,195, 32,112,114,111,103,114, + 97,109, 32,111,114, 32, 97, 32,114,111,117,116,105,110,101, 32,115, +101,118,101,114, 97,108, 32,108, 97,121,101,114,115, 32,116,104,105, + 99,107, 32,105,110, 32, 66, 65, 83, 73, 67, 39,115, 32, 34, 98,111, +103, 32, 97,110,100, 32,109,105,114,101, 34,195, 32,186,197, 32,186, +195, 32,116,111, 32,105,194,115,117,101, 32,111,110,101, 32,111,114, + 32,116,119,111, 32,108,105,194,116,108,101, 32,105,110,115,116,114, +117, 99,116,105,111,110,115, 32,116,104, 97,116, 32, 97,114,101, 32, +112,114,111, 98, 97, 98,108,121, 32, 97,118, 97,105,108, 97, 98,108, +101,195, 32,186,197, 32,186,195, 32,105,110, 32, 97, 32,116,105,110, +121, 32, 46, 67,111,109, 32,112,114,111,103,114, 97,109, 32,116,104, + 97,116, 32, 99, 97,109,101, 32,119,105,116,104, 32,116,104, 97,116, + 32, 99,111,110,102,117,115,105,110,103, 32,112,105,108,101, 32,111, +102, 32,115,116,117,194,102,196, 32,186,197, 32,186,195, 32,111,110, + 32,111,117,114, 32, 68,111,115, 32, 68,105,115,107, 46, 32, 40, 73, +102, 32,119,101, 32,104, 97,100, 32,116, 97,107,101,110, 32,116,104, +101, 32,116,105,109,101, 32,116,111, 32,119, 97,100,101, 32,116,104, +114,111,117,103,104, 32,116,104,101,200, 32,186,197, 32,186,195, 32, +109,111,117,110,100,115, 32,111,102, 32,100,111, 99,117,109,101,110, +116, 97,116,105,111,110, 32,119,101, 32,119,111,117,108,100, 32,117, +110,100,101,114,115,116, 97,110,100, 32,116,104, 97,116, 32,116,104, +101, 32, 77, 97,110,121, 32, 70,101, 97,116,117,114,101,115,196, 32, +186,197, 32,186,195, 32,111,110, 32,116,104,101, 32, 70, 97, 99,101, + 32,111,102, 32, 68,111,115, 32, 97,114,101, 32, 97, 32,100,101,108, +105, 98,101,114, 97,116,101, 32,101,194,102,111,114,116, 32,116,111, + 32,109, 97,107,101, 32,116,104,101, 32,115,121,115,116,101,109, 32, +109,111,114,101,196, 32,186,197, 32,186,195, 32,102,114,105,101,110, +100,108,121, 32, 97,110,100, 32,101,194,102,105, 99,105,101,110,116, + 32,116,104, 97,110, 32, 99,111,110,102,117,115,105,110,103, 32, 97, +110,100, 32,116,105,109,101, 45, 99,111,110,115,117,109,105,110,103, + 46, 41,204, 32,186,197, 32,186,255, 32,202, 32,186,197, 32,186,195, 32, + 84,104,105,115, 32,105,115, 32,119,104,101,114,101, 32,109,111,115, +116, 32,111,102, 32,117,115, 32, 97,115, 32,117,115,101,114,115, 32, +102, 97,105,108, 44, 32, 97,110,100, 32, 97,102,116,101,114, 32, 34, +119,101, 97,114,105,110,103, 32,111,117,114,200, 32,186,197, 32,186, +195, 32,102,105,110,103,101,114,115, 32,116,111, 32,116,104,101, 32, + 98,111,110,101, 34, 32,116,121,112,105,110,103, 32,101, 97, 99,104, + 32, 97,110,100, 32,101,118,101,114,121, 32, 99,111,194,109, 97,110, +100, 32,105,110, 32,115,111,114,116, 32,111,102, 32, 97,110,198, 32, +186,197, 32,186,195, 32,101,109,117,108, 97,116,105,111,110, 32,111, +102, 32, 34,104,117,110,116, 32, 97,110,100, 32,112,101, 99,107, 34, + 32,111,110, 32,116,104,101, 32,109, 97,110,117, 97,108, 32,116,121, +112,101,119,114,105,116,101,114, 44, 32,119,101, 32,115,112,114,105, +110,103, 32,102,111,114,194, 32,186,197, 32,186,195, 32,116,104,101, + 32,108, 97,116,101,115,116, 32,118,101,114,115,105,111,110, 32,111, +102, 32, 34, 84,104,101, 32, 70, 97,107,101,119, 97,114,101, 32, 87, +105,110,100,111,119, 32, 77,101,110,117, 32, 77,111,117,115,101, 32, + 67,111,194,109, 97,110,100,111, 34,199, 32,186,197, 32,186,195, 32, + 97,110,100, 32, 98,101, 99,111,109,101, 32,102,111,114,101,118,101, +114, 32,105,110,101,194,102,101, 99,116,105,118,101, 32,119,104,105, +110,105,110,103, 32, 34,109,101,109,111,114,121, 32,106,117,110,107, +105,101,115, 46, 34,206, 32,186,197, 32,186,255, 32,202, 32,186,197, 32, +193,200,255,205,202,205,188,255, 32,255, 32,229, 32,194, 23,255, 6, +204, 6,197, 23, 6,255, 7,202, 7, 6,197, 23,196, 6,255, 3,199, 7, + 6,197, 23,196, 6,255, 3,199, 3, 6,197, 23,196, 6,253, 3,201, 7, + 6,197, 23,196, 6,255, 3,199, 7, 6,197, 23, 6,255, 7,202, 7, + 6,197, 23,196, 6,255, 4, 4,198, 7, 6,197, 23,196, 6,255, 4, +199, 4, 6,197, 23,196, 6,255, 4,199, 4, 6,197, 23,196, 6,255, 4, +199, 4, 6,197, 23,196, 6,254, 4,200, 7, 6,197, 23,196, 6,255, 4, +199, 4, 6,197, 23,196, 6,255, 4,199, 4, 6,197, 23,196, 6,250, 4, +204, 7, 6,197, 23, 6,255, 7,202, 7, 6,197, 23,196, 6,254, 3, +200, 7, 6,197, 23,196, 6,255, 3, 3,198, 7, 6,197, 23,196, 6, +255, 3,199, 3, 6,197, 23,196, 6,255, 3,199, 7, 6,197, 23,196, 6, +248, 3,206, 7, 6,197, 23, 6,255, 7,202, 7, 6,197, 23,255, 6, +204, 6,195, 23,255, 7,255, 7,226, 7, +0}; /* terminator */ + +unsigned char BATCH003[]={ +194, 32,193,201,255,205,202,205,187,197, 32,186,211, 32, 67,111,194,109, + 97,110,100, 46, 67,111,109, 32, 97,110,100, 32,116,104,101, 32, 34, + 84,114, 97,105,110, 32,111,102, 32, 67,111,194,109, 97,110,100, 34, +208, 32,186,197, 32,186,199, 32,195,219,196, 32,193,219,194,223,193,219, +247, 32,186,197, 32,186,200, 32,193,219,197, 32,193,219,194, 32,193,219, + 32,198,219,200, 32,198,219,200, 32,198,219, 32,198,219,196, 32,193,219, +193,223,193,219,198, 32,186,197, 32,186,199, 32,203,219, 95,198,219, + 95,198, 32, 95,198,219, 95,198, 32, 95,198,219, 95,198,219, 95,193,223, +199,219,193,223,195, 32,186,197, 32,186,199, 32,203,219, 32,198,219, + 32,198,219, 32,198,219, 32,198,219, 32,198,219, 32,198,219, 32,193,192, +199,219,193,217,195, 32,186,197, 32,186,198, 32,193,219,194, 32, 79, +197, 32, 79,196, 32, 79,194, 32, 79,195, 32, 79,194, 32, 79,195, 32, + 79,194, 32, 79,195, 32, 79,194, 32, 79,195, 32, 79,194, 32, 79,195, 32, + 79,194, 32, 79,196, 32, 79,195, 32, 79,197, 32,186,197, 32,186,255, 32, +202, 32,186,197, 32,186,195, 32, 66,117,116, 32,105,109, 97,103,105, +110,101, 32,102,111,114, 32, 97, 32,109,111,109,101,110,116, 32,105, +102, 32,121,111,117, 32,107,110,101,119, 32,116,104,101, 32,109,111, +100,117,108,101,115, 32,111,102, 32, 68, 79, 83, 32,119,101,194,108, + 32,101,110,111,117,103,104,195, 32,186,197, 32,186,195, 32,116,104, + 97,116, 32,121,111,117, 32, 99,111,117,108,100, 32, 99,111,109, 98, +105,110,101, 32,101, 97, 99,104, 32,111,110,101, 32,116,104, 97,116, + 32,100,111,101,115, 32,111,110,101, 32,106,111, 98, 32,119,101,194,108, + 32,105,110,116,111, 32, 97, 32, 98, 97,116, 99,104,195, 32,186,197, 32, +186,195, 32,106,111, 98, 32, 40,111,114, 32, 99,104, 97,105,110, 32, +111,102, 32, 99,111,194,109, 97,110,100, 32, 97,115, 32,105,116, 32, +119,101,114,101, 41, 32, 97,110,100, 32,116,111, 32,115, 97,118,101, + 32, 97,194,108, 32,116,104, 97,116, 32,116,101,100,105,111,117,115, +197, 32,186,197, 32,186,195, 32,116,121,112,105,110,103, 44, 32,121, +111,117, 32,108,101,116, 32,116,104,101, 32,115,104,111,114,116, 32, + 34,112,114,111,103,114, 97,109, 34, 32,116,104, 97,116, 32,121,111, +117, 32,104, 97,118,101, 32, 99,114,101, 97,116,101,100, 32,105,110, + 32,121,111,117,114,197, 32,186,197, 32,186,195, 32,119,111,114,100, + 45,112,114,111, 99,101,194,115,111,114, 32,115,105,109,112,108,121, + 32, 34,100,117,109,112, 34, 32,101, 97, 99,104, 32, 99,111,194,109, + 97,110,100, 32,111,110,101, 45, 98,121, 45,111,110,101, 32,111,110, + 32,116,104,101, 32,115,121,115,116,101,109,196, 32,186,197, 32,186, +195, 32, 97,110,100, 32,119,105,116,104, 32,110,111, 32, 34, 98,101, +194,108,115, 32, 97,110,100, 32,119,104,105,115,116,108,101,115, 34, + 32,116,104,101, 32,106,111, 98, 32,105,115, 32,100,111,110,101, 46, +213, 32,186,197, 32,186,255, 32,202, 32,186,197, 32,186,195, 32, 87, +105,116,104,111,117,116, 32, 97,194,108, 32,116,104,101, 32, 34,111, +118,101,114,104,101, 97,100, 34, 32,111,102, 32,114,117,194,110,105, +110,103, 32, 97,110, 32,105,110,116,101,114, 97, 99,116,105,118,101, + 32, 99,111,194,109, 97,110,100,202, 32,186,197, 32,186,195, 32,105, +110,116,101,114,112,114,101,116,101,114, 32, 98, 97,116, 99,104, 32, +106,111, 98,115, 32,114,117,110, 32,105,110, 32, 97, 32,102,114, 97, + 99,116,105,111,110, 32,111,102, 32,116,104,101, 32,116,105,109,101, +195, 46,119,105,116,104, 32, 97, 98,105,116, 32,111,102,195, 32,186, +197, 32,186,195, 32,102,111,114,101,116,104,111,117,103,104,116, 32, + 97,110,100, 32,107,110,111,119,108,101,100,103,101, 32,111,110, 32, +116,104,101, 32,112, 97,114,116, 32,111,102, 32,116,104,101, 32,117, +115,101,114, 46,212, 32,186,197, 32,186,255, 32,202, 32,186,197, 32, +186,195, 32, 70,111,114, 32,109, 97,110,121, 32,116, 97,115,107,115, + 32,116,104,101, 32, 98, 97,116, 99,104, 32,106,111, 98, 32,105,115, + 32,116,104,101, 32,115,104,111,114,116,101,115,116, 32,100,105,115, +116, 97,110, 99,101, 32, 98,101,116,119,194,101,110, 32,112,111,105, +110,116,115,194, 32,186,197, 32,186,195, 32, 97,110,100, 32, 97,194,108, + 32,115,101,114,105,111,117,115, 32, 68, 79, 83, 32,117,115,101,114, +115, 32,115,104,111,117,108,100, 32, 98,101, 32,102,117,194,108,121, + 32,102, 97,109,105,108,105, 97,114, 32,119,105,116,104, 32,105,116, +115, 32,117,115, 97,103,101, 46,196, 32,186,197, 32,186,255, 32,202, 32, +186,197, 32,193,200,255,205,202,205,188,255, 32,255, 32,229, 32,194, 23, +255, 6,204, 6,197, 23, 6,211, 7,230, 4,208, 7, 6,197, 23, 6, +199, 7,203, 2,247, 7, 6,197, 23, 6,200, 7,209, 2,200, 7,198, 2, +200, 7,212, 2,198, 7, 6,197, 23, 6,199, 7,211, 2,198, 7,200, 2, +198, 7,219, 2, 6,197, 23, 6,199, 7,255, 2,195, 2, 6,197, 23, + 6,198, 7,255, 2,196, 2, 6,197, 23, 6,255, 7,202, 7, 6,197, 23, +196, 6,255, 4,199, 4, 6,197, 23,196, 6,255, 4,199, 4, 6,197, 23, +196, 6,255, 4,199, 4, 6,197, 23,196, 6,255, 4,199, 4, 6,197, 23, +196, 6,255, 4,199, 4, 6,197, 23,196, 6,241, 4,213, 7, 6,197, 23, + 6,255, 7,202, 7, 6,197, 23,196, 6,252, 2,202, 7, 6,197, 23, +196, 6,255, 2,199, 2, 6,197, 23,196, 6,242, 2,212, 7, 6,197, 23, + 6,255, 7,202, 7, 6,197, 23,196, 6,255, 4,199, 4, 6,197, 23, +196, 6,255, 4,199, 4, 6,197, 23, 6,255, 7,202, 7, 6,197, 23, +255, 6,204, 6,195, 23,255, 7,255, 7,226, 7, +0}; /* terminator */ + +unsigned char BATCH004[]={ +193,201,255,205,206,205,187, 32,186,210, 32,193,201,234,205,187,207, 32, +186, 32,186,210, 32,186,234, 32,186,207, 32,186, 32,186,210, 32,186, +194, 32, 66, 97,116, 99,104,101,115, 32, 97,114,101, 32,110,111,116, + 32,116,104,101, 32, 85,110,105,118,101,114,115, 97,108, 32, 80, 97, +110, 97, 99,101, 97,195, 32,186,207, 32,186, 32,186,210, 32,186,194, 32, + 98,117,116, 32, 97,114,101, 32, 97, 32,109,111,115,116, 32,101,194,102, +105, 99,105,101,110,116, 32,119, 97,121, 32,116,111, 32, 98,101,103, +105,110,195, 32,186,207, 32,186, 32,186,210, 32,186,194, 32,109, 97, +107,105,110,103, 32, 98,101,115,116, 32,117,115,101, 32,111,102, 32, +116,104,101, 32,101,110,118,105,114,111,110,109,101,110,116, 46,197, 32, +186,207, 32,186, 32,186,210, 32,186,234, 32,186,207, 32,186, 32,186, +210, 32,186,194, 32, 87,105,116,104, 32,116,104,101, 32, 80, 67, 32, + 99, 97,109,101, 32,116,104,101, 32, 97, 98,105,108,105,116,121, 32, +111,102, 32,116,104,101,197, 32,186,207, 32,186, 32,186,210, 32,186, +194, 32, 97,194,112,108,105, 99, 97,116,105,111,110,115, 32,111,112, +101,114, 97,116,111,114, 32,116,111, 32,109, 97,110, 97,103,101, 32, +116,104,101,197, 32,186,207, 32,186, 32,186,210, 32,186,194, 32,101, +110,118,105,114,111,110,109,101,110,116, 32, 97,115, 32,119,101,194,108, + 32, 97,115, 32,116,104,101, 32, 68, 97,116, 97, 46,200, 32,186,207, 32, +186, 32,186,210, 32,186,234, 32,186,207, 32,186, 32,186,210, 32,186, +194, 32, 87,105,116,104, 32,116,104, 97,116, 32, 97, 98,105,108,105, +116,121, 32, 99,111,109,101,115, 32,116,104,101, 32,111, 98,108,105, +103, 97,116,105,111,110,194, 32,186,207, 32,186, 32,186,210, 32,186, +194, 32,116,111, 32,117,115,101, 32,116,104, 97,116, 32,112,111,119, +101,114, 32,119,105,115,101,108,121, 46,207, 32,186,207, 32,186, 32, +186,210, 32,186,234, 32,186,207, 32,186, 32,186,210, 32,186,194, 32, + 77, 97,121, 32, 84,104,101, 32, 70,111,114, 99,101, 32, 66,101, 32, + 87,105,116,104, 32, 89,111,117, 46,206, 32,186,207, 32,186, 32,186, +210, 32,186,234, 32,186,207, 32,186, 32,186,210, 32,186,212, 32, 45, + 66,105,194,108, 32, 66,117, 99,107,101,108,115,194, 32, 49, 57,194, 56, +195, 32,186,207, 32,186, 32,186,210, 32,193,200,234,205,188,207, 32, +186, 32,186,209, 32,238,220,206, 32,186, 32,186,226, 32,193,218,205,196, +191,193,218,205,196,191,205, 32,186, 32,186,209, 32,198,221,203, 32, +179,196,205,193,192,195,196,193,217,196,205,194,179,196,205,193,192, +195,196,193,217,196,205,179,205, 32,186, 32,186,226, 32,193,192,205,196, +193,217,193,192,205,196,193,217,205, 32,186, 32,193,200,255,205,206,205, +188,255, 32,255, 32,227, 32,255, 6,208, 6, 7, 6,210, 7,236,113, +207, 7, 6, 7, 6,210, 7,113,234, 7,113,207, 7, 6, 7, 6,210, 7, +113,194, 7,199, 4, 7,195, 4, 7,195, 4, 7,195, 4, 7,201, 4, + 7,199, 4,195, 7,113,207, 7, 6, 7, 6,210, 7,113,194, 7,195, 4, + 7,195, 4, 7, 4, 7,196, 4, 7,201, 4, 7,195, 4, 7,194, 4, + 7,197, 4,195, 7,113,207, 7, 6, 7, 6,210, 7,113,194, 7,198, 4, + 7,196, 4, 7,195, 4, 7,194, 4, 7,195, 4, 7,204, 4,197, 7, +113,207, 7, 6, 7, 6,210, 7,113,234, 7,113,207, 7, 6, 7, 6, +210, 7,113,194, 7,196, 2, 7,195, 2, 7,194, 2, 7,196, 2, 7, +195, 2, 7,199, 2, 7,194, 2, 7,195, 2,197, 7,113,207, 7, 6, + 7, 6,210, 7,113,194, 7,204, 2, 7,200, 2, 7,194, 2, 7,198, 2, + 7,195, 2,197, 7,113,207, 7, 6, 7, 6,210, 7,113,194, 7,203, 2, + 7,194, 2, 7,196, 2, 7,194, 2, 7,195, 2, 7,197, 2,200, 7, +113,207, 7, 6, 7, 6,210, 7,113,234, 7,113,207, 7, 6, 7, 6, +210, 7,113,194, 7,196, 3, 7,196, 3, 7,199, 3, 7,197, 3, 7, +195, 3, 7,202, 3,194, 7,113,207, 7, 6, 7, 6,210, 7,113,194, 7, +194, 3, 7,195, 3, 7,196, 3, 7,197, 3, 7,199, 3,207, 7,113, +207, 7, 6, 7, 6,210, 7,113,234, 7,113,207, 7, 6, 7, 6,210, 7, +113,194, 7,195, 6, 7,195, 6, 7,197, 6, 7,194, 6, 7,196, 6, + 7,196, 6,206, 7,113,207, 7, 6, 7, 6,210, 7,113,234, 7,113, +207, 7, 6, 7, 6,210, 7,113,212, 7,197, 2, 7,199, 2,194, 7, +196, 2,195, 7,113,207, 7, 6, 7, 6,210, 7,236,113,207, 7, 6, + 7, 6,208, 7,240,112,205, 7, 6, 7, 6,208, 7,203,112,229,117, +205, 7, 6, 7, 6,208, 7,203,112,229,117,205, 7, 6, 7, 6,208, 7, +203,112,229,117,205, 7, 6, 7,255, 6,208, 6,255, 7,255, 7,227, 7, +0}; /* terminator */ + + +struct regs{ + int AX; + int BX; + int CX; + int DX; + int SI; + int DI; + int DS; + int ES; +}inregs,outregs; + +#define SCREENSIZE 4000 +unsigned int SCREENSEG= 0xb000; + +#define TERMINATOR 1 + +void showpic(int argc, unsigned char *argv) +{ + + unsigned int byteoff=0,secondoff=1,packet; + unsigned char byte,bytecount; + int wordcount,target; + unsigned char *databuf; + unsigned int segregs[4]; + + target = argc-TERMINATOR; + databuf = malloc(SCREENSIZE); + + wordcount=0; + do{ bytecount=1; /* start with a seed count */ + byte=argv[wordcount]; + wordcount++; + /* check to see if its raw */ + if(0xC0 == (0xC0 &byte)){ /* if its not, run encoded */ + bytecount= 0x3f &byte; + byte=argv[wordcount]; + wordcount++; + } + for(packet=0;packet +#include +#include +#include + +#define SCREENSIZE 4000 + +FILE *incfile; + +/* a microsoft compatible bsaved memory image format descriptor */ +unsigned char BSV_header[7]={ + + '\xfd', /* ID Flag = file descriptor identifier bsaved file */ + + /* afew words about what BASIC does with this header */ + /* and afew words about extending BASIC's ability to */ + /* read and use BINARY files created in this manner. */ + + /* BASIC will use original segment and offset information */ + /* to reload a memory image unless "DEF SEG" has been used */ + /* and then an explicit offset is used as the second arg */ + /* of the bload command. */ + + /* subsequently, once DEF SEG is invoked */ + /* If an offset is specified without then */ + /* first calling DEF SEG, The image will then be loaded to */ + /* the segment specified in the last segment pointed to */ + /* by the last call to DEF SEG. DEF SEG without args returns */ + /* to DGROUP (the default data segment) and resets the thing.*/ + + /* we can also implement and store an array in memory by use of */ + /* VARSEG and VARPTR to obtain the window for the array's */ + /* memory location, i.e. override the defaults by windowing */ + /* to the array base using DEF SEG = VARSEG(arrayname) then to */ + /* fill the array we would use BLOAD bsaved.bsv, VARPTR(arrayname) */ + /* using VARPTR to point to the offset from the memory base segment*/ + + '\x00', '\xb8', /* base address = MSB | LSB original segment */ + '\x00', '\x00', /* offset from base = MSB | LSB original offset */ + + '\xA0', '\x0F' /* file size = MSB | LSB of bytes to be loaded + */ + /* size of descriptors in bytes (8) */ + }; + +unsigned char BSAVED_tailer[1]={ /* for reference only */ + '\x1A' + }; + + +int encline(inbuff,inlen)/* encodes a raw line and writes it out */ +unsigned char *inbuff; +int inlen; +{ + unsigned char this,last; + int srcindex,i; + register int total; + register unsigned char runcount; + total=0; + last = *(inbuff); runcount=1; + +for(srcindex=1;srcindex!=inlen;srcindex++){ + this= *(++inbuff); + if(this==last){ + runcount++; + if(runcount==63){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + runcount=0; + } + } + else{ + if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + } + last=this; + runcount=1; + } + } + +if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + return(total+i); + } + return (total); + +} + + +int linelen=0; +int encput(byt,cnt) /* the writer for the encline function */ +unsigned char byt,cnt; +{ + if(linelen>16){ + fprintf(incfile,"\n"); + linelen=0; + } + + if(cnt){ + if((cnt==1)&& (0xc0 != (0xc0 &byt))){ + fprintf(incfile,"%3d,",(int)byt); + linelen++; + return(1); + } + else{ + fprintf(incfile,"%3d,",(int)(0xc0|cnt)); + fprintf(incfile,"%3d,",(int)byt); + linelen+=2; + return(2); + } + } + return(0); +} + + + + +int BSV2INC(char *name1, char *name2, char *name3) +{ + unsigned char *scratchbuffer; + unsigned char *buf; + + unsigned char header[7]; + int i,j,k; + + int fh; + + if((fh = open(name1,O_RDONLY)) == -1)return -1; + read(fh,header,7); + + /* make sure that we have a valid BSAVED file format */ + /* we can only check the first 2-bytes since it may */ + /* have been made on the HERCULES */ + + if(header[0]!=BSV_header[0] || header[1]!=BSV_header[1]) + { + close(fh); + return -2; + } + + printf("BSAVEINC(C) Copyright by Bill Buckels\n\n"); + printf("Input File: %s\n",name1); + printf("Output File: %s\n",name2); + + scratchbuffer= malloc(SCREENSIZE); + buf=malloc(SCREENSIZE/2); + + read(fh,scratchbuffer,SCREENSIZE); + close(fh); + + /* seperate the attribute bytes */ + /* use the two-tank system. */ + + incfile=fopen(name2,"w"); + fprintf(incfile,"unsigned char %s[]={\n",name3); + + for(k=0;k!=2;k++) + { + j=0; + for(i=k;i +#include +#include +#include + + +main(int argc, char **argv) +{ + FILE *fp; + int fh; + unsigned char *bigbuffer; + char buffer[128]; + char header[7]; + int limit = 24; + int ptr=0,rows,columns; + + + + switch(argc){ + case 4: limit=atoi(argv[3]); + if(limit<1||limit>25)limit==24; + case 3: + + if((fh = open(argv[1],O_RDONLY)) == -1)break; + read(fh,header,7); + bigbuffer= malloc(4000); + read(fh,bigbuffer,4000) ; + close(fh); + + if((fp=fopen(argv[2],"w"))!=NULL){ + for(rows=0;rows!=limit;rows++){ + for(columns=0;columns!=80;columns++){ + buffer[columns]=bigbuffer[ptr]; + ptr+=2; + } + columns=79; + buffer[columns]=0x00; + while(columns!=0){if(buffer[columns]==' '){ + buffer[columns]=0x00; + columns--; + } + else columns=0; + } + fprintf(fp,"%s\n",buffer); + } + fclose(fp); + } + free(bigbuffer); + break; + + default :printf( + "USAGE is \"BSV2TXT [infile] [outfile] [numberoflines-optional]\"\n"); + } + exit(0); +} + \ No newline at end of file diff --git a/Manx Aztec C86 v42b/SAMPLES/BSV2TXT/DOZY.BSV b/Manx Aztec C86 v42b/SAMPLES/BSV2TXT/DOZY.BSV new file mode 100644 index 0000000..adfd869 Binary files /dev/null and b/Manx Aztec C86 v42b/SAMPLES/BSV2TXT/DOZY.BSV differ diff --git a/Manx Aztec C86 v42b/SAMPLES/BSV2TXT/MAKEFILE b/Manx Aztec C86 v42b/SAMPLES/BSV2TXT/MAKEFILE new file mode 100644 index 0000000..47977db --- /dev/null +++ b/Manx Aztec C86 v42b/SAMPLES/BSV2TXT/MAKEFILE @@ -0,0 +1,11 @@ +# --------------------------------------------------------------------- +# makefile by bill buckels 1997 +# --------------------------------------------------------------------- + +bsv2txt.exe: bsv2txt.o + ln bsv2txt.o c.lib + rm bsv2txt.o + @echo All Done! + +bsv2txt.o: bsv2txt.c + cc bsv2txt.c diff --git a/Manx Aztec C86 v42b/SAMPLES/PTXMAKE/MAKEFILE b/Manx Aztec C86 v42b/SAMPLES/PTXMAKE/MAKEFILE new file mode 100644 index 0000000..3592cac --- /dev/null +++ b/Manx Aztec C86 v42b/SAMPLES/PTXMAKE/MAKEFILE @@ -0,0 +1,11 @@ +# --------------------------------------------------------------------- +# makefile by bill buckels 1997 +# --------------------------------------------------------------------- + +ptxmake.exe: ptxmake.o + ln ptxmake.o c.lib + rm ptxmake.o + @echo All Done! + +ptxmake.o: ptxmake.c + cc ptxmake.c diff --git a/Manx Aztec C86 v42b/SAMPLES/PTXMAKE/PTXMAKE.C b/Manx Aztec C86 v42b/SAMPLES/PTXMAKE/PTXMAKE.C new file mode 100644 index 0000000..c387bb0 --- /dev/null +++ b/Manx Aztec C86 v42b/SAMPLES/PTXMAKE/PTXMAKE.C @@ -0,0 +1,288 @@ +/* + PTXMAKE.c by Bill Buckels 1990 + written in AZTEC C small model + + Supported Screen Mode is CGA COLOR TEXT Mode 4. + + This is a companion utility to be used with BSAVED text images + and with my .PTX fileviewer PTXVU.EXE which was also written for fun. + I hope this code proves informative to those of you interested in + computer graphics. + + This is also a limited example of applied "Run Length Encoding." + + The IBM-PC 80- column text screen buffer-attribute pair arrangement + is suited to a 2-pass crunching algorithm. + + In purely poetic terms.... + + Blocks of repeats occur on increments of every second byte so + I leapfrog through the file using the .PCX encoding technique + but I skip every second byte, and encode the ascuii value of + the text character only, then when I am done I make a second + pass to encode the bytes that have been skipped on first pass, + encoding the screen attributes. + + Function: + + converts a BASIC BSAVED .BSV IMAGE FILE (full screen CGA text) + to a .PTX ( similar to the ZSOFT .PCX format image file per the + VERSION 2.8 STANDARD without Color Map.) + + +*/ + +#include +#include +#include +#include + +#define SCREENSIZE 4000 + +FILE *ptxfile; + +/* type conversion functions */ +unsigned char lsb(unsigned int word){ return word &0xff;} +unsigned char msb(unsigned int word){ return word >>8;} + +unsigned char ptxheader[128]; + +/* a microsoft compatible bsaved memory image format descriptor */ +unsigned char BSV_header[7]={ + + '\xfd', /* ID Flag = file descriptor identifier bsaved file */ + + /* afew words about what BASIC does with this header */ + /* and afew words about extending BASIC's ability to */ + /* read and use BINARY files created in this manner. */ + + /* BASIC will use original segment and offset information */ + /* to reload a memory image unless "DEF SEG" has been used */ + /* and then an explicit offset is used as the second arg */ + /* of the bload command. */ + + /* subsequently, once DEF SEG is invoked */ + /* If an offset is specified without then */ + /* first calling DEF SEG, The image will then be loaded to */ + /* the segment specified in the last segment pointed to */ + /* by the last call to DEF SEG. DEF SEG without args returns */ + /* to DGROUP (the default data segment) and resets the thing.*/ + + /* we can also implement and store an array in memory by use of */ + /* VARSEG and VARPTR to obtain the window for the array's */ + /* memory location, i.e. override the defaults by windowing */ + /* to the array base using DEF SEG = VARSEG(arrayname) then to */ + /* fill the array we would use BLOAD bsaved.bsv, VARPTR(arrayname) */ + /* using VARPTR to point to the offset from the memory base segment*/ + + '\x00', '\xb8', /* base address = MSB | LSB original segment */ + '\x00', '\x00', /* offset from base = MSB | LSB original offset */ + + '\xA0', '\x0F' /* file size = MSB | LSB of bytes to be loaded + */ + /* size of descriptors in bytes (8) */ + }; + +unsigned char BSAVED_tailer[1]={ /* for reference only */ + '\x1A' + }; + + +int encline(inbuff,inlen)/* encodes a raw line and writes it out */ +unsigned char *inbuff; +int inlen; +{ + unsigned char this,last; + int srcindex,i; + register int total; + register unsigned char runcount; + total=0; + last = *(inbuff); runcount=1; + +for(srcindex=1;srcindex!=inlen;srcindex++){ + this= *(++inbuff); + if(this==last){ + runcount++; + if(runcount==63){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + runcount=0; + } + } + else{ + if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + total+=i; + } + last=this; + runcount=1; + } + } + +if(runcount){ + if(!(i=encput(last,runcount))) + return(0); + return(total+i); + } + return (total); + +} + +int encput(byt,cnt) /* the writer for the encline function */ +unsigned char byt,cnt; +{ + if(cnt){ + if((cnt==1)&& (0xc0 != (0xc0 &byt))){ + if(EOF == fputc((int)byt,ptxfile)) + return(0); + return(1); + } + else{ + if(EOF ==fputc((int)0xc0|cnt,ptxfile)) + return(0); + if(EOF ==fputc((int)byt,ptxfile)) + return(0); + return(2); + } + } + return(0); + +} + + +/* the zsoft technical reference manual details the */ +/* structure of the following header */ +int makeheader() +{ + /* makes a standard header for a .PTX CGA FULL-SCREEN TEXT FILE */ + /* since this info is not really intended for text mode, we fudge */ + /* some portions of the info, but we try to be faithful as possible*/ + + int i; + unsigned char notzsoft=0,version=3,codetype=1,pixbits=16; + unsigned int xmin=0, ymin=0, xmax=79, ymax=24; + unsigned int hres=80, vres=25; + unsigned char no_planes=1; + unsigned int bytesperline=160; + + for(i=0;i!=128;i++)ptxheader[i]=0;/* pad the header with nulls */ + + ptxheader[0]=notzsoft; + ptxheader[1]=version; + ptxheader[2]=codetype; + ptxheader[3]=pixbits; + ptxheader[4] =lsb(xmin); + ptxheader[5] =msb(xmin); + ptxheader[6] =lsb(ymin); + ptxheader[7] =msb(ymin); + ptxheader[8] =lsb(xmax); + ptxheader[9] =msb(xmax); + ptxheader[10]=lsb(ymax); + ptxheader[11]=msb(ymax); + ptxheader[12]=lsb(hres); + ptxheader[13]=msb(hres); + ptxheader[14]=lsb(vres); + ptxheader[15]=msb(vres); + ptxheader[65]=no_planes; + ptxheader[66]=lsb(bytesperline); + ptxheader[67]=msb(bytesperline); + return 0; + +} + +int BSV2PTX(char *name1, char *name2) +{ + unsigned char *scratchbuffer; + unsigned char *buf; + + unsigned char header[7]; + int i,j,k; + + int fh; + + if((fh = open(name1,O_RDONLY)) == -1)return -1; + read(fh,header,7); + + /* make sure that we have a valid BSAVED file format */ + /* we can only check the first 2-bytes since it may */ + /* have been made on the HERCULES */ + + if(header[0]!=BSV_header[0] || header[1]!=BSV_header[1]) + { + close(fh); + return -2; + } + + printf("BSV2PTX(C) Copyright by Bill Buckels\n\n"); + printf("Input File: %s\n",name1); + printf("Output File: %s\n",name2); + + scratchbuffer= malloc(SCREENSIZE); + buf=malloc(SCREENSIZE/2); + + read(fh,scratchbuffer,SCREENSIZE); + close(fh); + + /* seperate the attribute bytes */ + /* use the two-tank system. */ + + makeheader(); + ptxfile=fopen(name2,"w"); + for(i=0;i!=128;i++)fputc(ptxheader[i],ptxfile);/* write the header */ + + for(k=0;k!=2;k++) + { + j=0; + for(i=k;i +#include +#include +#include + +#define SCREENSIZE 4000 +unsigned int SCREENSEG= 0xb000; + +/* this macro converts a base and offset to a far pointer */ +#define MK_FP(seg,off) ((char far *)(((long)(seg) << 16) | (off))) + +struct regs{ + int AX; + int BX; + int CX; + int DX; + int SI; + int DI; + int DS; + int ES; +}inregs,outregs; + +main(int argc, char **argv) +{ + int fh,i; + static char far *crt; + + unsigned int byteoff=0,secondoff=1,packet; + unsigned char byte,bytecount; + int wordcount,target; + unsigned char *databuf; + char combuffer[128]; + unsigned int status = 0; + + + sysint(0x11,&inregs,&outregs); /* get equipment list from the bios */ + /* get display type (bits 4 and 5 of ax) */ + if ((outregs.AX & 0x30) < 0x30)SCREENSEG=0xb800; + + +switch(argc) +{ + case 2: + + crt = MK_FP(SCREENSEG,0x0000); + databuf=malloc(SCREENSIZE); + + /* clearscreen and turn cursor off */ + system("cls"); + inregs.AX = 0x0100; + inregs.CX = 0x2000; + sysint(0x10,&inregs,&outregs); + + fh = open(argv[1],O_RDONLY); + read(fh,databuf,7); + + /********************* beginning of run raw ******************/ + if(databuf[0]== '\xfd' && databuf[1]== 0) + { + read(fh,databuf,SCREENSIZE); + close(fh); + i=SCREENSIZE+1; + while(i-->0)*crt++=*databuf++; + status++ ; + } + + /******************** beginning of run length encoded *************/ + + if(databuf[0]==0 && databuf[1]==3 && databuf[2]==1 && databuf[3]==16) + { + status++; + read(fh,databuf,121);/* blow the rest of the header */ + target = read(fh,databuf,SCREENSIZE); + close(fh); + + wordcount=0; + do{ bytecount=1; /* start with a seed count */ + byte=databuf[wordcount]; + wordcount++; + /* check to see if its raw */ + if(0xC0 == (0xC0 &byte)){ /* if its not, run encoded */ + bytecount= 0x3f &byte; + byte=databuf[wordcount]; + wordcount++; + } + for(packet=0;packet + +#ifndef MWC +#include +#include +#endif + +#define DIGITS_TO_FIND 200 /*9009*/ + +int main() { + + int N = DIGITS_TO_FIND; + int x = 0; + int a[ DIGITS_TO_FIND ]; + int n; + + for (n = N - 1; n > 0; --n) { + a[n] = 1; + } + + a[1] = 2, a[0] = 0; + while (N > 9) { + n = N--; + while (--n) { + a[n] = x % n; + + x = 10 * a[n-1] + x/n; + } + printf("%d", x); + } + + printf( "\ndone\n" ); + + return 0; +} diff --git a/Manx Aztec C86 v42b/code/SIEVE.C b/Manx Aztec C86 v42b/code/SIEVE.C new file mode 100644 index 0000000..236f1d4 --- /dev/null +++ b/Manx Aztec C86 v42b/code/SIEVE.C @@ -0,0 +1,35 @@ +/* sieve.c */ + +/* Eratosthenes Sieve Prime Number Program in C from Byte Jan 1983 + to compare the speed. */ + +#include + +#define TRUE 1 +#define FALSE 0 +#define SIZE 8190 +typedef int bool; + +char flags[SIZE+1]; + +int main() + { + int i,k; + int prime,count,iter; + + for (iter = 1; iter <= 10; iter++) { /* do program 10 times */ + count = 0; /* initialize prime counter */ + for (i = 0; i <= SIZE; i++) /* set all flags TRUE */ + flags[i] = TRUE; + for (i = 0; i <= SIZE; i++) { + if (flags[i]) { /* found a prime */ + prime = i + i + 3; /* twice index + 3 */ + for (k = i + prime; k <= SIZE; k += prime) + flags[k] = FALSE; /* kill all multiples */ + count++; /* primes found */ + } + } + } + printf("%d primes.\n",count); /*primes found in 10th pass */ + return 0; + } diff --git a/Manx Aztec C86 v42b/code/TM.C b/Manx Aztec C86 v42b/code/TM.C new file mode 100644 index 0000000..003a95c --- /dev/null +++ b/Manx Aztec C86 v42b/code/TM.C @@ -0,0 +1,165 @@ +#include + +#ifdef AZTEC86 +#include +#endif + +#ifdef HISOFTC +#include +#endif + +#ifdef WATCOM +#include +#include +#endif + + +#ifdef powerc +#define allocs 50 +#else +#ifdef HISOFTC +#define allocs 66 /* not enough RAM with hisoft to go higher */ +#else +/* most c runtimes work up to 69, but use 66 to have a consistent benchmark */ +#define allocs 66 +#endif +#endif + +int logging = 1; + +char * memset_x( p, v, c ) char * p; int v; int c; +{ + unsigned char * pc = (unsigned char *) p; + unsigned char val = (unsigned char) ( v & 0xff ); + int i; + + if ( 0 == p ) + { + printf( "request to memset a null pointer\n" ); + exit( 1 ); + } + + if ( logging ) +#ifdef CPMTIME + printf( " memset p %u, v %d, val %x, c %d\n", p, v, val, c ); +#else + +#ifdef HISOFTC + printf( " memset p %u, v %d, val %x, c %d\n", p, v, val, c ); +#else + printf( " memset p %p, v %d, val %x, c %d\n", p, v, val, c ); +#endif +#endif + + for ( i = 0; i < c; i++ ) + *pc++ = val; + return p; +} + +void chkmem( p, v, c ) char * p; int v; int c; +{ + unsigned char * pc = (unsigned char *) p; + unsigned char val = (unsigned char) ( v & 0xff ); + int i; + + if ( 0 == p ) + { + printf( "request to chkmem a null pointer\n" ); + exit( 1 ); + } + + for ( i = 0; i < c; i++ ) + { + if ( *pc != val ) + { +#ifdef CPMTIME + printf( "memory isn't as expected! p %u, v %d, c %d, *pc %d\n",p, v, c, *pc ); +#else + printf( "memory isn't as expected! p %p, v %d, c %d, *pc %d\n",p, v, c, *pc ); +#endif + exit( 1 ); + } + pc++; + } +} + +int main( argc, argv ) int argc; char * argv[]; +{ + int i, cb, c_cb, j; + char * pc; + char * ap[ allocs ]; + + logging = ( argc > 1 ); + pc = argv[ 0 ]; /* evade compiler warning */ + + for ( j = 0; j < 10; j++ ) + { + if ( logging ) + printf( "in alloc mode\n" ); + + for ( i = 0; i < allocs; i++ ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 5; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + ap[ i ] = (char *) malloc( cb ); + memset_x( ap[ i ], 0xaa, cb ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + + if ( logging ) + printf( "in free mode, even first\n" ); + + for ( i = 0; i < allocs; i += 2 ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 3; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + chkmem( ap[ i ], 0xaa, cb ); + memset_x( ap[ i ], 0xff, cb ); + free( ap[ i ] ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + + if ( logging ) + printf( "in free mode, now odd\n" ); + + for ( i = 1; i < allocs; i += 2 ) + { + cb = 8 + ( i * 10 ); + c_cb = cb + 7; + if ( logging ) + printf( " i, cb: %d %d\n", i, cb ); + + pc = (char *) calloc( c_cb, 1 ); + chkmem( pc, 0, c_cb ); + memset_x( pc, 0xcc, c_cb ); + + chkmem( ap[ i ], 0xaa, cb ); + memset_x( ap[ i ], 0xff, cb ); + free( ap[ i ] ); + + chkmem( pc, 0xcc, c_cb ); + free( pc ); + } + } + + printf( "success\n" ); + return 0; +} diff --git a/Manx Aztec C86 v42b/code/TTT.C b/Manx Aztec C86 v42b/code/TTT.C new file mode 100644 index 0000000..fec9a6b --- /dev/null +++ b/Manx Aztec C86 v42b/code/TTT.C @@ -0,0 +1,537 @@ +/* + This version builds with old compilers including: + Aztec C 1.06 for 8080 & Z80 on CP/M. + Microsoft C Compiler V1.04 for 8086 on DOS. (This is Lattice C) + Microsoft C Compiler V2.03 for 8086 on DOS. (Still Lattice C) + Microsoft C Compiler V3.00 for 8086 on DOS. + QuickC 1.0 + Turbo C 2.0 + The syntax is old and reminds me of 7th grade summer vacation. + Much of this code is awkward to satisfy the lowest common denominator of many compilers. + unsigned long isn't supported in many older compilers, so long is used instead. + Early DOS and CP/M require register variabes to be int, not char or other types. + The perf improvement of using register-int instead of stack-char is worth it. +*/ + +#define LINT_ARGS + +#include +#include + +#ifdef DOSTIME +#include +#include +#endif + +#define true 1 +#define false 0 + +/* Function Pointers are the fastest implementation for almost every compiler */ +#define UseFunPointers 1 +#define UseWinner2 2 +#define UseLookForWinner 3 +#define WinMethod UseFunPointers + +#define ABPrune true /* alpha beta pruning */ +#define WinLosePrune true /* stop early on win/lose */ +#define ScoreWin 6 +#define ScoreTie 5 +#define ScoreLose 4 +#define ScoreMax 9 +#define ScoreMin 2 +#define DefaultIterations 100 + +#define PieceX 1 +#define PieceO 2 +#define PieceBlank 0 + +typedef char ttype; /* 8-bit and 16-bit cpus do best with char aside from register in locals */ + +int g_Iterations = DefaultIterations; +ttype g_board[ 9 ]; + +#if WinMethod == UseFunPointers + +ttype pos0func() +{ + /* using "register int" instead of "ttype" for x is faster on 8086 and Z80 */ + register int x = g_board[0]; + + if ( ( x == g_board[1] && x == g_board[2] ) || + ( x == g_board[3] && x == g_board[6] ) || + ( x == g_board[4] && x == g_board[8] ) ) + return x; + return PieceBlank; +} + +ttype pos1func() +{ + register int x = g_board[1]; + + if ( ( x == g_board[0] && x == g_board[2] ) || + ( x == g_board[4] && x == g_board[7] ) ) + return x; + return PieceBlank; +} + +ttype pos2func() +{ + register int x = g_board[2]; + + if ( ( x == g_board[0] && x == g_board[1] ) || + ( x == g_board[5] && x == g_board[8] ) || + ( x == g_board[4] && x == g_board[6] ) ) + return x; + return PieceBlank; +} + +ttype pos3func() +{ + register int x = g_board[3]; + + if ( ( x == g_board[4] && x == g_board[5] ) || + ( x == g_board[0] && x == g_board[6] ) ) + return x; + return PieceBlank; +} + +ttype pos4func() +{ + register int x = g_board[4]; + + if ( ( x == g_board[0] && x == g_board[8] ) || + ( x == g_board[2] && x == g_board[6] ) || + ( x == g_board[1] && x == g_board[7] ) || + ( x == g_board[3] && x == g_board[5] ) ) + return x; + return PieceBlank; +} + +ttype pos5func() +{ + register int x = g_board[5]; + + if ( ( x == g_board[3] && x == g_board[4] ) || + ( x == g_board[2] && x == g_board[8] ) ) + return x; + return PieceBlank; +} + +ttype pos6func() +{ + register int x = g_board[6]; + + if ( ( x == g_board[7] && x == g_board[8] ) || + ( x == g_board[0] && x == g_board[3] ) || + ( x == g_board[4] && x == g_board[2] ) ) + return x; + return PieceBlank; +} + +ttype pos7func() +{ + register int x = g_board[7]; + + if ( ( x == g_board[6] && x == g_board[8] ) || + ( x == g_board[1] && x == g_board[4] ) ) + return x; + return PieceBlank; +} + +ttype pos8func() +{ + register int x = g_board[8]; + + if ( ( x == g_board[6] && x == g_board[7] ) || + ( x == g_board[2] && x == g_board[5] ) || + ( x == g_board[0] && x == g_board[4] ) ) + return x; + return PieceBlank; +} + +typedef ttype pfunc_t(); + +pfunc_t * winner_functions[9] = +{ + pos0func, + pos1func, + pos2func, + pos3func, + pos4func, + pos5func, + pos6func, + pos7func, + pos8func, +}; + +#endif + +#if WinMethod == UseWinner2 + +ttype winner2( move ) ttype move; +{ + register int x; /* faster than ttype x on the stack */ + + switch( move ) /* msc v3 from 1985 generates a jump table! */ + { + case 0: + { + x = g_board[ 0 ]; + if ( ( ( x == g_board[1] ) && ( x == g_board[2] ) ) || + ( ( x == g_board[3] ) && ( x == g_board[6] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[8] ) ) ) + return x; + break; + } + case 1: + { + x = g_board[ 1 ]; + if ( ( ( x == g_board[0] ) && ( x == g_board[2] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[7] ) ) ) + return x; + break; + } + case 2: + { + x = g_board[ 2 ]; + if ( ( ( x == g_board[0] ) && ( x == g_board[1] ) ) || + ( ( x == g_board[5] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[6] ) ) ) + return x; + break; + } + case 3: + { + x = g_board[ 3 ]; + if ( ( ( x == g_board[4] ) && ( x == g_board[5] ) ) || + ( ( x == g_board[0] ) && ( x == g_board[6] ) ) ) + return x; + break; + } + case 4: + { + x = g_board[ 4 ]; + if ( ( ( x == g_board[0] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[2] ) && ( x == g_board[6] ) ) || + ( ( x == g_board[1] ) && ( x == g_board[7] ) ) || + ( ( x == g_board[3] ) && ( x == g_board[5] ) ) ) + return x; + break; + } + case 5: + { + x = g_board[ 5 ]; + if ( ( ( x == g_board[3] ) && ( x == g_board[4] ) ) || + ( ( x == g_board[2] ) && ( x == g_board[8] ) ) ) + return x; + break; + } + case 6: + { + x = g_board[ 6 ]; + if ( ( ( x == g_board[7] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[0] ) && ( x == g_board[3] ) ) || + ( ( x == g_board[4] ) && ( x == g_board[2] ) ) ) + return x; + break; + } + case 7: + { + x = g_board[ 7 ]; + if ( ( ( x == g_board[6] ) && ( x == g_board[8] ) ) || + ( ( x == g_board[1] ) && ( x == g_board[4] ) ) ) + return x; + break; + } + case 8: + { + x = g_board[ 8 ]; + if ( ( ( x == g_board[6] ) && ( x == g_board[7] ) ) || + ( ( x == g_board[2] ) && ( x == g_board[5] ) ) || + ( ( x == g_board[0] ) && ( x == g_board[4] ) ) ) + return x; + break; + } + } + + return PieceBlank; +} /*winner2*/ + +#endif + +#if WinMethod == UseLookForWinner + +ttype LookForWinner() +{ + register int p = g_board[0]; /* faster as register int than ttype on 8086 and Z80 */ + if ( PieceBlank != p ) + { + if ( p == g_board[1] && p == g_board[2] ) + return p; + + if ( p == g_board[3] && p == g_board[6] ) + return p; + } + + p = g_board[3]; + if ( PieceBlank != p && p == g_board[4] && p == g_board[5] ) + return p; + + p = g_board[6]; + if ( PieceBlank != p && p == g_board[7] && p == g_board[8] ) + return p; + + p = g_board[1]; + if ( PieceBlank != p && p == g_board[4] && p == g_board[7] ) + return p; + + p = g_board[2]; + if ( PieceBlank != p && p == g_board[5] && p == g_board[8] ) + return p; + + p = g_board[4]; + if ( PieceBlank != p ) + { + if ( ( p == g_board[0] ) && ( p == g_board[8] ) ) + return p; + + if ( ( p == g_board[2] ) && ( p == g_board[6] ) ) + return p; + } + + return PieceBlank; +} /*LookForWinner*/ + +#endif + +int g_IMoves = 0; + +ttype MinMax( alpha, beta, depth, move ) ttype alpha; ttype beta; ttype depth; ttype move; +{ + ttype pieceMove, score; /* better perf with char than int. out of registers so use stack */ + register int p, value; /* better perf with these as an int on Z80, 8080, and 8086 */ + + g_IMoves++; + + if ( depth >= 4 ) + { +#if WinMethod == UseFunPointers + p = ( * winner_functions[ move ] )(); +#endif +#if WinMethod == UseWinner2 + p = winner2( move ); +#endif +#if WinMethod == UseLookForWinner + p = LookForWinner(); +#endif + + if ( PieceBlank != p ) + { + if ( PieceX == p ) + return ScoreWin; + + return ScoreLose; + } + + if ( 8 == depth ) + return ScoreTie; + } + + if ( depth & 1 ) + { + value = ScoreMin; + pieceMove = PieceX; + } + else + { + value = ScoreMax; + pieceMove = PieceO; + } + + for ( p = 0; p < 9; p++ ) + { + if ( PieceBlank == g_board[ p ] ) + { + g_board[p] = pieceMove; + score = MinMax( alpha, beta, depth + 1, p ); + g_board[p] = PieceBlank; + + if ( depth & 1 ) + { +#if WinLosePrune /* #if statements must be in first column for MS C 1.0 */ + if ( ScoreWin == score ) + return ScoreWin; +#endif + + if ( score > value ) + { + value = score; + +#if ABPrune + if ( value >= beta ) + return value; + if ( value > alpha ) + alpha = value; +#endif + } + } + else + { +#if WinLosePrune + if ( ScoreLose == score ) + return ScoreLose; +#endif + + if ( score < value ) + { + value = score; + +#if ABPrune + if ( value <= alpha ) + return value; + if ( value < beta ) + beta = value; +#endif + } + } + } + } + + return value; +} /*MinMax*/ + +long g_Moves = 0; + +int FindSolution( position ) ttype position; +{ + register int i; + + for ( i = 0; i < 9; i++ ) + g_board[ i ] = PieceBlank; + + g_board[ position ] = PieceX; + + for ( i = 0; i < g_Iterations; i++ ) + { + g_IMoves = 0; + MinMax( ScoreMin, ScoreMax, 0, position ); + g_Moves += g_IMoves; /* do the 4-byte long addition once per loop to save work */ + } + + return 0; +} /*FindSolution*/ + +#ifdef CPMTIME + +struct CPMTimeValue +{ + int h, m, s, l; +}; + +void print_time_now() +{ + /* This CP/M BDOS call of 105 is only implemented in NTVCM -- it's not a standard CP/M 2.2 call */ + + struct CPMTimeValue t; + t.h = t.m = t.s = t.l = 0; + + bdos( 105, &t ); + printf( "current time: %02d:%02d:%02d.%02d\n", t.h, t.m, t.s, t.l ); +} /*print_time_now*/ + +long get_ms() +{ + /* This CP/M BDOS call of 105 is only implemented in NTVCM -- it's not a standard CP/M 2.2 call */ + + long h, m, s, l; + struct CPMTimeValue t; + t.h = t.m = t.s = t.l = 0; + + bdos( 105, &t ); + h = t.h; + m = t.m; + s = t.s; + l = t.l; + + return h * 3600000 + m * 60000 + s * 1000 + l * 10; +} /*get_ms*/ + +#else /* no elif with old compilers */ + +#ifdef DOSTIME + +void print_time_now() +{ + /* Make a DOS interrupt call to get the time */ + + union REGS wrIn, wrOut; + + wrIn.h.ah = 0x2c; + intdos( &wrIn, &wrOut ); + printf( "current time: %02d:%02d:%02d.%02d\n", wrOut.h.ch, wrOut.h.cl, wrOut.h.dh, wrOut.h.dl ); + fflush( stdout ); +} /*print_time_now*/ + +long get_ms() +{ + /* this function takes about 3 milliseconds on the original IBM PC */ + + long h, m, s, l; + union REGS wrIn, wrOut; + + wrIn.h.ah = 0x2c; + intdos( &wrIn, &wrOut ); + + h = wrOut.h.ch; + m = wrOut.h.cl; + s = wrOut.h.dh; + l = wrOut.h.dl; + + return h * 3600000 + m * 60000 + s * 1000 + l * 10; +} /*get_ms*/ + +#else + +int print_time_now() { return 0; } + +long get_ms() +{ + struct tm t; + long hs = 0; + + dostime( &t ); + + hs = t.tm_hsec + (long) t.tm_sec * 100 + (long) t.tm_min * 60 * 100 + (long) t.tm_hour * 24 * 60 * 100; + + return hs * 10; +} + +#endif +#endif + +int main( argc, argv ) int argc; char * argv[]; +{ + long start_time, end_time; + + if ( 2 == argc ) + sscanf( argv[ 1 ], "%d", &g_Iterations ); /* no atoi in MS C 1.0 */ + + start_time = get_ms(); + + FindSolution( 0 ); + FindSolution( 1 ); + FindSolution( 4 ); + + end_time = get_ms(); + + printf( "runtime in ms: %ld\n", end_time - start_time ); + printf( "move count: %ld\n", g_Moves ); /* 6493 * g_Iterations */ + printf( "iteration count: %d\n", g_Iterations ); + printf( "method: %s\n", + ( WinMethod == UseFunPointers ) ? "function pointers" : + ( WinMethod == UseWinner2 ) ? "winner2" : + ( WinMethod == UseLookForWinner ) ? "look for winner" : + "invalid method" ); + return 0; +} /*main*/ + diff --git a/Manx Aztec C86 v42b/code/m.bat b/Manx Aztec C86 v42b/code/m.bat new file mode 100644 index 0000000..a8206fd --- /dev/null +++ b/Manx Aztec C86 v42b/code/m.bat @@ -0,0 +1,4 @@ +ntvdm -e:include=c:\include,path=c:\bin -r:.. ..\bin\cc -DAZTEC86 +F +A %1.c +del ctmp* 1>nul 2>nul +ntvdm -r:.. -e:lib=c:\lib ..\bin\ln %1 c:\lib\m.lib c:\lib\c.lib +