Commit graph

8288 commits

Author SHA1 Message Date
David Given 59b383afd0 Make the em interpreter build --- again, lots of warnings, so it probably won't
work on clang. I have no idea whether it runs or not as building a e.out
program is quite hard and needs a special platform.
2018-06-09 21:13:31 +09:00
David Given d10a594c04 Get ass running --- it's very K&R and almost certainly won't build on clang,
but it works on gcc.
2018-06-09 14:10:45 +09:00
David Given ae3074cd9a
Merge pull request #93 from davidgiven/dtrg-pc86-2
Rearrange the tests; don't run unsupported tests on emulators which don't support them.
2018-06-08 21:40:25 +09:00
David Given 19cd42124f Rearrange the tests into sets; allow plats to skip sets; pc86 and linux68k now
skip the tests which use floating point instructions (as their emulators don't
support them).
2018-06-08 15:59:04 +09:00
David Given b94199aba7
Merge pull request #92 from davidgiven/dtrg-pc86-2
Replace the qemu pc86 emulator with a custom x86emu-based one.
2018-06-08 00:18:18 +09:00
David Given 1d4ddb939d Merge from trunk. 2018-06-08 00:05:50 +09:00
David Given 37f466a8f4
Merge pull request #91 from davidgiven/dtrg-m68k
Add a Musashi-based 68020 emulator; use it to run the linux68k tests.
2018-06-07 13:48:06 +09:00
David Given b9c0e1d964 Dummied out some more system calls --- more tests pass. 2018-06-07 13:12:15 +09:00
David Given 2682c125e0 More real ELF loading and brk handling; more tests pass. 2018-06-07 13:03:36 +09:00
David Given 396795105f Beat the 68k simulator into enough shape that at least *some* of the tests pass. 2018-06-06 22:39:43 +09:00
David Given 4b26f75d23 Hang on, the 68k is big-endian --- I'm extracting words (and bytes) from longs
incorrectly.
2018-06-06 12:49:21 +09:00
David Given 2cf39be752 Get the emulator to the point where it'll start to run code; it then fails,
because the version of Musashi I imported doesn't support floating point...
2018-06-05 23:17:22 +09:00
David Given a8802c934b Enable tests for linux68k. 2018-06-05 23:16:34 +09:00
David Given 5034ed1c39 Crudely beat the standard Masushi simulator into working in the ACK framework. 2018-06-05 17:45:00 +09:00
David Given 3f049a4c29 Basic mid now throws an error on out-of-bounds parameters rather than returning
an uninitialised pointer (and crashing).

Fixes: #54
2018-06-05 09:53:56 +09:00
David Given 9dede01efe Fix bogus test.
Fixes: #89.
2018-06-05 09:41:31 +09:00
David Given 342a321c87 Fix bogus test.
Fixes: #90
2018-06-05 09:20:46 +09:00
David Given c6b9446722 Check in the x86emu-based emulator. Sadly, just like the 8086tiny-based
emulator, FPU instructions aren't supported.
2018-06-04 16:19:45 +09:00
David Given d908f9cfb2 Modify the pc86 test harness to use 8086tiny instead of qemu. Sadly, some tests fail. 2018-06-03 15:13:43 +02:00
David Given 0eb89d5d95 Add a clean copy of the Musashi emulator. 2018-06-05 17:04:47 +09:00
David Given d70eb76dbb Modify the pc86 test harness to use 8086tiny instead of qemu. Sadly, some tests fail. 2018-06-03 15:13:43 +02:00
David Given 9132641100 Add the pc86emu skeleton. 2018-06-03 08:24:21 -07:00
David Given eb96ea5d28 Add a clean copy of the x86emu library. 2018-06-03 08:06:23 -07:00
David Given b8cb840c12
Merge pull request #87 from davidgiven/dtrg-travis
Get clang working on travis.
2018-06-02 23:00:48 +03:00
David Given 5d292a0a36 Typo fix. 2018-06-02 21:48:18 +02:00
David Given 911ce7ceb5 Crudely tweak some of the prototypes to please clang, which is pickier about
K&R C than gcc is.
2018-06-02 21:31:18 +02:00
David Given 5a886787d3 Honour CFLAGS set in the Makefile. 2018-06-02 21:30:52 +02:00
David Given deeef55ea9 Try and *actually* use clang for the clang build.
Fixes: #67
2018-06-02 21:01:03 +02:00
David Given b85c25e4e5 Fix resource leak.
Closes: #75
2018-06-02 20:59:11 +02:00
David Given d6e65833fb Format. 2018-06-02 20:57:43 +02:00
David Given d1cbb9cf60 Crudely bounds check some naked fscanf("%s") parsing. Fixes #79, mostly. 2018-06-02 20:51:41 +02:00
David Given c47661f07e
Merge pull request #85 from davidgiven/dtrg-ed
Fix the incompatibility with modern ed
2018-06-02 19:23:19 +03:00
David Given be32d258cb Don't need ed any more in the travis configuration. 2018-06-02 18:08:55 +02:00
David Given 05ddefad65 Adopt a copy of Minix 2's ed; this allows the ACK's antiquated ed scripts to
run with a minimum of tweaking. Rewriting them for modern ed looks really hard.

Fixes: #84
2018-06-02 18:02:51 +02:00
David Given f8dfdef974
Merge pull request #81 from kernigh/kernigh-libfp
software floats, line editor for CP/M
2018-05-12 00:59:05 +02:00
George Koehler 019c7f9da7 Update cpm/README for console changes, ack -fp. 2018-05-07 16:08:44 -04:00
George Koehler 43458df777 Build a smaller startrek for CP/M.
The game was larger than the 64K address space.  I remove the intro
and replace part of libc.  Now I can play startrek in YAZE-AG.
2018-05-04 18:32:24 -04:00
George Koehler 154509038d Enable the line editor in read() for CP/M.
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.
2018-05-04 18:21:01 -04:00
George Koehler b4be612832 Change readstring() to use buffered input.
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.
2018-05-04 18:06:51 -04:00
George Koehler 4a3b7be795 Use ack -mcpm -fp for mandelbrot.c, startrek.c
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.
2018-04-28 13:18:27 -04:00
George Koehler 1df4db99c9 Optimize libfp. Don't lose -O6 in ackcflags.
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.
2018-04-25 22:48:28 -04:00
George Koehler 93e01eb5d1 Teach i80 ncg to use libfp. Enable ack -mcpm -fp.
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.
2018-04-25 16:09:56 -04:00
George Koehler b9b3428e01 Build (but don't use) libfp for cpm.
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.
2018-04-25 00:34:10 -04:00
David Given aabf0bdd69
Merge pull request #73 from kernigh/kernigh-pr
better code from PowerPC ncg and mcg
2018-03-13 13:57:28 +01:00
George Koehler 85fcbde22f Check LOI expressions to prevent a read after free.
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
2018-03-12 20:58:31 -04:00
George Koehler ebba76e08f Don't read INSTR(l) after oldline(l) frees it.
This bug got in my way while I was looking for another read-after-free
bug in the CS phase.
2018-03-11 20:10:13 -04:00
David Given 4cb4bdc85f There are two places where names are added to the global symbol table; one via
the -U command line option, and one via file scanning. Turns out only the
second would increment the number of global names, so adding names with -U
would cause names found via scanning to fall off the end of the list! This
wouldn't cause linker errors because fixups don't use the list, but would cause
the generated symbol table in the output to be incorrect.
2018-03-11 12:37:23 +01:00
David Given d5a9f1541a lchar() needs to return the character written. (This happens by magic on 386,
but no on PPC.) See #72.
2018-03-11 11:00:35 +01:00
George Koehler 12643f1740 Solve some gcc warnings in ego.
Some of these are from gcc -Wimplicit
2018-03-08 18:51:07 -05:00
George Koehler 860df1b067 Read from new, not old, buffer after realloc.
This got caught by MALLOC_OPTIONS=S in OpenBSD.  The B compiler filled
the buffer while compiling hilo.b.  Then realloc moved the buffer and
unmapped the old buffer.  The compiler tried to read the old buffer
and segfaulted.
2018-03-08 12:04:02 -05:00