Commit graph

125 commits

Author SHA1 Message Date
David Given 9d8ea79c7f rst 1 now takes an eight-bit parameter, not a 16 bit one. Reduces Star Trek
again from 43205 to 42339 bytes.
2019-02-07 08:45:20 +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 08b92153a0 Use a helper function for cai --- only saves two bytes per invocation, but is
much less embarassing.
2019-02-06 20:36:23 +01:00
David Given 2b0629f87f Common out boilerplate function prologue code; shrinks Star Trek from 44256 to
43892 bytes.
2019-02-06 16:06:07 +01:00
David Given b77f616598 Run through clang-format before editing. 2019-02-06 11:50:05 +01:00
David Given 02779325ab Move the standard ret boilerplate into a helper procedure, to save a little
space.
2019-02-06 08:08:11 +01: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 a1d1f38691 Add test for EM rol, ror. Fix i80, i86, powerpc.
EM instructions _rol_ and _ror_ do rotate an integer left or right.
Our compilers and optimizers never emit _rol_ nor _ror_, but I might
want to use them in the future.

Add _rol_ and _ror_ to powerpc.  Fix `rol 4` and `ror 4` in both i80
and i86, where the rules for `rol 4` and `ror 4` seem to have never
been tested until now.
2017-12-07 17:16:21 -05:00
George Koehler c95bcac91d Correct the stack pointer when i80 shrinks an integer.
The code used `sphl` to set the stack pointer, but the correct value
was in de, not hl.  Fix by swapping the values of de and hl, so `sphl`
is now correct.  When we shrink an integer from 4 to 2 bytes, both
registers de and hl point to copies of the result, but only one
register preserves the stack below the result.

This fixes writehex() in tests/plat/lib/test.c, when I compile it with
ack -mcpm, so it preserves the pointer to "0123456789abcdef", so it
writes hexadecimal digits and not garbage.

This bug goes back to commit 157b243 of Mar 18, 1985, so the bug is
32 years old, and probably the oldest bug that I ever fixed.
2017-12-07 15:39:41 -05:00
George Koehler 34cf0c8b63 Kill registers a, de, when i80 ncg does Call libem.
I compiled tests/plat/lib/test.c with ack -mcpm, but i80 ncg did emit
wrong code in writehex(uint32_t) for

    "0123456789abcdef"[code & 0xf]

The code called '.and' to evaluate `code & 0xf`, then tried to call
'.cii' to narrow the result from 4 to 2 bytes, but it passed garbage
instead of 4 to '.cii'.  The rule for '.and' was

    pat and defined($1)
    kills ALL
    uses dereg={const2,$1}
    gen Call {label,".and"}

This failed to kill register de={const2,4}, so ncg pushed de,
expecting to push 4, but actually pushing garbage.

Fix such rules using `mvi a,...` or `lxi de,...` so ncg doesn't track
the token in the register.  This is like the i86 table.  A different
fix would use a dummy instruction `killreg a` or `killreg de` like the
m68020 table.

Also correct 1 to $1 when calling '.exg'.
2017-12-06 22:14:00 -05:00
George Koehler 5301cceee3 Declare machine-dependent functions in mach/proto/ncg
This breaks all machines because the declared return type void
disagrees with the implicit return type int (when I compile mach.c
with clang).  Unbreak i386, i80, i86, m68020, powerpc, vc4 by adding
the return types to mach.c.  We don't build any other machines; they
are broken since commit a46ee91 (May 19, 2013) declared void prolog()
and commit fd91851 (Nov 10, 2016) declared void mes(), with both
declarations in mach/proto/ncg/fillem.c.

Also fix mach/vc4/ncg/mach.c where type full is long, so fprintf()
must use "%ld" not "%d" to print full nlocals.
2017-11-13 14:23:44 -05:00
David Given e3f8fb84dc Change the i80 assembler to be three-pass, which allows forward references;
required for assembling B.
2016-12-29 17:08:53 +00: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 f67c98e239 Distributions are a pain --- let's not bother any more. Instead, we just tag
the repository and download a complete snapshot, old and ancient stuff and all.
2016-09-02 23:00:38 +02:00
David Given 612e38f1c6 Remove the old make-based build system, plus some big chunks of horribly
obsolete protomake build system.
2016-09-02 22:17:51 +02:00
David Given 262c5fedcf Biggish refactor to break cycles; my build rules were full of them. cpm builds,
which requires top and topgen.
2016-08-14 01:39:40 +02:00
David Given 88bd7ce126 Remove defunct pmfiles.
--HG--
branch : default-branch
2016-06-03 13:56:50 +02:00
David Given 11377070fd Update distribution files.
--HG--
branch : dtrg-buildsystem
2013-05-15 23:46:15 +01:00
David Given 07453d184a Top, topgen, aelflod. Moved the libraries back into the platform-specific
directories --- wrangling descr files was too hard. C programs can be built
for cpm, pc86, linux386, linux68k!

--HG--
branch : dtrg-buildsystem
rename : util/ack/build.mk => util/led/build.mk
rename : util/LLgen/build.mk => util/topgen/build.mk
2013-05-13 23:26:15 +01:00
David Given 442306d557 Split off some of the platform-independent stuff (such as as and ncg).
--HG--
branch : dtrg-buildsystem
rename : plat/pc86/build.mk => mach/i386/build.mk
rename : plat/pc86/build.mk => mach/i80/build.mk
rename : plat/pc86/build.mk => mach/i86/build.mk
rename : plat/pc86/build.mk => mach/m68020/build.mk
rename : plat/pc86/build.mk => mach/powerpc/build.mk
2013-05-13 22:12:46 +01:00
George Koehler 0131ca4d46 Delete 689 undead files.
These files "magically reappeared" after the conversion from CVS to
Mercurial.  The old CVS repository deleted these files but did not
record *when* it deleted these files.  The conversion resurrected these
files because they have no history of deletion.  These files were
probably deleted before year 1995.  The CVS repository begins to record
deletions around 1995.

These files may still appear in older revisions of this Mercurial
repository, when they should already be deleted.  There is no way to fix
this, because the CVS repository provides no dates of deletion.

See http://sourceforge.net/mailarchive/message.php?msg_id=29823032
2012-09-20 22:26:32 -04:00
dtrg 54ce3f451b Configured distr system for the 6.0pre3 release. 2007-04-29 23:09:24 +00:00
dtrg df088c184b Added optimised rules for int<<8 and uint>>8 (which can be done with simple register shuffling rather than calling .sli). 2007-04-29 23:00:31 +00:00
dtrg be8baf3da6 Added cpm platform. 2007-04-27 22:42:41 +00:00
dtrg 440d6faadd Fixed a bug where loc lol stf was getting the constant pushed onto the stack *after* stf had popped it off. 2007-04-27 22:15:31 +00:00
dtrg 097c640a6c First version in CVS. 2006-07-20 23:24:28 +00:00
dtrg 4fdd9b83fc Converted to use termios, not sgtty. (pbetti@e-tech.net) 2005-08-10 22:48:40 +00:00
ceriel cdb362b628 removed 1995-12-06 14:04:51 +00:00
ceriel 1db6a3029b Header --> Id 1994-06-24 14:02:31 +00:00
ceriel 6f03cff48f Some minor modifications reflecting some changes in the peephole optimizer 1992-09-01 09:39:15 +00:00
ceriel 934e140c98 Fixed proto.make 1991-09-18 10:03:49 +00:00
ceriel 16b2c7c173 Fixed mach_params 1991-09-18 09:58:12 +00:00
ceriel 1d6a5c84b6 system-call to MON mapping is in libsys 1991-09-17 09:47:16 +00:00
ceriel 5c64a8d1ea install libmon AND libsys 1991-09-12 12:01:08 +00:00
ceriel b21d0acbdd new installation mechanism 1991-09-04 11:22:19 +00:00
ceriel 564cbc6eba Only call NOP routine when debugging table 1991-09-04 10:55:52 +00:00
ceriel 5d9dc323e9 New installation mechanism 1991-09-02 15:46:16 +00:00
ceriel 3168ce61ae New installation mechanism 1991-08-28 12:02:16 +00:00
ceriel c7edcc34d6 New installation mechanism 1991-08-27 10:47:25 +00:00
ceriel 22378eaff8 produce commons for newlbss 1991-03-18 15:06:01 +00:00
ceriel b893ec7013 m_a_i_n --> _m_a_i_n 1991-03-06 14:26:16 +00:00
ceriel 0d65b92220 removed -i flag 1991-02-19 16:57:39 +00:00
ceriel 91ee73faa3 made Makefile more portable 1990-11-27 16:51:58 +00:00
eck 4ef2c70ed3 added stackheight message handling 1990-07-18 14:53:19 +00:00
ceriel 89b736ba83 Added mechanism to warn correctly about conflicts 1990-01-19 16:05:44 +00:00
eck 78d3e500fb added CPP variable to Makefile 1989-10-20 11:05:00 +00:00
ceriel c820d77690 new floating point constant mechanism 1989-07-10 16:52:02 +00:00
ceriel c29ac899da added -L flag 1988-07-13 18:32:06 +00:00
ceriel 2f7e414d42 corrected lint entry 1988-06-28 14:36:21 +00:00
ceriel 6535d32447 Added libm2 1988-04-08 13:39:19 +00:00