Commit graph

290 commits

Author SHA1 Message Date
George Koehler 007a63d529 Begin to add long long to C compiler for linux386.
Add long long type, but without literals; you can't say '123LL' yet.
You can try constant operations, like `(long long)123 + 1`, but the
compiler's `arith` type might not be wide enough.  Conversions,
shifts, and some other operations don't work in i386 ncg; I am using a
union instead of conversions:

	union q {
		long long ll;
		unsigned long long ull;
		int i[2];
	};

Hack plat/linux386/descr to enable long long (size 8, alignment 4)
only for this platform.  The default for other platforms is to disable
long long (size -1).

In lang/cem/cemcom.ansi,

 - BigPars, SmallPars: Add default size, alignment of long long.
 - align.h: Add lnglng_align.
 - arith.c: Convert arithmetic operands to long long or unsigned long
   long when necessary; avoid conversion from long long to long.
   Allow long long as an arithmetic, integral, or logical operand.
 - ch3.c: Handle long long like int and long when erroneously applying
   a selector, like `long long ll; ll.member` or `ll->member`.  Add
   long long to integral and arithmetic types.
 - code.c: Add long long to type stabs for debugging.
 - conversion.c: Add long long to integral conversions.
 - cstoper.c: Write masks up to full_mask[8].  Add FIXME comment.
 - declar.g: Parse `long long` in code.
 - decspecs.c: Understand long long in type declarations.
 - eval.c: Add long long to operations, to generate code like `adi 8`.
   Don't use `ldc` with constant over 4 bytes.
 - ival.g: Allow long long in initializations.
 - main.c: Set lnglng_type and related values.
 - options.c: Add option like `-Vq8.4` to set long long to size 8,
   alignment 4.  I chose 'q', because Perl's pack and Ruby's
   Array#pack use 'q' for 64-bit or long long values; it might be a
   reference to BSD's old quad_t alias for long long.
 - sizes.h: Add lnglng_size.
 - stab.c: Allow long long when writing the type stab for debugging.
   Switch from calculating the ranges to hardcoding them in strings;
   add 8-byte ranges as a special case.  This also hardcodes the
   unsigned 4-byte range as "0;-1".  Before it was either "0;-1" or
   "0;4294967295", depending on sizeof(long) in the compiler.
 - struct.c: Try long long bitfield, but it will probably give the
   error, "bit field type long long does not fit in a word".
 - switch.c: Update comment.
 - tokenname.c: Define LNGLNG (long long) like LNGDBL (long double).
 - type.c, type.str: Add lnglng_type and ulnglng_type.  Add function
   no_long_long() to check if long long is disabled.
2019-09-02 11:24:44 -04:00
David Given 97d22973ee Add some BIOS bindings, and a zero-terminated print string routine. 2019-06-24 23:07:17 +02:00
David Given ac8edcbfc3 Give up trying to make the B tests pass on CP/M. 2019-06-17 23:33:58 +02:00
David Given 97e6baa052 Fix register corruption when incrementing locals; attempt to solve the
alignment issue.
2019-06-17 23:31:54 +02:00
David Given c2f48772e9 Correctly emit \r\n when a \n is written to the console, instead of \n\n...
Fixes: #198
2019-06-17 23:31:16 +02:00
David Given 0ecad6c860 Warning fix. 2019-06-17 23:29:41 +02:00
David Given 94867d24b7 Ensure that procedure labels are word aligned (required by the EM spec). 2019-06-17 22:26:31 +02:00
David Given 402468f6fd Bugfix the CP/M FCB parser, and add a test for it. 2019-06-17 00:41:49 +02:00
David Given 97e6d8f66a Update README. 2019-06-16 20:10:13 +02:00
David Given 2b013c34dc Some byte shaving; lseek returns the offset. 2019-06-16 20:04:07 +02:00
David Given 50dca8b954 First at-least-slightly working version of the CP/M read/write stuff. Not as
bad as I expected, but far too big.
2019-06-16 19:04:17 +02:00
David Given 3131dc9915 Partially working port of stdio to CP/M. I'm not sure this will work; it's
getting way too complicated (stdio is horribly subtle). I think I need to
rethink things.
2019-06-15 22:22:01 +02:00
David Given 9109d7af7f First stage in modularising FILE*. Refactor so that printf/scanf don't rely on
FILE* innards; allow plats to replace the entire emulated FILE* system.
2019-06-15 13:07:10 +02:00
David Given 784fc67596 Alignment issues mean we can't access 16-bit CP/M structure elements directly. 2019-06-11 22:33:25 +02:00
David Given 0607529df2 Miscellaneous bugfixed and renamings. 2019-06-11 21:33:57 +02:00
David Given a804375560 Miscellaneous byte shaving; you can now choose whether or not you want the CCP
overwritten or not, and cpm_exit() does the right thing.
2019-06-11 20:32:00 +02:00
David Given 3feb79ad0c Simplify the .trp API to make it a bit smaller. 2019-06-11 20:02:03 +02:00
David Given 4e90de00e9 Don't pull in all the trap handlers every time. 2019-06-11 19:47:42 +02:00
David Given f58d7e7d30 Add missing file. 2019-06-11 19:40:46 +02:00
David Given 48a9c48f56 Generate traps procedurally. For some reason they always keep getting pulled
in, though...
2019-06-11 00:12:00 +02:00
David Given ec2ea1feff Add missing file. 2019-06-10 23:57:43 +02:00
David Given d0967e683b Extend the CP/M libsys with a full set of (hopefully correct) 2.2 BDOS calls. 2019-06-10 23:54:23 +02:00
David Given 3f938d651b EM requires 2-alignment in structures, sadly. 2019-06-10 18:33:04 +02:00
George Koehler bec236c108 Include more headers to declare functions.
This causes clang to give fewer warnings of implicit declarations of
functions.

In mach/pdp/cv/cv.c, rename wr_int2() to cv_int2() because it
conflicts with wr_int2() in <object.h>.

In util/ack, rename F_OK to F_TRANSFORM because it conflicts with F_OK
for access() in <unistd.h>.
2019-03-22 15:59:35 -04:00
George Koehler 84f65f7ce3 Raise _XOPEN_SOURCE from 500 to 700
In OpenBSD, _XOPEN_SOURCE 500 forces _POSIX_C_SOURCE down to 199506,
which hides the declarations of openat() and fdopendir() and causes
compiler warnings.

Don't set _POSIX_C_SOURCE, because _XOPEN_SOURCE may set
_POSIX_C_SOURCE to a different value.
2019-03-22 14:35:07 -04:00
David Given 79a38ecc08 Instead of using parameterised rsts for stack access, add a huge swathe of
automatically built helper tools. Star Trek goes up from 40243 to 40779 bytes,
but should be a lot faster.
2019-02-13 22:45:22 +01:00
David Given 073451dd44
Merge pull request #154 from ccodere/buildfix
Bugfix of compilation on gcc 4.8
2019-02-12 21:51:46 +01:00
carl 664338aa49 Fix compilation issue on C90 compilers (gcc 4.8 was failing to compile with default flags) - updated following comment. 2019-02-13 00:17:45 +08:00
carl c63f527dde Fix compilation issue on C90 compilers (gcc 4.8 was failing to compile with default flags). 2019-02-12 00:46:09 +08:00
David Given 34e9573929 Merge from default. 2019-02-10 23:40:07 +01:00
David Given 666d9a3edb Add stray header. 2019-02-10 12:57:00 +01:00
David Given aa6aefdaa0 Add missing header. 2019-02-10 00:45:09 +01:00
David Given 810afbb5b9 Don't run the floating point tests on i80. 2019-02-09 14:24:31 +01:00
David Given bcc9c16bf7 More z80ex removal. 2019-02-09 13:42:09 +01:00
David Given 343cdf7983 Remove stray z80ex reference. 2019-02-09 13:30:29 +01:00
David Given 19f5ee3399 CP/M sbrk now handles overflow correctly. 2019-02-08 21:43:52 +01:00
David Given 22032575c5 Add a 'disassemble' command to the CP/M emulator. 2019-02-08 20:54:44 +01:00
David Given b47d59aa4a Merge from default. 2019-02-07 23:45:47 +01:00
David Given 8876ddcad2 Build the CP/M tests (which got turned off accidentally). Add a disassembler to
the emulator debugger.
2019-02-07 23:36:45 +01:00
David Given 7473601172 Add the cpm emulator from Cowgol, modified to work with an 8080 emulator rather
than libz80ex; enable tests for cpm.
2019-02-07 22:39:57 +01:00
David Given 5ac280026e Experimentally use rst 1 to optimise frame variable loads. Reduces Star Trek
from 43892 to 43205 bytes.
2019-02-07 00:06:32 +01:00
David Given 365c89c9e7 Updated READMEs with the MIPS platform. 2018-09-18 23:49:31 +02:00
David Given 9333b323a5 Make the MIPS boot code produce correct code. 2018-09-18 23:39:04 +02:00
David Given ec0891469f Array descriptor ranges are inclusive; adjust aar and the tests to check for
this. All the tests except rotate build now!
2018-09-17 19:34:38 +01:00
David Given b81e060372 Add huge numbers of failing tests. 2018-09-10 23:40:03 +02:00
David Given 776e93221f Thinko fix. 2018-09-09 18:57:44 +02:00
David Given c769fbec93 Use the correct ELF processor flags; align properly. 2018-09-09 18:57:35 +02:00
David Given f3bc9ef92a Call proper Linux system calls proper-like. 2018-09-09 18:57:12 +02:00
David Given ec46643124 Allow the ELF processor flags to be set. Generate MIPS ELF executables, not
PowerPC ones.
2018-09-09 14:29:34 +02:00
David Given 26fe3f7530 Added library skeletons. 2018-09-05 00:07:07 +02:00