ack.git
6 years agoThe ctype functions are pure.
David Given [Thu, 21 Jun 2018 21:06:29 +0000 (23:06 +0200)]
The ctype functions are pure.

6 years agoThe maths library is pure.
David Given [Thu, 21 Jun 2018 21:00:33 +0000 (23:00 +0200)]
The maths library is pure.

6 years agoMoved the setjmp functions into the new pure directoy.
David Given [Thu, 21 Jun 2018 20:55:42 +0000 (22:55 +0200)]
Moved the setjmp functions into the new pure directoy.

6 years agoMove the pure locale functions into the new pure directory.
David Given [Thu, 21 Jun 2018 20:54:25 +0000 (22:54 +0200)]
Move the pure locale functions into the new pure directory.

6 years agoMove the pure stdlib functions into the new pure directory.
David Given [Thu, 21 Jun 2018 20:52:31 +0000 (22:52 +0200)]
Move the pure stdlib functions into the new pure directory.

6 years agoRethink the libc layout.
David Given [Thu, 21 Jun 2018 20:47:02 +0000 (22:47 +0200)]
Rethink the libc layout.

6 years agoMove the str and mem functions into the new src/core.
David Given [Thu, 21 Jun 2018 20:39:08 +0000 (22:39 +0200)]
Move the str and mem functions into the new src/core.

6 years agoRun libcc.ansi through clang-format.
David Given [Thu, 21 Jun 2018 20:33:47 +0000 (22:33 +0200)]
Run libcc.ansi through clang-format.

6 years agoMerge pull request #96 from kernigh/kernigh-emu-1
David Given [Wed, 20 Jun 2018 20:30:01 +0000 (22:30 +0200)]
Merge pull request #96 from kernigh/kernigh-emu-1

Fixes to build emulators, ass, int on OpenBSD

6 years agoMerge pull request #103 from davidgiven/dtrg-warnings
David Given [Mon, 18 Jun 2018 20:31:35 +0000 (22:31 +0200)]
Merge pull request #103 from davidgiven/dtrg-warnings

Fix a lot of warnings.

6 years agoTurns out that the compiler needs access to the libpc headers too; refactor
David Given [Mon, 18 Jun 2018 20:17:38 +0000 (22:17 +0200)]
Turns out that the compiler needs access to the libpc headers too; refactor
into a separate target to avoid build loops and make it work.

6 years agoAnsify and warning fix.
David Given [Sun, 17 Jun 2018 20:30:27 +0000 (22:30 +0200)]
Ansify and warning fix.

6 years agoRun C files through clang-format.
David Given [Sun, 17 Jun 2018 14:11:29 +0000 (16:11 +0200)]
Run C files through clang-format.

6 years agoUse cproto to extract all the prototypes.
David Given [Sun, 17 Jun 2018 14:10:57 +0000 (16:10 +0200)]
Use cproto to extract all the prototypes.

6 years agoAdded a pc.h to contain libpc prototypes; some ansification.
David Given [Sun, 17 Jun 2018 13:54:18 +0000 (15:54 +0200)]
Added a pc.h to contain libpc prototypes; some ansification.

6 years agoMove the private Pascal headers into libpc where they belong.
David Given [Sun, 17 Jun 2018 13:44:33 +0000 (15:44 +0200)]
Move the private Pascal headers into libpc where they belong.

6 years agoWarning fixes.
David Given [Sun, 17 Jun 2018 13:42:26 +0000 (15:42 +0200)]
Warning fixes.

6 years agoWarning fix.
David Given [Sun, 17 Jun 2018 13:34:29 +0000 (15:34 +0200)]
Warning fix.

6 years agoMerge pull request #102 from davidgiven/dtrg-powerpc
David Given [Sun, 17 Jun 2018 09:45:26 +0000 (11:45 +0200)]
Merge pull request #102 from davidgiven/dtrg-powerpc

Add a PowerPC simulator for running the tests.

6 years agoFix edge case in rlwnm when the mask is 32 bits wide. All tests now pass.
David Given [Sun, 17 Jun 2018 09:00:01 +0000 (11:00 +0200)]
Fix edge case in rlwnm when the mask is 32 bits wide. All tests now pass.

6 years agoTurns out that andi and andis only have . forms. Fixed; another test passes.
David Given [Sun, 17 Jun 2018 08:43:39 +0000 (10:43 +0200)]
Turns out that andi and andis only have . forms. Fixed; another test passes.

6 years agoTurns out I was returning values from syscalls in the wrong register; fixed.
David Given [Sun, 17 Jun 2018 08:22:20 +0000 (10:22 +0200)]
Turns out I was returning values from syscalls in the wrong register; fixed.
More tests pass.

6 years agoLots of floating point, bugfixes, and system calls. Most of the tests pass now.
David Given [Sun, 17 Jun 2018 07:24:01 +0000 (09:24 +0200)]
Lots of floating point, bugfixes, and system calls. Most of the tests pass now.

6 years agoDo a bit of floating point stuff; added brk(); fixed a horrible bug where
David Given [Sat, 16 Jun 2018 20:55:23 +0000 (22:55 +0200)]
Do a bit of floating point stuff; added brk(); fixed a horrible bug where
stores with 16-bit displacements were storing the register number and not the
contents of the register.

6 years agoFix a setcr0 bug which was trashing the condition register; some system
David Given [Sat, 16 Jun 2018 06:35:36 +0000 (08:35 +0200)]
Fix a setcr0 bug which was trashing the condition register; some system
calls are now implemented. A few tests more-or-less pass (but crash on
exit).

6 years agoMerge pull request #100 from kernigh/kernigh-pdp
David Given [Fri, 15 Jun 2018 06:40:24 +0000 (15:40 +0900)]
Merge pull request #100 from kernigh/kernigh-pdp

Two fixes for ack -mpdpv7

6 years agoPrevent crash in isatty()
George Koehler [Fri, 15 Jun 2018 04:48:29 +0000 (00:48 -0400)]
Prevent crash in isatty()

The existing code allocated 2 bytes (char*), but gtty() needs 6 bytes
(struct sgttyb), so isatty() smashed the stack and corrupted its
return address, probably causing SIGBUS or SIGSEGV.

Fix by switching to TIOCGETD, which needs 2 bytes.  TIOCGETD isn't in
the manual for tty(4), but does appear in
https://minnie.tuhs.org//cgi-bin/utree.pl?file=V7/usr/sys/dev/tty.c

This fixes hilo_c.pdpv7 and hilo_mod.pdpv7 in simh-pdp11.

6 years agoUse 2-byte alignment in pdpv7 to prevent SIGBUS.
George Koehler [Fri, 15 Jun 2018 04:17:12 +0000 (00:17 -0400)]
Use 2-byte alignment in pdpv7 to prevent SIGBUS.

Change the alignment in C structs (wa, pa, sa, and so on) from 1 to 2
bytes.  This prevents the SIGBUS when PDP-11 Unix V7 catches the
misalignment.  This fixes hilo_p.pdpv7 in simh-pdp11.

Change ALIGN to document that sections have 2-byte alignment.  This
change should have no effect, because the sections only contain 2-byte
values.

6 years agoGot the emulator to the point where we're hitting the first major emulation bug
David Given [Thu, 14 Jun 2018 12:53:39 +0000 (05:53 -0700)]
Got the emulator to the point where we're hitting the first major emulation bug
(the calloc test hangs).

6 years agoSome code runs (up to needing setcr0).
David Given [Thu, 14 Jun 2018 11:41:21 +0000 (04:41 -0700)]
Some code runs (up to needing setcr0).

6 years agoImplement a non-functional skeleton of the PowerPC emulator (with, hopefully,
David Given [Thu, 14 Jun 2018 10:07:36 +0000 (03:07 -0700)]
Implement a non-functional skeleton of the PowerPC emulator (with, hopefully,
most of the instruction decode done).

6 years agoMerge pull request #99 from davidgiven/dtrg-ass
David Given [Thu, 14 Jun 2018 01:08:17 +0000 (10:08 +0900)]
Merge pull request #99 from davidgiven/dtrg-ass

Bodge together a buildable em22 plat for use with int.

6 years agoMerge from trunk.
David Given [Wed, 13 Jun 2018 12:47:25 +0000 (21:47 +0900)]
Merge from trunk.

6 years agoFile cleanup.
David Given [Wed, 13 Jun 2018 12:47:08 +0000 (21:47 +0900)]
File cleanup.

6 years agoBodge the ancient em monitor library into building as a libsys for the em22
David Given [Wed, 13 Jun 2018 12:44:25 +0000 (21:44 +0900)]
Bodge the ancient em monitor library into building as a libsys for the em22
plat. It's completely untested, but it builds and makes e.out executables.

6 years agoRename a function to avoid a clash with an em system call.
David Given [Wed, 13 Jun 2018 12:34:14 +0000 (21:34 +0900)]
Rename a function to avoid a clash with an em system call.

6 years agoAfter finding the em_table documentation, move it somewhere where other people
David Given [Wed, 13 Jun 2018 11:58:44 +0000 (20:58 +0900)]
After finding the em_table documentation, move it somewhere where other people
can find it.

6 years agoRemember to always link the libsys and libend.
David Given [Wed, 13 Jun 2018 11:57:31 +0000 (20:57 +0900)]
Remember to always link the libsys and libend.

6 years agoExpose our custom Lua interpreter to the build system so utility scripts can be
David Given [Wed, 13 Jun 2018 11:56:49 +0000 (20:56 +0900)]
Expose our custom Lua interpreter to the build system so utility scripts can be
written in it.

6 years agoMerge pull request #98 from davidgiven/dtrg-m68k
David Given [Tue, 12 Jun 2018 12:24:32 +0000 (14:24 +0200)]
Merge pull request #98 from davidgiven/dtrg-m68k

Fix sub-word-size type conversions for m68020.

6 years agoRemove bogus conversion from test which was causing failure; you're not allowed
David Given [Tue, 12 Jun 2018 12:04:27 +0000 (21:04 +0900)]
Remove bogus conversion from test which was causing failure; you're not allowed
to do cui or ciu with sizes smaller than a word.

6 years agoIt appears that the parameter to lol technically has to be word aligned; having
David Given [Tue, 12 Jun 2018 11:54:15 +0000 (20:54 +0900)]
It appears that the parameter to lol technically has to be word aligned; having
a non-word aligned parameter is illegal (but most of the toolchain accepts it).
So, word align data structures for em22.

6 years agoGet moncalls.c to compile on OpenBSD.
George Koehler [Sun, 10 Jun 2018 20:29:52 +0000 (16:29 -0400)]
Get moncalls.c to compile on OpenBSD.

Remove some declarations (not all correct) and #include <errno.h>,
<time.h>, and <unistd.h> to get the correct declarations.

Disable mount(2), umount(2), and stime(2) because BSD (around
4.3BSD-Reno) lost compatibility with these Unix v7 functions.

6 years agoRename setmode() to set_mode() to avoid BSD prototype.
George Koehler [Sun, 10 Jun 2018 20:26:54 +0000 (16:26 -0400)]
Rename setmode() to set_mode() to avoid BSD prototype.

4.4BSD added a non-standard function setmode() to <unistd.h>; its
prototype is not compatible.

6 years agoRemove extra `#include <stdio.h>` to fix `uint`
George Koehler [Sun, 10 Jun 2018 20:24:35 +0000 (16:24 -0400)]
Remove extra `#include <stdio.h>` to fix `uint`

From my request at https://github.com/kstenerud/Musashi/pull/31

There was a conflict between Musahi's uint and OpenBSD's uint:

    $ cc -o m68kmake m68kmake.c
    $ ./m68kmake
    $ cc -DM68K_COMPILE_FOR_MAME=0 -c m68kcpu.c
    In file included from m68kcpu.c:565:
    In file included from /usr/include/stdio.h:46:
    /usr/include/sys/types.h:58:22: error: cannot combine with previous 'int'
          declaration specifier
    typedef unsigned int    uint;           /* Sys V compatibility */
                            ^
    ./m68kcpu.h:75:25: note: expanded from macro 'uint'
    #define uint   unsigned int
                            ^
    1 error generated.

6 years agoStop using <X11/Xfuncproto.h> from x86emu.
George Koehler [Sun, 10 Jun 2018 20:00:23 +0000 (16:00 -0400)]
Stop using <X11/Xfuncproto.h> from x86emu.

The code included <X11/Xfuncproto.h> only for _X_ATTRIBUTE_PRINTF,
which tells some compilers to check the printf format string.  Remove
so ACK doesn't need any X11 headers.

Some machines don't have the X11 headers, or they need a flag like
-I/usr/X11R[67]/include to find them.

6 years agoMerge pull request #95 from davidgiven/dtrg-b
David Given [Sun, 10 Jun 2018 12:22:26 +0000 (21:22 +0900)]
Merge pull request #95 from davidgiven/dtrg-b

Fix occasional weird behaviour causing compilation failures in b.

6 years agoMerge.
David Given [Sun, 10 Jun 2018 11:26:10 +0000 (20:26 +0900)]
Merge.

6 years agoAdd the core of a simple em22 platform. Unfortunately it doesn't work; the old
David Given [Sun, 10 Jun 2018 11:25:48 +0000 (20:25 +0900)]
Add the core of a simple em22 platform. Unfortunately it doesn't work; the old
em libmon vanished decades ago (or never existed), and also ass appears to have
a different idea of what the em opcodes are to everything else and gets
confused.

6 years agoMerge.
David Given [Sun, 10 Jun 2018 09:09:18 +0000 (18:09 +0900)]
Merge.

6 years agoFix table underrun when looking up the character class of the EOF character,
David Given [Sun, 10 Jun 2018 08:52:45 +0000 (17:52 +0900)]
Fix table underrun when looking up the character class of the EOF character,
-1.

6 years agoMerge pull request #94 from davidgiven/dtrg-ass
David Given [Sat, 9 Jun 2018 13:44:24 +0000 (22:44 +0900)]
Merge pull request #94 from davidgiven/dtrg-ass

Get int and ass building.

6 years agoFile cleanup.
David Given [Sat, 9 Jun 2018 12:21:28 +0000 (21:21 +0900)]
File cleanup.

6 years agoMake ass and int built with clang --- surprisingly easy.
David Given [Sat, 9 Jun 2018 12:18:50 +0000 (21:18 +0900)]
Make ass and int built with clang --- surprisingly easy.

6 years agoMake the em interpreter build --- again, lots of warnings, so it probably won't
David Given [Sat, 9 Jun 2018 12:13:31 +0000 (21:13 +0900)]
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.

6 years agoGet ass running --- it's very K&R and almost certainly won't build on clang,
David Given [Sat, 9 Jun 2018 05:10:45 +0000 (14:10 +0900)]
Get ass running --- it's very K&R and almost certainly won't build on clang,
but it works on gcc.

6 years agoMerge pull request #93 from davidgiven/dtrg-pc86-2
David Given [Fri, 8 Jun 2018 12:40:25 +0000 (21:40 +0900)]
Merge pull request #93 from davidgiven/dtrg-pc86-2

Rearrange the tests; don't run unsupported tests on emulators which don't support them.

6 years agoRearrange the tests into sets; allow plats to skip sets; pc86 and linux68k now
David Given [Fri, 8 Jun 2018 06:59:04 +0000 (15:59 +0900)]
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).

6 years agoMerge pull request #92 from davidgiven/dtrg-pc86-2
David Given [Thu, 7 Jun 2018 15:18:18 +0000 (00:18 +0900)]
Merge pull request #92 from davidgiven/dtrg-pc86-2

Replace the qemu pc86 emulator with a custom x86emu-based one.

6 years agoMerge from trunk.
David Given [Thu, 7 Jun 2018 15:05:50 +0000 (00:05 +0900)]
Merge from trunk.

6 years agoMerge pull request #91 from davidgiven/dtrg-m68k
David Given [Thu, 7 Jun 2018 04:48:06 +0000 (13:48 +0900)]
Merge pull request #91 from davidgiven/dtrg-m68k

Add a Musashi-based 68020 emulator; use it to run the linux68k tests.

6 years agoDummied out some more system calls --- more tests pass.
David Given [Thu, 7 Jun 2018 04:12:15 +0000 (13:12 +0900)]
Dummied out some more system calls --- more tests pass.

6 years agoMore real ELF loading and brk handling; more tests pass.
David Given [Thu, 7 Jun 2018 04:03:36 +0000 (13:03 +0900)]
More real ELF loading and brk handling; more tests pass.

6 years agoBeat the 68k simulator into enough shape that at least *some* of the tests pass.
David Given [Wed, 6 Jun 2018 13:39:43 +0000 (22:39 +0900)]
Beat the 68k simulator into enough shape that at least *some* of the tests pass.

6 years agoHang on, the 68k is big-endian --- I'm extracting words (and bytes) from longs
David Given [Wed, 6 Jun 2018 03:49:21 +0000 (12:49 +0900)]
Hang on, the 68k is big-endian --- I'm extracting words (and bytes) from longs
incorrectly.

6 years agoGet the emulator to the point where it'll start to run code; it then fails,
David Given [Tue, 5 Jun 2018 14:17:22 +0000 (23:17 +0900)]
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...

6 years agoEnable tests for linux68k.
David Given [Tue, 5 Jun 2018 14:16:34 +0000 (23:16 +0900)]
Enable tests for linux68k.

6 years agoCrudely beat the standard Masushi simulator into working in the ACK framework.
David Given [Tue, 5 Jun 2018 08:45:00 +0000 (17:45 +0900)]
Crudely beat the standard Masushi simulator into working in the ACK framework.

6 years agoBasic mid now throws an error on out-of-bounds parameters rather than returning
David Given [Tue, 5 Jun 2018 00:53:56 +0000 (09:53 +0900)]
Basic mid now throws an error on out-of-bounds parameters rather than returning
an uninitialised pointer (and crashing).

Fixes: #54

6 years agoFix bogus test.
David Given [Tue, 5 Jun 2018 00:41:31 +0000 (09:41 +0900)]
Fix bogus test.

Fixes: #89.

6 years agoFix bogus test.
David Given [Tue, 5 Jun 2018 00:20:46 +0000 (09:20 +0900)]
Fix bogus test.

Fixes: #90

6 years agoCheck in the x86emu-based emulator. Sadly, just like the 8086tiny-based
David Given [Mon, 4 Jun 2018 07:19:45 +0000 (16:19 +0900)]
Check in the x86emu-based emulator. Sadly, just like the 8086tiny-based
emulator, FPU instructions aren't supported.

6 years agoModify the pc86 test harness to use 8086tiny instead of qemu. Sadly, some tests fail.
David Given [Sun, 3 Jun 2018 13:13:43 +0000 (15:13 +0200)]
Modify the pc86 test harness to use 8086tiny instead of qemu. Sadly, some tests fail.

6 years agoAdd a clean copy of the Musashi emulator.
David Given [Tue, 5 Jun 2018 08:04:47 +0000 (17:04 +0900)]
Add a clean copy of the Musashi emulator.

6 years agoModify the pc86 test harness to use 8086tiny instead of qemu. Sadly, some tests fail.
David Given [Sun, 3 Jun 2018 13:13:43 +0000 (15:13 +0200)]
Modify the pc86 test harness to use 8086tiny instead of qemu. Sadly, some tests fail.

6 years agoAdd the pc86emu skeleton.
David Given [Sun, 3 Jun 2018 15:24:21 +0000 (08:24 -0700)]
Add the pc86emu skeleton.

6 years agoAdd a clean copy of the x86emu library.
David Given [Sun, 3 Jun 2018 15:06:23 +0000 (08:06 -0700)]
Add a clean copy of the x86emu library.

6 years agoMerge pull request #87 from davidgiven/dtrg-travis
David Given [Sat, 2 Jun 2018 20:00:48 +0000 (23:00 +0300)]
Merge pull request #87 from davidgiven/dtrg-travis

Get clang working on travis.

6 years agoTypo fix.
David Given [Sat, 2 Jun 2018 19:48:18 +0000 (21:48 +0200)]
Typo fix.

6 years agoCrudely tweak some of the prototypes to please clang, which is pickier about
David Given [Sat, 2 Jun 2018 19:31:18 +0000 (21:31 +0200)]
Crudely tweak some of the prototypes to please clang, which is pickier about
K&R C than gcc is.

6 years agoHonour CFLAGS set in the Makefile.
David Given [Sat, 2 Jun 2018 19:30:52 +0000 (21:30 +0200)]
Honour CFLAGS set in the Makefile.

6 years agoTry and *actually* use clang for the clang build.
David Given [Sat, 2 Jun 2018 19:01:03 +0000 (21:01 +0200)]
Try and *actually* use clang for the clang build.

Fixes: #67

6 years agoFix resource leak.
David Given [Sat, 2 Jun 2018 18:59:11 +0000 (20:59 +0200)]
Fix resource leak.

Closes: #75

6 years agoFormat.
David Given [Sat, 2 Jun 2018 18:57:43 +0000 (20:57 +0200)]
Format.

6 years agoCrudely bounds check some naked fscanf("%s") parsing. Fixes #79, mostly.
David Given [Sat, 2 Jun 2018 18:51:41 +0000 (20:51 +0200)]
Crudely bounds check some naked fscanf("%s") parsing. Fixes #79, mostly.

6 years agoMerge pull request #85 from davidgiven/dtrg-ed
David Given [Sat, 2 Jun 2018 16:23:19 +0000 (19:23 +0300)]
Merge pull request #85 from davidgiven/dtrg-ed

Fix the incompatibility with modern ed

6 years agoDon't need ed any more in the travis configuration.
David Given [Sat, 2 Jun 2018 16:08:55 +0000 (18:08 +0200)]
Don't need ed any more in the travis configuration.

6 years agoAdopt a copy of Minix 2's ed; this allows the ACK's antiquated ed scripts to
David Given [Sat, 2 Jun 2018 16:02:51 +0000 (18:02 +0200)]
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

6 years agoMerge pull request #81 from kernigh/kernigh-libfp
David Given [Fri, 11 May 2018 22:59:05 +0000 (00:59 +0200)]
Merge pull request #81 from kernigh/kernigh-libfp

software floats, line editor for CP/M

6 years agoUpdate cpm/README for console changes, `ack -fp`.
George Koehler [Mon, 7 May 2018 20:08:44 +0000 (16:08 -0400)]
Update cpm/README for console changes, `ack -fp`.

6 years agoBuild a smaller startrek for CP/M.
George Koehler [Fri, 4 May 2018 22:32:24 +0000 (18:32 -0400)]
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.

6 years agoEnable the line editor in read() for CP/M.
George Koehler [Fri, 4 May 2018 22:21:01 +0000 (18:21 -0400)]
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.

6 years agoChange readstring() to use buffered input.
George Koehler [Fri, 4 May 2018 22:06:51 +0000 (18:06 -0400)]
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.

6 years agoUse `ack -mcpm -fp` for mandelbrot.c, startrek.c
George Koehler [Sat, 28 Apr 2018 17:18:27 +0000 (13:18 -0400)]
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.

6 years agoOptimize libfp. Don't lose -O6 in ackcflags.
George Koehler [Thu, 26 Apr 2018 02:48:28 +0000 (22:48 -0400)]
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.

6 years agoTeach i80 ncg to use libfp. Enable `ack -mcpm -fp`.
George Koehler [Wed, 25 Apr 2018 20:09:56 +0000 (16:09 -0400)]
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.

6 years agoBuild (but don't use) libfp for cpm.
George Koehler [Wed, 25 Apr 2018 04:17:19 +0000 (00:17 -0400)]
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.

6 years agoMerge pull request #73 from kernigh/kernigh-pr
David Given [Tue, 13 Mar 2018 12:57:28 +0000 (13:57 +0100)]
Merge pull request #73 from kernigh/kernigh-pr

better code from PowerPC ncg and mcg

6 years agoCheck LOI expressions to prevent a read after free.
George Koehler [Tue, 13 Mar 2018 00:58:31 +0000 (20:58 -0400)]
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

6 years agoDon't read INSTR(l) after oldline(l) frees it.
George Koehler [Mon, 12 Mar 2018 00:10:13 +0000 (20:10 -0400)]
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.