Commit graph

198 commits

Author SHA1 Message Date
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 1d4ddb939d Merge from trunk. 2018-06-08 00:05:50 +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 5034ed1c39 Crudely beat the standard Masushi simulator into working in the ACK framework. 2018-06-05 17:45:00 +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 0eb89d5d95 Add a clean copy of the Musashi emulator. 2018-06-05 17:04:47 +09: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
George Koehler 019c7f9da7 Update cpm/README for console changes, ack -fp. 2018-05-07 16:08:44 -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 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 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
David Given 09e7d8f3d0 I figured out how to get top working. 2018-02-23 22:42:38 +01:00
David Given 4b5a7fee14 Made the cgg and the cg code generator work; use this to beat the PDP/11
backend into shape. It now generates binaries --- no idea whether they work or
not.
2018-02-23 22:31:46 +01:00
George Koehler b3c0a767a5 Sync qemuppc with linuxppc.
- Don't reverse bitfields; do use ego (41f3bf7).
 - Use MACHOPT_F=-m2 (3dae9e4).
 - Remove old trap.s (26de4c1).

At this commit, one can build qemuppc with mcg by editing the root
build.lua to uncomment "qemuppc" in "vars.plats".  If one also
uncomments "qemuppc" from "vars.plats_with_tests", then mcg fails to
build the tests.  If one uses ncg (by editing plat/qemuppc/descr to
change "mcg" to "ncg"), then the tests pass.
2018-01-27 21:41:13 -05:00
George Koehler cdde55535e For osxppc, change size 8 to alignment 4.
You may need to delete and recompile some .o files!  This changes the
alignment of 8-byte values in C structs to match what Apple's gcc
does.  See Apple's "32-bit PowerPC Function Calling Conventions" at

    https://developer.apple.com
      /library/content/documentation/DeveloperTools/Conceptual/LowLevelABI
      /100-32-bit_PowerPC_Function_Calling_Conventions/32bitPowerPC.html
2018-01-27 16:35:48 -05:00
George Koehler 3dae9e49cc Use subfic (val - reg) and mulli (reg * val).
In the instruction list, put /* kills xer */ for sraw, srawi, subfic;
and correct the (now unused) "addi." and "lfdu".

Change MACHOPT_F from -m3 to -m2.  This changes the code for 15 * i
from

    slwi r3,r4,4
    subfic r5,r4,0
    add r3,r3,r5

to

    mulli r3,r4,15

If the sequence "slwi subfic addi" takes 3 cycles and 12 bytes, and
mulli takes 3 cycles and 4 bytes, then mulli is better.
2018-01-27 15:53:05 -05:00
George Koehler c6ceaac1af Make osx386 and osxppc use _hol0.s like the other platforms.
Because I'm lazy, I didn't make another copy of _hol0.s; I am building
plat/linux/libsys/_hol0.s for OS X.
2018-01-23 13:55:39 -05:00
George Koehler f1304e1a3c Use extended mnemonics and ha16/lo16.
Remove wrong comment: that's a right shift, not a left shift.
2018-01-11 20:04:27 -05:00
George Koehler 103d44c27c Rewrite sigaction() to prevent another race.
A signal handler might call sigaction().  We must block all signals,
not only our signal, to prevent a race between us and the next signal
handler.

Use /* comments */ because cpp might expand macros in ! comments
though such expansion is probably harmless.

The bridge is now shorter by 2 instructions.
2018-01-11 17:59:02 -05:00
George Koehler 2b09d3756c These are EM trap numbers.
Remove .sect; absolute symbols don't go in a section.
2018-01-09 00:40:11 -05:00
George Koehler de2c7c3f25 Hide some i386 stuff from linux68k, linuxppc.
Rename plat/linux/libsys/errno.s to plat/linux386/libsys/trapno.s and
stop building it for linux68k and linuxppc.  It defines symbols for
mach/i386/libem.

In syscalls.h, the numbers after 165 are only for i386, so hide them
from 68k, ppc.  These numbers are unused, because the system calls now
in libsys use the lower numbers.

Also teach the build system that libsys depends on the internal
headers in plat/linux/libsys/*.h
2018-01-08 23:46:30 -05:00
George Koehler 26de4c1ab1 Add test for EM _rck_. Fix traps in PowerPC ncg.
The new test rck_e.e segfaults on PowerPC unless I make some changes.
The inline code for _rck_ was wrong because it didn't allow the trap
handler to return.  _sig_ forgot to push the old trap handler.

Move plat/linuxppc/libsys/trap.s to mach/powerpc/libem/trp.s and
rewrite it with simplified/extended mnemonics.  Remove .trap alias for
.trp procedure.  Add a missing `mtspr lr, r0` so we can return from
the trap handler.  Call write() and _exit() so trp.s works with both
linuxppc and osxppc.  Before, Mac OS X was wrongly using the trap.s
for Linux.

In powerpc/libem, simplify .aar4; teach .csa and .csb to raise the
trap if the default target is zero.

C programs don't need these changes.  You may relink your C programs
with the changed .csa and .csb, but C code doesn't raise the trap.
Modula-2 code can raise traps, so you may want to relink your Modula-2
programs with the changed libem, but you might keep your old .o files
from Modula-2.  You may need to recompile your Pascal programs (delete
old .o files from Pascal) because the Pascal compiler might use _rck_.
2017-12-24 22:37:52 -05:00
George Koehler 41f3bf78cd Edit descr for linuxppc. Use powerpc.descr of ego.
ack -mlinuxppc -O4 now runs more phases of ego, including the register
allocation phase, so ncg emits better code.

Set MACHOPT_F=-m3 as I did it for osxppc; see commit 0c2b6f5.

Remove CC_ALIGN=-Vr so bitfields agree with gcc for PowerPC Linux.

Remove unused C_LIB and OLD_C_LIB.
2017-10-18 13:23:01 -04:00
David Given a96c846a29 Don't build mcg as part of linuxppc; it's not used and crashes Travis. 2017-08-06 13:54:07 +02:00
George Koehler a585ddf578 Fix parameters of signal handlers for linuxppc.
Linux passes the arguments in registers, but our compiler expects
arguments on the stack.  Signal handlers got garbage instead of the
signal number.  Some handlers, like the one in lang/m2/libm2/sigtrp.c,
need the correct signal number.

I write a "bridge" in PowerPC assembly that moves the arguments to the
stack.  I put the bridge in sigaction(), so I provide a signal() that
calls sigaction().  I remove the *.c glob or wildcard from build.lua,
so linuxppc only compiles its own signal.c, not the other signal.c for
linux386 and linux68k.

My bridge uses sigprocmask(), so I also add sigprocmask().  Because
linux386 and linux68k use globs, they also get sigprocmask().  I sync
the header files so all three Linux platforms declare execve(),
sigprocmask(), and unlink(), but not remove(), because we have
remove() in <stdio.h>.

I am using sigaction.s to test some features that we recently added to
our PowerPC assembler.  These are the "hi16[...]" and "lo16[...]"
syntax, and also the extended names like "beq", "cmpwi", "li", "subi".
2017-01-22 00:52:32 -05:00
David Given 81c677d218 Add a bunch more set operations to the PowerPC backends, and the Pascal test
for the same.
2017-01-17 22:31:38 +01:00
David Given e7e29d34ff Add a test (currently failing) to check that Pascal char sets can store all 256
possible values. Add the PowerPC ncg and mcg backend support to let the test
actually run, including modifying a bunch of PowrePC libem functions so that
they can be called from both ncg and mcg.
2017-01-15 22:28:14 +01:00
David Given 51862cff82 Merge pull request #32 from dram/add-execve
Add execve() system call for Linux
2017-01-07 23:23:00 +01:00
David Given abbead482a Sections are now aligned (required by the EM spec). 2017-01-07 18:47:46 +01:00
Xin Wang 24d26b2826 Add execve() system call for Linux 2017-01-06 18:33:52 +08:00
David Given 0e10329876 Fix an issue throughout where B couldn't be built by ackprogram due to symbol
laziness.
2016-12-29 17:11:53 +00:00
David Given a43258fe9d Build the B compiler and standard library (also the Basic one, which was
missing).
2016-12-29 17:11:07 +00:00
David Given 3cdceaa700 Merge in B changes. 2016-12-28 17:30:14 +00:00
David Given e50f4be710 Merge from default. 2016-12-26 19:44:48 +00:00
George Koehler df86e3b84f Fix typo: msr0 should be msr. 2016-12-09 16:04:21 -05:00
George Koehler d94ea4c508 Teach qemuppc to halt the cpu on _exit().
Without this, qemu-system-ppc spins the host cpu until I close its
window.  I assume the default G3 emulation.  The emulator yields the
host cpu if I set certain flags in hid0 then msr.  The hid0 flag can
be any of DOZE, NAP, SLEEP, so I just set all 3.  I encode mfmsr and
mtmsr with .data4, because our assembler doesn't know instructions for
supervisor mode.

Also move some common symbols from .rom to .bss.  Our assembler puts
common symbols in any section.

Also clean up the file.  Delete a comment about linuxppc that is wrong
here.  Delete redundant .extern because .define is the same.
2016-12-07 18:11:12 -05:00
George Koehler 6cbea83f7f Don't share as, ncg, top between Linux and Mac OS X.
Telling osx386 and osxppc to build and run their own tools, not to
reuse the tools from linux386 and linuxppc.  This wastes time to build
identical tools, but it removes some bogus dependencies.  OS X tools
had wrongly depended on Linux descr files and aelflod; now they don't.

Discussion in https://github.com/davidgiven/ack/pull/23
2016-12-05 20:13:29 -05:00
David Given c569ca15d8 Clean up how the language libraries refer to plat headers; they should be using
the +pkg forms of the rules and getting the headers via the paths in descr,
rather than depending on the +headers version.
2016-12-05 21:05:24 +01:00
David Given c5aff6fc2e Change dependency from simplerule{} with a dependency but no outputs to an
installable; otherwise, the dependency would be built, but the result wouldn't
get added to the header path and so wouldn't be seen.
2016-12-05 20:33:26 +01:00
George Koehler 969e98b82d Create Mach-o files with mode 0777 to allow executing them.
Until now, I was always doing chmod +x before running my files on the
Mac.  Now files get created +x.  There's no change when overwriting
an existing file.  I needed to gmake clean my build to remove the
example programs without +x, so cvmach can create them with +x.
2016-12-03 17:52:24 -05:00
George Koehler 355cc06fff Write README files for osx386 and osxppc. 2016-12-03 17:17:44 -05:00
George Koehler 25e159c930 Remove bad overflow check from plat/osx/libsys/brk.c
If I want to check for overflow, then I should check it before I do
base + incr, not after.

Now that I have no check, I am passing the overflowed base + incr to
brk1(), where it will probably fail the nbreak < segment check.
2016-12-03 17:07:51 -05:00
George Koehler e06b1fa05e Write a manual page for cvmach(6).
This manual is in the new mdoc(7) format.  All existing ack manuals
use the old man(7) format.  This might be a problem if someone can't
display mdoc(7) files.

The build system doesn't install the cvmach(6) manual; that might
happen later.  The current build system installs manuals in two
different places, and doesn't install some manuals, so I don't know
what to do.
2016-12-02 18:04:06 -05:00