Commit graph

7068 commits

Author SHA1 Message Date
David Given 2d0bc7ef0d Finally fix the build system issue where ackprogram would try to explicitly
link all the language libraries.
2016-11-20 18:57:44 +01:00
David Given 953c08839f inn works now; add a helper for it. 2016-11-20 12:53:44 +01:00
David Given 196fa914b3 lxa now works, I hope; traps are better (and stubbed out on qemuppc). 2016-11-20 11:57:21 +01:00
David Given d5328492d7 Better handling of float conversions; more tests; converting to unsigned ints
works now.
2016-11-20 11:27:40 +01:00
David Given 132baac78a Add some more tests. 2016-11-20 10:46:53 +01:00
David Given 84c7b6ba90 No, sudo doesn't get openbios-ppc installed. I added a whitelisting request:
https://github.com/travis-ci/apt-package-whitelist/issues/3745
2016-11-20 10:36:30 +01:00
David Given 3f45a7d633 Need sudo to install openbios-ppc. 2016-11-20 10:09:58 +01:00
David Given 5423a175c6 Install openbios on Travis (needed by qemu-system-ppc). 2016-11-20 10:00:59 +01:00
David Given 454a7494bb cif8 and cuf8 work now. More tests. 2016-11-19 11:42:30 +01:00
David Given cc660b230f Floats and doubles are now written out correctly. 2016-11-19 11:39:13 +01:00
David Given db3564f35a Use .hol0 as an additional name for hol0; mcg requires it. 2016-11-19 11:09:07 +01:00
David Given d31bc6a3f9 Made csa and csb work with mcg; adjust the libem functions and the
corresponding invocation in the ncg table so the same helpers can be used for
both mcg and ncg. Add a new IR opcode, FARJUMP, which jumps to a helper
function but saves volatile registers.
2016-11-19 10:55:41 +01:00
David Given 5208e5f751 Yet another OB1 stack format fix. 2016-11-19 10:42:22 +01:00
David Given a4616b7124 Betterer timeout handling. 2016-11-17 22:04:50 +01:00
David Given 43439c6d0c Remember to push the result of lor onto the stack. 2016-11-17 22:04:32 +01:00
David Given 745eb8f17b Now _errsym and _erlsym are defined in the standard library, don't define them
in the program.
2016-11-16 21:13:00 +01:00
David Given c25ad82a89 Tests can now specify (via a hacky filename suffix) which runtime they want. 2016-11-16 21:08:03 +01:00
David Given 71e6ca26d5 Add another test. 2016-11-16 20:56:45 +01:00
David Given 81bc2c74c5 A bb's regsin are no longer the same as those of its first instruction;
occasionally the first hop of a block would try to rearrange its registers (due
to evicted throughs), resulting in the phi moves copying values into the wrong
registers.
2016-11-16 20:52:15 +01:00
David Given edfee33576 Cleanup; the test driver is now way more robust. 2016-11-16 20:50:14 +01:00
David Given 581fa4a457 Reenable eviction of corrupted registers, which had been broken by a previous
change. Change the register move code to get swaps right, or at least righter.
2016-11-15 21:55:10 +01:00
David Given 86c832ef86 Put saved registers in *actually* the write place. I hope. 2016-11-15 21:54:15 +01:00
David Given cc686ded62 Get subtractions the right way round. 2016-11-15 20:25:11 +01:00
David Given 5e8babf098 Add a basic integer shift test. 2016-11-14 22:12:13 +01:00
David Given c6bce0aaee Add basic integer comparison test. 2016-11-14 22:01:25 +01:00
David Given 0289b1004e Allow values left on the stack at the end of the procedure (it's legal!). 2016-11-14 21:47:49 +01:00
David Given 408b69b17d aelflod and aslod now default to not showing the memory dump. 2016-11-13 20:50:23 +01:00
David Given 91c15c1c63 Precise's qemu package is qemu-system. 2016-11-13 14:20:14 +01:00
David Given 1ef4780af4 Typo fix. 2016-11-13 14:17:38 +01:00
David Given 0699e7af97 Attempt to enable the qemuppc tests on Travis. 2016-11-13 14:10:44 +01:00
David Given e7132183fb Fix buffer overrun: if LABEL_STARTER is seen but LABEL_TERMINATOR is not, the
label parser will keep going forever looking for the end of the label. It now
stops at the end of the string.
2016-11-13 14:04:58 +01:00
David Given 6a4f465f53 Add a rather bodged test framework for the qemuppc plat, which only runs if the
qemu-system-ppc emulator is installed.
2016-11-13 13:37:22 +01:00
David Given e9fe1d70a6 Fix (or at least, work around) an issue with library order. Make sure the Basic
error symbols are actually defined.
2016-11-13 13:28:09 +01:00
David Given f52cb45e49 Add just enough Open Firmware support for an output console. 2016-11-12 22:09:54 +01:00
David Given 48e74f46fc Add the very experimental qemuppc plat, intended to generate minimal images
which can be emulated using qemu (for, hopefully, a test suite). Currently it
generates images which won't run because there's no RAM.
2016-11-12 19:20:58 +01:00
David Given 852d3a691d Update the table to return call output values in the right registers. Fix the
register allocator so the corrupted registers only apply to throughs
(otherwise, you can't put output registers in corrupted registers).
2016-11-11 21:48:36 +01:00
David Given b5c1d622f5 Rework the way stack frames are laid out to be simpler and, hopefully, more
correct. Saved registers are now placed in what may be the right place.
2016-11-11 21:17:45 +01:00
David Given 84ee75ec07 Merge from default. 2016-11-11 20:17:54 +01:00
David Given d82df74a7a Rename addr_t to address_t to avoid clashes with the system addr_t. 2016-11-11 20:17:10 +01:00
David Given e7eb563ee9 Disable gethostid() in the build system Lua; it's unused and doesn't work on
Haiku.
2016-11-11 20:16:43 +01:00
David Given 4d7c27391f Merge. 2016-11-10 22:06:08 +01:00
David Given fd91851005 Add enough return types to the K&R C that the ACK builds (on Linux) using clang
now.
2016-11-10 22:04:18 +01:00
David Given 57cb99ade1 Remove sys_time in favour of directly calling time(). 2016-11-09 21:52:04 +01:00
David Given 07113c069b Merge pull request #9 from kernigh/fix-flt-trek
fixes for floating point and startrek
2016-11-07 20:15:48 +01:00
George Koehler 82c2d18482 Edit startrek.c so I can compile it with gcc and OpenBSD libc.
Rename our getline() to get_line() to prevent a conflict with POSIX
getline() declared in stdio.h.

Remove dangerous call to gets().  OpenBSD does not have gets(), C99
deprecated it and C11 removed it.

Also change spelling "sheild" to "shield".
2016-11-06 20:21:48 -05:00
George Koehler e5e96d5226 Convert 1 to 1.0, not 0.0, for machines with 64-bit long.
This fixes flt_arith2flt() when sizeof(arith) != 4, where arith is
long.  When cemcom.ansi sees an expression like d + 1 (where d is some
double), it calls flt_arith2flt() to convert 1 to floating-point.  On
machines where sizeof(arith) != 4, the code did n >>= 1 when n should
not have been changed.  If n was 1, then n == 0 became true.  This
caused the code to convert 1 or -1 to 0.0.

My fix assumes sizeof(arith) >= 8, so I can use n >> 32.  Machines
with sizeof(arith) of 5 to 7 would need to do (uarith)n >> 32, where
uarith must be an unsigned integer type of same size as arith.

In startrek.c, the Enterprise can now dock with a starbase.  The
compiler no longer translates s1 - 1 to s1 - 0.0 and s1 + 1 to s1 +
0.0, so the game now looks for starbases next to the Enterprise.
2016-11-06 19:34:51 -05:00
George Koehler 08f9869a63 Remove unused defines from lang/cem/libcc.ansi/math/localmath.h
This undoes part of bfeb736, and returns to using DBL_MAX_EXP and
DBL_MIN_EXP from float.h.

Add a dependency on math/localmath.h and other local header files so
libc is rebuilt when those headers change.
2016-11-06 15:49:47 -05:00
George Koehler 19ca28e22f Undo commit bfeb736 for lang/cem/libcc.ansi/headers/float.h
This restores the correct values of DBL_MAX, DBL_MIN_EXP, and related
constants.  This fixes some range checks within libc, causing
atof("-36e90") and atof("1.44e-288") to return the correct values.
2016-11-06 15:01:25 -05:00
George Koehler daeeb5aca3 Simplify flt_arith now that mantissa uses uint32_t.
It seems that someone wanted to build flt_arith with a compiler that
had long but not unsigned long.  This required extra code to
accomplish unsigned right shift, unsigned division, and unsigned
comparison using the signed operations.  Now that we use uint32_t, we
can simply use the unsigned operations and remove the ucmp() function.
We have similar code in mach/proto/fp/ and in
lang/cem/libcc.ansi/stdlib/ext_comp.c where we use the unsigned
operations.

Some long variables become uint32_t, and some masks with 0xFFFFFFFF
disappear because uint32_t has only 32 bits.

Update flt_arith.3 to show that mantissa uses uint32_t.

Provide a target to install modules/src/flt_arith/test.c as flt_test
so I can run the tests.
2016-11-05 21:51:53 -04:00
George Koehler 3bb41d3910 Switch flt_mantissa fields from long to uint32_t.
This seems to fix an error when flt_arith converts a literal
double-precision float to IEEE format.  For example, 0.5 and 0.75 got
converted to slightly below their correct values.

My host gcc for amd64 has 64-bit long, but flt_arith needs only 32
bits.  The code (at least flt_add.c) can make 32-bit overflows.  Such
overflows would set the higher bits of a 64-bit long, which might
cause problems later.

I need to use uint32_t and not int32_t because the code still uses
long, and the sign extension from int32_t to long would cause
problems.  The mantissa represents a value in [0, 2) that can't be
negative, so unsigned type is better.  Also, signed overflow is
undefined behavior in C, so flt_add.c better make overflows with
uint32_t and not int32_t.

This commit doesn't touch lang/cem/libcc.ansi/stdlib/ext_fmt.h which
continues to use unsigned long for its mantissa fields.
2016-11-05 17:00:24 -04:00