Commit graph

7056 commits

Author SHA1 Message Date
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
George Koehler 5c62ec2d8f Assume ANSI C in modules/src/flt_arith
Remove the #include "ansi.h" and always use the prototypes.
2016-11-05 16:24:18 -04:00
David Given 4ba409eb74 Ensure the modules properly depend on their headers. 2016-11-05 11:52:54 +01:00
David Given fee47b25c3 Merge from default. 2016-11-05 11:47:53 +01:00
David Given 7f64fe96c7 Properly declare the library headers as dependencies. 2016-11-05 11:47:36 +01:00
David Given 4fa2c94a4a Correctly mangle labels used in initialisers. 2016-10-31 23:21:33 +01:00
David Given 9261cd978d Typo fix. 2016-10-31 23:16:02 +01:00
David Given 941072e0d7 Add, I hope, patterns for fmsub, fnmadd, and fnmsub (also float versions). 2016-10-31 22:36:54 +01:00
David Given 44f0cea6ca Also use fmadd for single-precision floats. 2016-10-31 19:55:16 +01:00
David Given 064d1a5d5d Use fmadd for multiply-and-add instructions. 2016-10-31 19:52:17 +01:00
David Given e19850b114 Fix a few c11isms. 2016-10-30 16:51:06 +01:00
David Given 694d1e2deb Merge from default. 2016-10-30 15:59:44 +01:00
David Given db03785109 Merge pull request #7 from davidgiven/travis
Use built-in Lua rather than relying on a system one
2016-10-30 15:59:04 +01:00