1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00
Commit Graph

305 Commits

Author SHA1 Message Date
acqn
768e03a474 Small fixes and tidy-up based on PR review.
Renamed GetReplacementType() to GetStructReplacementType().
Clarified in comments that most *Struct* facilities work for unions as well.
Made it clear in some error messages with regards to structs/unions.
2020-07-19 10:58:33 +02:00
acqn
b45d373fd6 Fixed passing by value structs/unions <= 4 bytes in size to functions. Larger ones are forbidden for now. 2020-07-19 10:58:33 +02:00
acqn
9f67b45ea0 Fixed returning by value structs/unions <= 4 bytes in size from functions. Larger ones are forbidden for now. 2020-07-19 10:58:33 +02:00
acqn
333fa97326 Whitespaces/newlines fixes. 2020-07-18 12:54:29 +02:00
acqn
9198b3be00 Fixed '&function' and '&array'. 2020-07-18 12:54:29 +02:00
acqn
d23b577331 More compiler flags on address types to match the location types of expressions. 2020-07-18 12:54:29 +02:00
acqn
2108489523 Fix for Issue #1075 and #1077. 2020-07-18 12:54:29 +02:00
acqn
8066cd9ace Fixed wrong case in PreDec codegen, which never seems to be in use though. 2020-06-01 22:37:40 +02:00
acqn
33e103fdc6 Fixed Issue #1040: non-byte pointer +=/-= byte codegen bug. 2020-06-01 22:37:40 +02:00
Greg King
90a2edcfa2 Made cc65 detect a possibly missing argument at the end of a function argument list.
(It could be a stray comma at the end of the list.)
2020-01-25 04:14:58 -05:00
Greg King
a0db846a97 Allowed old-style (K and R) function declarations to be fastcall.
That lets them match old-style definitions.  It avoids "Type conflict" error messages.  It allows shorter function calls.

Fixed the types of some variables in "test/ref/otccex.c".  It avoids crashes on 64-bit Windows (32-bit Windows with 64-bit pointers).
2019-07-22 09:26:23 -04:00
Lauri Kasanen
654d972288 C90 param, void 2019-04-21 12:46:03 -04:00
Lauri Kasanen
a9cbb5305c Fix missing spaces 2019-04-21 12:46:03 -04:00
Lauri Kasanen
3b3b16ee9c Add support for computed gotos
This is a GCC extension that allows C to use fast jump tables.
2019-04-21 12:46:03 -04:00
Greg King
a6b04f6e97 Changed most "backticks" (grave accents) into apostrophes.
Quotations that are embraced by tick marks now look better, in most fonts.
2019-01-05 14:57:12 -05:00
Laubzega
581c46c213 Add checks for risky goto statements. 2018-10-02 18:49:53 +02:00
Greg King
c67e90dd19 Changed the type of a compiler variable that holds either integers or pointers.
The change allows cc65 to be compiled on 64-bit Windows, without getting warnings.  That OS is actually 32 bits with 64-bit pointers.  Its pointers are "long long" instead of "long".  The change uses type-names that are configured for the actual pointer width.
2018-01-09 05:34:16 -05:00
Oliver Schmidt
c8d6ca908d Minor style fix. 2017-10-23 18:22:51 +02:00
Oliver Schmidt
11b01b908d Merge pull request #424 from clbr/trampoline
Trampoline support
2017-05-18 16:29:34 +02:00
Lauri Kasanen
f6fa74a636 Rename trampoline to wrappedcall everywhere 2017-05-18 16:00:04 +03:00
Lauri Kasanen
a2f61c667a Update comments and location checks according to Greg 2017-05-07 20:31:41 +03:00
Lauri Kasanen
ead0338c0d Add fast path for char postdec 2017-05-06 13:35:39 +03:00
Lauri Kasanen
767f093ff8 Add fast path for char postinc 2017-05-06 13:35:39 +03:00
Lauri Kasanen
2890b3a810 Pragma trampoline 2017-05-02 20:51:53 +03:00
Greg King
7e14dde07b Fixed the cc65 code that handled an addition of a pointer to a 32-bit offset.
It didn't demote the offset to int because it looked at the pointer (instead of the offset) which already was 16 bits.
2015-12-31 17:41:48 -05:00
Greg King
3b303396bf Made cc65 accept comparisons between pointers with different qualifiers (similarly to subtractions between pointers). 2015-12-29 04:18:17 -05:00
Oliver Schmidt
d3eebc8fcf Merge branch 'pointer' of https://github.com/mrdudz/cc65 into mrdudz-pointer 2015-07-15 12:24:09 +02:00
mrdudz
6ab197f364 patch from Uz that makes some illegal operations on pointers error out 2015-07-10 14:27:49 +02:00
Greg King
8189339e7d Added special-case compiler code that handles a pointer-to-array dereference.
The type needs to change (to array); but, the address shouldn't be changed -- it already points to the first element.
Based on a bug analysis by Daniel Serpell.
2015-07-01 06:55:57 -04:00
Greg King
8743e9911d Added a command-line option to compile a program, with __cdecl__ as the default calling convention. 2015-04-22 09:59:23 -04:00
Greg King
a798b1d648 Made __fastcall__ be the default calling convention for non-variadic functions. 2015-03-10 05:53:52 -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
Oliver Schmidt
4185caf855 Normalized code. 2014-03-04 01:11:19 +01:00
Oliver Schmidt
f488f7576c Applied fix contributed by Greg King.
The code
  void foo(void)
  {
    int i;
    long l = 1L * i;
  }
triggered an
  Internal compiler error:
  Code generation messed up: StackPtr is -4, should be -2

Greg King: "We are lucky that the bug is simple -- a missing "else".  The result is that the compiler thinks that it does the opposite of what it actually does:  It thinks that it pushes the non-constant expression onto the stack. It doesn't; so, cc65's stack pointer is wrong."
2013-10-08 23:04:41 +02:00
Oliver Schmidt
85885001b1 Removed (pretty inconsistently used) tab chars from source code base. 2013-05-09 13:57:12 +02:00
uz
0eed753578 Prevent a literal string that is an argument for sizeof to be output into the
literal pool.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5968 b7a2c559-68d2-44c3-8de9-860c34a00d81
2013-01-25 20:45:40 +00:00
uz
ec1f955a6e For commutative operators processed by hie_internal, if the left side is a
constant, exchange the order of the operands so that better code can be
generated.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5721 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-16 18:12:24 +00:00
uz
b5d88fdedd Mark commutative operators as such (no change in code until now).
git-svn-id: svn://svn.cc65.org/cc65/trunk@5720 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-06-16 15:49:53 +00:00
uz
cbefb85d47 Fixed a problem reported by Greg King. structs returned from functions in the
primary register are actually rvalues and need special treatment.
                                                                 


git-svn-id: svn://svn.cc65.org/cc65/trunk@5413 b7a2c559-68d2-44c3-8de9-860c34a00d81
2012-01-20 16:01:25 +00:00
uz
80a5686bd9 The code for compares with a constant result may not be removed, because it
may contain side effects.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5010 b7a2c559-68d2-44c3-8de9-860c34a00d81
2011-05-01 18:48:06 +00:00
uz
3f5b2a8fbd Allow to disable the "Result of comparison is constant" warning.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4883 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-11-28 21:16:46 +00:00
uz
477b77f528 Another minor improvement in compares.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4745 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-07-11 21:53:48 +00:00
uz
2bb2d97ab0 Fixed and improved the code for compares. Before, compares of chars to a
constant where sometimes passed down to the code generator in a way that
caused wrong code to be generated.

This change may go into 2.13 after some testing.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4743 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-07-11 16:11:45 +00:00
uz
1a4e2edede Reenable compile time evaluation of strlen for string literals.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4631 b7a2c559-68d2-44c3-8de9-860c34a00d81
2010-03-20 18:51:59 +00:00
uz
3976746735 Rewrote literal handling. Literals are now saved together with other function
data, and at the end of compilation merged if possible. Literals for unused
functions are removed together with the function.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4501 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-05 22:39:45 +00:00
uz
50ff6d0768 Create one literal pool per function, so that literal pool data is removed
together with a function, if it is not used. Literal storage can now be
controlled by #pragma writable-strings on a per function basis.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4499 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-12-04 14:12:25 +00:00
uz
ce931b85be In case of parse errors for structs, don't just set the type of the result to
"int", return a valid lvalue instead.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4483 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-11-24 23:02:58 +00:00
uz
548336a7bd Renamed attribute handling functions. Added SymHasAttr().
git-svn-id: svn://svn.cc65.org/cc65/trunk@4375 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-19 10:19:26 +00:00
uz
5a00b38aab Fixed the existing but unused attribute parsing code. Added
__attribute__((noexit)) that may be used to mark functions that won't return.
Added this attribute to the exit() function in stdlib.h.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4372 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-18 18:31:02 +00:00
uz
0ce362a69b Some cleanup in the code generator. Added a g_drop function. g_drop and
g_space can now handle sizes > 255 bytes.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4370 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-15 21:08:03 +00:00
uz
17d592352c Fixed an error with r4329: In case of a struct pointer the qualifiers of the
pointers had been used, not the qualifiers of the struct.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4340 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-08 09:54:46 +00:00
uz
9c5224165f Fixed a bug: A similar problem as that with structs does also exist for
arrays. An array element has all qualifiers from itself and from the array
declaration.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4334 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 18:46:39 +00:00
uz
7992bfb74a Changed solution for r4329 so that it uses less memory.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4331 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 18:22:28 +00:00
uz
c69e2d9f0f Fixed a bug: Function designators are converted to rvalues of type "pointer to
function", so dereferencing a function is a legal operation. The result is
immediately converted back to "pointer to function" again. Note: Because of
performance considerations, cc65 does treat functions as "pointer to function"
internally, but nevertheless dereferencing a function must be possible.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4330 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 17:49:45 +00:00
uz
43c89d5fd0 Fixed a bug: A struct field has all qualifiers from its definition plus the
qualifiers of the struct.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4329 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-05 17:37:45 +00:00
uz
8e35f0d9c8 The combined assignment operator (-=, +=, ...) did not check that the rhs is
actually an integer.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4297 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-10-01 19:41:40 +00:00
uz
b5db4cd5fa Added wide char literals, but treat them identical as normal strings.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4185 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-18 14:28:52 +00:00
uz
e68332a10b Fixed several more problems like the one in Assignment() some time ago: An
expression that yields a constant value may have side effects, and the
expression code must not be removed in this case.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4138 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-08 20:29:12 +00:00
uz
2d3b0f1146 Fixed a problem similar to the one in Assignment() some time ago: An
expression that yields a constant value may have side effects, and the
expression code must not be removed in this case.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4137 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-08 20:08:21 +00:00
uz
0c20177fce Allow to store start and end of generated code in the ExprDesc structure. New
function MarkedExprWithCheck.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4135 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-08 19:48:22 +00:00
uz
94a2223443 Use SymIsTypeDef and SymIsBitField instead of accessing Sym->Flags directly.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4123 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-06 16:51:08 +00:00
uz
944057238e Simplify code generated for the ?: operator when type conversion code for the
second operand is necessary. Instead of generating interleaved code with
several jumps, just move the code to the right place.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4105 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-01 08:57:36 +00:00
uz
6b4fe90928 First implementation of bit fields.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4079 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-29 21:20:13 +00:00
uz
bd872a6324 Added code to parse bit fields and enter them into the symbol table. They're
not supported in code generation until now.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4072 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-29 17:38:53 +00:00
uz
c214fa6395 When preprocessing, all compares evaluate to constants, so don't print a
warning in this case.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4059 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-27 22:09:46 +00:00
uz
d65928829f Added a warning if the result of a compare operation is constant. This should
protect against missing parenthesis like in (si & 0x7F == 0). Hopefully
without too many false positives.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4057 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-08-27 22:00:18 +00:00
uz
a3eed9016f Fix problem with R3904: Chars on the lhs of opeq must still be accessed as
such.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3985 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-07-30 15:15:13 +00:00
uz
37157a31a8 Fixed problems with R3977: While the solution was correct, the generated code
is bad, since information is lost when converting functions and arrays to
pointers and cannot be regained easily. So I've reverted the change and fixed
the problem in a less general manner.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3984 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-07-30 14:45:50 +00:00
uz
4dd9c523e7 Check for division by/modulo by zero when parsing the /= and %= operators.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3937 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-02-17 21:09:59 +00:00
uz
c4dac550a8 Small change to avoid endless error loops (aborted by the maximum error count)
if an unexpected token is encountered in Primary().


git-svn-id: svn://svn.cc65.org/cc65/trunk@3936 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-02-17 20:56:13 +00:00
uz
308ceeacf9 Fixed problems with casts, where larger values weren't truncated when casting
down to char size.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3904 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-12-28 16:25:03 +00:00
uz
cc36f8a93a Moved the fascall and near/far flags from the function desriptor into the
type. Started to add general handling of address size flags in types.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3891 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-24 17:33:30 +00:00
uz
0b60ac4716 Use GlobalModeFlags() if apropriate.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3885 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-09 20:33:11 +00:00
uz
1e672a3169 Fixed a bug: The op= operators (+=, -=, etc.) worked on const qualified
objects.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3883 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-07 22:22:58 +00:00
uz
66b3f9d974 Fixed a bug: It was possible to increment or decrement const qualified
objects.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3882 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-07 22:18:12 +00:00
uz
5cd0b86a1a Indexing a string by an expression which was not a simple variable didn't
work:  "abcd"[atoi("2")];
                         


git-svn-id: svn://svn.cc65.org/cc65/trunk@3880 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-05 21:20:42 +00:00
uz
9127774a4d Pass a complete ExprDesc and not just the Flags field to GlobalModeFlags to
allow for better debugging (output) in case of problems.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3879 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-05 21:11:26 +00:00
uz
dbb9a31fd9 Fixed wrong code generation for
((unsigned char *)(&shadow))[reg & 0x0f] = value;


git-svn-id: svn://svn.cc65.org/cc65/trunk@3875 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-05 19:47:57 +00:00
uz
3482a9e7ce Fixed a comment
git-svn-id: svn://svn.cc65.org/cc65/trunk@3868 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-08-03 20:09:03 +00:00
cuz
52c0c284da Calling an undefined function is an error in C99.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3857 b7a2c559-68d2-44c3-8de9-860c34a00d81
2008-07-31 18:30:33 +00:00
cuz
10c949062b Fixed a bug: The compiler evaluated constant expressions internally always
using signed integers as data types. This led to wrong results for mod, div
and compares.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3797 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-08-26 18:53:46 +00:00
cuz
80a4c8c02b Fix type of "&array" - it will actually generate pointer to array, not pointer
to element. This will make some valid code work but emits now errors for
questionable code.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3775 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-03-18 19:15:35 +00:00
cuz
9601baf6ec Fixed internal compiler error on invalid input code.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3768 b7a2c559-68d2-44c3-8de9-860c34a00d81
2007-02-03 18:11:37 +00:00
cuz
eb745b3d1b Fixed a problem with undefined identifiers in #if expressions: If the
identifier is not the last token on the line, the compiler will run into
an error.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3744 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-05-29 20:38:44 +00:00
cuz
de3a20a898 Changed the low level type representation from a strung of unsigned short
elements to a string of structs, each representing one type element. This
should fix problems on unusual architectures, since it is no longer necessary
to embedd pointers and other data converted to numbers in the string of
unsigned shorts.
Increased the TypeCode length to unsigned long to make room for more type
bits.
Inline more functions in datatype.h.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3709 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-02-19 12:29:37 +00:00
cuz
64921852dd Parse the C99 "restrict" keyword correctly (but ignore it otherwise).
git-svn-id: svn://svn.cc65.org/cc65/trunk@3706 b7a2c559-68d2-44c3-8de9-860c34a00d81
2006-02-17 20:19:35 +00:00
cuz
e4ec9014d2 Reversed accidentally checked in changes
git-svn-id: svn://svn.cc65.org/cc65/trunk@3613 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-08-31 21:49:12 +00:00
cuz
d6c50c1826 Added HuC6280 cpu (will be treated as a 65C02)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3612 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-08-31 21:48:08 +00:00
cuz
c218639977 Fixed a bug: The compiler aborted with an internal error if a non function
was called as a function after printing the diagnostic.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3526 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-07-17 09:49:34 +00:00
cuz
b01c0cf2b7 Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@3511 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-05-11 13:54:22 +00:00
cuz
e06d9d0d84 Fixed a bug (hopefully).
The ArrayRef() does really need a rewrite, now since we have better
expression info.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3364 b7a2c559-68d2-44c3-8de9-860c34a00d81
2005-01-09 21:17:19 +00:00
cuz
40d01eb4ce Fixed bug with braces in initializer lists
git-svn-id: svn://svn.cc65.org/cc65/trunk@3193 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-09-23 17:34:03 +00:00
cuz
366d066375 Fixed the last fix
git-svn-id: svn://svn.cc65.org/cc65/trunk@3171 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-08-02 17:19:52 +00:00
cuz
123677c802 In a function call for all parameters not covered by a prototype, convert
arrays to pointer to first element, and functions to pointer to function.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3169 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-08-02 16:39:55 +00:00
cuz
104f041111 Add dummy return value to avoid a wcc warning
git-svn-id: svn://svn.cc65.org/cc65/trunk@3162 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-07-17 22:16:02 +00:00
cuz
0ba074995c Check for invalid function names before trying to compare the name against
the names of known standard functions.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3154 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-07-11 13:47:57 +00:00
cuz
9df7321d90 Cleanup in ShiftExpr.
Changed GetCodePos to also remember the stack pointer at the given location,
this removes the necessity to manipulate the stack when removing code. Since
CodeMark is now a struct, the API for most asmcode functions has changed.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3145 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-07-06 11:30:08 +00:00
cuz
e354d269f6 Remove shifts from kcalc
git-svn-id: svn://svn.cc65.org/cc65/trunk@3139 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-29 20:44:50 +00:00
cuz
809d1408ce Move shift expression evaluation into a separate module. More checks and
improvements for shift expressions.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3138 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-29 20:44:01 +00:00
cuz
daf8e0d1e6 Added license information preproc.h
git-svn-id: svn://svn.cc65.org/cc65/trunk@3135 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-29 20:26:27 +00:00
cuz
d8279302a9 Make the -O and --codesize options stackable.
Copy the current optimization settings into a code segment on creation.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3129 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-15 20:29:49 +00:00
cuz
8752f0b2c1 Removed ExprLoad to LoadExpr.
Moved LoadExpr + support functions into a separate module.
Removed obsolete files.
Some cleanup and makefile adjustments.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3113 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-09 14:12:57 +00:00
cuz
8425d988fe Removed debug code
git-svn-id: svn://svn.cc65.org/cc65/trunk@3110 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-06 18:36:15 +00:00
cuz
f500a641c5 Added support for floating point constants in the scanner and Primary()
git-svn-id: svn://svn.cc65.org/cc65/trunk@3108 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-06 15:59:44 +00:00
cuz
9fc71c5e93 Renamed ExprDesc.Val to ExprDesc.IVal. Added an FVal field for a floating
point constant.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3107 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-06 14:48:59 +00:00
cuz
5586527fcc Move the test flags into the Flags bitset of struct ExprDesc
git-svn-id: svn://svn.cc65.org/cc65/trunk@3101 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-05 20:29:47 +00:00
cuz
104ae3a54f Move the compiler stack pointer into its own module.
Improved the inlining of standard C functions. Added more standard functions
to inline.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3095 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-05 11:35:53 +00:00
cuz
87d0d88986 Check the InlineStdFuncs flag later
git-svn-id: svn://svn.cc65.org/cc65/trunk@3086 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-04 14:37:50 +00:00
cuz
8c4b3599a2 Fixed a typo
git-svn-id: svn://svn.cc65.org/cc65/trunk@3073 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-03 12:09:24 +00:00
cuz
2fa9b6e5ac Improved code generation
git-svn-id: svn://svn.cc65.org/cc65/trunk@3072 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-03 12:08:49 +00:00
cuz
01104d26ea Fixed generation of non optimal code in StructRef()
git-svn-id: svn://svn.cc65.org/cc65/trunk@3071 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-03 11:10:30 +00:00
cuz
6e34e386cb Rewrote code generation for the strlen standard function. Added code for
other standard functions in several places.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3069 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-06-02 21:33:35 +00:00
cuz
111c69a826 String literals can be handled as static data in most cases
git-svn-id: svn://svn.cc65.org/cc65/trunk@3062 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-05-31 19:51:13 +00:00
cuz
8d8162eb23 Rewrite/cleanup of the complete expression flags handling.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3056 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-05-31 15:27:33 +00:00
cuz
fedb566ff1 Some renaming and restructuring
git-svn-id: svn://svn.cc65.org/cc65/trunk@3050 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-05-26 16:15:28 +00:00
cuz
878e4f1352 Changed the expression parser to return the lvalue flag as part of the
ExprDesc structure, not as separate value.
WARNING: The current code does compile but does not work correctly, because
the lvalue flag is part of ExprDesc.Flags and not masked out in several tests
throughout the code.


git-svn-id: svn://svn.cc65.org/cc65/trunk@3046 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-05-25 20:59:38 +00:00
cuz
89fc8f3df7 Fixed a bug: The volatile keyword was not accepted in type casts or as
argument to the sizeof operator, if the type spec is starting with this
keyword.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2921 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-03-13 22:37:13 +00:00
cuz
d0ea9f34b6 Made several options that can be changed by #pragmas stackable.
Added new #pragma regvars.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2902 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-03-07 21:53:35 +00:00
cuz
e47ed98aa7 Move the expression test code into separate modules.
The Test() and TestInParens() functions do now return information about the
expression that was tested.
An if... statement where the expression is always true will now print a
warning "Unreachable code" if it has an else clause.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2889 b7a2c559-68d2-44c3-8de9-860c34a00d81
2004-03-02 18:00:08 +00:00
cuz
f4e5baa444 Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@2437 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-09-14 11:12:27 +00:00
cuz
14fc5c1073 Renamed exprhs to ExprLoad
git-svn-id: svn://svn.cc65.org/cc65/trunk@2426 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-29 09:16:28 +00:00
cuz
7989e202a6 Fixed a type conversion bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@2419 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-27 19:40:40 +00:00
cuz
aef8789873 Fixed several type conversion issues
git-svn-id: svn://svn.cc65.org/cc65/trunk@2380 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-20 08:32:07 +00:00
cuz
e20bda21b3 Fixed type conversion problems
git-svn-id: svn://svn.cc65.org/cc65/trunk@2371 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-19 20:31:10 +00:00
cuz
a70d466e3e Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@2351 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-17 15:20:18 +00:00
cuz
81f94afd5c Rewrote type conversions
git-svn-id: svn://svn.cc65.org/cc65/trunk@2262 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-11 20:18:30 +00:00
cuz
73dfa23c98 Fixed a bug that caused problems locating the last parameter of a function
git-svn-id: svn://svn.cc65.org/cc65/trunk@2259 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-08-10 17:05:18 +00:00
cuz
d5b3ff4bca Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@2234 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-07-26 07:31:15 +00:00
cuz
8b3ab210be Fixed a bug in character literal handling
git-svn-id: svn://svn.cc65.org/cc65/trunk@2029 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-03-17 20:18:58 +00:00
cuz
c008e555b2 Fixed a bug in sign extension of constant values
git-svn-id: svn://svn.cc65.org/cc65/trunk@1998 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-03-04 10:46:27 +00:00
cuz
c5868d30c0 Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1922 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-02-02 21:05:39 +00:00
cuz
abcc981253 Move the Debug flag into a new module "debugflag" in the common directory.
Remove the const qualifier from the argument of xfree().


git-svn-id: svn://svn.cc65.org/cc65/trunk@1877 b7a2c559-68d2-44c3-8de9-860c34a00d81
2003-01-04 16:59:51 +00:00
cuz
ed2bb59bcb Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1862 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-12-29 21:23:28 +00:00
cuz
4e2110a7a9 Fixed the inlined strlen function
git-svn-id: svn://svn.cc65.org/cc65/trunk@1738 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-12-12 17:40:58 +00:00
cuz
ede471904c Reenable register variables
git-svn-id: svn://svn.cc65.org/cc65/trunk@1625 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-24 23:31:54 +00:00
cuz
b6898c3f1e Check register before static
git-svn-id: svn://svn.cc65.org/cc65/trunk@1624 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-24 21:07:39 +00:00
cuz
89f00263af Fixed a problem with the test expression in a for loop: It was not evaluated
correctly if it did not contain an explicit comparison operator.
Removed an old hack from the test subroutine that did no longer work.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1619 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-24 18:18:16 +00:00
cuz
ca1386e9d4 Removed unused code
git-svn-id: svn://svn.cc65.org/cc65/trunk@1522 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-14 22:52:29 +00:00
cuz
dadd136ae1 Use constants for datatype sizes
git-svn-id: svn://svn.cc65.org/cc65/trunk@1480 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-02 12:39:10 +00:00
cuz
8810e38bb7 Move the assignment parser into a separate module.
When assigning structures, copy them using the primary register when the
size is 1, 2, or 4.
When assigning structures, allow structures by value when the size is 1,
2, or 4. These structures are expected to be in the primary register. The
only case when this can happen is by return from function, so this change
makes div() work.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1477 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-01 21:27:31 +00:00
cuz
5548b6fd56 Work on better type casts - not yet finished
git-svn-id: svn://svn.cc65.org/cc65/trunk@1476 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-11-01 15:16:16 +00:00
cuz
4389b0c438 Fixed a small bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1426 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-10-03 09:00:57 +00:00
cuz
257005696f Improve type casts for ints.
Allow the second and third operand of the :? operator to be of type int.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1395 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-09-18 20:14:51 +00:00
cuz
8d8458032d Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1371 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-07-26 19:27:55 +00:00
cuz
02c26efdd3 Replace calls to memset with _bzero if the fill value is zero and -Oi in
effect.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1359 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-07-16 11:01:51 +00:00
cuz
7c9bf720d8 Fixed a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1350 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-07-12 08:45:42 +00:00
cuz
f93eb903ba Fixed/worked around a bug
git-svn-id: svn://svn.cc65.org/cc65/trunk@1343 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-07-10 21:04:02 +00:00
cuz
a96da498f5 Renamed the functions working with "struct Function".
Fixed a problem with K&R functions: In a function with no return type
specified, the compiler did not allow a simple "return" statement. However,
there was no "void" type at that time, so it was not possible to specify
something else. The solution is to allow omission of a return value in a
K&R function with an implicit int type. Other types or an explicit int is
still checked.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1302 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-06-12 12:12:04 +00:00
cuz
21afe25e90 Indirect fastcall functions with no parameters may be called as if it were
cdecl functions, this generates better code.
Remove a small error that caused indirect non fastcall function to always be
handled as variadic, which meant a useless load of the Y register was added.


git-svn-id: svn://svn.cc65.org/cc65/trunk@1292 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-05-26 11:08:17 +00:00
cuz
3292569a89 One less bug in sizeof ("ABC").
git-svn-id: svn://svn.cc65.org/cc65/trunk@1274 b7a2c559-68d2-44c3-8de9-860c34a00d81
2002-05-16 17:05:36 +00:00