1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-01 23:29:41 +00:00
Commit Graph

445 Commits

Author SHA1 Message Date
Oliver Schmidt
ac0b452834 Added '_' prefix to sin and cos.
Users complained that otherwise the names might clash with their functions.
2019-04-13 11:25:54 +02:00
Oliver Schmidt
fc6a63a15e Avoid unintended file "shadowing".
3d8c3a4948 caused an unintended "shadowing" of files in /libsrc/runtime by files in /libsrc/common. Therefore the files in question are renamed (again) in /libsrc/common to make the files in /libsrc/runtime "visible" again.
2019-04-04 09:16:59 +02:00
IrgendwerA8
3d8c3a4948 Code review adaptations, removed "cc65_" prefix from functions 2019-03-29 22:53:04 +01:00
IrgendwerA8
db8bd84a82 Changes due to code review. 2019-03-29 22:53:04 +01:00
Christian Groessler
58484449b4 remove TABs 2019-02-05 23:27:52 +01:00
Paul Gardner-Stephen
1b46dfe820 change reference to $0200FF to $0200xx 2018-12-30 03:49:26 -05:00
Paul Gardner-Stephen
576d64da38 remove redundant line 2018-12-30 03:49:26 -05:00
Paul Gardner-Stephen
837b9b3c2c use pre-existing ZP storage. Make 32-bit pointer value loading more self-evident 2018-12-30 03:49:26 -05:00
Paul Gardner-Stephen
19ca1f6b48 add support for detecting 45GS02 2018-12-30 03:49:26 -05:00
IrgendwerA8
923fa8fc93 Saved 2 bytes and fixed error in case of negative result. 2018-11-09 17:27:35 -05:00
Oliver Schmidt
03a99569e3 Optimize for size. 2018-08-19 14:35:30 +02:00
Patrick Pelletier
411a5a9483 Don't pass mode argument to open() from _fopen().
It isn't necessary, since paravirt.c has a default if the mode isn't
pushed onto the stack.
2018-08-17 23:28:45 +02:00
Patrick Pelletier
aba320eade Allow "mode" argument to open() to be passed from 6502 code.
Implements this suggestion:
https://github.com/cc65/cc65/pull/719#issuecomment-413809096
2018-08-17 23:28:45 +02:00
Oliver Schmidt
842c151edd Replaced _systime with clock_gettime.
We want to add the capability to not only get the time but also set the time, but there's no "setter" for the "getter" time().

The first ones that come into mind are gettimeofday() and settimeofday(). However, they take a struct timezone argument that doesn't make sense - even the man pages says "The use of the timezone structure is obsolete; the tz argument should normally be specified as NULL." And POSIX says "Applications should use the clock_gettime() function instead of the obsolescent gettimeofday() function."

The ...timeofday() functions work with microseconds while the clock_...time() functions work with nanoseconds. Given that we expect our targets to support only 1/10 of seconds the microseconds look preferable at first sight. However, already microseconds require the cc65 data type 'long' so it's not such a relevant difference to nanoseconds. Additionally clock_getres() seems useful.

In order to avoid code duplication clock_gettime() takes over the role of the actual time getter from _systime(). So time() now calls clock_gettime() instead of _systime().

For some reason beyond my understanding _systime() was mentioned in time.h. _systime() worked exactly like e.g. _sysremove() and those _sys...() functions are all considered internal. The only reason I could see would be a performance gain of bypassing the time() wrapper. However, all known _systime() implementations internally called mktime(). And mktime() is implemented in C using an iterative algorithm so I really can't see what would be left to gain here. From that perspective I decided to just remove _systime().
2018-08-15 16:06:44 +02:00
Oliver Schmidt
a9ce4dc76c "Inverted" time_t value handling.
So far time_t values were interpreted as local time values. However, usually time_t values are to be interpreted as "seconds since 1 Jan 1970 in UTC". Therefore all logic handling time_t values has to be changed.

- So far gmtime() called localtime() with an adjusted time_t, now localtime() calls gmtime() with an adjusted time_t.
- mktime() has to do "the opposite" of localtime(), to keep it that way mktime() does now the inverse adjustment made by localtime().
- All currently present time() implementations internally call mktime() so they don't require individual adjustments.
2018-08-02 17:12:12 +02:00
IrgendwerA8
c9869c1a26 Quick fix for missing _div() adaptation after 95223be. 2018-07-26 10:44:22 +02:00
Greg King
6d87370881 Fixed strpbrk().
Added its prototype.  Documented it.
2018-05-29 14:29:50 -04:00
IrgendwerA8
dd411efd1c Adapted div & mod for popptr1. 2018-05-24 03:55:40 +02:00
IrgendwerA8
ba2c6d9008 Further optimizations in common/conio. 2018-05-22 16:00:05 +02:00
IrgendwerA8
d4081b43a6 Fixed comments. 2018-05-21 14:41:12 +02:00
Irgendwer
32bbacbb78
Merge branch 'master' into popptr1 2018-05-21 13:33:14 +02:00
IrgendwerA8
839aa93198 Resolved conflict and removed adaptation for strpbrk for time being. 2018-05-21 13:30:27 +02:00
IrgendwerA8
911b86de67 Fixed formatting and two import issues. 2018-05-21 13:02:56 +02:00
IrgendwerA8
c95ed4b8b5 Added "popptr1" which is of common use to save some bytes. 2018-05-20 15:30:18 +02:00
Marco van den Heuvel
61e5b9d218 Changed #10 to #-basha for clarity. 2018-04-01 13:14:44 -07:00
Marco van den Heuvel
9db6f059ac Fixed cpu detection. 2018-03-31 18:59:15 -07:00
Greg King
b844572159 Moved most of the tgi_colors.s files into the libsrc/common/ directory.
Only the Apple2 and Lynx platforms use different codes for the white color; they have their own files.
2018-03-27 07:28:46 -04:00
Marco van den Heuvel
b37e06da8f Fixed hex digits case. 2018-03-02 14:09:02 -08:00
Marco van den Heuvel
5a9d908007 Added 2a03/2a07 and HuC6280 detection. 2018-03-01 14:57:42 -08:00
Marco van den Heuvel
5d029af79e Fixed the 65816/65802 detection. 2018-02-27 11:44:34 -08:00
Marco van den Heuvel
e79e779aba Removed bit opcode, not needed anymore. 2018-02-26 19:30:25 -08:00
Marco van den Heuvel
e3779978b2 Added proper 65sc02, 65ce02 and 4510 detection. 2018-02-26 19:22:54 -08:00
Oliver Schmidt
c0ce20e9cc Save/restore jmpvec as it is used by generated code - see g_callind(). 2017-10-23 18:57:28 +02:00
Oliver Schmidt
bd9b4ef60c Replaced three (logically) identical files with a single file. 2017-10-23 18:35:06 +02:00
Piotr Fusik
b31ae57be1 Make some arrays const. 2017-06-28 20:43:31 +02:00
Lauri Kasanen
4235e569d2 Small lz4 optimizations 2017-06-09 16:57:47 +03:00
Lauri Kasanen
c444ed5e4f Mention the optimizations in a comment 2017-06-09 10:42:24 +03:00
Lauri Kasanen
bba961e54d Use hex immediates 2017-06-09 10:40:17 +03:00
Lauri Kasanen
cd460a8160 Remove _ from internal vars 2017-06-09 10:37:50 +03:00
Lauri Kasanen
ee49ecdf43 Expand tabs to spaces in lz4.s 2017-06-06 19:31:16 +03:00
Lauri Kasanen
e75a59d7a8 Add LZ4 decompression support 2017-06-06 18:48:25 +03:00
Oliver Schmidt
035baa49bd Merge pull request #438 from bbbradsmith/ca65_rand_comment
rand.s comment update
2017-05-26 15:16:42 +02:00
Brad Smith
950d65e8ed detectabl > detectable 2017-05-25 03:20:11 -04:00
Brad Smith
1602aab6e9 forgot to update comments from earlier #323 rand.s change 2017-05-25 03:01:25 -04:00
Oliver Schmidt
e43dbe1c24 Just some white space fixes of recently contributed code. 2017-04-06 17:53:57 +02:00
IrgendwerA8
8d1b80e6fd Fixed CPU-flag usage which fails on build server?! 2017-03-05 11:38:55 +01:00
IrgendwerA8
81115aa826 Added further optimizations and unit tests. 2017-03-05 02:09:12 +01:00
IrgendwerA8
3d28f5ca90 Fixed indentation 2017-02-26 22:36:19 +01:00
IrgendwerA8
c240d42a9e Added "strrchr" optimizaion a matching unit test and tiny unit test framework. (Documentation for that will follow later) 2017-02-26 20:03:05 +01:00
IrgendwerA8
6afcc370ed Optimization of two string functions (size & speed). 2017-02-25 20:19:50 +01:00
Sven Oliver Moll
c0d2643952 added 4510 cpu detection to getcpu.s 2016-09-07 19:44:11 +02:00
Brad Smith
32d000fb4c Fix broken rand() implementation. The high 8 bits were unused, reducing it to a 24-bit implementation (while still doing all the work for a 32-bit one). The best entropy is in the unused high byte, returning these bits in A instead of bits 8-15, which had considerably lower entropy (i.e. rand() & 255 was effectively a 16-bit LCG). 2016-07-11 20:48:47 -04:00
Christian Groessler
94ba9575ec Implement exec() for Atari XDOS.
- Adds new ENOEXEC error code, also used by Apple2 targets.
- Maximum command line length is 40, incl. program name. This is
  an XDOS restriction.
- testcode/lib/tinyshell.c has been extended to be able to run
  programs.
2016-06-13 20:40:01 +02:00
Christian Groessler
5705d0b55b Use 'return0' for default 'doesclrscrafterexit()' implementation in libsrc/common.
Fix include/atari.h formatting.
2016-06-07 15:05:00 +02:00
Christian Groessler
346d88a6a7 Add issues from pull request #307. 2016-06-07 12:07:38 +02:00
Oliver Schmidt
1d1ba3ed3b Adjusted constructors.
The constructors are _NOT_ allowed anymore to access the BSS. Rather they must use the DATA segment or the INIT segment. The latter isn't cleared at any point so the constructors may use it to expose values to the main program. However they must make sure to always write the values as they are not pre-initialized.
2016-03-16 16:28:32 +01:00
Oliver Schmidt
419eb700b5 Renamed INITBSS to INIT and INIT to ONCE.
The way we want to use the INITBSS segment - and especially the fact that it won't have the type bss on all ROM based targets - means that the name INITBSS is misleading. After all INIT is the best name from my perspective as it serves several purposes and therefore needs a rather generic name.

Unfortunately this means that the current INIT segment needs to be renamed too. Looking for a short (ideally 4 letter) name I came up with ONCE as it contains all code (and data) accessed only once during initialization.
2016-03-06 21:27:19 +01:00
Oliver Schmidt
3d08abcfa8 Load INITBSS segment from disk.
Conceptually the INITBSS segment is not initialized in any way. Therefore it makes sense to not load it from disk. However the INIT segment has to be loaded from disk and therefore moved to its run location above the INITBSS segment. The necessary move routine increases runtime RAM usage :-(

Therefore we now "unnecessarily" load the INITBSS segment from disk too meaning that the INIT segment is loaded at its run location. Therefore there's no need for the move routine anymore.

After all we trade disk space for (runtime) RAM space - an easy decision ;-)

Notes:

- The code allowing to re-run a program without re-load present so far could not have worked as far as I can see as it only avoided to re-run the move routine but still tried to re-run the code in the INIT segment that was clobbered by zeroing the BSS. Therefore I removed the code in question altogether. I'm personally not into this "dirty re-run" but if someone wants to add an actually working solution I won't block that.

- INITBSS is intentionally not just merged with the DATA segment as ROM-based targets can't reuse the INIT segment for the BSS and therefore have no reason to place the INIT segment above INITBSS.

- Because ROM-based targets don't copy INITBSS from the ROM (like it is done with the DATA segment) all users of INITBSS _MUST_NOT_ presume INITBSS to be initialized with zeros!
2016-02-28 19:45:36 +01:00
Greg King
8e8d112029 Added pce-specific substitutes for memcpy() and memmove().
They are smaller and faster because they take advantage of the pce CPU's block-copy instructions.

Also, made a small improvement to the common memmove(), so that it is similar to the pce version.
2015-10-23 18:02:21 -04:00
Oliver Schmidt
0ee9b2e446 Changed run location of INIT segment.
So far the INIT segment was run from the later heap+stack. Now the INIT segment is run from the later BSS. The background is that so far the INIT segment was pretty small (from $80 to $180 bytes). But upcoming changes will increase the INIT segment in certain scenarios up to ~ $1000 bytes. So programs with very limited heap+stack might just not been able to move the INIT segment to its run location. But moving the INIT segment to the later BSS allows it to occupy the later BSS+heap+stack.

In order to allow that the constructors are _NOT_ allowed anymore to access the BSS. Rather they must use the DATA segment or the new INITBSS segment. The latter isn't cleared at any point so the constructors may use it to expose values to the main program. However they must make sure to always write the values as they are not pre-initialized.
2015-10-14 22:52:09 +02:00
Greg King
8a880580dc Reduced the size of the moveinit subroutine.
Made other changes that were recommended by Oliver.
* Changed its name from move_init to moveinit.
* Used self-modifying code in the subroutine.
* The INIT segment doesn't need to be optional (it's used by the start-up file).
2015-10-07 14:56:14 -04:00
Greg King
074e10d288 Adapted, to the c64 target, the INIT-segment overlay scheme from the apple2 targets.
When a program starts running, INIT is moved from one place to another place.  Then, INIT's code is executed; and, the first place is re-used for variables.  After the INIT code has finished, the second place can be re-used by the heap and the C stack.  That means that initiation code and data won't waste any RAM space after they stop being needed.
2015-10-05 05:47:43 -04:00
Greg King
b82bb4f5ba Moved two errno helper functions into separate files.
Only the function that actually is needed will be linked.  It is very useful for targets that do not have file-system I/O.
2015-09-25 14:06:58 -04:00
Greg King
dbf0adcec9 Improved longjmp() and setjmp(). 2015-09-11 14:18:22 -04:00
Greg King
9c55bd1c96 Fixed bugs in the interface for C-level interrupt handlers.
* Added an important ".code" directive.

* Import a linker-created zero-page symbol as an absolute address; then, convert it to zero-page when it is used.

Fixes bug report #198.
2015-08-26 19:33:34 -04:00
Greg King
0b6bcb565e Fixed a hardware-stack leak. 2015-07-17 20:36:56 -04:00
Greg King
146daa1d0a Made some string output functions reject an invalid NULL buffer pointer. 2015-07-09 14:46:28 -04:00
Greg King
219905c6bc Fix two string output functions' handling of their buffer-size parameter.
That parameter's type is unsigned; but, the functions return an int.  If the size is too big for a signed integer, then return an error code.
If the size is zero, then don't write anything into a buffer (the buffer pointer may be NULL).  But, do format and count the arguments.
2015-07-09 10:43:45 -04:00
Greg King
08e18c93c5 Added explicit settings of calling conventions in pointer-to-function declarations in system and library headers. 2015-06-22 00:15:48 -04:00
Greg King
38231a5cc6 Made _afailed() and uncompress() be fastcall functions. 2015-03-13 07:35:47 -04:00
Greg King
74c2415795 Changed literal zeroes of the style "#>0" into the style "#>$0000". 2014-09-10 19:15:07 -04:00
Greg King
0390c34e88 Changed multi-line C comments into another style.
The left side doesn't look unbalanced.
2014-06-30 16:51:07 -04:00
Greg King
2cc26e6e23 More conforming to the cc65 project's apparent writing style. 2014-05-23 16:52:02 -04:00
Greg King
a92f51fea5 Conformed to the cc65 project's coding style. 2014-05-23 00:35:19 -04:00
Greg King
0ec8c8cea7 Added a quoted-token parsing function. 2014-05-20 16:33:16 -04:00
Greg King
f82a43b98d Fixed the comments to say where the actual Left-Hand Side and Right-Hand Side are put.
A description of positions [left, right] is appropriate more for C code than for Assembly code.  (A description of timing [first argument, second argument] is more appropriate for the way that Assembly code is written.)
2014-05-11 10:43:06 -04:00
Greg King
228b9d1718 Added a fast subroutine to multiply two signed 8-bit numbers. 2014-05-11 01:08:27 -04:00
Oliver Schmidt
986c2248e2 Added cc65_umul8x8r16() based on umul8x8r16. 2014-03-27 21:22:02 +01:00
Oliver Schmidt
d001a6f1a0 Have _heapmaxavail() work as advertised.
The cc65 doc explicitly states that the return value of _heapmaxavail() can be used as parameter of malloc(). To actually allow for that the size of HEAP_ADMIN_SPACE has to be substracted from the raw size of the largest free heap block.
2014-02-20 21:04:11 +01:00
Oliver Schmidt
e0262750ce Have %I yield values [1..12] instead of [0..11]. 2013-12-09 19:53:54 +01:00
Emanuele Fornara
35388418fd fixed timep handling in time() 2013-10-02 20:55:01 +01:00
Christian Groessler
2051adeb4d Fix strtol 'endptr' return value. 2013-09-12 12:38:20 +02:00
Christian Groessler
5a84da0d4e Fix strtoul 'endptr' return value: It should point to the first invalid character,
not to the last valid character.
2013-09-11 21:54:50 +02:00
Greg King
0684ab7ab9 Fixed some return pointers.
$1234 pointers were returned as $3434.
2013-08-28 02:58:41 -04:00
Oliver Schmidt
85885001b1 Removed (pretty inconsistently used) tab chars from source code base. 2013-05-09 13:57:12 +02:00
Oliver Schmidt
008b4c4e1d Replaced whole bunch for Makefiles with a single generic Makefile.
- No complex shell logic.
- "Source file shadowing" for all targets via vpath.
- Dependency handling.
- True incremental build.
- Don't write into source directories.
- Easy cleanup by just removing 'wrk'.
2013-05-04 22:10:48 +02:00
Greg King
b225adaf03 Fixed isgraph() and ispunct() (macroes and library functions). 2013-05-01 16:23:47 -04:00
silverdr
deb18b8e1e typo in the doc corrected, tabs adjusted
git-svn-id: svn://svn.cc65.org/cc65/trunk@5964 b7a2c559-68d2-44c3-8de9-860c34a00d81
2013-01-15 11:30:11 +00:00
uz
6eefd591c1 Moved the string that contains the ascii representation of LONG_MIN into its
own file.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5941 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-11-26 16:28:46 +00:00
uz
e04f1d8cb0 Fixed an error in calloc reported by Marc 'BlackJack' Rintsch.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5932 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-11-12 23:07:02 +00:00
uz
dc4e898abd Use the new declarations from the zeropage include file. In interrupt handlers
that call C code, we don't need to save the register bank, because the C code
will save it, when needed.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5909 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-11-04 15:23:05 +00:00
uz
7a0fa3ce67 Modifications for smaller code size.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5777 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-07-10 20:45:16 +00:00
uz
383157e743 Size optimizations.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5714 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-11 18:16:17 +00:00
uz
efb4cc9e37 Rearrangements for smaller size of generated code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5704 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-10 19:02:54 +00:00
uz
c03fd881e3 Changes for better code generation.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5703 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-10 18:55:22 +00:00
uz
130e8fd090 Changed the code so that it better suits the code generation of the compiler
(which means, the resulting code is shorter).


git-svn-id: svn://svn.cc65.org/cc65/trunk@5702 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-10 18:32:38 +00:00
uz
bfd0f58686 Shortened the code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5701 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-10 18:25:22 +00:00
uz
9ee0fa91e6 Fixed an invalid store offset, which caused an invalid pointer as a function
result. The actual conversion was ok.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5625 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-03-25 13:14:13 +00:00
uz
f059634cda Fixed an invalid store offset which resulted in random values returned by the
function.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5624 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-03-25 13:13:37 +00:00
uz
285aaf8933 Patch by Stefan Haubenthal: Remove __fastcall__ in comments and/or the
function description for functions that don't take any parameters.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5573 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-03-04 13:08:54 +00:00