ack.git
5 years agoTurn lol; loc 1; adu w; stl into inl. (And for subtractions.) dtrg-8080
David Given [Wed, 13 Mar 2019 21:12:00 +0000 (22:12 +0100)]
Turn lol; loc 1; adu w; stl into inl. (And for subtractions.)

5 years agoIn certain common operations, don't leave values in A because they just get
David Given [Wed, 13 Mar 2019 19:34:29 +0000 (20:34 +0100)]
In certain common operations, don't leave values in A because they just get
coerced into a 16-bit register, which is wasteful.

5 years agoOptimise the case when a 8-bit value is being written to a local and then
David Given [Tue, 12 Mar 2019 23:57:07 +0000 (00:57 +0100)]
Optimise the case when a 8-bit value is being written to a local and then
immediately read back from the local.

5 years agoMerge pull request #177 from davidgiven/dtrg-8080
David Given [Mon, 11 Mar 2019 16:00:12 +0000 (17:00 +0100)]
Merge pull request #177 from davidgiven/dtrg-8080

i80: Better peephole optimiser rules

5 years agoDon't buffer overflow when trying to process source bytes with the high bit
David Given [Mon, 11 Mar 2019 13:50:30 +0000 (13:50 +0000)]
Don't buffer overflow when trying to process source bytes with the high bit
set.

5 years agoAdd a 'kill' pseudoinstruction to the 8080 assembler, which marks when the code
David Given [Fri, 8 Mar 2019 22:06:34 +0000 (23:06 +0100)]
Add a 'kill' pseudoinstruction to the 8080 assembler, which marks when the code
generator is finished with a register; use this to create some more effective
peephole optimiser rules.

5 years agoMerge pull request #174 from ccodere/carl-ansi-part1
David Given [Thu, 7 Mar 2019 19:51:08 +0000 (20:51 +0100)]
Merge pull request #174 from ccodere/carl-ansi-part1

Carl ansi part1

5 years ago+ Better type checking in function tables.
carl [Fri, 1 Mar 2019 17:41:01 +0000 (01:41 +0800)]
+ Better type checking in function tables.

5 years ago+ M2 Compiler ISO C90 compatibility
carl [Fri, 1 Mar 2019 17:39:25 +0000 (01:39 +0800)]
+ M2 Compiler ISO C90 compatibility
* Fixing of potential crash issue with function tables in compiler.
+ SYSTEM.h is now renamed to SYSTEMM2.h to avoid conflicts on non case sensitive filesystems.

5 years agoCPP ISO C90 compatibility and conversion.
carl [Fri, 1 Mar 2019 17:36:11 +0000 (01:36 +0800)]
CPP ISO C90 compatibility and conversion.

5 years agoBasic compiler is now ISO C90 compliant.
carl [Fri, 1 Mar 2019 17:35:09 +0000 (01:35 +0800)]
Basic compiler is now ISO C90 compliant.

5 years agoMerge pull request #173 from ccodere/carl-ansi-part1
David Given [Mon, 25 Feb 2019 22:23:04 +0000 (23:23 +0100)]
Merge pull request #173 from ccodere/carl-ansi-part1

Carl ansi part1

5 years agoFix issue again with wrong macro on error.
carl [Mon, 25 Feb 2019 16:46:10 +0000 (00:46 +0800)]
Fix issue again with wrong macro on error.

5 years ago* Fix more tabs.
carl [Mon, 25 Feb 2019 16:44:52 +0000 (00:44 +0800)]
* Fix more tabs.

5 years ago* Convert spaces -> tabs to keep consistency with existing code.
carl [Sat, 23 Feb 2019 17:15:23 +0000 (01:15 +0800)]
* Convert spaces -> tabs to keep consistency with existing code.

5 years ago* Remove some more compiler warnings.
carl [Sat, 23 Feb 2019 16:46:05 +0000 (00:46 +0800)]
* Remove some more compiler warnings.

5 years agoBugfix of fprint using correct output redirection (fix from last commit).
carl [Sat, 23 Feb 2019 16:45:35 +0000 (00:45 +0800)]
Bugfix of fprint using correct output redirection (fix from last commit).

5 years agoPascal compiler better type checking and function declarations (Better ISO C compatib...
carl [Sat, 23 Feb 2019 16:44:50 +0000 (00:44 +0800)]
Pascal compiler better type checking and function declarations (Better ISO C compatibility)

5 years agoMerge pull request #172 from ccodere/carl-ansi-part1
David Given [Wed, 20 Feb 2019 18:36:49 +0000 (19:36 +0100)]
Merge pull request #172 from ccodere/carl-ansi-part1

Carl ansi part1

5 years agoRemove unused variable.
carl [Wed, 20 Feb 2019 16:43:49 +0000 (00:43 +0800)]
Remove unused variable.

5 years agoRemove CMake changes and generic sed scripts so they are move to a separate branch.
carl [Wed, 20 Feb 2019 16:43:04 +0000 (00:43 +0800)]
Remove CMake changes and generic sed scripts so they are move to a separate branch.

5 years ago* Was trying to use the new system API which is not ready causing stack issues.
carl [Tue, 19 Feb 2019 16:44:32 +0000 (00:44 +0800)]
* Was trying to use the new system API which is not ready causing stack issues.

5 years ago+ Add missing files.
carl [Tue, 19 Feb 2019 16:32:19 +0000 (00:32 +0800)]
+ Add missing files.

5 years ago+ Add topgen
carl [Mon, 18 Feb 2019 16:48:21 +0000 (00:48 +0800)]
+ Add topgen

5 years agoBetter ANSI C compatibility and portability:
carl [Mon, 18 Feb 2019 16:44:39 +0000 (00:44 +0800)]
Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake

5 years agoBetter ANSI C compatibility and portability:
carl [Mon, 18 Feb 2019 16:44:19 +0000 (00:44 +0800)]
Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
.

5 years agoBetter ANSI C compatibility and portability:
carl [Mon, 18 Feb 2019 16:42:15 +0000 (00:42 +0800)]
Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
+ Scripts to generate compiler header is now sed based.

5 years ago+ Addition of scripts to generate compiler include files.
carl [Mon, 18 Feb 2019 16:40:51 +0000 (00:40 +0800)]
+ Addition of scripts to generate compiler include files.

5 years agoBetter ANSI C compatibility and portability:
carl [Mon, 18 Feb 2019 16:39:39 +0000 (00:39 +0800)]
Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
+ Initial support for CMake

5 years agoBetter ANSI C compatibility and portability:
carl [Mon, 18 Feb 2019 16:39:05 +0000 (00:39 +0800)]
Better ANSI C compatibility and portability:
+ Addition of function prototypes and include files.
+ Change function definitions to ANSI C style.
- Remove support for generating K&R code.
- Remove mkstemp and replace by tmpnam (more portable but less safe)

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:37:52 +0000 (00:37 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:37:26 +0000 (00:37 +0800)]
* Initial support of CMake

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:37:11 +0000 (00:37 +0800)]
* Initial support of CMake

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:36:48 +0000 (00:36 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Initial support for CMake
+ Added support for sys_tmpdir for better portability.

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:35:32 +0000 (00:35 +0800)]
* Initial support of CMake

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:35:24 +0000 (00:35 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.

5 years ago* Add missing header file.
carl [Mon, 18 Feb 2019 16:35:01 +0000 (00:35 +0800)]
* Add missing header file.

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:34:44 +0000 (00:34 +0800)]
* Initial support of CMake

5 years ago* Adapt to new sys_filesize prototype.
carl [Mon, 18 Feb 2019 16:34:24 +0000 (00:34 +0800)]
* Adapt to new sys_filesize prototype.

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:34:03 +0000 (00:34 +0800)]
* Initial support of CMake

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:33:54 +0000 (00:33 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h (TMPDIR is no longer hard coded)

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:33:21 +0000 (00:33 +0800)]
* Initial support of CMake
+ Generation of header files is now made through a C program to make it more portable.

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:32:48 +0000 (00:32 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h

5 years ago* Initial support of CMake
carl [Mon, 18 Feb 2019 16:32:17 +0000 (00:32 +0800)]
* Initial support of CMake

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:31:58 +0000 (00:31 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:31:29 +0000 (00:31 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:30:47 +0000 (00:30 +0800)]
Better ANSI C compatibility and portability - part 1:
* Adapt to new sys_filesize prototype.

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:30:35 +0000 (00:30 +0800)]
Better ANSI C compatibility and portability - part 1:
* Adapt to new sys_filesize prototype.

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:30:01 +0000 (00:30 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h

5 years agoBetter ANSI C compatibility and portability - part 1:
carl [Mon, 18 Feb 2019 16:29:42 +0000 (00:29 +0800)]
Better ANSI C compatibility and portability - part 1:
+ Addition of function prototypes.
+ Change function definitions to ANSI C style.
+ Convert to sed scripts some shell scripts for better portability.
+ Reduce usage of em_path.h

5 years agoFix typo.
David Given [Mon, 18 Feb 2019 10:04:23 +0000 (11:04 +0100)]
Fix typo.

5 years agoMinor improvements to the way types are expanded (should avoid embarassing ands
David Given [Sun, 17 Feb 2019 09:09:22 +0000 (10:09 +0100)]
Minor improvements to the way types are expanded (should avoid embarassing ands
with 0xff).

5 years agoMerge pull request #171 from davidgiven/dtrg-comparisons
David Given [Sat, 16 Feb 2019 00:23:27 +0000 (01:23 +0100)]
Merge pull request #171 from davidgiven/dtrg-comparisons

i80: a few more minor fixes

5 years agoAdd a few minor top optimisations.
David Given [Sat, 16 Feb 2019 00:18:31 +0000 (01:18 +0100)]
Add a few minor top optimisations.

5 years agoFix typo where I was confusing sbi and sui, with hilarious results.
David Given [Sat, 16 Feb 2019 00:18:21 +0000 (01:18 +0100)]
Fix typo where I was confusing sbi and sui, with hilarious results.

5 years agoMerge pull request #170 from davidgiven/dtrg-i169
David Given [Fri, 15 Feb 2019 22:56:00 +0000 (23:56 +0100)]
Merge pull request #170 from davidgiven/dtrg-i169

Fix driver crash when using -R

5 years agoFix memory corruption when using -R; the values being stored in the list
David Given [Fri, 15 Feb 2019 22:40:42 +0000 (23:40 +0100)]
Fix memory corruption when using -R; the values being stored in the list
weren't freeable when they should have been.

5 years agoReformat before editing.
David Given [Fri, 15 Feb 2019 22:24:10 +0000 (23:24 +0100)]
Reformat before editing.

5 years agoMerge pull request #168 from davidgiven/dtrg-i167
David Given [Fri, 15 Feb 2019 22:12:12 +0000 (23:12 +0100)]
Merge pull request #168 from davidgiven/dtrg-i167

i80: fix large stack frames

5 years agoLoading large constants now computes the stack offset correctly.
David Given [Fri, 15 Feb 2019 22:03:01 +0000 (23:03 +0100)]
Loading large constants now computes the stack offset correctly.

5 years agoGenerate the proper function prologues for big stack frames.
David Given [Fri, 15 Feb 2019 22:01:33 +0000 (23:01 +0100)]
Generate the proper function prologues for big stack frames.

5 years agoMerge pull request #166 from davidgiven/dtrg-comparisons
David Given [Fri, 15 Feb 2019 21:54:13 +0000 (22:54 +0100)]
Merge pull request #166 from davidgiven/dtrg-comparisons

i80: grabbag of optimisations

5 years agoCleanup.
David Given [Fri, 15 Feb 2019 21:26:14 +0000 (22:26 +0100)]
Cleanup.

5 years agoAdd rules for converting smallnconst2 and smallpconst2 to registers, to stop
David Given [Fri, 15 Feb 2019 21:20:07 +0000 (22:20 +0100)]
Add rules for converting smallnconst2 and smallpconst2 to registers, to stop
the conversion from happening via the stack. Star Trek goes from 39450 to 39384
bytes.

5 years agoUsing regpair instead of hl_or_de is not, in fact, safe until we've stopped
David Given [Fri, 15 Feb 2019 20:38:17 +0000 (21:38 +0100)]
Using regpair instead of hl_or_de is not, in fact, safe until we've stopped
using bc.

5 years agoFix nearly all the comparisons, a lot of which were broken. Using a rst for
David Given [Fri, 15 Feb 2019 20:30:27 +0000 (21:30 +0100)]
Fix nearly all the comparisons, a lot of which were broken. Using a rst for
unsigned comparisons is surprisingly not that useful due to marshalling
overhead; it's only four bytes to do inline (plus jc), or six for a constant.
Also add some useful top optimisations.  Star Trek goes from 39890 to 39450
bytes.

5 years agoCall cmps rather than cmpu for bge... make cmps and cmpu rsts. Apply various
David Given [Thu, 14 Feb 2019 23:38:39 +0000 (00:38 +0100)]
Call cmps rather than cmpu for bge... make cmps and cmpu rsts. Apply various
other tiny optimisations.

5 years agoUse nicely optimised helper tools to do signed comparisons of words. Star Trek
David Given [Thu, 14 Feb 2019 22:57:55 +0000 (23:57 +0100)]
Use nicely optimised helper tools to do signed comparisons of words. Star Trek
goes from 40452 to 39890 bytes.

5 years agoMerge pull request #165 from davidgiven/dtrg-b164
David Given [Thu, 14 Feb 2019 22:29:41 +0000 (23:29 +0100)]
Merge pull request #165 from davidgiven/dtrg-b164

i80: fix bad code in inl using faddrn

5 years agoFix bad helper tool invocation for inl with faddrn.
David Given [Thu, 14 Feb 2019 22:21:47 +0000 (23:21 +0100)]
Fix bad helper tool invocation for inl with faddrn.

5 years agoAdd failing test case.
David Given [Thu, 14 Feb 2019 22:19:11 +0000 (23:19 +0100)]
Add failing test case.

5 years agoMerge pull request #163 from davidgiven/dtrg-regmoves
David Given [Wed, 13 Feb 2019 23:13:41 +0000 (00:13 +0100)]
Merge pull request #163 from davidgiven/dtrg-regmoves

i80: fix pathological behaviour in asp

5 years agoTurns out that every time the compiler tried to do a stack retraction with asp,
David Given [Wed, 13 Feb 2019 23:05:08 +0000 (00:05 +0100)]
Turns out that every time the compiler tried to do a stack retraction with asp,
it would flush registers onto the stack. This stops it doing this. Star Trek
goes from 40779 to 40452 bytes.

5 years agoMerge pull request #161 from davidgiven/dtrg-faststack
David Given [Wed, 13 Feb 2019 21:56:18 +0000 (22:56 +0100)]
Merge pull request #161 from davidgiven/dtrg-faststack

i80: use helper functions for stack access

5 years agoMerge from default.
David Given [Wed, 13 Feb 2019 21:46:00 +0000 (22:46 +0100)]
Merge from default.

5 years agoInstead of using parameterised rsts for stack access, add a huge swathe of
David Given [Wed, 13 Feb 2019 21:45:22 +0000 (22:45 +0100)]
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.

5 years agoDon't do weird things if files starting with a hyphen exist in the build
David Given [Wed, 13 Feb 2019 21:42:05 +0000 (22:42 +0100)]
Don't do weird things if files starting with a hyphen exist in the build
directory.

5 years agoMerge pull request #160 from davidgiven/dtrg-b159
David Given [Wed, 13 Feb 2019 20:16:06 +0000 (21:16 +0100)]
Merge pull request #160 from davidgiven/dtrg-b159

i80, powerpc, mips: fix issue with logical operations and signed small constants

5 years agoFix issue with logical operations and small signed constants which turned out
David Given [Wed, 13 Feb 2019 19:56:10 +0000 (20:56 +0100)]
Fix issue with logical operations and small signed constants which turned out
to affect multiple platforms.

5 years agoUpdate test case to provoke bug.
David Given [Wed, 13 Feb 2019 19:10:38 +0000 (20:10 +0100)]
Update test case to provoke bug.

5 years agoMerge pull request #158 from davidgiven/dtrg-b157
David Given [Tue, 12 Feb 2019 21:29:01 +0000 (22:29 +0100)]
Merge pull request #158 from davidgiven/dtrg-b157

i80: fix bad code in comparisons

5 years agoFix bad code generation due to not correctly flushing the stack before
David Given [Tue, 12 Feb 2019 21:19:07 +0000 (22:19 +0100)]
Fix bad code generation due to not correctly flushing the stack before
comparisons.

5 years agoAdded a test case for #157.
David Given [Tue, 12 Feb 2019 21:08:08 +0000 (22:08 +0100)]
Added a test case for #157.

5 years agoMerge pull request #154 from ccodere/buildfix
David Given [Tue, 12 Feb 2019 20:51:46 +0000 (21:51 +0100)]
Merge pull request #154 from ccodere/buildfix

Bugfix of compilation on gcc 4.8

5 years agoFix compilation issue on C90 compilers (gcc 4.8 was failing to compile with default...
carl [Tue, 12 Feb 2019 16:17:45 +0000 (00:17 +0800)]
Fix compilation issue on C90 compilers (gcc 4.8 was failing to compile with default flags) - updated following comment.

5 years agoReplace the non-working Z80 style signed comparison sign adjustment with
David Given [Tue, 12 Feb 2019 10:57:37 +0000 (11:57 +0100)]
Replace the non-working Z80 style signed comparison sign adjustment with
something which actually works on the 8080. Sadly, Star Trek is up to
40243 bytes again.

5 years agoMerge pull request #156 from davidgiven/dtrg-arraysizes
David Given [Mon, 11 Feb 2019 20:35:16 +0000 (21:35 +0100)]
Merge pull request #156 from davidgiven/dtrg-arraysizes

i80: add 8085 instruction support

5 years agoApply Alan Cox's patch to add the 8085 extended instructions to the i80
David Given [Mon, 11 Feb 2019 20:14:35 +0000 (21:14 +0100)]
Apply Alan Cox's patch to add the 8085 extended instructions to the i80
assembler.

5 years agoMerge pull request #155 from davidgiven/dtrg-arraysizes
David Given [Mon, 11 Feb 2019 20:09:52 +0000 (21:09 +0100)]
Merge pull request #155 from davidgiven/dtrg-arraysizes

i80: fix signed comparisons

5 years agoSigned comparisons now work correctly; sadly, Star Trek increases from 39656 to
David Given [Mon, 11 Feb 2019 19:46:06 +0000 (20:46 +0100)]
Signed comparisons now work correctly; sadly, Star Trek increases from 39656 to
39726 bytes. Note that the emulator doesn't set P/V correctly and all the tests
fail. Testing in z80ex works fine.

5 years agoFix compilation issue on C90 compilers (gcc 4.8 was failing to compile with default...
carl [Mon, 11 Feb 2019 16:46:09 +0000 (00:46 +0800)]
Fix compilation issue on C90 compilers (gcc 4.8 was failing to compile with default flags).

5 years agoMerge from default.
David Given [Sun, 10 Feb 2019 22:40:07 +0000 (23:40 +0100)]
Merge from default.

5 years agoAdd tests for simple comparisons (which i80 fails).
David Given [Sun, 10 Feb 2019 22:39:15 +0000 (23:39 +0100)]
Add tests for simple comparisons (which i80 fails).

5 years agoMerge pull request #153 from davidgiven/dtrg-i80
David Given [Sun, 10 Feb 2019 18:45:00 +0000 (19:45 +0100)]
Merge pull request #153 from davidgiven/dtrg-i80

i80: more code generator improvements

5 years agoImprove subtractions, using dad and inline constants where possible. Shrinks
David Given [Sun, 10 Feb 2019 18:40:48 +0000 (19:40 +0100)]
Improve subtractions, using dad and inline constants where possible. Shrinks
Star Trek from 39740 to 39656 bytes.

5 years agoSimplify simple comparisons and use inlie constants where possible. Reduces
David Given [Sun, 10 Feb 2019 18:22:43 +0000 (19:22 +0100)]
Simplify simple comparisons and use inlie constants where possible. Reduces
Star Trek from 39771 to 39740 bytes.

5 years agoUse pop rather than inx;inx to retract the stack; consumes a register but
David Given [Sun, 10 Feb 2019 17:57:20 +0000 (18:57 +0100)]
Use pop rather than inx;inx to retract the stack; consumes a register but
halves the number of calls. Reduces Star Trek from 39976 to 39771 bytes.

5 years agoTeach the i80 code generator how to do left shifts by using dad hl; prevents it
David Given [Sun, 10 Feb 2019 17:44:47 +0000 (18:44 +0100)]
Teach the i80 code generator how to do left shifts by using dad hl; prevents it
from calling out to .sli2 for simple shifts. Shrinks Star Trek from 40055 bytes
to 39976.

5 years agoMerge pull request #152 from davidgiven/dtrg-osx
David Given [Sun, 10 Feb 2019 15:40:16 +0000 (16:40 +0100)]
Merge pull request #152 from davidgiven/dtrg-osx

Enable OSX builds again.

5 years agoReplace mkstemp() with the more modern and safer and simpler tmpfile().
David Given [Sun, 10 Feb 2019 13:36:15 +0000 (14:36 +0100)]
Replace mkstemp() with the more modern and safer and simpler tmpfile().