This changes the BDOS call from CPM_BDOS_CONSOLE_INPUT to
CPN_BDOS_READ_CONSOLE_BUFFER. This allows commands like ^H to delete
characters and ^C to exit to CCP. This is more like how Unix read(2)
uses canonical mode of termios to read a line.
This change has a disadvantage: the user buffer to read(2) must now be
large enough for an entire line. This is because CP/M, unlike Unix,
lacks a kernel buffer to hold the rest of the line. If you use a
buffered input library like stdio to call read(2), then it works; but
if you try to read part of a line or a single character, then it
doesn't work.
Change from `uread(0, c, 1)` to `read(c)`, so input goes through
libpc's buffer. If input is a tty in Unix, this reduces the number of
read(2) system calls from one per character to one per line.
This change will become necessary in CP/M when I enable the line
editor.
Add a variable %{ackldflags} so I can pass `-fp`. This change seems
to cause the build to relink every ackprogram, because the link now
needs to use %{ackldflags} even if the flags are empty.
mandelbrot_c_cpm runs in YAZE-AG; startrek_c_cpm doesn't run because
it doesn't fit in the 16-bit address space.
This drops 124 bytes from the mandelbrot command (from 15015 to 14891
bytes) but has almost no effect on performance; the command takes
about 144 seconds (in YAZE-AG) both before and after optimizing libfp.
Old .o files stop working if they use floating point. One must
recompile those files. Old files don't call libfp in the correct way,
and may use symbols that I removed from libem. I don't keep old
symbols in libem/flp.s, because a program that pulls both libfp and
flp.s would get "multiply defined" errors in the linker.
I teach mach/i80/ncg/table to use libfp by copying or adapting the
patterns from mach/i86/ncg/table. I did not test all the patterns,
but I did use `ack -mcpm -fp -O4` to compile examples/mandelbrot.c,
then I ran it in the emulator YAZE-AG. It worked, but it was slow.
This library is for software floating point. The i80 back end has
never implemented floating point, and might not be ready for libfp.
This commit only builds libfp without using it.
I edit first/build.lua and plat/build.lua to allow `ack -c.s`, then
use FP.script to edit the assembly code. I edit FP.script so it
writes the edited assembly code to stdout, not to the input file.
CS eliminates outer expressions before inner ones, as `x * y * z`
before `x * y`. It does this by reversing the order of expressions in
the code. This almost always works, but it sometimes doesn't work if
a STI changes the value number of a LOI. In code like `expr1 LOI
expr2 STI expr2 LOI`, CS might eliminate the inner `expr2` before the
outer `expr2 LOI`. This caused a read after free because the
occurrence of `expr2 LOI` pointed to the eliminated lines of `expr2`.
This bug went unnoticed until my recent changes caused CS to crash
with a double free. I did not get the crash in OpenBSD, but I saw the
crash in Travis, then David Given reproduced the crash in Linux. See
the discussion in https://github.com/davidgiven/ack/pull/73