Commit Graph

131 Commits

Author SHA1 Message Date
Jeremiah Orians 754c5de7d9
Add note about big endian architectures 2023-04-30 18:36:30 -04:00
Andrius Štikonas 85dd953b70 Add padding when loading global ints on 64-bit arches. 2023-04-30 23:18:48 +01:00
Andrius Štikonas dba5c792c0 Make sure to use signed/unsigned instructions in load_value. 2022-12-10 18:04:46 +00:00
Andrius Štikonas 4f17e046e8 Fix support for arrays of structs. 2022-12-07 23:47:17 +00:00
Andrius Štikonas 259ff86c1b Add support for . operator that is after array. 2022-12-06 21:42:30 +00:00
Andrius Štikonas 39ca206412 Fix segfault. 2022-12-04 20:57:33 +00:00
Andrius Štikonas 62b53a554e Implement fixed sized integers: (u)int8_t, (u)int16_t, (u)int32_t. 2022-12-04 02:04:36 +00:00
Andrius Štikonas d310700151 Switch to new GAS style x86 defines. 2022-12-02 21:50:42 +00:00
Andrius Štikonas 18a7484a99 Add support for local structs. 2022-11-06 18:15:26 +00:00
Andrius Štikonas bf66daaf4c Chage riscv stack depth sign convention to match x86 and amd64. 2022-11-06 17:11:20 +00:00
Andrius Štikonas 7e7558768a Add support for global structs. 2022-11-05 23:30:46 +00:00
Andrius Štikonas f7fcc0af6e Adapt to M2libc changes.
* Some test includes have changed.
* New GAS style amd64 defines.
* Make M2-Planet output position independent code on amd64.
2022-10-09 14:15:07 +01:00
Jeremiah Orians 65444b33d2
Clearing out more segfaults 2022-05-18 07:37:42 -04:00
Jeremiah Orians 0a07af340b
Found new segfaults 2022-05-14 21:51:09 -04:00
Jeremiah Orians 406d0856df
Backport macro functionality to better handle nested #if statements 2022-01-21 22:35:45 -05:00
Andrius Štikonas 1e784f5afb Add riscv32 port. 2021-12-02 22:41:27 +00:00
Jeremiah Orians 9613c28c4b
Catch segfault caused by missing C statements 2021-11-16 22:01:35 -05:00
Andrius Štikonas 185ef7a7c2 Improve handling of compound assignment operators.
Previously, compound assignment operators were replaced in preprocessor.
This only worked for simple cases where we only had 1-token variable.

This commit switches to proper implementation in the parser.
2021-11-15 00:06:08 +00:00
Andrius Štikonas 511601bcd9 Revert "Add support for pre-increment and pre-decrement operators."
This reverts commit ab49bcafa4.
2021-11-13 20:55:11 +00:00
Andrius Štikonas ab49bcafa4 Add support for pre-increment and pre-decrement operators.
At the moment there is a limitation on only one unary operator,
so things like *++p wouldn't work but ++*p would work.
2021-11-12 19:37:54 +00:00
Andrius Štikonas 575f91cac1 Fix typos / add copyright. 2021-11-11 15:21:28 +00:00
Jeremiah Orians a025387b81
Catch walking off the end of a variable dereference 2021-11-11 09:48:26 -05:00
Andrius Štikonas 6ebe45f369 Implement variable dereferencing. 2021-11-10 00:14:30 +00:00
Andrius Štikonas 546cb1ac95 Add support for char** arrays. 2021-11-07 21:18:59 +00:00
Andrius Štikonas a900bc6632 Implement C99 negation.
!a is 1 if a == 0 and 0 otherwise.
2021-10-29 00:52:29 +01:00
Andrius Štikonas 56ee526c4c Implement support for large immediates on RISC-V. 2021-10-03 11:37:03 +01:00
Jeremiah Orians 5e74995c13
Catch truncated function calls and truncated array statements 2021-10-02 22:02:39 -04:00
Jeremiah Orians 0577243444
Fix Problem with global arrays #18 2021-10-02 10:38:04 -04:00
Andrius Štikonas ae48dbd6cb Add riscv64 port. 2021-10-02 11:59:21 +01:00
Jeremiah Orians 745998ac13
Fix global array initialization to allocate the correct amount of memory 2021-06-26 11:58:13 -04:00
Jeremiah Orians 99df87bc0d
Breakup program to reduce complexity and risk of errors 2021-06-26 11:51:54 -04:00
Jeremiah Orians b37dfc7b12
Report proper error message for negative global array values. Thank you melg8 2021-06-26 10:53:45 -04:00
Jeremiah Orians 8bc09f2b2e
Fixed hang on large global arrays. Thanks melg8 2021-06-23 07:32:40 -04:00
Jeremiah Orians d80d8a652b
Move more functionality into M2libc 2021-04-03 22:41:52 -04:00
Jeremiah Orians 46cf81af83
Replace file_print with fputs 2021-04-03 18:56:55 -04:00
Jeremiah Orians 6f8e2eb905
Removed need for fixup 2021-02-02 23:39:27 -05:00
Jeremiah Orians c5068b227a
Add support for &global_variable 2021-01-28 22:22:08 -05:00
Sanne Wouda 0e3d5b609a Add support for global char foo[12]; definitions
- only enabled in --bootstrap-mode

- allocates space for both the char array and the pointer to the start of
  the array
2021-01-10 23:01:08 +00:00
Sanne Wouda 49fbe8942f Add error checking for unexpected #endif 2021-01-05 22:56:30 +00:00
Sanne Wouda cd96f65a23 Add macro directives to token_list
- change the lexer to not remove preprocessor directives
- preprocess() removes any lines starting with a macro directive that it
  doesn't understand (which is currently all of them)
2021-01-05 22:53:39 +00:00
Sanne Wouda 7b8a99db3c Add a preprocessor-only mode
- Very useful for testing and debugging
- Add preprocess() stub and skip compilation in preprocessor mode
2021-01-05 22:53:04 +00:00
Sanne Wouda a18e0c1782 Add newline tokens to parse stream
- needed to determine start and end of macro directives
- the main parser doesn't need them, so strip out the newline tokens
  before parsing to avoid changing it
2021-01-05 22:23:15 +00:00
Jeremiah Orians 921cc86ce6
First generation implemention of typedef 2021-01-02 22:00:02 -05:00
Jeremiah Orians 358b6cfb96
Fix modulus behavior that is wrong.
Thank you janneke
2021-01-01 16:39:27 -05:00
Jeremiah Orians c220d14928
Catching some segfaults 2020-12-31 09:53:05 -05:00
Jeremiah Orians e25c1995aa
Make types more proper 2020-12-27 21:51:46 -05:00
Jeremiah Orians 6fe6f44a29
Make type information localized to the inside of statements 2020-12-19 16:35:33 -05:00
Jeremiah Orians d9504e3872
Allow M2-Planet to support larger outputs without hitting a segfault 2020-12-19 06:50:11 -05:00
Sanne Wouda 968fdfea65 AArch64 support for unsigned comparison 2020-12-17 00:01:17 +00:00
Jeremiah Orians e5befc4fee
armv7l support for unsigned comparisons 2020-12-15 21:09:26 -05:00