Compare commits

...

1589 Commits

Author SHA1 Message Date
drmortalwombat 6ed4adb0ed OPtimize signed+unsigned char arithmetic 2025-06-19 21:54:23 +02:00
drmortalwombat f16c24363c Improve pointer compare constant folding 2025-06-19 12:58:40 +02:00
drmortalwombat fd7e68573c Fold CLC into prev block for dual pointer increment 2025-06-19 09:37:03 +02:00
drmortalwombat f1873f0794 Optimize carry flag analysis with indexed tables 2025-06-17 21:51:19 +02:00
drmortalwombat a01d98e584 Propagate closed bool variables to use sign bit instead of zero/one 2025-06-15 18:10:50 +02:00
drmortalwombat c7a53a5be6 Bump version number 2025-06-15 14:27:49 +02:00
drmortalwombat 4633631d7e Fix double condition propagation 2025-06-15 13:56:11 +02:00
drmortalwombat 100608e0ac Fix loop head split for infinite loops 2025-06-14 12:53:55 +02:00
drmortalwombat 35a0b36a0d Make rasterirq handler more resilient for timing glitches 2025-06-11 09:34:21 +02:00
drmortalwombat 5470db3a5f Fix sidfx state machine sequence end 2025-06-10 21:06:28 +02:00
drmortalwombat d6802f3cb9 Make loop head extraction explicit 2025-06-10 17:41:16 +02:00
drmortalwombat 5b4e0c2b55 Sidfx extend gate sprike condition 2025-06-08 18:19:37 +02:00
drmortalwombat 8175fae67a Add complex loop value forwarding, tweak sidfx state machine 2025-06-07 19:35:40 +02:00
drmortalwombat 13c90eb542 Change SIDFX state machine reset 2025-06-06 20:00:38 +02:00
drmortalwombat f98665c577 Fix bool artihmetic assign combos 2025-06-01 18:40:19 +02:00
drmortalwombat 8843f3feba Fix pointer loop reversal counting from one 2025-06-01 11:51:24 +02:00
drmortalwombat 514cf59398 More short loop reversal 2025-05-31 19:44:33 +02:00
drmortalwombat 03c133cd48 Swap shift/add if add fits in byte before but not after 2025-05-30 17:39:40 +02:00
drmortalwombat 880abea32e Shortcut tiny jump detours after placement 2025-05-29 13:38:00 +02:00
drmortalwombat fc9a8f2a89 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2025-05-28 20:49:00 +02:00
drmortalwombat 40c467d958 Improve copy elision 2025-05-28 20:48:37 +02:00
drmortalwombat 4bde6385b8
Merge pull request #250 from ilmich/fix-compiler-build
prepare output directory also to build only the compiler
2025-05-28 12:55:39 +02:00
drmortalwombat 688ef958e3 Add default move constructor and assignment operators 2025-05-27 20:47:03 +02:00
ilmich 6da7223472 prepare output directory also to build only the compiler 2025-05-27 16:33:36 +02:00
drmortalwombat a1d4bc8375 Improve const initialized simple type usage for local variables 2025-05-27 14:03:04 +02:00
drmortalwombat 197e2a91be Optimize carry propagation 2025-05-25 17:37:52 +02:00
drmortalwombat 4d9d628b67 Add static_assert 2025-05-25 12:31:15 +02:00
drmortalwombat f720feebbf Fix global register forward mixing up x and y in one case 2025-05-25 10:15:47 +02:00
drmortalwombat 6076808f5e Relax interrupt complexity limits for local variables on stack 2025-05-24 20:48:04 +02:00
drmortalwombat 0af17f0f40 Fix constness of reference parameter of standard copy assignment operator 2025-05-24 17:49:51 +02:00
drmortalwombat 81e5321bfc Return short simple structs in accu 2025-05-23 12:02:12 +02:00
drmortalwombat 27d3666285 Fix pass struct rvalue return to rvalue parameter conflicting zero page registers 2025-05-22 15:28:39 +02:00
drmortalwombat c6b794db3a Fix kernal io return values 2025-05-22 08:11:49 +02:00
drmortalwombat 1fa4c39a20 Add more math intrinsics 2025-05-21 16:59:52 +02:00
drmortalwombat 0ba148b6bb Make raster interrupt start more deterministic 2025-05-20 18:26:42 +02:00
drmortalwombat 65540da3f7 Optimize signed long compare 2025-05-20 16:05:09 +02:00
drmortalwombat e660757824 Some low level shift optimizations 2025-05-20 11:09:20 +02:00
drmortalwombat 05a6d16dde Some cascading store optimization 2025-05-19 17:23:28 +02:00
drmortalwombat 79ec9af3f2 Fix signed unsigned char compare to promote to int 2025-05-19 15:31:30 +02:00
drmortalwombat 8f37df448f Optimize constant array parameters 2025-05-19 10:03:45 +02:00
drmortalwombat d710a71ba0 Fix static const member qualification with dot 2025-05-19 08:16:58 +02:00
drmortalwombat 8dd211b662 Fix crash in peephole optimizer on potential oob static const array access 2025-05-18 19:25:47 +02:00
drmortalwombat 398ed22b09 Fix array member packing strategy 2025-05-18 18:41:37 +02:00
drmortalwombat 6f1da4335b Fix continue/break for unrolled loops 2025-05-18 14:04:14 +02:00
drmortalwombat c86dc364b1 Fixed array size template parameter 2025-05-18 11:35:13 +02:00
drmortalwombat 70eb7a5eab Fix assert with negative array offset in local variable of a recursive function 2025-05-18 11:03:04 +02:00
drmortalwombat c1cd2ba57e Fix crash with partial reference of ternary conditional operator 2025-05-18 09:42:37 +02:00
drmortalwombat 00da0ef87d Add CAPACITYCHECK to static_vector 2025-05-17 09:07:33 +02:00
drmortalwombat be9abbf510 Optimize vector copy 2025-05-16 18:20:23 +02:00
drmortalwombat 0b72e6b2f2 Force nop for breakpoint() to avoid elimination if alone in basic block 2025-05-16 17:25:58 +02:00
drmortalwombat 6ea39d7bfa CTT file import 2025-05-15 17:50:59 +02:00
drmortalwombat c0abe031ee Fix enum base type selection with trailing comma 2025-05-15 08:46:57 +02:00
drmortalwombat fe667863b2 Constant folding of absolute pointer difference 2025-05-15 07:58:58 +02:00
drmortalwombat e514e05dc8 Fix crash constant folding uninitialized constants 2025-05-14 20:22:25 +02:00
drmortalwombat d978d0a483 Fix error message location for integer const truncation 2025-05-14 18:25:20 +02:00
drmortalwombat 37cacdafa7 Improve cross compilation unit template matching 2025-05-14 18:18:13 +02:00
drmortalwombat 78e3696663 Improve nullptr check for addresses of placed linker objects 2025-05-14 17:09:12 +02:00
drmortalwombat a0215a4f21 Add fix for template overload with multiple includes 2025-05-14 15:15:24 +02:00
drmortalwombat 2310416c46 Propagate non aliasing initializers to compile time constants 2025-05-13 20:48:12 +02:00
drmortalwombat 52db653ec1 Optimize shift code generation 2025-05-12 20:09:57 +02:00
drmortalwombat 6fe76e478f Add -ii option to change default include path 2025-05-11 18:29:57 +02:00
drmortalwombat ba05ec743d Fix high byte address forwarding 2025-05-11 17:31:01 +02:00
drmortalwombat 05ef25a61e Add optimization -Ox to simplify pointer arithmetic by non page crossing 2025-05-11 12:41:40 +02:00
drmortalwombat b26cc4ede7 Remove assembly debug output 2025-05-10 20:24:30 +02:00
drmortalwombat 8dc5f703e8 Fix copy indirect lea elimination 2025-05-10 20:23:45 +02:00
drmortalwombat c05d7e47f4 Add assign to vector and static_vector 2025-05-10 18:50:13 +02:00
drmortalwombat 9dc8489693 Fix copy struct to value struct param, add vsprintf 2025-05-10 17:49:34 +02:00
drmortalwombat f443c97f70 Fix for default copy constructor on init calls 2025-05-10 13:40:36 +02:00
drmortalwombat 4837ceb73f Fix inline assembler optimzier for JSR returning result in X and Y 2025-05-10 13:13:27 +02:00
drmortalwombat 42299c9406 Improve const to immediate propagation 2025-05-10 10:50:42 +02:00
drmortalwombat 850bbfc31a Fix alignment increment problem 2025-05-10 09:53:31 +02:00
drmortalwombat 1e95f51469 Fix building object directly on call stack 2025-05-10 08:33:02 +02:00
drmortalwombat e525e5d62e Optimize copy of arrays of ints 2025-05-09 16:52:04 +02:00
drmortalwombat 18deb8846d Add full() to static_vector 2025-05-08 17:31:16 +02:00
drmortalwombat 34ce9afeae Fix memory use after free error in vector 2025-05-08 17:26:10 +02:00
drmortalwombat d0411b7d52 Fix more function overloads with const 2025-05-08 15:21:59 +02:00
drmortalwombat 34fda8c9b5 Fix const struct parameter overload matching 2025-05-08 13:50:51 +02:00
drmortalwombat b4a357e44f Add clear to vector and static_vector 2025-05-08 12:30:50 +02:00
drmortalwombat 2b224f262b Fix use of hash character in preprocessor defines 2025-05-08 08:18:57 +02:00
drmortalwombat 3c306e0899 Fix loss of register dependency chain when splitting 16bit adds into basic blocks 2025-05-07 13:13:33 +02:00
drmortalwombat e82ab0c7ca Improve shift carry combine 2025-05-06 18:38:44 +02:00
drmortalwombat 983064c694 Fix removal of reference returns when struct member used 2025-05-06 17:00:36 +02:00
drmortalwombat 9230d95bad Fix copy constructor selection in placement new 2025-05-06 08:53:57 +02:00
drmortalwombat 8b0790588b Fix integer range when combining same instruction on alternate paths 2025-05-05 16:52:17 +02:00
drmortalwombat 0a9c43757a Fix reference to value cast 2025-05-05 11:44:10 +02:00
drmortalwombat fccfe35c4f Fix 16bit const add propagation 2025-05-05 11:17:00 +02:00
drmortalwombat 064fed63f5 Fix operator() call on reference parameter 2025-05-04 16:18:07 +02:00
drmortalwombat f43f471124 Fix internal const cast 2025-05-04 16:00:08 +02:00
drmortalwombat f99abb32e2 Fix cost method selection for pointers to incomplete types 2025-05-04 15:27:28 +02:00
drmortalwombat 18f044e90c Fix crash in profile generation 2025-05-04 13:12:14 +02:00
drmortalwombat 5b961c031c Fix reference return from inlined function into inline parameter 2025-05-04 11:05:15 +02:00
drmortalwombat 500cce511f Fix removal of function reference result if only used as target 2025-05-03 17:22:18 +02:00
drmortalwombat 885d6ff706 Fix crash in complex select statement 2025-05-03 09:41:15 +02:00
drmortalwombat efc182ce27
Merge pull request #238 from polluks/patch-4
Fixed minor typo
2025-05-02 17:43:29 +02:00
drmortalwombat 06ef87fe63
Merge pull request #237 from polluks/patch-5
Fixed minor typo
2025-05-02 17:43:05 +02:00
drmortalwombat f3d8251072
Merge pull request #236 from polluks/patch-6
Fixed minor typo
2025-05-02 17:42:37 +02:00
drmortalwombat 0d5efc90ed
Merge pull request #235 from polluks/patch-7
Fixed minor typo
2025-05-02 17:42:18 +02:00
drmortalwombat 30b8e4e970
Merge pull request #234 from polluks/patch-8
Fixed minor typo
2025-05-02 17:41:52 +02:00
drmortalwombat 3da1ddf5da
Merge pull request #233 from polluks/patch-9
Fixed typo
2025-05-02 17:41:29 +02:00
drmortalwombat bfdd1b85fb
Merge pull request #239 from polluks/patch-3
Fixed minor typo
2025-05-02 17:40:59 +02:00
drmortalwombat 686d468d32
Merge pull request #240 from polluks/patch-2
Fixed minor typo
2025-05-02 17:40:39 +02:00
drmortalwombat 23b15678cd
Merge pull request #232 from polluks/patch-10
Fixed minor typo
2025-05-02 17:40:13 +02:00
Stefan d1054abd90
Fixed minor typo 2025-05-02 16:50:57 +02:00
Stefan d358c8359b
Fixed typo 2025-05-02 16:48:56 +02:00
Stefan 9e9494ebf9
Fixed minor typo 2025-05-02 16:46:27 +02:00
Stefan 015ada7a33
Fixed minor typo 2025-05-02 16:44:44 +02:00
drmortalwombat 12e832ebd3 Fix static constexpr in class context 2025-05-02 16:44:24 +02:00
Stefan e327d2a148
Fixed minor typo 2025-05-02 16:41:42 +02:00
Stefan 366f9686dd
Fixed minor typo 2025-05-02 16:39:17 +02:00
Stefan a2927401bc
Fixed minor typo 2025-05-02 16:36:01 +02:00
Stefan bbb339d641
Fixed minor typo 2025-05-02 16:33:35 +02:00
Stefan 8e76334c20
Fixed minor typo 2025-05-02 16:30:49 +02:00
drmortalwombat 739f1e2161 Improve conditional branch integer range propagation 2025-05-01 20:23:13 +02:00
drmortalwombat 4ee6ca5b94 Improve function automatic template matching 2025-05-01 16:04:10 +02:00
drmortalwombat 347898ea53 fix mixup of stack and fast call in virtual function parameter offsets 2025-05-01 10:21:35 +02:00
drmortalwombat 6caed58be4 Fix new operator broken with placement new fix 2025-04-30 22:38:43 +02:00
drmortalwombat c4185832ba Fix method invocation on rvalue reference 2025-04-30 17:06:28 +02:00
drmortalwombat 2b0994b086 Fix placement new for vector constructor 2025-04-29 20:12:48 +02:00
drmortalwombat f9acbc152d Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2025-04-29 14:26:58 +02:00
drmortalwombat 3eed21567e Fix disabled warning bitset size 2025-04-29 14:26:55 +02:00
drmortalwombat f3370cb149
Merge pull request #226 from CTalkobt/main
Update to reflect mega65 in .md
2025-04-27 14:23:54 +02:00
ctalkobt@ctalkobt.net 494fb97e49 Update to reflect mega65 in .md 2025-04-27 07:38:14 -04:00
drmortalwombat bd8786af0b Improve carry propagation to eliminate sec and clc 2025-04-26 21:25:43 +02:00
drmortalwombat f0a7499814 Ignore nullptr access for volatile data 2025-04-24 15:31:39 +02:00
drmortalwombat da4a90b724 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2025-04-24 09:05:59 +02:00
drmortalwombat 96a9109915 Add warning pragma, improved token concatenation in preprocessing 2025-04-24 09:05:57 +02:00
drmortalwombat f5a33edcf4
Merge pull request #224 from polluks/patch-1
Changed make target everywhere
2025-04-23 16:58:45 +02:00
Stefan 1bd98bdeb2
Changed make target everywhere
oops
2025-04-23 15:32:26 +02:00
drmortalwombat e4696a6539
Merge pull request #223 from polluks/wildcard
More POSIX, fixed #190
2025-04-23 11:23:21 +02:00
polluks 74350d6133 oops 2025-04-23 10:40:28 +02:00
drmortalwombat cbf86b2e8f
Merge pull request #219 from polluks/patch-3
Changed make target
2025-04-22 08:21:40 +02:00
Stefan cb757dfaf9
Changed make target
https://www.gnu.org/software/make/manual/html_node/Standard-Targets.html
2025-04-21 22:22:40 +02:00
drmortalwombat 5ad94d01d4
Merge pull request #218 from CTalkobt/main
Correct end address for Mega 65
2025-04-21 20:13:40 +02:00
ctalkobt@ctalkobt.net cdba71b353 Correct end address for M65 2025-04-21 13:46:53 -04:00
drmortalwombat 01d187cf83
Merge pull request #217 from CTalkobt/main
Initial patch to add -tm=mega65 support
2025-04-21 18:48:38 +02:00
drmortalwombat ab06ce74c5 More global namespace fixes 2025-04-21 18:29:01 +02:00
Craig Taylor 1e2b227113
Merge branch 'drmortalwombat:main' into main 2025-04-21 11:53:36 -04:00
ctalkobt@ctalkobt.net 9d5dbe67fe Adjust M65 top of memory to $e000 2025-04-21 11:48:12 -04:00
ctalkobt@ctalkobt.net 9a409ca347 Initial patch to add -tm=mega65 support 2025-04-21 11:12:02 -04:00
drmortalwombat 449acece05 Fix global namespace access 2025-04-21 15:58:49 +02:00
drmortalwombat ee3f6fc4a5 Struct value forwarding 2025-04-21 08:18:55 +02:00
drmortalwombat e95b51609c Optimize loop unrolling 2025-04-18 17:16:56 +02:00
drmortalwombat 323589a484 Optimize compilation time 2025-04-18 12:55:10 +02:00
drmortalwombat 33f4b25f28 Fix C64 ascii to petscii output in conio 2025-04-17 22:38:54 +02:00
drmortalwombat 538d965636 Fix 16bit forward for middle 32bit registers 2025-04-17 18:55:53 +02:00
drmortalwombat 4b99110533 Bump version number 2025-04-10 08:47:24 +02:00
drmortalwombat 94f2489083 Fix TAXA range bypass with trailing multi store 2025-04-08 18:22:45 +02:00
drmortalwombat 6de1b1fd96 Code size optimizations 2025-03-31 17:30:57 +02:00
drmortalwombat 80abcdfe95 Optimize local struct variable usage 2025-03-30 20:22:50 +02:00
drmortalwombat 0dc6588a66 Improve double index register single block loops 2025-03-29 13:30:03 +01:00
drmortalwombat 65ad05c608 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2025-03-24 08:56:07 +01:00
drmortalwombat 2db8890453 Fix temp spilling in recursive functions 2025-03-24 08:56:03 +01:00
drmortalwombat 3f4268328e
Merge pull request #198 from root42/detect-basic-and-gotoxy-for-pet
Implement gotoxy for PET
2025-03-23 14:54:10 +01:00
Arne Schmitz 33cabb487b pure C implementation 2025-03-23 13:15:09 +01:00
Arne Schmitz ab2ca897ce pure asm implementation of bsplot 2025-03-22 12:31:05 +01:00
Arne Schmitz 2c37e150a9 comment 2025-03-22 12:31:05 +01:00
Arne Schmitz ee68f2575a better implementation, inspired by cc65 2025-03-22 12:31:05 +01:00
Arne Schmitz 4f100266c3 fix ldy 2025-03-22 12:31:05 +01:00
Arne Schmitz c22a67f95f basic version detection and and implement bsplot for PET 2025-03-22 12:31:05 +01:00
drmortalwombat e6bc6371c9 Fix PET target zero page variable range 2025-03-19 17:16:20 +01:00
drmortalwombat 2acca6d7b1 Fix register load/store bypass when register result still needed 2025-03-19 09:38:40 +01:00
drmortalwombat fc2095301d Fix aliasing problem when auto inlining non early embedded assembly stubs 2025-03-16 20:29:03 +01:00
drmortalwombat 32f0b8c6f3 Fix warnings in unreachable code 2025-03-16 15:53:27 +01:00
drmortalwombat 10c9b735e9 Fix short infinite loop code split 2025-03-15 21:17:21 +01:00
drmortalwombat fefb511404 Fix integer range loss in loop index reduction 2025-03-15 17:59:45 +01:00
drmortalwombat bedafe7b6f Fix loss of type reduction in loop causing overflow error 2025-03-15 12:05:34 +01:00
drmortalwombat 242d7f1700 Fix optimizer crash with volatile long ops 2025-03-14 08:10:36 +01:00
drmortalwombat 90e892dfa5
Merge pull request #199 from polluks/patch-2
Fixed install
2025-03-12 08:12:34 +01:00
drmortalwombat c98e0751b0 Fix carry usage check in inline assembler, add optional volatile to __asm 2025-03-12 08:11:23 +01:00
Stefan f3b4a4e5fc
Fixed install
Long options are not POSIX.
2025-03-11 23:01:49 +01:00
drmortalwombat 1c7d71cadb Fix loop unrolling changing boundary constant 2025-03-11 08:19:49 +01:00
drmortalwombat 840050738f Fix compare of enum in striped bitfield 2025-03-09 10:49:23 +01:00
drmortalwombat 2ee5cc7bf4 Fix loss of memory live status when reversing compare 2025-03-07 17:23:50 +01:00
drmortalwombat 490180f9dc Fix compare reversal and reuse if z flag used 2025-03-07 08:17:51 +01:00
drmortalwombat 2582f3076d Fix passing rvalue to non const reference 2025-03-02 15:02:01 +01:00
drmortalwombat 0032d42b2c Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2025-02-28 16:20:10 +01:00
drmortalwombat 5c70c20c6e Reverse cross block accu to index propagation 2025-02-28 16:20:07 +01:00
drmortalwombat 71236aa405
Merge pull request #193 from polluks/patch-1
Fixed minor typos
2025-02-25 15:50:15 +01:00
Stefan 31a38e2a62
Fixed minor typos 2025-02-25 13:44:32 +01:00
drmortalwombat ee0e4d5428 Fix void pointer arithmetic 2025-02-23 11:04:29 +01:00
drmortalwombat f6296e83e5 Improve outliner for short loops 2025-02-18 14:51:42 +01:00
drmortalwombat 39840b5fb1 Convert add to compare if only flags needed 2025-02-18 11:35:06 +01:00
drmortalwombat fe0bfccfaa Reduce eagerness to join stores with short leas 2025-02-18 09:22:28 +01:00
drmortalwombat 25ee4e9b2b Shortcut known branch cascades 2025-02-17 13:12:28 +01:00
drmortalwombat 9f7d4c0ab0 Improved index register use in short loops 2025-02-16 17:16:27 +01:00
drmortalwombat 038928232c Propagate conditional stores behind blocks 2025-02-15 10:51:55 +01:00
drmortalwombat 100affa083 Reverse zp register alias move across single block loops 2025-02-14 10:40:00 +01:00
drmortalwombat e27075955d Optimize enums in bitfield usage 2025-02-12 15:12:06 +01:00
drmortalwombat 0959a15b10 Fixed striped structs with bitfields 2025-02-09 22:10:39 +01:00
drmortalwombat 4a87e4d97b Fix no inline for overloaded operators 2025-02-08 11:04:19 +01:00
drmortalwombat 9de7caa68d Fix enums in bitfields 2025-02-05 10:57:58 +01:00
drmortalwombat e23d78eb86 Fix move of store abs cross function call 2025-02-01 20:13:18 +01:00
drmortalwombat d0b45fce78 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2025-01-31 18:43:07 +01:00
drmortalwombat 0126dd53a3 Fix infinite optimizer loop 2025-01-31 18:43:01 +01:00
drmortalwombat 901c8459ec
Merge pull request #186 from seclorum/main
Created a CMakeLists.txt for the project
2025-01-24 20:09:43 +01:00
Jay Vaughan 746fed6704 Get target_sources through glob'ing instead of explicit filenames 2025-01-24 19:07:18 +01:00
Jay Vaughan 54c0f2a670 Created a CMakeLists.txt for the project - oscar64 can now be built on MacOS/Darwin with cmake 2025-01-24 15:17:31 +01:00
drmortalwombat 28ea8ef24f Fix integer value range for ext8to16 unsigned 2025-01-22 21:40:51 +01:00
drmortalwombat 115129e1dd Reorder lda x, cmp y to reuse y 2025-01-21 22:26:57 +01:00
drmortalwombat f41d594015 Fix load/binop/store with different sizes 2025-01-19 21:26:25 +01:00
drmortalwombat c8abb42c3c Optimize outliner compile time performance 2025-01-19 18:10:02 +01:00
drmortalwombat 95732265f6 Add experimental native code outliner 2025-01-19 17:28:20 +01:00
drmortalwombat 9f834c4232 Fix integer type coercion with cast operator 2025-01-18 10:13:29 +01:00
drmortalwombat d10d8bf7ae Optimize index register use for one bit high byte 2025-01-10 21:09:03 +01:00
drmortalwombat f6a2db7866 Reuse index register transfer to avoid compare 2025-01-09 20:12:09 +01:00
drmortalwombat d2fdbd29f5 Add loop sinking optimization 2025-01-09 10:54:45 +01:00
drmortalwombat f5dff9620b Fix degrading merge of stores that prevent absolute addressing 2025-01-07 22:07:36 +01:00
drmortalwombat 28e75a8fa2 Fix invalid double dereference reorder 2025-01-06 22:05:43 +01:00
drmortalwombat 6170c81af3 Improve 8 to 16 bit signed add 2025-01-06 18:54:21 +01:00
drmortalwombat 3d578170db Improve 16bit op pair reordering 2025-01-06 15:58:41 +01:00
drmortalwombat d99499b6e3 Improve double indexed pointer from table 2025-01-04 11:11:37 +01:00
drmortalwombat 950c434157 Improve const range propagation after byte compare 2025-01-04 09:12:56 +01:00
drmortalwombat d6362a305f Improve const bitmask optimization 2025-01-03 14:29:08 +01:00
drmortalwombat 38bb033328 Fix global variable changes bypassing assembly blocks 2024-12-30 18:06:26 +01:00
drmortalwombat 87f1ddd27f Fix usage of assembler labels as pointer initializer 2024-12-29 10:22:01 +01:00
drmortalwombat 9e994560a7 Improve double indexed loop with fixed stride 2024-12-29 09:46:33 +01:00
drmortalwombat e37de95079 Add bounded integer class 2024-12-26 14:57:23 +01:00
drmortalwombat 8e46ae95ec Improve unsigned compare result propagation 2024-12-24 15:23:02 +01:00
drmortalwombat e7cece0f0f Fix debug assert for negative array index intermediate result 2024-12-23 22:31:04 +01:00
drmortalwombat 890a4b996e Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2024-12-22 21:22:08 +01:00
drmortalwombat 5b2ae228cc Improve table pointer forwarding 2024-12-22 21:22:05 +01:00
drmortalwombat 9fc8315f92
Merge pull request #179 from root42/pet-kbhit
kbhit variant for CBM PET
2024-12-18 12:02:31 +01:00
Arne Schmitz 32935cd7a1 use keyboard buffer instead 2024-12-18 11:59:01 +01:00
Arne Schmitz fd02382d38 kbhit variant for CBM PET 2024-12-18 11:47:26 +01:00
drmortalwombat 4fce263228 Optimize hires line draw 2024-12-15 16:34:53 +01:00
drmortalwombat 50c7e10814 Add forward declaration of __asm code 2024-12-08 12:05:02 +01:00
drmortalwombat 7c8ab991be Bump version number 2024-12-07 13:08:37 +01:00
drmortalwombat 067e169803 Fix analysis of register usage of inline assembler 2024-12-06 18:54:55 +01:00
drmortalwombat ccdbbe799a Fix assert in linux autotest 2024-12-05 08:05:43 +01:00
drmortalwombat fac53cfd54 Add "-strict" command line option, to loosen C syntax and allow default arguments when not set 2024-12-03 09:03:43 +01:00
drmortalwombat cfe2c7bed5 Fix infinite loop in parser due to failure to detect label 2024-12-02 16:27:13 +01:00
drmortalwombat f0b9b5cce4 More C++ aggregate initialization 2024-12-02 15:39:14 +01:00
drmortalwombat 803b868356 Improve zero page addressing of global variables in inline assembler 2024-12-01 15:33:51 +01:00
drmortalwombat 907452d918 Fix rirq_sort when called from within interrupt 2024-11-30 13:01:09 +01:00
drmortalwombat c12bca7b4e Fix crash in optimizer due to lack of updated register dependecy set when splitting block in loop 2024-11-30 09:40:26 +01:00
drmortalwombat e1736c8214 Reverse shift with negated distance 2024-11-21 22:02:25 +01:00
drmortalwombat d3e7a991a4 Fix int to bool coercion 2024-11-19 18:42:07 +01:00
drmortalwombat e7b0d17a83 Add some std library functions 2024-11-19 16:22:09 +01:00
drmortalwombat df18dc273e Forward binary op in txax 2024-11-17 21:54:55 +01:00
drmortalwombat b6341e402d Fix const bool to int conversion in loop 2024-11-16 13:48:47 +01:00
drmortalwombat 3f2f703936 Bump version number 2024-11-14 17:37:07 +01:00
drmortalwombat 4acee4531c Remove needless register transfers from inner loops 2024-11-12 13:37:50 +01:00
drmortalwombat 2a476d3372 Fix const void * type propagation 2024-11-07 10:56:21 +01:00
drmortalwombat 0a41cb044c Relax rules for argument forwarding in direct call chains 2024-11-05 17:20:22 +01:00
drmortalwombat 5a0f736d41 Fix in block branch collides with fcall proxy generation 2024-11-05 08:17:18 +01:00
drmortalwombat 020534dbc8 Bump version number 2024-11-03 17:35:19 +01:00
drmortalwombat cee2801847 Fixed negative offset leas 2024-11-03 15:36:53 +01:00
drmortalwombat 51c38a4723 Fix short lea coalescing with negative offsets 2024-11-03 10:14:18 +01:00
drmortalwombat bb01d1024a Fix striped indirect arrays 2024-11-02 14:52:06 +01:00
drmortalwombat 903a5d9b8b
Update README.md 2024-11-02 11:45:31 +01:00
drmortalwombat e360dea558 Fix link text 2024-11-02 11:40:02 +01:00
drmortalwombat 582443ef5c Split readme and reference 2024-11-02 11:36:30 +01:00
drmortalwombat 80a42216c7 Prepare split of readme and manual 2024-11-02 10:30:11 +01:00
drmortalwombat 6576f4d090
Merge pull request #170 from sehugg/main
Fixed stack-use-after-return bug found with -fsanitize=address,undefined
2024-11-01 22:37:25 +01:00
Steven Hugg 55e983e5a1 Fixed stack-use-after-return bug found with -fsanitize 2024-11-01 15:30:17 -05:00
drmortalwombat a6f9c733a1 Fix drop of reading from volatile with discarding result 2024-11-01 20:32:54 +01:00
drmortalwombat 3c129ff4e5 Fix complex diamond pointer forwarding
Forwarding failed when pointer was used and modified in one branch of the diamond
2024-10-31 22:48:34 +01:00
drmortalwombat db386a5958 Fix multi indirection lea propagation 2024-10-31 07:13:30 +01:00
drmortalwombat 179cc694e3 Reduce code size by recycling nearby jmp for far branches 2024-10-27 16:56:35 +01:00
drmortalwombat 887a51b176 Fix array in struct const declaration without braces 2024-10-26 18:35:29 +02:00
drmortalwombat 5b81379dac Fix const structs in arrays without braces 2024-10-26 17:28:13 +02:00
drmortalwombat 4fff9f7060 Add optional static memory profile output file 2024-10-24 13:58:14 +02:00
drmortalwombat 40c407782d Fix uppercase flag in iostream 2024-10-24 07:21:39 +02:00
drmortalwombat 5946f17632 Detangle XY abs load/store pairs 2024-10-22 17:17:29 +02:00
drmortalwombat 7e0ff7449c Fix address/register mismatch in 16bit sum forwarding 2024-10-22 13:21:16 +02:00
drmortalwombat d597219aea Fix loss of memory live status when shortcuting zp shift add 2024-10-21 21:36:18 +02:00
drmortalwombat a311396cf8 Loop optimization for x and y used in simple loop 2024-10-20 18:09:50 +02:00
drmortalwombat 94607cab7f Fix extern const struct merging 2024-10-20 11:11:43 +02:00
drmortalwombat 4d193a30b0 Fix cia init code 2024-10-19 09:19:07 +02:00
drmortalwombat c1ad265f47 Fix memory type propagation in loop strength reduction 2024-10-18 15:24:08 +02:00
drmortalwombat 4e2a2c99ba Fix x reg zp dependency during peephole shuffle 2024-10-17 18:12:08 +02:00
drmortalwombat ea33f253d4 Reduce branches in short basic block sequences 2024-10-15 07:37:35 +02:00
drmortalwombat ebc41560d9 Fix value forwarding register forgetting memory reference 2024-10-13 19:52:52 +02:00
drmortalwombat 2d2c696aa4 Add sprite pad tile import 2024-10-10 16:12:35 +02:00
drmortalwombat b622c25a56 FIx previous case for TYA as well 2024-10-06 22:31:22 +02:00
drmortalwombat 439cf499ed Fix peephole opt for while (x--) 2024-10-06 22:17:29 +02:00
drmortalwombat cd5f1daaba Fixing O3 cases for gcc tests 2024-10-06 16:44:22 +02:00
drmortalwombat ec95f6dc98 Fix dynamic variable initalizer 2024-10-06 13:59:06 +02:00
drmortalwombat 66dfe5df46 Fixed constant array bounds check regression 2024-10-06 12:47:53 +02:00
drmortalwombat 9117827cfc Bump version number 2024-10-05 21:57:23 +02:00
drmortalwombat ad115701d5 Fix sprite pad level 3 read 2024-10-05 21:39:51 +02:00
drmortalwombat a15125d6af Fix crash with const access to zero size array 2024-10-05 14:01:58 +02:00
drmortalwombat dadd8eb41c Extend number of usable variables in assembler block to 32 2024-10-05 13:42:39 +02:00
drmortalwombat 056b49e1d1 Optimize 8 by 16 bit multiply 2024-10-04 20:06:56 +02:00
drmortalwombat 1f492e7820 Improve size optimization 2024-10-03 20:57:01 +02:00
drmortalwombat 4c687dfa54 Improve struct value return propagation 2024-10-03 12:53:11 +02:00
drmortalwombat e1f5bdf48b Add named variadic macro arguments 2024-10-03 10:29:42 +02:00
drmortalwombat 3ba7e0a8a4 Bump Version Number 2024-10-02 21:58:35 +02:00
drmortalwombat a71fae5bb1 Add template based bank switch proxy code 2024-10-02 20:10:47 +02:00
drmortalwombat f6c78d57ef Add __forceinline storage specifier 2024-10-02 18:27:20 +02:00
drmortalwombat 6af50f5eae Add early dead code elimination to speed up template compilation 2024-10-01 18:30:07 +02:00
drmortalwombat 62ab925e01 Add raster IRQ handler for cartridge with ROM switching 2024-10-01 09:45:41 +02:00
drmortalwombat 5126ba482e Fixed placement of static class members 2024-09-30 20:41:33 +02:00
drmortalwombat fb477b33f7 Don't use floats as num counter replacement 2024-09-30 20:33:08 +02:00
drmortalwombat 756fe9354a Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2024-09-30 20:14:02 +02:00
drmortalwombat 73c2206a1a Improve bankof implementation 2024-09-30 20:13:54 +02:00
drmortalwombat c1071ecd3c
Merge pull request #155 from jadziamd/main
Standardise Implementation of get_s C function
2024-09-30 20:13:22 +02:00
John Schneiderman 534ddc3a4c Removes the include for STD bool since it's no longer used. 2024-09-30 20:07:44 +02:00
John Schneiderman ebce50320f Fixes incorrect specification implementation not reading all the
characters.
Simplfies the buffer size checks.
2024-09-30 20:04:33 +02:00
John Schneiderman cfd2e5142a Changes from being mostly assembly to be based upon a C version.
Adds the additional error conditions for get_s: truncation
	and too small buffer.
2024-09-30 19:32:23 +02:00
drmortalwombat 581137ade7 Fix template void return of reference parameter 2024-09-30 16:54:50 +02:00
drmortalwombat c3b46d6a78 Fix condition hoisting side path check 2024-09-30 13:31:31 +02:00
drmortalwombat 84a8bf22e8 Constant folding of pointer type cast 2024-09-29 17:24:42 +02:00
drmortalwombat daeb3ddfdd Add non constant structured initializers 2024-09-29 14:31:05 +02:00
drmortalwombat bf5f5a807c Reduce inline assembly in stdio and conio 2024-09-28 12:25:44 +02:00
drmortalwombat 3dfba389ff Fix command line parsing for -O and -O1 2024-09-28 11:15:49 +02:00
drmortalwombat a4f1341587 bump version number 2024-09-27 20:14:10 +02:00
drmortalwombat 57d8747cb7 Reduce generated code size with -Os 2024-09-27 20:01:22 +02:00
drmortalwombat 1fb68c1bf3 Add -rpt option to generate error map and asm files if linker fails 2024-09-26 20:32:20 +02:00
drmortalwombat 5613a719c5 Fix linux make dependencies 2024-09-26 17:56:55 +02:00
drmortalwombat bf6343616b Fix XY detangling in loop 2024-09-26 14:03:42 +02:00
drmortalwombat 861eeaefe2 Improve signed integer compare 2024-09-26 12:39:38 +02:00
drmortalwombat db3c6a3135 Peephole optimizations 2024-09-26 09:15:09 +02:00
drmortalwombat 4c7dafed25 Bump version number 2024-09-24 11:36:36 +02:00
drmortalwombat b1440a9b3f Fix zero page parameter aliasing 2024-09-23 21:27:27 +02:00
drmortalwombat 21b5e75ddb Improve redundant loop counter removal 2024-09-23 17:53:12 +02:00
drmortalwombat 49893f6976 Fix various gcc torture tests 2024-09-22 21:40:27 +02:00
drmortalwombat c87887cbd1 Fix drop of Y register in asm code 2024-09-22 13:46:29 +02:00
drmortalwombat bcd118a8b3 Fix temporary object structured initialization 2024-09-21 23:02:59 +02:00
drmortalwombat d7bfd0a668 Fix invalid function parameter crossing 2024-09-21 22:00:54 +02:00
drmortalwombat aeceb36e2a Fix reverse 8bit unsigned range 2024-09-21 20:48:38 +02:00
drmortalwombat f67d537c7c Add abort to stddef calling exit(-1) 2024-09-21 18:12:10 +02:00
drmortalwombat 87d2163f2d Fix constant int value function return type coercion 2024-09-21 17:00:34 +02:00
drmortalwombat 639008b990 Fix direction of constant folded ordered bool comparison 2024-09-21 16:48:22 +02:00
drmortalwombat 3c21ecb1d3 Fix constant float and long conversion during data flow analysis 2024-09-21 16:24:24 +02:00
drmortalwombat f764cf1936 Avoid infinite recursion when coercing to base class reference 2024-09-21 15:36:05 +02:00
drmortalwombat 44a9aaf89b Fix range correction for post dec loop counters 2024-09-21 15:17:15 +02:00
drmortalwombat 925ee9d8f3 Fix constant pointer if conditions 2024-09-21 14:38:35 +02:00
drmortalwombat a04b09c737 Fix wrong loop invariant when result temp used before 2024-09-21 13:50:14 +02:00
drmortalwombat 2c9fd0e1a6 Fix immediate coalescing with zero flag loss 2024-09-21 13:06:06 +02:00
drmortalwombat d7c9f15593 Fix constant fold of byte right shift 2024-09-21 12:49:29 +02:00
drmortalwombat b61aa37f71 Disable const parameter optimization in variadic functions 2024-09-21 12:13:19 +02:00
drmortalwombat e80f9812ef Fix invalid destruct on shortcut evaluation 2024-09-20 19:22:12 +02:00
drmortalwombat 84a0a9660f Fix constructor call on declaration 2024-09-20 18:10:01 +02:00
drmortalwombat a93b495ac5 Fix param value range on store with index 2024-09-20 16:15:02 +02:00
drmortalwombat 5d7dcf9373 Fix crash on select statement with void result 2024-09-20 13:26:59 +02:00
drmortalwombat 2f5faaa5ab Fix compare value range of longs 2024-09-20 12:34:01 +02:00
drmortalwombat dfe233a95e Fix pointer to object size propagation 2024-09-19 21:55:24 +02:00
drmortalwombat 92b72b19ec Fix loop wrap around aliasing 2024-09-19 21:01:24 +02:00
drmortalwombat ff4a0802ea Fix invalid memory range requirements due to select statement 2024-09-19 20:05:19 +02:00
drmortalwombat 9adcbd2706 Avoid inline of functions with missing return statement 2024-09-19 18:02:01 +02:00
drmortalwombat 6981b28a64 Fixed assignment of numeric 0 to pointer after inline expansion 2024-09-19 14:24:56 +02:00
drmortalwombat 7f41936df0 Fix constant pointer difference 2024-09-19 14:10:23 +02:00
drmortalwombat ccf72c6b77 Fix returning numeric 0 as nullptr 2024-09-19 13:46:34 +02:00
drmortalwombat c508d94d7c Fix loop exit value of loop counter derived values 2024-09-19 11:27:30 +02:00
drmortalwombat ce710fca5d Add float long conversion 2024-09-19 09:49:16 +02:00
drmortalwombat ce0ac30280 Fix value propagation in loop dependency analysis 2024-09-19 08:12:04 +02:00
drmortalwombat dec7580d8d Revert address of array type to pointer to array
not realy sure why I changed it in the first place
2024-09-19 07:47:34 +02:00
drmortalwombat 40001164d4 Fix missing error in const function return 2024-09-18 22:33:40 +02:00
drmortalwombat 8bd5ec76c3 Fix optimizing loop with subtract negative constant on counter 2024-09-18 18:30:53 +02:00
drmortalwombat 534a42d2fe Implement C vs C++ void pointer semantics 2024-09-18 16:27:16 +02:00
drmortalwombat 226d8afc24 Fix type handling in pointer const folding 2024-09-18 14:47:09 +02:00
drmortalwombat 47531ac5e8 Fix flat initializer for stacked arrays 2024-09-18 14:14:11 +02:00
drmortalwombat b3be121f41 Fix constant fold mixed signed long 2024-09-17 20:53:13 +02:00
drmortalwombat e7e53580ea Add ul / lu suffix for numbers 2024-09-17 20:30:41 +02:00
drmortalwombat 8a1eeee22d Fix arrow dereferencing of array variables 2024-09-17 15:34:41 +02:00
drmortalwombat 3e78933e9c Fix negative range propabation on binary or 2024-09-17 15:19:01 +02:00
drmortalwombat 637a10b234 Fix float const propagation 2024-09-17 14:49:07 +02:00
drmortalwombat c5dff3caf3 Fix sizeof string literals with zero byte 2024-09-17 14:27:23 +02:00
drmortalwombat c529fc2b59 Fix lvalue in switch expression 2024-09-17 09:31:01 +02:00
drmortalwombat 4886d0194f Fix bit field member naming and placement 2024-09-17 09:19:16 +02:00
drmortalwombat aae7d81cc6 Fix bitfield delcaration in function local struct 2024-09-16 22:30:19 +02:00
drmortalwombat 8d18969940 Fix unsigned division constant folding 2024-09-16 18:05:03 +02:00
drmortalwombat 68b57bb9a8 Fix short param forwarding of struct elements 2024-09-16 17:45:32 +02:00
drmortalwombat 5aeec2fad4 Fix function pointer const propagation 2024-09-16 17:16:45 +02:00
drmortalwombat 73dece7b58 Fix crash with unnamed unions 2024-09-16 16:45:51 +02:00
drmortalwombat bfa1254eb7 Fix octal string escaped 2024-09-16 16:36:06 +02:00
drmortalwombat e89aa11e86 Implement parse of octal numbers 2024-09-16 13:31:03 +02:00
drmortalwombat 4423837888 fixed varadic function inlining 2024-09-15 20:18:33 +02:00
drmortalwombat 723f407757 FIx unary not for unsigned const long 2024-09-15 19:54:00 +02:00
drmortalwombat f2338f1d13 Allow "long unsigned" type 2024-09-15 18:38:53 +02:00
drmortalwombat 235cbbc227 Add list expressions in for statement 2024-09-15 18:31:10 +02:00
drmortalwombat a2ca0de809 Fix compare pointer to rvalue refs 2024-09-15 16:14:44 +02:00
drmortalwombat f7b00eff95 Fix object array member init regression 2024-09-15 13:00:33 +02:00
drmortalwombat 163354b33e
Merge pull request #94 from jadziamd/main
Adds Diagnostic Directives & Fixes comparison between different enumeration types
2024-09-15 12:16:24 +02:00
drmortalwombat 7efd512ee9 Fix class member array initialization 2024-09-15 12:13:28 +02:00
John Schneiderman 7b7fe6c5a9 Adds the warning diagnositc directive. 2024-09-15 10:49:33 +02:00
John Schneiderman 7abd615a18 Adds support for the error diagnostic directive. 2024-09-15 10:28:25 +02:00
John Schneiderman 14e5896e37 Fixes comparison between different enumeration types. 2024-09-15 08:53:38 +02:00
drmortalwombat 381aaa1509 Fix compiler crash with empty switch statement 2024-09-11 13:13:40 +02:00
drmortalwombat f0f174e439 Optimize conditional select of const values 2024-09-10 22:26:34 +02:00
drmortalwombat 1f9226255a Fix default member constructor for single sized member arrays 2024-09-04 12:17:58 +02:00
drmortalwombat dcfa50e36e Fix float fast parameter aliasing 2024-09-02 22:01:50 +02:00
drmortalwombat 0b2c36ab1a Fix for sidfx in tight loop
Change might have been disregarded due to missing volatile
2024-09-02 15:26:05 +02:00
drmortalwombat 0163fb729a
Merge pull request #86 from polluks/patch-1
Shorter build call
2024-09-02 13:03:42 +02:00
Stefan d6c4828bef
Shorter build call 2024-09-02 11:05:00 +02:00
drmortalwombat e7dbd39adf Fix macos build 2024-09-01 09:51:11 +02:00
drmortalwombat 759a701df8 Add kernal banking for plus/4 kernalio.c 2024-08-30 18:40:48 +02:00
drmortalwombat 17ec90cfe7 Bump version number 2024-08-29 14:36:08 +02:00
drmortalwombat e7ec859dfc Fix unused parameter optimization for deep call stacks 2024-08-29 14:18:01 +02:00
drmortalwombat da93410468 Fix cascaded type casts 2024-08-29 13:34:55 +02:00
drmortalwombat f38b366d81 Fix error message for undefined identifier in case statement 2024-08-27 08:05:28 +02:00
drmortalwombat 8fbe96b9ac Add options to disable BSS clear on startup 2024-08-23 20:31:17 +02:00
drmortalwombat b48b8b836d Extended line limit to 32k 2024-08-23 18:16:42 +02:00
drmortalwombat 967b315be5 Add qualified constructor invocation 2024-08-23 17:53:58 +02:00
drmortalwombat ca995bf342 Fix zero delimiter on opp::string for fixed range string constructor 2024-08-21 19:28:40 +02:00
drmortalwombat c58bb46e7e Fix invalid abs,y to abs,x propagation 2024-08-18 13:26:35 +02:00
drmortalwombat 122dc12d40 Eliminate stores to unused function arguments 2024-08-17 20:55:00 +02:00
drmortalwombat cc576bd640 Fix name space pollution in __asm sections 2024-08-17 17:03:57 +02:00
drmortalwombat 09641d16f5 Add PLx and PHx to non simple asm instructions 2024-08-17 16:08:36 +02:00
drmortalwombat 552c4945bf Fix template expansion of out of class constructor/destructor 2024-08-16 18:03:32 +02:00
drmortalwombat 34d6131471 Fix __asm example in readme 2024-08-15 17:00:57 +02:00
drmortalwombat 9ecf1546cc Fix invalid "ldx abs,x" code generation when propagating 16bit values in merge tree 2024-08-14 22:53:14 +02:00
drmortalwombat 7ffa623d92 Fix clrscr() for VIC20 2024-08-13 19:16:19 +02:00
drmortalwombat 8e81e6aad5
Merge pull request #82 from polluks/main
Fixed sh #81
2024-08-12 14:55:02 +02:00
Stefan 3a3a76a2e1
Update makefile 2024-08-12 14:23:40 +02:00
drmortalwombat 4027b2dbe0 Add optional define for basic upstart line 2024-08-11 14:54:50 +02:00
drmortalwombat 62cede95ce Optimize right shift with small 16 bit values 2024-08-11 14:11:07 +02:00
drmortalwombat abb2d7a417
Merge pull request #79 from jadziamd/main
Support Installed Oscar64 Usage
2024-08-11 14:03:59 +02:00
John Schneiderman f9afb3edb7 Fixes being unable to use the compiler when
installed in the system.
2024-08-11 13:41:55 +02:00
John Schneiderman 32c090880b Adds the definition files as they're needed when
building code outside the repository.
2024-08-11 13:28:59 +02:00
drmortalwombat be5626adc9
Merge pull request #78 from jadziamd/main
Adds the ability to build from the top-level directory.
2024-08-11 10:18:23 +02:00
John Schneiderman b1c68d04dd Adds the ability to build from the top-level directory. 2024-08-11 09:59:53 +02:00
drmortalwombat f9b7dd8418 Fix breakpoint to tail jmp conversion 2024-08-09 20:14:45 +02:00
drmortalwombat 8a6e3eb924 Add breakpoint intrinsic in oscar.h 2024-08-09 18:05:44 +02:00
drmortalwombat 932c7ec222 Fix static stack in recursion
Fix static stack allocation and placement for non recursive sub trees in a recursive call tree
2024-08-09 16:18:38 +02:00
drmortalwombat e4e997fef2 Fix gcc build autotest 2024-08-08 22:47:18 +02:00
drmortalwombat 3ec8a7bc06
Merge pull request #74 from jadziamd/main
Change to a packagable makefile
2024-08-08 22:08:20 +02:00
drmortalwombat d98c4b760f Optimize sprite multiplexer 2024-08-08 22:07:44 +02:00
John Schneiderman d67980d79f Updates the instructions on how to build. 2024-08-08 20:34:19 +02:00
John Schneiderman 092592a05b Adds an installation target.
Adds an uninstallation target.
2024-08-08 20:16:11 +02:00
John Schneiderman 586fab6b6b Changes to use a top-level variable for the Oscar compiler uses. 2024-08-07 21:24:40 +02:00
John Schneiderman eab2a490f4 Adds the tests to the all target.
Silences the cleaning targets.
2024-08-07 20:39:05 +02:00
John Schneiderman 95992df67d Adds the samples building to the all target. 2024-08-07 20:14:56 +02:00
John Schneiderman 89ba57e18d Adds disclean and prep targets for building. 2024-08-07 19:43:27 +02:00
drmortalwombat 6f069946ba Pointer arguments in constexpr evaluation 2024-08-05 18:19:54 +02:00
drmortalwombat 3df85b09fc Align heap allocation on four byte boundaries 2024-08-04 18:02:04 +02:00
John Schneiderman fb5b69ae5c Changes to use commands from variables. 2024-08-04 17:32:13 +02:00
John Schneiderman 7350b11001 Changes to compile all the files in the build directory. 2024-08-04 17:08:19 +02:00
John Schneiderman b7d7614471 Determines the directory lcoation of the project. 2024-08-04 16:47:25 +02:00
drmortalwombat f49027b2d7 Fix loss of carry when moving shift up to store 2024-08-04 11:53:26 +02:00
drmortalwombat d24e666f92 Fix left shift 1ul for upper 16 bits 2024-08-03 19:18:17 +02:00
drmortalwombat 2ba46283b2 Optimize line draw for vertical/horizontal lines 2024-08-02 19:56:38 +02:00
drmortalwombat 65b9c58504 Move zero page shift up to previous store 2024-08-01 22:19:16 +02:00
drmortalwombat 02a2874a19 Bump version number 2024-08-01 15:49:51 +02:00
drmortalwombat 60868c71d3 Fix single tail loop opt for search loops (e.g. strlen) 2024-07-31 21:11:13 +02:00
drmortalwombat 9013952431 Fix missing int range adaption on complex address optimization 2024-07-31 17:59:20 +02:00
drmortalwombat 0b8304b40d More cross block const pointer forwarding 2024-07-28 17:52:07 +02:00
drmortalwombat 1bc5a2ad7e Add compile time error for undefined labels 2024-07-28 14:41:29 +02:00
drmortalwombat 5bb8ca0b89 Improve fix point arithmetic 2024-07-28 14:41:17 +02:00
drmortalwombat 7ecd6adb20 Improve global address in register reuse 2024-07-24 15:31:23 +02:00
drmortalwombat 5b50389340 Optimize 32bit shifts 2024-07-21 21:43:59 +02:00
drmortalwombat 5f2e05d1dd Fix some partial value forwarding errors 2024-07-21 17:53:52 +02:00
drmortalwombat 3cc37acaa4 Bump version number 2024-07-21 11:47:37 +02:00
drmortalwombat 4680ee32f0 Allow defines for #embed arguments 2024-07-21 11:12:34 +02:00
drmortalwombat 3dd23ec789 Additional register allocation step after late inlining 2024-07-21 10:40:37 +02:00
drmortalwombat efd688320f Improve peephole optimizer for shifts 2024-07-18 14:18:06 +02:00
drmortalwombat d0fb062006 Make log and exp intrinsics for const evaluation 2024-07-17 12:42:15 +02:00
drmortalwombat c229a27992 Improve cross loop value propagation 2024-07-16 08:36:52 +02:00
drmortalwombat d3536a718e Merge partially common register loads across basic blocks 2024-07-13 20:44:49 +02:00
drmortalwombat 5909db71d5 Fix loss of dependency when propagating (zp),y single use load across basic blocks 2024-07-12 21:02:46 +02:00
drmortalwombat 96ada6e22a Optimize int->long conversion for known positive values 2024-07-11 16:32:11 +02:00
drmortalwombat 85f01b833c Fix invalid index propagation 2024-07-10 18:49:10 +02:00
drmortalwombat 68a648440a Fix crash on short lea optimization due to lost temp dependencies 2024-07-10 18:31:32 +02:00
drmortalwombat a3bf7296bb Reduce index register usage, where ORA Imm would suffice 2024-07-09 11:24:02 +02:00
drmortalwombat dd1f5b9043 Fix literal string concatenation in parser 2024-07-07 21:18:17 +02:00
drmortalwombat fcc2cbbebe Remove superfluous CPX/CPY with #0 2024-07-06 15:08:03 +02:00
drmortalwombat 470462fe8b Optimize consecutive increments 2024-07-05 22:59:16 +02:00
drmortalwombat 301431f12a Eliminate duplicate loop counting variables 2024-07-05 10:12:55 +02:00
drmortalwombat c0e524cd82 Bump version number 2024-07-04 11:01:58 +02:00
drmortalwombat 4068957442 Fix register dependency update in multi block loop optimization 2024-07-04 10:42:22 +02:00
drmortalwombat bf89d7af33 Improve loop register allocation 2024-07-03 22:23:27 +02:00
drmortalwombat d070e32b4d Loop unrolling for pointer limited short loops 2024-06-30 21:54:56 +02:00
drmortalwombat ad310f8484 Fix sign flag propagationa after immediate ora 2024-06-30 21:28:35 +02:00
drmortalwombat 7eb149a71b Optimize value range of right shifts 2024-06-30 15:45:34 +02:00
drmortalwombat 1c0db235a8 Fix emulator cycle count 2024-06-30 12:29:41 +02:00
drmortalwombat 94181326ca Add uppercase -D for define without separate argument 2024-06-28 16:00:48 +02:00
drmortalwombat cd7567452a Fix return of reference of simple type from inlined function into non ref argument 2024-06-27 19:34:57 +02:00
drmortalwombat 2fec9f066f Refactor large peephole optimizer loop 2024-06-27 15:28:21 +02:00
drmortalwombat fe736289e6 Fix goto to label connection in inlined functions 2024-06-25 21:56:36 +02:00
drmortalwombat 715f295f5e Add goto and labels in C code 2024-06-25 20:45:44 +02:00
drmortalwombat a71c433fc4 Add -D for gcc compliant defines 2024-06-24 18:14:07 +02:00
drmortalwombat 9678814654 Fix crash with extern object pointer arithmetic 2024-06-23 17:05:46 +02:00
drmortalwombat 1598360b65 Fix relational bool ops constant folding 2024-06-22 15:41:02 +02:00
drmortalwombat 9d890228bf
Merge pull request #68 from Kopromaster/main
Windows: support of GCC (MinGW)
2024-06-22 13:56:57 +02:00
Test User 2d82727565 Fixed spacing 2024-06-21 23:17:09 +02:00
Kopromaster 3851a4c2db
Merge branch 'drmortalwombat:main' into main 2024-06-21 21:08:24 +00:00
Test User 17f56d0a69 Bugfix for GCC: order of objects and libs matters; prepared list of libs for GCC (MinGW) 2024-06-21 23:00:17 +02:00
drmortalwombat 1a6a98e57e Reduce stack usage when compiled with MSVC due to optimizer function size limit 2024-06-21 12:04:39 +02:00
Test User 5ddfc628dc Bugfix: __try and __except are MSVC specific 2024-06-20 23:01:46 +02:00
drmortalwombat bf5099f57b Improve auto inline heuristics 2024-06-20 21:02:55 +02:00
drmortalwombat d4a381f71c Fix size heuristic of loop condition slicing 2024-06-20 09:42:22 +02:00
drmortalwombat 17002e4c78 More native code load/store forwarding 2024-06-19 21:40:38 +02:00
drmortalwombat cf9a006005 Retain Z flag when restoring Y after index reduction 2024-06-19 17:45:20 +02:00
drmortalwombat 1fa9828f6a Add additiona raster irq for kernal with potential no IO 2024-06-18 20:35:38 +02:00
drmortalwombat 3f9d042863 Optimize xy before loop index register assignment 2024-06-18 16:08:53 +02:00
drmortalwombat 277afd156d Fix over eager const pointer forwarding 2024-06-16 09:01:36 +02:00
drmortalwombat b428b608b5 Fix extern undefined struct in header file 2024-06-15 17:24:04 +02:00
drmortalwombat 58361e39b8 Fix crash on late const typecast to pointer 2024-06-15 13:35:17 +02:00
drmortalwombat 3770a05aee Add fast loader library flossiec 2024-06-13 21:16:42 +02:00
drmortalwombat 5993f75c92 Bump version number 2024-06-12 21:30:16 +02:00
drmortalwombat d7a2b98b4d Add buffered lzo decompress 2024-06-12 21:07:58 +02:00
drmortalwombat 02b28096af fix pragma optimize inline 2024-06-12 07:36:30 +02:00
drmortalwombat 02e921364b Add support for charpad 9 format 2024-06-11 22:26:10 +02:00
drmortalwombat 4cf64ee170 Fix loop inversion invariant integer range recovery 2024-06-11 21:01:20 +02:00
drmortalwombat c99c1756a9 Fix parameter address reference in __asm embedding 2024-06-11 13:07:50 +02:00
drmortalwombat 5ccfab0342 Fix IEC code for non interrupt usage 2024-06-11 12:12:29 +02:00
drmortalwombat 42eea7f8f4 Mark krnio_save as noinline to ensure zpage params 2024-06-10 22:36:07 +02:00
drmortalwombat ff6bb8ccd5 Fix type of addressof reference 2024-06-08 16:48:44 +02:00
drmortalwombat 2e3aea9d96 Fix reference parameter capture 2024-06-08 16:43:33 +02:00
drmortalwombat 4954a285e7 Add interleave option for sectors in disk image 2024-06-05 22:21:21 +02:00
drmortalwombat 46b52a57f7 Add binary not operator to inline assembler operand parsing 2024-06-04 09:07:50 +02:00
drmortalwombat 41ba2e73f2 Fix labels in inline assembler with an offset > 255 2024-06-03 13:06:45 +02:00
drmortalwombat fbc9607e17 Ensure actual update of index variable in loops in non debug builds 2024-05-30 17:51:59 +02:00
drmortalwombat 2e696d9e1a Optimize small inline function calls 2024-05-30 17:51:34 +02:00
drmortalwombat b09e9a2434 Delete oscar64.zip 2024-05-28 10:11:39 +02:00
drmortalwombat 2e1c020db4 Bump version number 2024-05-26 08:43:14 +02:00
drmortalwombat 13629c70d4 Fix auto deduction of void return type 2024-05-25 22:25:59 +02:00
drmortalwombat b1b5ee737b Fix functional for no parameters 2024-05-25 22:05:31 +02:00
drmortalwombat 884fe50dd7 Add missing assigns for opp::function 2024-05-25 21:26:23 +02:00
drmortalwombat af38f64a99 Add opp::function 2024-05-25 21:25:02 +02:00
drmortalwombat a22dfa6ba7 Add pure virtual functions 2024-05-23 21:15:47 +02:00
drmortalwombat 9fa8b644a7 Add object placement retry if page locking does not fit 2024-05-23 09:54:07 +02:00
drmortalwombat 375307822e Fix auto template expansion of class constructor 2024-05-22 22:44:53 +02:00
drmortalwombat c0152b1ce4 fix template deduction for member functions 2024-05-22 20:53:23 +02:00
drmortalwombat 3460c06508 Improve strength reduction in loops 2024-05-22 20:36:22 +02:00
drmortalwombat d3734a66e0 Fix complex loop intercode index reversal 2024-05-22 12:16:30 +02:00
drmortalwombat ccf13c78f0 Fix index register conflict when removing condition check after load 2024-05-21 22:03:51 +02:00
drmortalwombat 2c28551ca3 Improve index register cross block handling 2024-05-20 16:24:28 +02:00
drmortalwombat 4fb35a7af2 Add error when exceeding assembler limits 2024-05-20 09:03:41 +02:00
drmortalwombat a2a22476ed Add constexpr pointers for inline assembler 2024-05-19 22:20:52 +02:00
drmortalwombat 1b22a5e3c5 Fix constant fold error 2024-05-19 21:38:19 +02:00
drmortalwombat ab06d85a91 Add global inline assembler optimization for static const to immediate propagation 2024-05-19 20:48:14 +02:00
drmortalwombat 80b1683fa2 Document member offset in inline assembler 2024-05-19 19:14:01 +02:00
drmortalwombat d79aae3078 Fix inline mapper for inline assembler 2024-05-19 19:11:48 +02:00
drmortalwombat 4c0e737508 Fix over eager pre processor tokenizer 2024-05-19 17:16:14 +02:00
drmortalwombat 86e0cbf9c2 Alternate forward and backward int value range check 2024-05-19 10:19:42 +02:00
drmortalwombat 142bc988b1 Bump version number 2024-05-17 13:12:24 +02:00
drmortalwombat 3ea44d1979 Fix usage of "ldx abs,x" in some corner cases 2024-05-16 17:45:36 +02:00
drmortalwombat 04d1abd803 Some peephole loop optimizations 2024-05-12 21:06:50 +02:00
drmortalwombat ba1bc29b1a Fix X vz Z flag swapping 2024-05-05 20:54:21 +02:00
drmortalwombat 37776dfaee Remove more conditional branches from loops 2024-05-05 13:14:23 +02:00
drmortalwombat c28f342f3e Remove some superflous range violation warnings 2024-05-03 14:54:58 +02:00
drmortalwombat 354a420aa4 Bump version number 2024-05-01 15:49:17 +02:00
drmortalwombat fb72e8baf8 Fix over eager parameter reordering 2024-05-01 15:30:18 +02:00
drmortalwombat 976703f713 Fix O2 parameter forwarding optimization 2024-05-01 14:08:42 +02:00
drmortalwombat dc5afa6e79 Fix shift optimization had wrong address check 2024-04-30 08:51:22 +02:00
drmortalwombat 740762d4a1 Fix loss of zero flag in 16bit optimization 2024-04-30 08:06:20 +02:00
drmortalwombat f0b7cddeb1 Optimize indirecte 16bit store by flipping low/high order 2024-04-28 21:13:41 +02:00
drmortalwombat 9b47a34840 Improve reordering of function arguments 2024-04-28 20:15:17 +02:00
drmortalwombat bb8c31bf32 Some peephole optimization 2024-04-23 20:54:48 +02:00
drmortalwombat 87ca43e5b7 Add spritepad version 1 file parsing 2024-04-23 17:51:42 +02:00
drmortalwombat 411648b130 Improve long counting loops 2024-04-22 22:48:15 +02:00
drmortalwombat 611f672b81 Add warning for static buffer overflow 2024-04-15 15:40:37 +02:00
drmortalwombat 755c9234e1 Update C128 exit code 2024-04-13 19:49:40 +02:00
drmortalwombat c3c0583f19 Fix const array dereference 2024-04-12 16:51:26 +02:00
drmortalwombat 55ddce2211 Fix const array access folding 2024-04-12 16:11:47 +02:00
drmortalwombat 5971f9a80f bump version number 2024-04-12 15:54:54 +02:00
drmortalwombat fbfd597306 Fix float param to const propagation 2024-04-12 15:50:46 +02:00
drmortalwombat 0184a550c5 Fix volatile violation when recycling immediates 2024-04-10 15:15:22 +02:00
drmortalwombat 2cdc95ba05 Fix assert in samples 2024-04-09 15:57:53 +02:00
drmortalwombat fefa462730 Improve zero page variable usage 2024-04-08 22:04:50 +02:00
drmortalwombat 7b20e6cca0 Optimize 16 bit counting loops 2024-03-31 14:29:22 +02:00
drmortalwombat ed82e3595b Bump version number 2024-03-30 10:40:00 +01:00
drmortalwombat 6cfdc0ce5f Fix removal of consecutive indexed stores in unrolled loop 2024-03-29 18:49:58 +01:00
drmortalwombat 1f17f1c198 Fix assert in peephole optimizer 2024-03-26 08:23:13 +01:00
drmortalwombat 99da637734 Fix include guard of kernalio.h 2024-03-25 12:25:56 +01:00
drmortalwombat afcc8bc101
Merge pull request #53 from Ecte86/patch-2
Update kernalio.h
2024-03-25 12:24:00 +01:00
Ecte 4b2525b7a4
Update kernalio.h
Removed extra "#ifndef C64_KERNALIO_H" to fix "unterminated conditional directive" error.
2024-03-25 17:38:27 +10:30
drmortalwombat aa601a5727 Change memset and memclr to intrinsic functions 2024-03-24 11:22:13 +01:00
drmortalwombat 85fad64e9c Optimize post inc/dec while loop conditions 2024-03-21 19:33:50 +01:00
drmortalwombat 30d942478f Fix infinite loop in move condition out of loop 2024-03-13 22:14:29 +01:00
drmortalwombat 89750c3f73 promote array of const members to be const as well 2024-03-11 13:40:54 +01:00
drmortalwombat ee43223543 Fix missing member definition in opp string 2024-03-09 14:16:28 +01:00
drmortalwombat 89ac4ee9b9
Merge pull request #52 from Ecte86/patch-1
added standard c++ method c_str to opp::string that calls cstr method.
2024-03-09 14:14:32 +01:00
Ecte b411178aae
added standard c++ method c_str to opp::string that calls cstr method.
This should help Intellisense while allowing code that still uses the cstr method to work.
2024-03-09 19:44:59 +10:30
drmortalwombat 45246a2f2d Fix variable size when defining extern struct with anon struct 2024-03-07 20:42:21 +01:00
drmortalwombat 0c43952e37 Improve constant branch forwarding 2024-03-07 13:20:39 +01:00
drmortalwombat f877e5b8c2 Fix assert in linux sample build 2024-02-28 21:26:25 +01:00
drmortalwombat 2d50d56606 Fix copy and load with striped arrays 2024-02-27 18:02:12 +01:00
drmortalwombat bdecbe77e4 Fix 16bit zero page global variable inc/dec 2024-02-27 09:08:56 +01:00
drmortalwombat f39cb38eb3 Fix unary ops on striped struct members 2024-02-26 20:38:02 +01:00
drmortalwombat 148c288942 Add extract char operator to istream 2024-02-26 18:22:21 +01:00
drmortalwombat e2f822e7d1 Improve short function call loop 2024-02-25 18:43:53 +01:00
drmortalwombat 0b58e9eaaf Fix global aliasing collision with striped data 2024-02-25 18:00:10 +01:00
drmortalwombat 0a76a57f18 Bump version number 2024-02-24 15:50:47 +01:00
drmortalwombat 22ffbfa63c Fix source location when coalescing JSR and RTS in JMP 2024-02-24 09:52:32 +01:00
drmortalwombat 94a3097ba7 Fix find loop optimization with mirrored condition 2024-02-21 15:05:17 +01:00
drmortalwombat c05bd269ad Fix stop petscii definition 2024-02-21 12:12:29 +01:00
drmortalwombat aab71cbab3 Add more std c include files 2024-02-20 14:16:32 +01:00
drmortalwombat 1041ef03eb Bump version number 2024-02-19 14:30:53 +01:00
drmortalwombat e2f36bbb9a Fix parse embed with hex skip or size setting 2024-02-19 14:19:15 +01:00
drmortalwombat 5e9df61ffc Fix read after write hazzard in function param proxy size optimization 2024-02-18 20:35:07 +01:00
drmortalwombat cc5a90ac21 Fix long unsigned int comparison 2024-02-18 18:30:51 +01:00
drmortalwombat 3900e1cf92 fix pragma strings with petscii 2024-02-18 17:57:27 +01:00
drmortalwombat 6b98a44fc0 Improve auto inlining decision with O2 2024-02-18 14:35:41 +01:00
drmortalwombat 2698595302 bump version number 2024-02-18 10:02:29 +01:00
drmortalwombat f6ab79319f More compatibility fixes for -psci 2024-02-18 09:31:05 +01:00
drmortalwombat 264a80d88e Pausing petscii string options for #include and #embed 2024-02-17 17:43:24 +01:00
drmortalwombat 020ab117a4 Fix value copy crossing function call 2024-02-17 17:37:47 +01:00
drmortalwombat 8457316815 Fix unsigned promotion for binary not operator 2024-02-17 13:10:14 +01:00
drmortalwombat 58ffe2ad06 Fix hex arguments for pragmas 2024-02-17 12:53:31 +01:00
drmortalwombat 6f7efd9efc Optimized long multiply 2024-02-17 12:06:15 +01:00
drmortalwombat b84cce7609 Improve compatibility with some C quirks 2024-02-16 21:39:35 +01:00
drmortalwombat 8fc382c11e Fix high byte address calculation cascade 2024-02-15 20:52:10 +01:00
drmortalwombat fadcb61bc7 bump version number 2024-02-15 16:20:15 +01:00
drmortalwombat 7ebf71b161 Switch to Visual Studio 2022 toolset 2024-02-15 15:36:25 +01:00
drmortalwombat 003550337a Fix debug and linux build 2024-02-15 13:29:02 +01:00
drmortalwombat c909995011 Reduce compiler memory footprint 2024-02-15 09:58:26 +01:00
drmortalwombat 18cfbc713a Force some inline calls in vdc 2024-02-14 15:24:01 +01:00
drmortalwombat 806539a2d6 add "tan" to intrinsic functions 2024-02-13 20:49:11 +01:00
drmortalwombat 77f035e2b5
Merge pull request #47 from polluks/patch-1
Fixed warning
2024-02-13 19:12:33 +01:00
Stefan 1d49e0a987
Fixed warning
c++ -c -g -O2 -std=c++11 -Wno-switch ../oscar64/oscar64.cpp -o oscar64.o
../oscar64/Scanner.cpp:768:29: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
                                        while (mTokenString[i] = def->mString[i])
                                               ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
../oscar64/Scanner.cpp:768:29: note: place parentheses around the assignment to silence this warning
                                        while (mTokenString[i] = def->mString[i])
                                                               ^
                                               (                                )
../oscar64/Scanner.cpp:768:29: note: use '==' to turn this assignment into an equality comparison
                                        while (mTokenString[i] = def->mString[i])
                                                               ^
                                                               ==
1 warning generated.
2024-02-13 18:28:33 +01:00
drmortalwombat bcc20d3986 Switch to x64 compiler binary 2024-02-13 16:53:44 +01:00
drmortalwombat 431c5d3282 Add info message, if object cannot be placed by linker 2024-02-12 18:06:30 +01:00
drmortalwombat ce5be92225 Fix linux build 2024-02-12 17:40:03 +01:00
drmortalwombat 2ed3d8b445 Bump version number 2024-02-04 11:26:37 +01:00
drmortalwombat f498da5e42 Add __DATE__ and __TIME__ defines 2024-02-04 10:45:02 +01:00
drmortalwombat 7d6eb36ee7 Fix assignment of immediates to returned struct 2024-02-04 09:43:52 +01:00
drmortalwombat ecaab1b5b3 Fix crash compiling infinite loop 2024-01-30 15:04:13 +01:00
drmortalwombat 623b511ce6 restore order of vdc 16 bit writes 2024-01-29 12:42:13 +01:00
drmortalwombat 80efe2351b Optimize short wait loop handling 2024-01-28 19:09:59 +01:00
drmortalwombat 91c907be7e Improve BYT operands in inline assembler 2024-01-28 09:39:40 +01:00
drmortalwombat fafbbe82d1 Fix prevent swap of X and Y when used in JSR 2024-01-27 19:50:34 +01:00
drmortalwombat b3d80bcb0f Limit inline asm check to same section 2024-01-27 17:50:53 +01:00
drmortalwombat 4901e015f6 Undo JSR optimization for testing 2024-01-27 17:48:30 +01:00
drmortalwombat fdb52bcdc6 Limit JSR->JMP forwarding 2024-01-27 17:43:08 +01:00
drmortalwombat 974688a8a5 Fix overlay prg file save 2024-01-27 17:11:10 +01:00
drmortalwombat 2ad71ef867 Bump version number 2024-01-27 10:26:22 +01:00
drmortalwombat c1083b44dc Optimize constant loops 2024-01-27 10:19:14 +01:00
drmortalwombat b0dc6fdd1e Add save as .prg for overlay files 2024-01-27 09:37:48 +01:00
drmortalwombat 7f51d6330e Fixed 1 - i for bytes, wrong operand order 2024-01-26 12:41:13 +01:00
drmortalwombat 3992b1d547 Add warning for out of bounds accesses 2024-01-24 17:30:03 +01:00
drmortalwombat 2c1a87ce02 Control assert with _DEBUG to avoid gcc core dump 2024-01-23 16:53:30 +01:00
drmortalwombat 529618ffa4 Changed error format to "oscar64:" when error outside of source file 2024-01-23 15:58:47 +01:00
drmortalwombat bcc5e9d362 Fix propagation of conditions out of loops 2024-01-23 09:02:38 +01:00
drmortalwombat 6444ba58cf bump version number 2024-01-21 15:39:26 +01:00
drmortalwombat 4fc3e019d5 Add ranges in case statements (gcc extension) 2024-01-21 15:17:46 +01:00
drmortalwombat dcebdeaa5f Fix parsing of trailing comma in initializer list 2024-01-21 09:25:34 +01:00
drmortalwombat 8a49ffd111 Improve unrolled loops towards zero 2024-01-20 13:49:25 +01:00
drmortalwombat a19469d851 Fix exportet variable alignment calculation 2024-01-16 08:12:47 +01:00
drmortalwombat 265be6e766 Move linker chattyness into -v2 2024-01-12 22:51:11 +01:00
drmortalwombat cac7db4358 Fix memory size mismatch in reverse integer range propagation due to register renaming 2024-01-10 22:59:45 +01:00
drmortalwombat 4eaa6c8b1e Add immediate variable address parameter in inline assembler 2024-01-10 12:22:46 +01:00
drmortalwombat 9a0256449b
Merge pull request #43 from xahmol/main
Proposals for krnio additions: setbnk and save
2024-01-10 11:49:35 +01:00
Xander Mol 299374aa50 Proposals for krnio additions: setbnk and save 2024-01-09 23:50:46 +01:00
drmortalwombat 5634abdba4 Fix compiler warnings on linux/macos 2024-01-09 20:04:40 +01:00
drmortalwombat a6b3533e61 Fix struct volatile cast 2024-01-08 20:41:48 +01:00
drmortalwombat 4ea3633b5a Fixed fix 2024-01-08 20:11:11 +01:00
drmortalwombat bcf19136d4 Fix zp clear in C128 on exit 2024-01-08 20:10:46 +01:00
drmortalwombat 1abdd1476e Fix error message when propagating invalid function parameter to const 2024-01-08 18:20:55 +01:00
drmortalwombat 7f31ee9c71
Merge pull request #41 from polluks/patch-1
Fixed README typos
2024-01-08 18:20:16 +01:00
Stefan 4ca9c82a2e
Fixed README typos 2024-01-08 13:15:09 +01:00
drmortalwombat 0bc4e7cda6 Fix inc/mov of absolute values 2024-01-07 16:13:01 +01:00
drmortalwombat 36d6fc6760 Fix placement of proxy variables for unused parameters 2024-01-06 20:00:55 +01:00
drmortalwombat 7ea4356361 Fix function end location in dbj file 2024-01-06 17:07:10 +01:00
drmortalwombat 3821b228e9 Fix missing defines for c128e conio 2024-01-06 14:18:00 +01:00
drmortalwombat d676ccc1bd Fix dbj file reference with optimized variable 2024-01-06 14:03:29 +01:00
drmortalwombat 1c1d7fefaa Add c128e target machine 2024-01-06 09:09:52 +01:00
drmortalwombat a7d7db37df Bump version number 2024-01-04 17:56:42 +01:00
drmortalwombat 5d51cf75e8 Fix cross block zp move optimization 2024-01-04 14:14:28 +01:00
drmortalwombat d9f81ad653 Improve cross function memory aliasing analysis 2024-01-03 22:23:20 +01:00
drmortalwombat 34947da898 Fix loop integer range propagation 2024-01-02 22:21:05 +01:00
drmortalwombat 0d7ffd787f
Merge pull request #39 from ra1fh/out-of-bounds-access
Fix out of bounds access to LinkerObjectTypeNames
2024-01-01 18:15:39 +01:00
Ralf Horstmann fc6c83e9cd Fix out of bounds access to LinkerObjectTypeNames
One entry was missing, causing segmentation fault on some platforms.
2024-01-01 14:16:02 +01:00
drmortalwombat 940cb4a5b9 Add declaration to reference list in dbj 2023-12-31 13:30:29 +01:00
drmortalwombat c138c0f2ae Fix loss of zp dependency on diamond register propagation 2023-12-31 10:29:59 +01:00
drmortalwombat 2911321914 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2023-12-30 12:17:54 +01:00
drmortalwombat 5a3cbff259 Add references to dbj file 2023-12-30 12:17:46 +01:00
drmortalwombat 2ff3b6d3d5
Merge pull request #38 from polluks/patch-2
Updated makefile
2023-12-30 09:24:46 +01:00
drmortalwombat da20b4d27a Fix atan2, failed in mathtest.c 2023-12-30 09:21:17 +01:00
Stefan bc45bc08b9
Updated makefile 2023-12-30 00:01:19 +01:00
drmortalwombat 064bf0f8e5 Bump Version Number 2023-12-23 10:45:00 +01:00
drmortalwombat a305dbb1cd Improve function placement in linker 2023-12-23 10:40:45 +01:00
drmortalwombat 59b1d971d0 Changes sprintf to snprintf 2023-12-18 13:00:54 +01:00
drmortalwombat ef6598e94b Fix unnamed structs 2023-12-18 07:40:31 +01:00
drmortalwombat 5055635d3d fix unnamed union in math.c until supported by compiler 2023-12-17 22:47:14 +01:00
drmortalwombat 04518e4ff3 Add error message for unnamed structs 2023-12-17 22:45:21 +01:00
drmortalwombat 4a8010a3a0 Fix loss of zero page dependency in tail code merge 2023-12-17 12:40:09 +01:00
drmortalwombat ae4b48c445 Various loop optimizations 2023-12-16 21:03:09 +01:00
drmortalwombat 6cf8466dfd Fix overeager lda/sta join of tail blocks 2023-12-12 22:39:22 +01:00
drmortalwombat 6bbf325720 Add BIT instruction for sign check, add inlay sections in linker 2023-12-12 11:08:59 +01:00
drmortalwombat 2b0f074c94 Change C128 vdc ready check 2023-12-11 12:23:34 +01:00
drmortalwombat f76599ac08 Change C128 bank 1 code to use __noinline 2023-12-10 16:48:49 +01:00
drmortalwombat ee67c6dec1 Add more HEAPCHECK 2023-12-10 12:41:37 +01:00
drmortalwombat 16810b63d4 Fix over eager lda/sta movement 2023-12-10 09:48:23 +01:00
drmortalwombat 1e0450cd8a Optimize sprite multiplexer 2023-12-09 13:40:58 +01:00
drmortalwombat 1d337f1244 Fix accu train movement to end of block 2023-12-07 14:22:05 +01:00
drmortalwombat cce2f272ef Add optimization section to readme 2023-12-06 13:55:38 +01:00
drmortalwombat d48da32586 Improve placement of "if" cascades 2023-12-04 22:09:33 +01:00
drmortalwombat 11f454390e Add HEAPCHECK 2023-12-03 10:50:00 +01:00
drmortalwombat 8a33fe3e60 Bump version number 2023-12-02 11:04:20 +01:00
drmortalwombat 8ab46e29dd Direct parameter forwarding 2023-12-02 10:58:20 +01:00
drmortalwombat 003306f961 Fix noinline, improve cartridge use of bank 0 2023-11-29 20:53:04 +01:00
drmortalwombat cf28c1a618 Move conditions out of loops 2023-11-28 17:40:44 +01:00
drmortalwombat 8fd560a643 Bump version number 2023-11-26 22:41:17 +01:00
drmortalwombat d5026ed9b0 Fix join common branch sequence 2023-11-26 21:34:06 +01:00
drmortalwombat 57537cd43a Join common branch code sequences 2023-11-26 15:46:59 +01:00
drmortalwombat eec4ed45d1 Fix global array aliasing error 2023-11-20 22:53:12 +01:00
drmortalwombat a9fc83d63c Add xname attribute to .dbj file 2023-11-20 17:28:48 +01:00
drmortalwombat a5f4cf3252 Fix default constructor with classes in header file 2023-11-20 17:03:34 +01:00
drmortalwombat 6995f5a683 Decorate vcall multiplexer 2023-11-20 13:07:29 +01:00
drmortalwombat 0309fcb286 Fixed copy with offset 2023-11-20 08:29:23 +01:00
drmortalwombat 38e1cd0bab Fix join entry loadstore zp if accu is used cross block 2023-11-16 21:52:06 +01:00
drmortalwombat 157f9c00e5 Fix do while loop with function condition 2023-11-16 16:40:11 +01:00
drmortalwombat 44e6921842 Change string literal processing to use unsigned chars 2023-11-14 15:02:35 +01:00
drmortalwombat ee03f08f52 Fix over eager zp parameter reuse 2023-11-11 22:37:35 +01:00
drmortalwombat a59f55c1f3 Fix block join target move zp 2023-11-10 20:53:20 +01:00
drmortalwombat 3be6d20006 Add enum class 2023-11-09 16:33:50 +01:00
drmortalwombat 70c6fb23cc Fix for stack virtual call 2023-11-08 15:35:45 +01:00
drmortalwombat e43c086545 Add enum to int conversion in function call overload 2023-11-07 08:08:44 +01:00
drmortalwombat 06ab48461b Implement striped unions 2023-11-06 21:33:04 +01:00
drmortalwombat 8ea991db81 Optimize div/mod unsigned pairs 2023-11-03 20:16:23 +01:00
drmortalwombat d9c84e3a15 Disable vtable dispatcher inlining 2023-11-02 08:18:09 +01:00
drmortalwombat 8aeddf0316 Fix previous fix 2023-10-30 19:43:37 +01:00
drmortalwombat 8a27cba1f9 Fix inifinite pumping loop in integer range optimizer 2023-10-30 18:02:34 +01:00
drmortalwombat f808309058 Fix wrong string mangling for auto param names 2023-10-30 13:17:23 +01:00
drmortalwombat ae15eca0ef Fix array to pointer cast in const initializer 2023-10-29 20:00:38 +01:00
drmortalwombat 781bb83dd1 Bump version number 2023-10-29 17:57:32 +01:00
drmortalwombat 1d4eb70414 Optimize struct copies 2023-10-29 17:55:26 +01:00
drmortalwombat 75301fa12d Fix crash with array new 2023-10-28 12:02:28 +02:00
drmortalwombat f541cf3848 Fix per tile color in charpad import 2023-10-27 17:59:37 +02:00
drmortalwombat d9a8c5ea08 Fix template expansion of member functions 2023-10-27 14:53:19 +02:00
drmortalwombat 0889afbdae
Merge pull request #34 from polluks/patch-1
Optimisation crt.c
2023-10-26 16:52:04 +02:00
Stefan 25a0c0b4ad
Optimisation crt.c 2023-10-26 16:37:51 +02:00
drmortalwombat 0080a85345 Fix deadlock on empty switch statement 2023-10-26 07:54:03 +02:00
drmortalwombat 50031f56af
Merge pull request #32 from icepic/main
Simplify samples/build.sh by using subshells
2023-10-25 10:59:19 +02:00
drmortalwombat 7d80dfac25
Merge pull request #33 from icepic/patch-1
small readme update
2023-10-25 10:58:35 +02:00
drmortalwombat f6536a412e Fix SAR/MUL optimization 2023-10-24 21:20:07 +02:00
Janne Johansson 0f539d239c
Merge branch 'drmortalwombat:main' into patch-1 2023-10-24 21:06:24 +02:00
Janne Johansson a0ef0b3be2 Simplify samples/build.sh by using subshells 2023-10-24 21:02:51 +02:00
drmortalwombat 982fe17aed Fix compiler crash when using function result in if condition 2023-10-24 14:29:46 +02:00
drmortalwombat 0a3ad006b7 Fix simple struct member optimization for array cases 2023-10-22 19:50:26 +02:00
drmortalwombat f8f81f6d4c Optimize compile time 2023-10-22 19:35:37 +02:00
drmortalwombat 3377ac04fc Fix const use and vtable incompatibility 2023-10-22 12:34:26 +02:00
drmortalwombat aad35e0243 Fix IEC drive timing 2023-10-22 12:14:15 +02:00
drmortalwombat 6e4bf52781 Optimize switch case tree 2023-10-19 21:15:01 +02:00
drmortalwombat 6cb15fd7d9 Improve incompatible type error message 2023-10-19 17:27:09 +02:00
drmortalwombat f7d6b52074 Fixed striped auto pointer 2023-10-18 20:26:11 +02:00
drmortalwombat 0f5e933002 Optimize cross block constant propagation 2023-10-18 15:57:59 +02:00
drmortalwombat 9e3b014927 Eliminate some simple dead X/Y loops 2023-10-16 21:51:20 +02:00
drmortalwombat f5c13c02af Some native code opts 2023-10-16 21:29:42 +02:00
drmortalwombat 63725f3511 Fix const eval of sin/cos 2023-10-16 17:24:35 +02:00
drmortalwombat da5326cc5f Fix local multi dim array init 2023-10-16 15:01:30 +02:00
drmortalwombat 19e2498cc8 Fix member constructor for multi dim array members 2023-10-16 14:13:20 +02:00
drmortalwombat 7858e32d12 Improve handling of single member structs 2023-10-15 20:17:04 +02:00
drmortalwombat 454c4f5dbe Bump version number 2023-10-15 14:22:59 +02:00
drmortalwombat eb16767bdb Optimize wide right shift 2023-10-15 13:59:30 +02:00
drmortalwombat 6e6e3b2adb Fix line directive over consumption 2023-10-15 12:26:32 +02:00
drmortalwombat 3da58bf1ca Fix line directive off by one error 2023-10-15 12:01:24 +02:00
drmortalwombat 4e76b34f53 constexpr constructor 2023-10-14 18:50:27 +02:00
drmortalwombat d160b2ae65 Optimize bitfields 2023-10-14 16:51:33 +02:00
drmortalwombat 4f76ffa311 Implement #line directive 2023-10-14 15:19:24 +02:00
drmortalwombat 9156db9c32 Restart integer range estimation from full state 2023-10-14 13:43:11 +02:00
drmortalwombat ecf8e69cf2 Add restricted pointer attribute to newly allocated memory 2023-10-13 11:18:16 +02:00
drmortalwombat 2027ac5d4c Fix template expansion in multiple cpp 2023-10-12 14:10:34 +02:00
drmortalwombat 020afb8722 bump version number 2023-10-10 09:06:31 +02:00
drmortalwombat 6a30a38415 Fix multi instantiation of inline constructors 2023-10-10 09:02:30 +02:00
drmortalwombat 312914d78c Bump version number 2023-10-08 21:44:30 +02:00
drmortalwombat d4f979b1bc Fix accu return with temp spilling 2023-10-08 21:30:53 +02:00
drmortalwombat 33d692194a Add iterators to string 2023-10-08 16:27:52 +02:00
drmortalwombat e084035a71 Common sub expression across if 2023-10-03 15:21:33 +02:00
drmortalwombat 313b6dcf93 Fix struct assign in constexpr 2023-10-03 12:47:24 +02:00
drmortalwombat 4e6769d81c Add <new> header file 2023-10-02 18:43:58 +02:00
drmortalwombat c53a288d0b Optimize index chains 2023-10-01 21:48:09 +02:00
drmortalwombat 235437be56 Fix absolute address high byte propagation error 2023-09-30 22:22:33 +02:00
drmortalwombat 078d14861c Some data path optimizations 2023-09-30 18:10:03 +02:00
drmortalwombat c98ff08f56 Fix infinite loop eating the entry block 2023-09-27 18:53:35 +02:00
drmortalwombat e6b865130a Fix volatile in vsprites 2023-09-25 19:20:30 +02:00
drmortalwombat d93cffaa30 Fix const pointers in vic_setmode 2023-09-25 19:18:22 +02:00
drmortalwombat 619c4f8962 Join consecutive functions in linker 2023-09-24 22:22:48 +02:00
drmortalwombat da29a87477 Fix address of array in const declaration to return correct pointer type 2023-09-24 11:03:54 +02:00
drmortalwombat bba8931860 Fix const node polution in const param optimization 2023-09-23 18:52:26 +02:00
drmortalwombat cda66f3ec4 Function pointer forwarding 2023-09-23 18:01:28 +02:00
drmortalwombat 9d8c6991e8 Add global optimizer for parameter/return optimizations 2023-09-23 14:56:04 +02:00
drmortalwombat c7f919e22e Bump version number 2023-09-20 18:06:48 +02:00
drmortalwombat a0409002b6 Fix pointers in constexpr 2023-09-20 14:19:56 +02:00
drmortalwombat e20c098ab1 Fix samples build error 2023-09-18 07:41:49 +02:00
drmortalwombat f211eef837 Add fold expressions for argument packs 2023-09-17 20:34:42 +02:00
drmortalwombat 38274fb4f7 Add emplace_back in vector 2023-09-17 15:40:05 +02:00
drmortalwombat c674fc9a8b Add variadic sizeof... 2023-09-17 11:39:18 +02:00
drmortalwombat 06ebf85d9d Recursive variadic templates 2023-09-17 10:24:28 +02:00
drmortalwombat 935a38607b Bump version number 2023-09-14 19:45:55 +02:00
drmortalwombat d9106be820 Lambda in constexpr 2023-09-14 12:03:28 +02:00
drmortalwombat 0e6cb5557a Auto parameters in lambdas 2023-09-14 10:30:52 +02:00
drmortalwombat 64b3bfa30f Optimize temporary object livetime 2023-09-13 19:05:33 +02:00
drmortalwombat 532bf51718 Range for loop with reference iteration 2023-09-13 17:24:38 +02:00
drmortalwombat eccb2787dc Add simple range for loop 2023-09-12 21:33:59 +02:00
drmortalwombat d94d52b852 fix assert in linux autotest 2023-09-12 15:44:16 +02:00
drmortalwombat 2b51f20b1c Add lambda 2023-09-12 15:36:24 +02:00
drmortalwombat c926456560 Add simple return type deduction 2023-09-11 17:49:04 +02:00
drmortalwombat ab49281b0d Implement operator() 2023-09-11 16:19:11 +02:00
drmortalwombat 1b50baf852 Fix wrong unicode character in error message 2023-09-11 13:03:07 +02:00
drmortalwombat c1ecf1c281 Added bitfields 2023-09-11 08:04:09 +02:00
drmortalwombat 3374544ced Fix base type compare in template check 2023-09-10 10:28:25 +02:00
drmortalwombat bd37877c8c Add heap support to constexpr 2023-09-09 12:09:05 +02:00
drmortalwombat 4dd3cd967a Add switch, break and continue to constexpr 2023-09-08 21:03:18 +02:00
drmortalwombat ab273181f5 First shot implementing constexpr 2023-09-08 20:12:38 +02:00
drmortalwombat cb352fcc7c Bump version number 2023-09-04 22:23:00 +02:00
drmortalwombat e9afd5e284 Fix template function included multiple ways 2023-08-31 20:17:39 +02:00
drmortalwombat da9b8f2a42 Fix return of const array as pointer 2023-08-31 14:13:43 +02:00
drmortalwombat fa19e466de Fix opp string append char 2023-08-28 18:52:14 +02:00
drmortalwombat 7bf5ce7581 Add debug file docu to readme 2023-08-25 11:03:49 +02:00
drmortalwombat 5b4e5b545d Add or/and/shift to inline assembler 2023-08-20 19:06:24 +02:00
drmortalwombat 54296bdd71 Add friend classes 2023-08-20 15:06:51 +02:00
drmortalwombat 4732f76bd5 Add static member variables 2023-08-20 14:17:40 +02:00
drmortalwombat 07dc6dc4db Optimize simple virtual with const return to table lookup 2023-08-20 12:02:06 +02:00
drmortalwombat 6ff2409596 Fix return register optimization in v table call 2023-08-20 09:26:26 +02:00
drmortalwombat 04b10bb04d Update readme 2023-08-19 22:01:16 +02:00
drmortalwombat bd3c7571c5 bump version number 2023-08-19 21:57:44 +02:00
drmortalwombat 8dc37e9ab2 Mangling function types in template expansion 2023-08-18 23:03:15 +02:00
drmortalwombat 3a9cd85072 Optimize simple const ref to value in functions 2023-08-18 13:13:39 +02:00
drmortalwombat 0440f0ef19 More template support 2023-08-17 14:55:43 +02:00
drmortalwombat b7daafcac8 Add list and iterators to opp 2023-08-16 16:16:04 +02:00
drmortalwombat 82dff88ba8 Added numeric conversion to opp strings 2023-08-15 16:55:58 +02:00
drmortalwombat 952d087a2b Add using with list of names 2023-08-15 13:16:39 +02:00
drmortalwombat 69b46c4b7b Fix namespaces for templates 2023-08-15 12:46:57 +02:00
drmortalwombat 50cc2afb52 Add template algorithm sort 2023-08-15 11:05:52 +02:00
drmortalwombat ae2fbb6256 Global object initialization 2023-08-14 18:09:35 +02:00
drmortalwombat 80426d974c Add RValue Reference 2023-08-13 20:53:39 +02:00
drmortalwombat 61f8b68c2f Fix duplicate member cons/destructor if class included from multiple cpp 2023-08-13 11:00:02 +02:00
drmortalwombat 9d6691cf91 Copy constructor and destruct for scalar types 2023-08-12 18:19:46 +02:00
drmortalwombat cb5451b9b9 Automatic function template expansion 2023-08-12 15:25:30 +02:00
drmortalwombat 5b7334bb17 Add placement new and destructor call 2023-08-11 19:04:13 +02:00
drmortalwombat fef6bc29bc Add templates 2023-08-11 07:41:27 +02:00
drmortalwombat 07969d1fa6 Fix type coercion from empty string pointer to 0 2023-08-08 17:33:47 +02:00
drmortalwombat b7630450f1 Improve C++ compliance 2023-08-08 14:19:08 +02:00
drmortalwombat c46870ec10 bump version number 2023-08-07 17:50:17 +02:00
drmortalwombat 0f31a4e8c6 Add error for overlapping data sections 2023-08-07 16:06:34 +02:00
drmortalwombat 0d95a74813 Add cartridge bank lookup for lables in asm file 2023-08-07 15:50:01 +02:00
drmortalwombat 1407d9d948 Add function default parameters 2023-08-06 15:21:11 +02:00
drmortalwombat 8161ff88a8 Fix crash on infinite macro expansion 2023-08-06 11:51:11 +02:00
drmortalwombat 1931f25475 Add struct member initializer 2023-08-05 21:52:44 +02:00
drmortalwombat 58ab6818ed Add alignment for functions 2023-08-03 13:34:23 +02:00
drmortalwombat eac12e4559 Fix cpp compare of two derived pointers 2023-08-02 22:29:10 +02:00
drmortalwombat f3eb6e19cf Fix linux build 2023-08-02 16:52:45 +02:00
drmortalwombat ec15336174 Fix stack allocation with false recursion with function pointers 2023-08-01 22:17:55 +02:00
drmortalwombat b1a42e5ecf Fix linux build 2023-08-01 15:50:11 +02:00
drmortalwombat 19ab2b8d38 Fix linux build 2023-08-01 13:46:30 +02:00
drmortalwombat fa218d8dd7 Fix adc to inx with wrong address mode 2023-07-31 22:53:55 +02:00
drmortalwombat 34c0df228b Bump version number 2023-07-30 14:46:32 +02:00
drmortalwombat 8a283cc43b Fix register conflict in short index forwarding 2023-07-30 13:57:15 +02:00
drmortalwombat e013142cb1 Cross block register optimizations 2023-07-30 11:24:19 +02:00
drmortalwombat 0b1d42b7d5 Expand global aliasing analysis 2023-07-29 22:15:00 +02:00
drmortalwombat ae21bbac09 Bump version number 2023-07-28 18:59:12 +02:00
drmortalwombat 3664645393 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2023-07-28 18:51:34 +02:00
drmortalwombat 02e7f15810 Improve outer loop optimizations 2023-07-28 18:51:29 +02:00
drmortalwombat f6f2b4c37e
Merge pull request #26 from polluks/main
Support of more platforms
2023-07-27 18:30:20 +02:00
Stefan 312265c395
Support of more platforms
See http://aminet.net/package/dev/cross/oscar64
2023-07-27 13:00:07 +02:00
drmortalwombat 4c5a9c3b70 Fix over eager register promotion 2023-07-26 22:48:15 +02:00
drmortalwombat 2b9ae73795 Bump version number 2023-07-26 19:46:07 +02:00
drmortalwombat 551316fe59 Fix autotest assert 2023-07-26 18:02:22 +02:00
drmortalwombat d8f31b170d Mangle constructor name 2023-07-25 14:37:00 +02:00
drmortalwombat 07323b12f9 Static init of structs with base classes 2023-07-25 11:19:00 +02:00
drmortalwombat adda4044ca Complete value forwardign abs,x and abs,y 2023-07-24 22:23:37 +02:00
drmortalwombat df28d2f83f Value forwarding abs,x and abs,y 2023-07-24 22:19:35 +02:00
drmortalwombat 6cfa24b8ad Fix over eager constant propagation 2023-07-24 19:03:34 +02:00
drmortalwombat b8a993aa34 Bump version number 2023-07-23 18:23:11 +02:00
drmortalwombat 893aa7effa Add late inlining step 2023-07-23 17:41:56 +02:00
drmortalwombat 33b7bee047 Fastcall for virtual functions 2023-07-23 13:51:24 +02:00
drmortalwombat 9b2d90ec58 Add autotest for string stream 2023-07-23 11:19:26 +02:00
drmortalwombat fbde581475 Add file and string streams 2023-07-21 22:07:19 +02:00
drmortalwombat bd6db60802 Add iostream library 2023-07-20 14:46:10 +02:00
drmortalwombat bbf2bd5b6a
Merge pull request #24 from polluks/patch-1
Fixed makefile (stupid typo)
2023-07-18 12:17:49 +02:00
Stefan 7b1b81aeb7
Fixed makefile (stupid typo) 2023-07-18 12:09:18 +02:00
drmortalwombat 9cdfad7d34 Improve cpp code generation 2023-07-17 07:52:59 +02:00
drmortalwombat 18c21b3fda Optimize long shifts 2023-07-15 22:32:07 +02:00
drmortalwombat 4115bdcb4f
Merge pull request #23 from polluks/main
Added makefile for autotest
2023-07-15 22:03:54 +02:00
polluks 76b6039256 Added makefile for autotest 2023-07-15 18:56:03 +02:00
drmortalwombat fa60c2e658 Improve operator overloading 2023-07-14 07:48:48 +02:00
drmortalwombat 6178bb1f9d Shortcut jump cascades 2023-07-10 22:12:41 +02:00
drmortalwombat 00ded29b35 Improve opp string library 2023-07-09 21:35:49 +02:00
drmortalwombat 66631c915b Prefix and inc operator overload 2023-07-09 10:52:11 +02:00
drmortalwombat 0bab98ccc6 Optimize short signed table access 2023-07-08 22:20:42 +02:00
drmortalwombat a46cf3a0d3 Add virtual destructor 2023-07-08 22:04:55 +02:00
drmortalwombat ed9aa3503b Added virtual functions 2023-07-08 18:53:06 +02:00
drmortalwombat 0b6a9c3584 Copy elision on return statements 2023-07-05 17:10:23 +02:00
drmortalwombat 0b79d44345 Fix location of error message of duplicate function definition 2023-07-03 22:39:24 +02:00
drmortalwombat e8587105c4 Fix duplicate label in crt.c 2023-07-03 17:48:55 +02:00
drmortalwombat 184f306eb2
Merge pull request #18 from polluks/patch-1
Update makefile
2023-07-03 17:30:46 +02:00
drmortalwombat da88dea271
Merge pull request #19 from polluks/patch-2
Update build.sh
2023-07-03 17:30:22 +02:00
drmortalwombat 1e9e426758 Fix wrong enum type check 2023-07-03 16:44:47 +02:00
Stefan 69480c8742
Update build.sh
missing prg
2023-07-03 15:59:51 +02:00
Stefan b91e76f216
Update makefile
missing prg
2023-07-03 15:56:16 +02:00
drmortalwombat 6c7347310b Init const copy construction 2023-07-02 20:48:46 +02:00
drmortalwombat ef0a79b8f0 Index operator overload 2023-07-02 18:21:40 +02:00
drmortalwombat 7f6cf654f6 Implemented new and delete operators 2023-07-02 16:34:17 +02:00
drmortalwombat 291ff890e6 Change heap layout for vector delete 2023-07-02 13:36:02 +02:00
drmortalwombat 7858c2135b Add malloc/free as intrinsic 2023-07-02 12:00:53 +02:00
drmortalwombat 08adc7f1bd Bump version number 2023-07-01 10:06:08 +02:00
drmortalwombat c8fbc15c37 Copy propagation on struct return of functionr result 2023-07-01 09:27:03 +02:00
drmortalwombat 1b73df7e25 const member functions 2023-06-29 18:11:11 +02:00
drmortalwombat fa9aa9c2bb Visibility in base classes 2023-06-29 16:34:38 +02:00
drmortalwombat 3d6b60c9f4 Implement base class constructors 2023-06-28 22:14:29 +02:00
drmortalwombat 478f93922d Error on pointer/integer compare 2023-06-27 18:16:13 +02:00
drmortalwombat a41c3d445b Add class, public, private and protected keywords 2023-06-27 17:18:12 +02:00
drmortalwombat f99185e56d Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2023-06-27 15:34:15 +02:00
drmortalwombat 63ebf6aa7c strlen optimization 2023-06-27 15:34:13 +02:00
drmortalwombat 228bf95329
Merge pull request #15 from polluks/patch-1
Added multithreading hint
2023-06-27 08:13:23 +02:00
drmortalwombat 8f39d736d5 Fixing member functions with includes 2023-06-27 08:12:20 +02:00
Stefan 6de38be207
Added multithreading hint 2023-06-26 12:08:47 +02:00
drmortalwombat 0b1b4a7d9b Array constructors 2023-06-25 22:24:13 +02:00
drmortalwombat 0f67f7150f Fix linux build 2023-06-25 16:16:26 +02:00
drmortalwombat 6b753c1418 Destructor tracking of temporary variables 2023-06-25 14:25:29 +02:00
drmortalwombat 56740b630d Member constructor and destructor 2023-06-22 19:17:45 +02:00
drmortalwombat a854133f8e Fix over eager global address progpagation 2023-06-22 14:04:18 +02:00
drmortalwombat 04eeedb0b9 Object destruction on break, continue and return 2023-06-21 22:30:28 +02:00
drmortalwombat 9bcec5bf17 Destructors when leaving scopes the normal way 2023-06-21 22:07:00 +02:00
Janne Johansson 576d2a96cd
Update README.md for unix builds 2023-06-21 15:16:02 +02:00
drmortalwombat daf412a47b Add default constructor 2023-06-20 17:16:22 +02:00
drmortalwombat e577791252 Constructors with parameter overloading 2023-06-20 10:26:49 +02:00
drmortalwombat b008d39eae Function overloading in cpp mode 2023-06-18 20:27:20 +02:00
drmortalwombat f72048383a Access to member variables in member functions 2023-06-18 16:37:53 +02:00
drmortalwombat 9e92c2863a Add member functions in cpp mode 2023-06-18 14:41:23 +02:00
drmortalwombat 37416a61cb Add struct inheritance in cpp mode 2023-06-18 10:20:50 +02:00
drmortalwombat b8478348ed Fix nullptr reference cause assert in linux 2023-06-18 09:24:50 +02:00
drmortalwombat 95afe011c8
Merge pull request #14 from polluks/main
Multi-threaded makefiles
2023-06-18 09:08:36 +02:00
polluks c93cc8b680 Multi-threaded makefiles 2023-06-18 01:37:57 +02:00
drmortalwombat 7b40aa59a1 Add references for cpp mode 2023-06-17 21:07:31 +02:00
drmortalwombat fd391690b9 Add .cpp mode and namespace/using 2023-06-17 15:08:03 +02:00
drmortalwombat 433270f90f Fix global analyzer not following recursive structs 2023-06-16 16:29:08 +02:00
drmortalwombat 0f182d2d6d Fix over eager function parameter optimiztion 2023-06-16 15:21:30 +02:00
drmortalwombat c300f6c364 Bump version number 2023-06-14 17:19:48 +02:00
drmortalwombat 8a886f0a60 Fix loop invariant error 2023-06-14 16:44:03 +02:00
drmortalwombat c83804a76c Cross function constant propagation 2023-06-14 14:40:59 +02:00
drmortalwombat 72687b7581 Add compound literals 2023-06-10 15:17:57 +02:00
drmortalwombat ab9ae6bf0e Fix error in intermediate code peephole optimizer 2023-06-09 21:21:35 +02:00
drmortalwombat 404e9ad998 Bump version number 2023-06-08 20:43:37 +02:00
drmortalwombat e593e2affb Loop optimizations 2023-06-08 20:27:11 +02:00
drmortalwombat d054818aa3 Bump version number 2023-06-04 17:37:51 +02:00
drmortalwombat 373811f2bb Report error if void result used in condition 2023-06-03 18:23:35 +02:00
drmortalwombat 962240f09d Fix init state of 32 vsprites mux 2023-06-03 13:01:52 +02:00
drmortalwombat 7c0db6161d Optimize some pointer arithmetic 2023-06-01 22:23:08 +02:00
drmortalwombat 5e699a8dc0 Optimize signed division by 4 and 8 2023-06-01 11:22:36 +02:00
drmortalwombat d80518871a Fix bypass a->y->a chain with tya in middle 2023-06-01 08:13:11 +02:00
drmortalwombat 9e985f7f3d Optimize double and shift 2023-05-29 21:54:55 +02:00
drmortalwombat 9175257bbc Fix function return source position with implicit return 2023-05-28 16:12:12 +02:00
drmortalwombat d6faefb5fc Propagate static stack usage through recursions 2023-05-28 14:30:46 +02:00
drmortalwombat a4faf204cb Fix enums in debug output 2023-05-27 14:17:30 +02:00
drmortalwombat 7d3dc493c0 Fix inter instruction cross block move 2023-05-26 20:16:19 +02:00
drmortalwombat 5564b01d11 Fix sample build crash on linux 2023-05-23 11:05:29 +02:00
drmortalwombat 400017bc54 Assign function exit code to first return statement 2023-05-21 21:14:00 +02:00
drmortalwombat cdbb24b6b2 Add iecbus library 2023-05-21 17:19:26 +02:00
drmortalwombat e6b46a3acf More aggressive value forwarding with local arrays 2023-05-20 13:49:34 +02:00
drmortalwombat d58e74e19a Bump version number 2023-05-19 22:49:54 +02:00
drmortalwombat 2ac276458a Optimize loop invariants in single entry/exit loops 2023-05-19 21:25:29 +02:00
drmortalwombat f8d69f7945 Add "enter" and "leave" attributes to dbj for local variables 2023-05-17 18:27:09 +02:00
drmortalwombat d4caa6bb71 Optimize right shift of byte values with variable shift distance 2023-05-16 19:07:59 +02:00
drmortalwombat 5b9f865a9d
Merge pull request #11 from polluks/chmod
Fixed permissions
2023-05-15 12:32:42 +02:00
drmortalwombat 5b0fe1e050 Fix clang warnings 2023-05-14 19:07:10 +02:00
drmortalwombat 8142ed3e72 Merge branch 'main' of https://github.com/drmortalwombat/oscar64 2023-05-14 19:01:41 +02:00
drmortalwombat 28bdb2e395
Merge pull request #9 from polluks/main
Fixed typos
2023-05-14 19:01:25 +02:00
polluks 0ca23344af Fixed permissions 2023-05-13 16:45:01 +02:00
polluks 1616b9335f Fixed typos 2023-05-13 15:57:46 +02:00
drmortalwombat 45963102b8 Fix lower bound of byte -- operator 2023-05-12 14:17:35 +02:00
drmortalwombat 30c602d468 Fix missing enums in dbj files 2023-05-11 09:39:00 +02:00
drmortalwombat 556301366f More readme 2023-05-08 17:35:53 +02:00
drmortalwombat 1b931c4abd Add link to source level debugger in readme 2023-05-08 17:33:43 +02:00
drmortalwombat a9651a4f2e Optimize combining bits using shift 2023-05-07 20:55:35 +02:00
drmortalwombat 7b16d2c795 Bump version number 2023-05-07 18:03:08 +02:00
drmortalwombat 4aa6b1c47d Improve int dependency in loop analysis 2023-05-07 17:46:53 +02:00
drmortalwombat 0639fdc008 Unify instruction dependency check in optimizer 2023-05-06 18:28:59 +02:00
drmortalwombat 7d12fd4c02 Fix same XY optimization 2023-05-04 11:32:12 +02:00
drmortalwombat df733d09a8 Fix add cross move in native code optimizer 2023-05-01 19:16:25 +02:00
drmortalwombat 30b3ed610e Keep unused variable stores if optimization is turned off 2023-05-01 17:10:27 +02:00
drmortalwombat d047152646 Reduce line number toggling in debug file 2023-05-01 15:38:48 +02:00
drmortalwombat b1fc2e3736 Add __bankof operator 2023-04-30 18:35:04 +02:00
drmortalwombat ac7e1d5867 Fix over eager function parameter optimization 2023-04-16 22:56:58 +02:00
drmortalwombat 2d2d030145 Fix dbj "member" name having a space 2023-04-16 14:51:35 +02:00
drmortalwombat 8ede3abcab Fix loss of loop head status in native basic blocks 2023-04-16 14:05:09 +02:00
drmortalwombat e5805716e2 Fix propagation of volatile flags 2023-04-15 21:53:33 +02:00
drmortalwombat bb00b5af12 Add more generic cartridge support 2023-04-14 18:40:27 +02:00
drmortalwombat 6308f22f25 Fix warnings 2023-04-12 19:02:27 +02:00
drmortalwombat 4c8d7a08d0 Do not add optimized away local variables to dbj file 2023-04-11 20:45:47 +02:00
drmortalwombat 78e48c75fd Auto place globals in zero page with -Oz option 2023-04-10 18:26:59 +02:00
drmortalwombat e23ab50512 Add local variables to debug file 2023-04-09 19:19:57 +02:00
drmortalwombat 373ef6ca85 Add local variables to .dbj files 2023-04-09 10:05:01 +02:00
drmortalwombat 85df217c50 Add warning for const integer truncation 2023-04-09 09:45:13 +02:00
drmortalwombat d5c347da9b Add vera sprite image 2023-04-07 15:47:08 +02:00
drmortalwombat 6ff2038b0e Add commander X16 VERA library 2023-04-06 21:53:47 +02:00
drmortalwombat 97bb7981a3 Improve struct copy alias analysis 2023-04-06 17:14:53 +02:00
drmortalwombat 7803e2ecc4 Fix infinite loop in compiler trying to optimize infinite loops 2023-04-04 08:37:26 +02:00
drmortalwombat 62c3c4ab90 Bump version number 2023-04-02 19:54:45 +02:00
drmortalwombat 32ea493c17 Prepare per function optimization config using pragmas 2023-04-02 19:04:10 +02:00
drmortalwombat 14ab294a47 Add getchx() call to conio 2023-04-02 13:51:53 +02:00
drmortalwombat 4a2e417e31 Add quotes to attribute names in dbj export 2023-03-31 17:51:09 +02:00
drmortalwombat 0555f3d75d Bump version number 2023-03-29 19:45:08 +02:00
drmortalwombat 2f1172076a Add source level debug information 2023-03-28 21:01:17 +02:00
drmortalwombat 451eaca2b2 Bump version number 2023-03-26 14:35:07 +02:00
drmortalwombat 36a57c87d8 Add commander x16 as target machine 2023-03-24 21:06:27 +01:00
drmortalwombat c2c0244990 More native code common subexpression elimination 2023-03-24 20:23:10 +01:00
drmortalwombat 55a2c25b44
Merge pull request #7 from JettMonstersGoBoom/main
neslib.c fixes
2023-03-23 13:35:14 +01:00
MonstersGoBoom 3165f65377 corrected oam_clear to be off screen
added nstc/pal detection.
2023-03-23 08:22:19 -04:00
drmortalwombat 6af03b34ad Fix infinite optimizer loop 2023-03-21 08:09:12 +01:00
drmortalwombat ba2a90030c Improved striped array pointer propagation 2023-03-19 17:36:03 +01:00
drmortalwombat f354e5bf88 Bump Version Number 2023-03-18 19:07:59 +01:00
drmortalwombat a584f74788 More native code common subexpression elimination 2023-03-18 19:02:05 +01:00
drmortalwombat 9c5e018c5a More simple common subexpression elimination in native code 2023-03-17 09:32:22 +01:00
drmortalwombat 9f28fdfcc0 Fix memmove const correctness 2023-03-16 11:59:38 +01:00
drmortalwombat 2479ec5dd8 Fix const void pointer assignment check 2023-03-15 22:53:19 +01:00
drmortalwombat 485282019b Optimize 8bit add and pointer access 2023-03-15 17:58:49 +01:00
drmortalwombat 66d17d6df4 Bump version number 2023-03-14 22:18:43 +01:00
drmortalwombat da29f1c0a5 Fix gcc build 2023-03-14 21:53:50 +01:00
drmortalwombat 7617029652 More volatile checks 2023-03-14 20:51:54 +01:00
drmortalwombat f590284ae2 Fix volatile code movement 2023-03-14 20:32:32 +01:00
drmortalwombat 11c624fb4a Optimize loops with shift 2023-03-14 17:49:17 +01:00
drmortalwombat 175520c885 Optimize pointer forwarding with striped addressing 2023-03-14 16:23:37 +01:00
drmortalwombat 83869ad3a0 Shortcut redundant conditional branch sequences 2023-03-13 22:13:02 +01:00
drmortalwombat 718d3ad940 Bump version number 2023-03-12 22:47:19 +01:00
drmortalwombat ecd0fbd364 Fix over eager loop load/store optimizations for values needed after loop 2023-03-12 20:27:00 +01:00
drmortalwombat 7d6f637948 Fix broken volatile check in (),y 2023-03-11 11:29:35 +01:00
drmortalwombat aed086bdb9 Add rom mappers to NES target 2023-03-11 11:01:11 +01:00
drmortalwombat 868564ff08 Add -v3 option for call graph data, change some function in neslib to inline 2023-03-10 17:08:22 +01:00
drmortalwombat 5bd4f4e9a5 Add local labels to listings 2023-03-09 21:04:56 +01:00
drmortalwombat efff725745 Improve labels in disassembler listing, add mlb file for nes 2023-03-09 19:29:46 +01:00
drmortalwombat 2959016496 Fix movement of accu train across JSR that uses the same register 2023-03-09 16:25:51 +01:00
drmortalwombat 30680777f3 Fix neslib oam_spr functions 2023-03-09 14:08:59 +01:00
drmortalwombat dd6f1e0cb6 Fix const cast of functions to void * in struct inits 2023-03-08 20:26:46 +01:00
drmortalwombat 905afd6451 Fix preprocessor concat with macro argument 2023-03-08 18:39:40 +01:00
drmortalwombat 4f89ad7680 Add support for Atari 8 bit systems 2023-03-08 15:51:27 +01:00
drmortalwombat 0f4f0ed297 Improve compiler speed 2023-03-08 08:37:43 +01:00
drmortalwombat be15913bd0 Bump version number 2023-03-07 19:18:33 +01:00
drmortalwombat c3977627e9 Fix calling __interrupt function from __interrupt function 2023-03-07 08:27:54 +01:00
drmortalwombat 9662f5e69f Loop counter depend index optimizations for small xy loops 2023-03-06 20:34:02 +01:00
drmortalwombat e1606ab6e7 Bump version number 2023-03-05 22:11:28 +01:00
drmortalwombat 9bd7b5cd48 Add device libraries for various C computers 2023-03-05 15:13:02 +01:00
drmortalwombat 6189e0cc49 Prepare NES machine type 2023-03-04 14:07:34 +01:00
drmortalwombat f34aa2dcbe Prepare support for VIC20 and C128 2023-03-02 20:19:47 +01:00
drmortalwombat e09361295e Relax zero page value forwarding intersection rules 2023-03-01 18:43:35 +01:00
drmortalwombat df89082846 Track state of fast call parameters across function calls to avoid duplicate push 2023-03-01 08:49:51 +01:00
drmortalwombat 49bfd63033 Bump version number 2023-02-27 15:41:37 +01:00
drmortalwombat 096d9efcd9 Fix over eager taxa range reduction 2023-02-27 15:38:19 +01:00
drmortalwombat 1b31742d3b Bump version number 2023-02-26 15:14:25 +01:00
drmortalwombat 797e235056 Small loop accu optimizations 2023-02-26 15:11:37 +01:00
drmortalwombat 4117c9a553 More functions for reu library 2023-02-25 21:02:06 +01:00
drmortalwombat 0bb470939f Add reu library 2023-02-23 14:19:18 +01:00
drmortalwombat 153c0ef4fa Short loop optimizations 2023-02-22 22:43:35 +01:00
drmortalwombat cddfa5c95f Bump version number 2023-02-20 08:30:04 +01:00
drmortalwombat a91112c05c Pointer in loop optimizations 2023-02-19 18:07:25 +01:00
drmortalwombat 347c336b09 Optimize X vs. Y usage for indexed increment 2023-02-15 22:03:04 +01:00
drmortalwombat 23091a0536 Combining consecutive pointer arithmetic 2023-02-12 20:09:02 +01:00
drmortalwombat 71a071fea4 Loop direction inversion for simple counts 2023-02-11 10:36:46 +01:00
drmortalwombat acbd70a84f Fix XY register propagation for incomming fast parameters 2023-02-10 18:10:41 +01:00
drmortalwombat 5852ca5aea Shortcut conditional branch blocks in intermediate code 2023-02-08 08:51:58 +01:00
drmortalwombat 115b34626e More XY register cross block optimizations 2023-02-07 16:37:41 +01:00
drmortalwombat ff26dffada Optimize alternate XY cross block register use 2023-02-05 12:30:18 +01:00
drmortalwombat 932a65be8c Optimize cross block XY register usage 2023-02-02 20:10:35 +01:00
drmortalwombat d15fd8a451 Fix over eager cross block zp move 2023-01-30 19:27:09 +01:00
drmortalwombat e624011415 Fix crash when compiling address of structs in constants 2023-01-29 10:17:36 +01:00
drmortalwombat dbd0fb6a56 Fix propagate of compare result over potential dual entry empty basic block 2023-01-22 15:18:07 +01:00
drmortalwombat 946b1fe53d Add mouse library 2023-01-22 11:01:03 +01:00
drmortalwombat 0fae7abd72 Optimize simple inline assembler code 2023-01-21 22:41:13 +01:00
drmortalwombat 677de2508b Shuffle temp moves to avoid duplicates 2023-01-21 08:42:22 +01:00
drmortalwombat 16faec8627 Fix loop exit condition broken by Y register lifting 2023-01-19 20:28:02 +01:00
drmortalwombat 862b8aaf06 bump version number 2023-01-19 19:33:38 +01:00
drmortalwombat 29611ec3db Fix striped constant pointer initializer 2023-01-19 19:03:02 +01:00
drmortalwombat 0b30258f80 Dataflow optimizations 2023-01-17 22:42:02 +01:00
drmortalwombat 2f4b2790f6 Register condition block bypassing 2023-01-17 08:02:36 +01:00
drmortalwombat 02db5b5eb1 Static call graph analysis for function arguments 2023-01-15 18:38:18 +01:00
drmortalwombat 761206d009 Propagation of unsigend attribute accross function arguments 2023-01-13 20:14:16 +01:00
drmortalwombat fdb051bd2b Fix right + left shift optimization when shifting from long to int 2023-01-13 15:41:21 +01:00
drmortalwombat 7c11a5347c Fix over eager move of volatile stores 2023-01-13 13:33:34 +01:00
drmortalwombat a9d3673f4e Optimize left shift by four from byte to int 2023-01-12 22:57:19 +01:00
drmortalwombat d6fcb5f9ca Use CPU register A for single byte parameter and returns 2023-01-10 20:41:55 +01:00
drmortalwombat 9a64bcc8b6 Fix select operator for string constants 2023-01-08 22:29:13 +01:00
drmortalwombat b04f05b575 Optimize signed divide by two 2023-01-08 19:17:25 +01:00
drmortalwombat 50d3c843b4 Use X instead of A when lda/sta sequence inside TAXA range 2023-01-08 10:56:14 +01:00
drmortalwombat 10359224d4 Fix write to CPU port not marked as volatile 2023-01-08 10:38:58 +01:00
drmortalwombat ffe07a6a3c Optimize multiplication with short negative constants 2023-01-07 13:41:59 +01:00
drmortalwombat c105c3b778 Fix error in final code size reduction step 2023-01-03 21:48:50 +01:00
drmortalwombat 59d77504c8 Fix compile time load of const striped array data 2023-01-01 18:34:52 +01:00
drmortalwombat 57449e3f4a Optimize adds to ors when possible 2022-12-30 20:20:49 +01:00
drmortalwombat 425aae8f72 Fix pointer register loss while forwarding index 2022-12-30 15:55:03 +01:00
drmortalwombat 1a06102668 Shortcut identical consecutive conditional branches 2022-12-25 22:14:12 +01:00
drmortalwombat 5696691a19 Bump version number 2022-12-23 22:50:13 +01:00
drmortalwombat 9daf4fa621 Some more cross block pointer forwarding 2022-12-18 20:33:52 +01:00
drmortalwombat cdd7a15a42 Fix half pointer cross block move 2022-12-18 10:02:16 +01:00
drmortalwombat e202f8e5b5 Bump version number 2022-12-13 20:16:11 +01:00
drmortalwombat ac0f4d232e Fix .d64 layout 2022-12-13 08:49:05 +01:00
drmortalwombat de3c7415b3 Fix error in recursive macro expansion 2022-12-13 08:18:25 +01:00
drmortalwombat 0055911491 Add overlay support 2022-12-10 17:15:25 +01:00
drmortalwombat 0aa9ca0c70 Bump Version number 2022-12-10 16:15:04 +01:00
drmortalwombat 5bb21b3b0a Fix block allocator for .d64 generator 2022-12-09 15:45:40 +01:00
drmortalwombat 50ae45a533 Bump version number 2022-12-06 19:07:59 +01:00
drmortalwombat 3edd541750 Fix over eager forwarding of global addresses across loop boundaries 2022-12-06 18:29:37 +01:00
drmortalwombat f56fb9e505 Fix crash in optimizer when declaring too many unused local variables 2022-12-06 15:55:31 +01:00
drmortalwombat 8b631d564e Add autotest for striped arrays 2022-12-03 13:28:03 +01:00
drmortalwombat 9c6b745993 Fix self destruct of load store forwarding dict 2022-11-30 22:47:13 +01:00
drmortalwombat ec31b845b8 Fix type check of pointers derived by address of operator 2022-11-30 15:07:06 +01:00
drmortalwombat bfe6311ca4 Add assignment of structs from and to striped arrays 2022-11-29 18:11:42 +01:00
drmortalwombat 02e4d4bd1b Optimize indexing in loops 2022-11-26 14:12:13 +01:00
drmortalwombat bc058a1c80 Known zero register value propagation 2022-11-25 22:31:23 +01:00
drmortalwombat ebe9476bcc Fix strided array unsigned struct member assignment 2022-11-24 18:15:16 +01:00
drmortalwombat 688fd92a6b Bump version number 2022-11-22 20:25:03 +01:00
drmortalwombat a5a27c039e Fix __asume declaration in loop causing loss of temp chain 2022-11-20 17:35:31 +01:00
drmortalwombat c6d0f44364 Fix unsigend int to/from float conversion 2022-11-19 10:58:44 +01:00
drmortalwombat 74f93ca4fb Improve precision of float log function 2022-11-16 20:51:07 +01:00
drmortalwombat 42b4f46356 Add striped array memory layout 2022-11-16 08:59:02 +01:00
drmortalwombat 6283f5f9e6 Improve accu train movement 2022-11-09 18:06:33 +01:00
drmortalwombat 54955b6b5f Bump version number 2022-10-29 10:59:20 +02:00
drmortalwombat 93943f8f87 Fix pre decrement operator l value return type 2022-10-25 17:12:36 +02:00
drmortalwombat 44bd9cf595 Fix const enum type check 2022-10-25 11:02:00 +02:00
drmortalwombat 04624f208c Fix multiply add 2n + 1 2022-10-23 17:02:34 +02:00
drmortalwombat 0aee1ad452 Code size reduction for jmp to rts 2022-10-22 18:21:45 +02:00
drmortalwombat 7271106397 bump version number 2022-10-17 08:00:35 +02:00
drmortalwombat ef7b391da0 Fix 16 bit indexed ops lost high byte offset 2022-10-16 16:05:55 +02:00
drmortalwombat e52e554fec Add warning for missing return statement 2022-10-16 14:06:27 +02:00
drmortalwombat 4ff762b711 Add warning/error for unassigned variable access 2022-10-16 13:33:20 +02:00
drmortalwombat 8ee390a532 Fix negative array access in native code path propagation 2022-10-16 10:49:51 +02:00
drmortalwombat 77010a0ab2 Fix propagation of volatile memory reads in loops 2022-10-15 17:44:49 +02:00
drmortalwombat 53e4019ecd Fix 2D array access 2022-10-15 10:50:28 +02:00
drmortalwombat 634b7914ea Fix movement of LDY/STY pair that conflicts with Z flag usage 2022-10-13 22:43:50 +02:00
drmortalwombat 4a49456a57 Improve accu train movement 2022-10-09 13:44:59 +02:00
drmortalwombat bd32b38027 Preserve X or Y cross conditions 2022-10-08 11:34:42 +02:00
drmortalwombat 571d60cbb7 Bump version number 2022-10-03 19:41:22 +02:00
drmortalwombat 4daecdc51a Optimize select statement 2022-10-03 18:56:17 +02:00
drmortalwombat 3e59f47748 Loop index optimizations 2022-10-03 10:50:24 +02:00
drmortalwombat 27a227501a Bump version number 2022-09-29 15:40:22 +02:00
drmortalwombat 0c633d114c Added late stage loop optimization for indexed offset addressing 2022-09-29 15:32:00 +02:00
drmortalwombat 3907068014 Fix over eager down movement of xy load store 2022-09-25 16:41:21 +02:00
drmortalwombat 121f0476e1 Bump version number 2022-09-24 14:31:09 +02:00
drmortalwombat 03be76f7f5 Fix postcondition in false branch of integer range estimation after signed less than comparison 2022-09-22 21:57:37 +02:00
drmortalwombat 259abf4c4b Improve compiler speed 2022-09-20 15:01:47 +02:00
drmortalwombat c3e89d5d32 Optimize raster mutliplexer 2022-09-18 21:24:34 +02:00
drmortalwombat 01365c38b7 Move more invariants out of complex loops 2022-09-18 12:59:01 +02:00
drmortalwombat d1c22573da Bump version number 2022-09-17 23:03:44 +02:00
drmortalwombat 5156055e53 Fix index subtract using wrong direction 2022-09-17 22:57:01 +02:00
drmortalwombat 0835b90219 Optimize negative const offsets in array index 2022-09-17 22:36:17 +02:00
drmortalwombat bd2e198339 Fix loop exit condition z when using xy as loop invariants 2022-09-17 18:33:48 +02:00
drmortalwombat 49a822afbf Fix load int range estimation 2022-09-17 16:15:35 +02:00
drmortalwombat 31dfc702ab Fix lingering branch in idle loop elimination 2022-09-14 08:21:53 +02:00
drmortalwombat 03b5a0655a Bump version number 2022-09-13 22:10:58 +02:00
drmortalwombat 840175d218 More accu train movement 2022-09-13 22:08:02 +02:00
drmortalwombat 38fab44cca Dump cartridge bank usage to map file 2022-09-13 09:55:38 +02:00
drmortalwombat 76f463daff Add fractal tree sample 2022-09-12 22:30:26 +02:00
drmortalwombat 8c19b1f148 Add heapsize and stacksize pragmas and check in linker 2022-09-12 22:01:58 +02:00
drmortalwombat f0c36c6400 Propagate sign and zero information cross branches 2022-09-11 11:50:57 +02:00
drmortalwombat 612e88456c Bump version number 2022-09-10 16:56:49 +02:00
drmortalwombat e50f3f9814 Fix lenient semicolon handling in parser 2022-09-10 10:05:44 +02:00
drmortalwombat 8287f03f49 Fix shortcut moves violating carry dependencies 2022-09-04 23:05:52 +02:00
drmortalwombat b6a02550f9 Shortcut move from zp to parameter registers 2022-09-04 20:23:06 +02:00
drmortalwombat 9f1205a6cd bump version number 2022-08-27 22:33:34 +02:00
drmortalwombat 6014018f4e Improve XY usage in 16 bit arithmetic 2022-08-27 16:52:27 +02:00
drmortalwombat 5435e1c930 Improve register allocation in complex loops 2022-08-27 15:23:50 +02:00
drmortalwombat da2c0b44ad Bump version number 2022-08-25 18:51:27 +02:00
drmortalwombat 7dd8f4dae3 Fix easyflash placement of auto copied main section 2022-08-25 18:01:58 +02:00
drmortalwombat 4b4c8866dd Optimize multiply of ranges 0..1 2022-08-22 22:00:16 +02:00
drmortalwombat 49330ce101 Extend zero bank crt copy to $3f00 bytes instead of $3800 2022-08-22 14:22:56 +02:00
drmortalwombat eafe13e557 Fix carray propagation in 16bit subtract with low byte const 2022-08-20 14:03:46 +02:00
drmortalwombat 1805e311b8 Add data flow calculation before moving const op ups to fix change of used dst temps in other branch 2022-08-15 22:08:00 +02:00
drmortalwombat 65fc43c123 More multi path constant folding 2022-08-14 17:52:58 +02:00
drmortalwombat 3d23e7f0b1 Combine partialy constant 16bit adds 2022-08-09 16:39:47 +02:00
drmortalwombat b9396542f0 Add page level unrolling 2022-08-07 22:29:33 +02:00
drmortalwombat 4d274f46d7 Fix move of 16 bit shft lower part across carry boundary 2022-08-06 18:45:37 +02:00
drmortalwombat f0deaab394 Add charpad and spritepad import 2022-08-05 18:08:10 +02:00
drmortalwombat ff1377f7bb Optimize simple search loops 2022-07-30 12:36:05 +02:00
drmortalwombat e1a30a25c7 Fix data dependency violation in cross diamond movement 2022-07-26 19:36:10 +02:00
drmortalwombat ca37ebff0b Fix native code peephole optimization with wrong type/mode enum 2022-07-23 14:50:28 +02:00
drmortalwombat f9f2516a65 Move accu eval trains up to connect them 2022-07-23 14:12:11 +02:00
drmortalwombat 67142bdb01 Add charwin get/put rect functions 2022-07-20 08:10:05 +02:00
drmortalwombat 864c8ec9a5 Add samples for 32 and 64 sprite multiplexing 2022-07-18 21:22:12 +02:00
drmortalwombat 0742be3204 Improve dataflow analysis 2022-07-16 14:14:02 +02:00
drmortalwombat 460a1b9d84 Bump version number 2022-07-12 20:07:40 +02:00
drmortalwombat 67e3071920 Fix cascaded indexing with byte postincrement 2022-07-12 17:05:23 +02:00
drmortalwombat 4666e7a176 Fix single block loop optimization for function call in loop 2022-07-12 14:50:55 +02:00
drmortalwombat 0bd2ab9e3c Fix global analyzer for global variable arrays of function pointers 2022-07-12 13:08:34 +02:00
drmortalwombat ae07b2cee6 Fix local array of function pointers indexing 2022-07-11 09:15:01 +02:00
drmortalwombat 9df036f4d4 Fix uninitialized variable
Fixed uninitialized variable in intermediate code generation leading to divergent windows and linux builds
2022-07-10 16:09:39 +02:00
drmortalwombat f3197d641c Rebuild intermediate data flow set after final basic block merge 2022-07-10 15:41:51 +02:00
drmortalwombat 5f8797b4be Fix regression with open array index by byte generated by a subtract 2022-07-10 10:07:33 +02:00
drmortalwombat 9424723536 Force pra of cia1 to 0xff when starting key check 2022-07-09 16:13:06 +02:00
drmortalwombat 5d51ea13c5 Improve register allocator 2022-07-08 21:30:22 +02:00
drmortalwombat 931f9e71b9 Optimize bit check to bool conversion 2022-07-03 22:41:41 +02:00
drmortalwombat eb55b2f55d Remove dangling tail recursion rts after jmp 2022-07-03 13:13:32 +02:00
drmortalwombat bcc59a9afb Add intermediat code select operator 2022-07-02 14:53:00 +02:00
drmortalwombat ba661759fb Fix reordering of function calls 2022-06-30 20:28:36 +02:00
drmortalwombat fdcaf54666 Add unroll pragma for simple loops 2022-06-30 09:33:11 +02:00
drmortalwombat 350403121d Move load temporary register moves out of loops 2022-06-26 15:15:59 +02:00
drmortalwombat 5dc63248d8 bump version number 2022-06-22 22:23:20 +02:00
drmortalwombat 2eeef2d71c Fix data dependency lost due to instruction reshuffling 2022-06-22 22:09:32 +02:00
drmortalwombat 002c10ad13 Optimize array access and value propagation across simple loops 2022-06-21 20:57:58 +02:00
drmortalwombat 3cdc9032b4 Fix parameter loss in intermediate code branch forwarding 2022-06-19 18:31:07 +02:00
drmortalwombat 657b79cd3f bump version number 2022-06-19 15:25:09 +02:00
drmortalwombat ecfb206d1c Improve zero page register allocator 2022-06-19 15:20:53 +02:00
drmortalwombat 5000d521a1 Intermediate code generator cleanup 2022-06-18 20:21:41 +02:00
drmortalwombat fc7bb2c377 Optimize parameter handling in loops 2022-06-18 17:32:14 +02:00
drmortalwombat e7332192c0 Fix over eager elimination of byte to word conversion 2022-06-14 22:29:42 +02:00
drmortalwombat d37980e73c Bump version number 2022-06-12 13:46:19 +02:00
drmortalwombat 6e37060c24 More aggressive reverse value range limit forwarding 2022-06-12 13:39:46 +02:00
drmortalwombat 078007c9fe Fix infinite loop during size reduction 2022-06-10 16:36:52 +02:00
drmortalwombat a81f810a63 Size optimizations 2022-06-10 15:56:08 +02:00
drmortalwombat bf6fc7fd0b Add default preprorcessor __STDC__ 2022-06-07 08:24:12 +02:00
drmortalwombat a480e5e922 Fix overeager load forwarding 2022-06-06 22:26:58 +02:00
drmortalwombat beb8d8e6d7 Fix crash on error messages with unnamed objects 2022-06-06 22:06:57 +02:00
drmortalwombat 05ecc267ef Bump version number 2022-06-06 08:57:17 +02:00
drmortalwombat e73c40ba55 Fixed build issue with hscrollshmup on linux 2022-06-06 08:38:08 +02:00
drmortalwombat 36a5eaae00 Propagate independent instructions across diamond shaped basic blocks 2022-06-04 20:56:28 +02:00
drmortalwombat f9eb91e980 Optimize X and Y usage 2022-06-03 19:04:05 +02:00
drmortalwombat 0ba2ddf195 Propagate x and y across block boundaries 2022-06-02 22:19:10 +02:00
drmortalwombat 1b8e1f4048 Optimize cmp#0 always has carry set 2022-05-30 22:28:36 +02:00
drmortalwombat a86f5b877a Upstream variant constant propagation 2022-05-29 21:02:57 +02:00
drmortalwombat d833ca6834 Use array of struct assignments for index range validation 2022-05-26 13:55:00 +02:00
drmortalwombat 3dc35c5fff Fix invalid bypassing of JSR with X register 2022-05-22 16:41:40 +02:00
drmortalwombat 3351ee81cc Extend static stack allocation to zero page spilling 2022-05-22 13:22:36 +02:00
drmortalwombat b356f726a4 More local xy register usage 2022-05-21 17:17:16 +02:00
drmortalwombat e0f87c676c Eliminate non existing data dependencies 2022-05-21 13:39:12 +02:00
drmortalwombat b42c992a58 Fix buffer overflow in sprintf 2022-05-19 08:30:00 +02:00
drmortalwombat 9d18aef634 Optimize interval comparison cascades 2022-05-15 22:18:42 +02:00
drmortalwombat 46fe117f1f add alias _Bool for bool 2022-05-15 10:53:58 +02:00
drmortalwombat 728e707024 Optimize single page 2D array access 2022-05-14 17:57:32 +02:00
drmortalwombat 3dd61dac4a Fix invalid define of true and false 2022-05-14 08:16:26 +02:00
drmortalwombat e70162b2cc Forward native code instruction if only used on single outgoing path 2022-05-12 17:55:24 +02:00
drmortalwombat 2feb8b9e6d Add srand to stdlib 2022-05-09 22:18:34 +02:00
drmortalwombat b85b222fc0 Fix comment detection in defines 2022-05-09 08:04:16 +02:00
drmortalwombat d7b0e54494 Fix define with single line comment 2022-05-08 21:44:28 +02:00
drmortalwombat 75e5471dd1 Add support for d64 image creation 2022-05-08 15:37:30 +02:00
drmortalwombat c7de44b015 Optimize signed int with unsigned char comparison 2022-05-08 10:36:02 +02:00
drmortalwombat 29bd0c8d2d Optimizations for global variables 2022-05-07 14:03:56 +02:00
drmortalwombat fa223b90ad Update README.md 2022-05-01 12:59:21 +02:00
drmortalwombat 0cf2520df7 Update readme for compressed embeds 2022-05-01 12:58:31 +02:00
drmortalwombat ea1fa189b2 Add lz compression for embedded assets 2022-05-01 12:55:13 +02:00
drmortalwombat 62d08e139b Optimize pointer arithmetic in loops 2022-04-28 15:52:27 +02:00
drmortalwombat 7aec7f5c50 Fix crash compiling indexed memcpy size 2022-04-25 21:22:25 +02:00
drmortalwombat f619c5e0ab More verbose debug output 2022-04-25 07:57:31 +02:00
drmortalwombat 3a689cc7a1 Validate register livetime during peephole optimization 2022-04-23 22:11:25 +02:00
drmortalwombat 4cdc501a34 Bit shift optimizations 2022-04-21 08:26:04 +02:00
drmortalwombat 253be26335 Constant pointer arithmetic for pointer initializers 2022-04-18 22:23:13 +02:00
drmortalwombat ecb9bbee8a Bump version number 2022-04-17 21:12:54 +02:00
drmortalwombat 41a4db4402 Prepare compressed embedded data 2022-04-17 18:41:53 +02:00
drmortalwombat 72d2fc1fac Reverse integer range limit calculation 2022-04-15 11:06:49 +02:00
drmortalwombat 8f32b87b18 Fix call of function pointers in array 2022-04-13 16:29:36 +02:00
drmortalwombat 417574b4bb Fix volatile copy 2022-04-12 22:08:40 +02:00
drmortalwombat 07afbc4714 Bump version number 2022-04-12 20:25:41 +02:00
drmortalwombat 1ee7845bb4 Fix disassembler choking on long names 2022-04-12 18:22:38 +02:00
drmortalwombat 6331ec5707 Fix crash with macro undefine 2022-04-11 07:46:50 +02:00
drmortalwombat e312dddb12 Bump version number 2022-04-10 22:13:32 +02:00
drmortalwombat 7ed7134b53 Remove superfluous temporary move 2022-04-10 21:54:12 +02:00
drmortalwombat 6a40fdc75d Opetimize sequence of ADC/SBC in native code 2022-04-10 15:29:07 +02:00
drmortalwombat c635ae8136 Optimize const and/or sequences 2022-04-10 12:28:39 +02:00
drmortalwombat 546dbfc45a Some add/sub optimizations for global variables 2022-04-07 22:45:40 +02:00
drmortalwombat 0be3114e7d Bump version number 2022-04-06 19:18:55 +02:00
drmortalwombat 72264109e9 Add experimental zero page allocation for global variables 2022-04-06 19:16:44 +02:00
drmortalwombat 27dee0223c Cross block value forwarding 2022-04-05 16:56:02 +02:00
drmortalwombat c9e1775469 Optimize data forwarding on loop exit 2022-04-04 20:25:05 +02:00
drmortalwombat 6b3c5249cf Add \y00 for non adapted characters in s" or p" string literals 2022-04-04 16:35:37 +02:00
drmortalwombat 2435797bd1 Optimize x and y index order 2022-04-03 20:39:56 +02:00
drmortalwombat 8bdf48faba add tab output in printf 2022-04-03 15:51:41 +02:00
drmortalwombat 9e7139f344 Bump version number 2022-04-03 11:55:52 +02:00
drmortalwombat aafb4adfa2 Optimize linker placement, avoiding array crossing page boundaries 2022-04-03 11:40:23 +02:00
drmortalwombat 58c99a5dca Add left alignment in padding for printf 2022-04-02 13:36:15 +02:00
drmortalwombat 358def836d Fix optimization for absolute addressing and two indices 2022-04-01 20:35:55 +02:00
drmortalwombat 48f97b6e60 Optimize compare to boolean variable 2022-03-31 18:16:31 +02:00
drmortalwombat cb4f60b2ff Optimize muldiv8b8y 2022-03-30 20:05:09 +02:00
drmortalwombat 5a1ff68926 Fix binary and/or with boolean values, now raising a warning 2022-03-30 14:58:41 +02:00
drmortalwombat a60f5a783f Optimize X and Y register livespan 2022-03-28 19:03:43 +02:00
drmortalwombat 7bd3622bbd Instructions bypassing small if branches 2022-03-27 22:41:29 +02:00
drmortalwombat c24cf916db Bump version number 2022-03-27 17:21:23 +02:00
drmortalwombat d2503aaf1f Constant folding address of global and static variables 2022-03-27 17:18:44 +02:00
drmortalwombat 0aacc14287 Bump version number 2022-03-26 21:42:54 +01:00
drmortalwombat f50613704c Fix moving of abs store across function call 2022-03-26 21:39:30 +01:00
drmortalwombat 68e048b945 Fix volatile loads with unused result 2022-03-26 12:30:48 +01:00
drmortalwombat fc5c9f137a Add indexed const array initializer 2022-03-26 10:29:48 +01:00
drmortalwombat 5f0e0225e1 Loop MSB optimizations 2022-03-22 22:21:59 +01:00
drmortalwombat 8c77a5d256 Add "16bit * 8bit / 8bit" to fixed point math library 2022-03-20 22:53:51 +01:00
drmortalwombat 4538f0295d Fix byte to long conversion 2022-03-20 21:33:58 +01:00
drmortalwombat 4dd31f6c69 Bump version number 2022-03-19 20:05:43 +01:00
drmortalwombat 13f3ea57a3 Fix signed unsigned shift with mixed signed arguments 2022-03-19 19:46:40 +01:00
drmortalwombat 91cb2fda15 Documenting compiler optimizations 2022-03-19 14:35:49 +01:00
drmortalwombat 65f1349ce2 Update sample documentation in readme 2022-03-19 10:57:07 +01:00
drmortalwombat d37ecc44da More documentation 2022-03-18 22:29:12 +01:00
drmortalwombat b456086ee4 Update README.md 2022-03-16 21:27:48 +01:00
drmortalwombat 3d3618876f Bump version number 2022-03-15 18:50:15 +01:00
drmortalwombat dc0951ee9f Order inter instructions into eval trains and sequences, optimize copyloops for size 2022-03-15 18:45:34 +01:00
drmortalwombat a4fa4cd482 Basic block struct copy propagation 2022-03-14 14:07:09 +01:00
drmortalwombat a65c802485 Address promotion into struct copy inter instructions 2022-03-14 08:35:59 +01:00
drmortalwombat ea09c2aa7b Static stack allocations for complex locals in non recursive calls 2022-03-13 15:46:03 +01:00
drmortalwombat 24a17c937b Bump version number 2022-03-12 12:56:30 +01:00
drmortalwombat 736298238e Pointer and float loop optimizations 2022-03-12 12:52:43 +01:00
drmortalwombat 3cb4bd0fba Fix == instead of = for assignment 2022-03-11 13:07:38 +01:00
drmortalwombat 6f52a7beed Loop optimizing index register usage 2022-03-10 22:18:09 +01:00
drmortalwombat 6fe9a4f167 Fastcall optimization for 2nd and 3rd level calls 2022-03-10 16:35:35 +01:00
drmortalwombat b43edb2b4c Avoid inlining of native functions into byte code 2022-03-09 20:27:11 +01:00
drmortalwombat c5fc186336 Add horizontal scroll shmup sample game 2022-03-06 21:49:10 +01:00
drmortalwombat d1104e1eb3 Optimize y index progression 2022-03-05 11:25:56 +01:00
drmortalwombat 7e458d1eda More promotion of abs and abs indexed when only single use 2022-03-03 19:23:47 +01:00
drmortalwombat 51d447618b Bump version 2022-03-03 08:11:02 +01:00
drmortalwombat 9ec2b4fdef Replace JMP with branch when possible 2022-03-02 21:18:06 +01:00
drmortalwombat 2a815a9709 More forward 8 bit index optimizations 2022-03-01 08:53:54 +01:00
drmortalwombat fbdb513697 Optimize single use of global variables in function 2022-02-27 17:19:51 +01:00
drmortalwombat 756245694f Optimize indexed static variable access 2022-02-26 18:10:23 +01:00
drmortalwombat 2719b1156b Fix over eager livetime reduction of X and Y registers 2022-02-26 12:35:59 +01:00
drmortalwombat f4f9ae1a6a Some xy optimizations 2022-02-25 18:43:11 +01:00
drmortalwombat a2293a0ed1 Native code size reduction 2022-02-23 18:48:31 +01:00
drmortalwombat 2fd8d8673a Oprtimize right shift multiply combination 2022-02-23 15:00:08 +01:00
drmortalwombat ed609f124b Improve loop invariant hoisting 2022-02-20 20:51:05 +01:00
drmortalwombat 8b63d5bb34 Shortcut zero page register moves 2022-02-20 14:12:01 +01:00
drmortalwombat 46e1caaa4a Some pointer index optimizations 2022-02-19 17:14:52 +01:00
drmortalwombat 6ac606c91b Fix compile order based on dependency graph 2022-02-19 12:58:51 +01:00
drmortalwombat 6bd3ecb689 Fix over eager const expression inliner 2022-02-19 12:16:33 +01:00
drmortalwombat 3aa142957c Fix pointer comparison and interrupt warning 2022-02-16 16:31:03 +01:00
drmortalwombat 1221649a3d Add check for __interrupt attribute on function pointers call from interrupt code 2022-02-15 09:49:46 +01:00
drmortalwombat fdb112a037 Add constant address calculation for struct members 2022-02-14 20:13:30 +01:00
drmortalwombat a52fb469b6 Eliminate some redundant instructions during peephole optimization 2022-02-09 22:20:44 +01:00
drmortalwombat de9e8cfe64 Add score to breakout sample 2022-02-09 07:50:59 +01:00
drmortalwombat 42f71e264e Fix uninitialized interrupt flag in linux builds 2022-02-08 12:58:22 +01:00
drmortalwombat 2f009f129e Add regions replicated in multiple easyflash banks 2022-02-07 18:04:17 +01:00
drmortalwombat a5d5060048 Bump version number 2022-02-06 21:47:08 +01:00
drmortalwombat 3a7ea0837b Fix logic or inversion 2022-02-06 17:29:07 +01:00
drmortalwombat d4352ef043 Add __hwinterrupt function decoration 2022-02-06 10:28:09 +01:00
drmortalwombat 5147ec6bc9 Fix function pointers in struct consts 2022-02-05 16:52:54 +01:00
drmortalwombat 4831950e61 Optimizing right shifts greater 5 bits by left shifts 2022-02-05 11:37:03 +01:00
drmortalwombat 49b5067619 Add keyboard scan code enum 2022-02-04 17:40:04 +01:00
drmortalwombat 05d6b3d223 Fix table based multiplication for 16bit results 2022-02-03 22:10:17 +01:00
drmortalwombat 34220b96e3 Add auto generation of multiplier tables if variable factor is known to be small 2022-02-02 22:05:55 +01:00
drmortalwombat c6133ce7c0 Add error message on crash, fix infinite loop, extend asm listing 2022-02-02 08:58:35 +01:00
drmortalwombat ce6714006c Bump version number 2022-02-01 22:27:09 +01:00
drmortalwombat 90a1462ece Add raw functions for putat in charwin 2022-02-01 22:23:38 +01:00
drmortalwombat 3507b09207 Optimize PETSCII conversion in charwin 2022-02-01 22:00:33 +01:00
drmortalwombat 25ba5ca789 Fix absolute const pointer to int cast 2022-01-31 22:40:53 +01:00
drmortalwombat 5a9f82b147 Add resources for missile command 2022-01-31 21:20:37 +01:00
drmortalwombat 995e39a57d Add missile command sample game 2022-01-31 21:17:14 +01:00
drmortalwombat e1f605b28c Optimize value forwarding and memory alias check 2022-01-31 13:33:39 +01:00
drmortalwombat 94efcaeca6 Circle drawing in multicolor bitmap 2022-01-31 08:08:18 +01:00
drmortalwombat 18be0dfc0b Optimize dynamic code generation 2022-01-29 21:55:52 +01:00
drmortalwombat 08d6358932 Fix local variable array member forwarding 2022-01-29 16:06:47 +01:00
drmortalwombat 60165a7fc3 Add "*" symbol for current address in inline assembler 2022-01-29 13:33:57 +01:00
drmortalwombat 5ca651bc36 Add games to samples 2022-01-28 22:49:15 +01:00
drmortalwombat 65201f27b6 Bump version number 2022-01-28 14:24:55 +01:00
drmortalwombat 2d41edfc97 Fix byte limit in #embed 2022-01-28 14:13:49 +01:00
drmortalwombat aee284c1d6 Add irq autocrawler sample 2022-01-28 08:49:21 +01:00
drmortalwombat dfe3d71f85 Make shore memcpy calls intrinsic 2022-01-27 23:08:57 +01:00
drmortalwombat 79a841a422 Mark vic registers as volatile 2022-01-27 16:38:47 +01:00
drmortalwombat 5c8b1c6daf Add __export, __native and __interrupt storage class specifiers 2022-01-26 21:48:19 +01:00
drmortalwombat 94532fe038 Fix enum size 2022-01-26 12:41:12 +01:00
drmortalwombat 792751e3a4 Fix error swapping global variables with negation 2022-01-25 21:45:33 +01:00
drmortalwombat 0ea87ea322 Reduce speculation of integer value range analyzer 2022-01-25 21:05:00 +01:00
drmortalwombat f25bf80a0f Fix LF line ending on windows, float and loop optimizations 2022-01-25 14:31:36 +01:00
drmortalwombat 9f41a55a18 Fix static declaration in header files 2022-01-23 21:14:30 +01:00
drmortalwombat 5a8dbfea60 Fix placement of sections in cartridges at other locations than start 2022-01-23 12:03:54 +01:00
drmortalwombat ca93f107c3 Add relocated sections 2022-01-22 18:21:52 +01:00
drmortalwombat 5bda8a4d01 Fix scale in sid.h 2022-01-22 15:07:55 +01:00
drmortalwombat 742866c8c2 Enable charmap inside a series of string literals 2022-01-22 13:41:24 +01:00
drmortalwombat 9dd493d20b Add sid and easyflash includes 2022-01-22 11:16:59 +01:00
drmortalwombat fad67d18aa Add auto loop unrolling and binary (verbatim) format linking 2022-01-21 21:52:16 +01:00
drmortalwombat cc927d778f Improve C const declaration compatibility 2022-01-21 14:42:49 +01:00
drmortalwombat 8b4eff3ee1 More constant folding and value propagation 2022-01-20 17:43:08 +01:00
drmortalwombat 76322c005d Fix errors introduced with strength reduction 2022-01-20 13:39:55 +01:00
drmortalwombat 1c403dfeeb Add strength reduction in trivial loops 2022-01-19 20:55:33 +01:00
drmortalwombat 9161b088ee More integer range optimizations 2022-01-16 18:30:38 +01:00
drmortalwombat 6eedb931a7 More value range optimizations 2022-01-16 09:41:59 +01:00
drmortalwombat de562fccb6 Add carry optimizations 2022-01-15 18:09:48 +01:00
drmortalwombat de920f2418 Optimize global variable usage 2022-01-14 17:53:30 +01:00
drmortalwombat c72ca3547b Fix longjump and kernalio end of file handling 2022-01-13 10:37:44 +01:00
drmortalwombat d9946e12b9 Optimize byte size right shift 2022-01-12 15:54:50 +01:00
drmortalwombat 180e2598b8 Fix multicolor flood fill if target color is back color 2022-01-12 08:55:23 +01:00
drmortalwombat ed37f360eb New multicolor bitmap library 2022-01-11 18:27:13 +01:00
drmortalwombat 55affa4de9 Add auto inline of functions that trivially compute to a constat with constant arguments 2022-01-10 20:05:51 +01:00
drmortalwombat 1be469aa9b Optimize placement of basic blocks 2022-01-10 14:06:21 +01:00
drmortalwombat 68f8628409 Optimize size of generated byte code 2022-01-09 19:00:02 +01:00
drmortalwombat 640007546f Add __assume builtin function 2022-01-08 15:51:17 +01:00
drmortalwombat 085fba137f optimize aligned address arithmetic 2022-01-06 16:26:19 +01:00
drmortalwombat 85f99fe411 Bump version number 2022-01-05 20:11:17 +01:00
drmortalwombat d2511b558c Reoder eight bit adds 2022-01-05 20:06:25 +01:00
drmortalwombat d4a9308627 More inter code value forwarding 2022-01-05 16:38:56 +01:00
drmortalwombat 2b7c7300d7 Integer value range optimizations 2022-01-04 22:26:44 +01:00
drmortalwombat a86a19fc8c Add raw mode for charwin 2022-01-04 15:38:06 +01:00
drmortalwombat 639a33f9eb Simple loop invariant optimization for native code 2022-01-04 14:07:56 +01:00
drmortalwombat 78615c0725 Optimize cross block single evaluation 2022-01-04 11:44:01 +01:00
drmortalwombat 60ca42e759 Inner loop invariant optimization for non single block intermediate loops 2022-01-03 14:36:31 +01:00
drmortalwombat d621ab32cd Optimize space in linker when using aligned objects 2022-01-02 15:08:47 +01:00
drmortalwombat 272b7b08df Optimize more short multiplies in native code 2022-01-02 12:44:37 +01:00
drmortalwombat 2d0f20cadc Added comments to source samples 2022-01-01 12:39:54 +01:00
drmortalwombat b9a1689dc6 Add some library documentation 2021-12-31 18:57:54 +01:00
drmortalwombat b5ef25ad30 Add linux script to build samples 2021-12-31 15:03:17 +01:00
drmortalwombat 66807c2374 Add samples to windows installer 2021-12-30 17:30:36 +01:00
drmortalwombat 7e66836e07 More samples 2021-12-30 15:41:06 +01:00
drmortalwombat 1fcc39acd5 Add sprite multiplexer 2021-12-29 20:07:13 +01:00
drmortalwombat 80fea25916 More samples 2021-12-28 13:13:05 +01:00
drmortalwombat a64f771d0c more samples 2021-12-27 22:48:42 +01:00
drmortalwombat b09c5c769e More samples 2021-12-27 14:17:12 +01:00
drmortalwombat 57c72b1788 Reduce y register pressure if x available 2021-12-27 10:49:18 +01:00
drmortalwombat 743510b54e Add verbose option -v to compiler 2021-12-26 11:31:04 +01:00
drmortalwombat f91bf21999 More samples 2021-12-25 20:55:15 +01:00
drmortalwombat a1db507816 Add sample for opening border 2021-12-25 15:24:49 +01:00
drmortalwombat e397e88cd3 Start sample projects 2021-12-25 14:49:15 +01:00
drmortalwombat 24cc6e20c8 Fix compiler getting stuck on optimizing infinite loop 2021-12-25 12:30:24 +01:00
drmortalwombat 9bd3d3391a Fix lost zero page register on y address shortcut 2021-12-24 16:54:03 +01:00
drmortalwombat 720e532d22 Added scanf and sscanf to stdio 2021-12-24 14:39:03 +01:00
drmortalwombat 0dd6a0655c Optimize call to 8 by16 mul 2021-12-23 20:27:45 +01:00
drmortalwombat 99f674c866 Add gfx libraries 2021-12-23 14:39:04 +01:00
drmortalwombat 71c574478c More integer value range optimizations 2021-12-23 14:31:58 +01:00
drmortalwombat 6b7dc15d30 Optimize short float arrays 2021-12-22 15:36:12 +01:00
drmortalwombat 183864208f More integer value range optimizations 2021-12-22 12:58:17 +01:00
drmortalwombat 05a6c71698 Value range annotation for intermediate code 2021-12-22 07:46:06 +01:00
drmortalwombat b9c477976a Strength reduction for simple native code loops with y register 2021-12-20 20:44:10 +01:00
drmortalwombat 893b6f2294 Optimize long divide for short divisor 2021-12-19 22:18:05 +01:00
drmortalwombat 4a9c662cc9 Optimize float native code size 2021-12-19 16:53:12 +01:00
drmortalwombat 6d716b9478 Optimize 32bit shifts 2021-12-18 22:21:39 +01:00
drmortalwombat 178a5e23a8 Some optimizations for on the fly asm code generation 2021-12-14 14:31:18 +01:00
drmortalwombat 381a70839d Fix dynamic code generator library 2021-12-13 22:23:54 +01:00
drmortalwombat 88c3764f69 Bump version number 2021-12-13 08:16:01 +01:00
drmortalwombat 4cf62a67ff Optimize jmp to rts 2021-12-12 20:34:33 +01:00
drmortalwombat fefa2e7d9a Optimize jump to rts and simple loop invariants in native code generator 2021-12-11 23:04:38 +01:00
drmortalwombat f7a5c94229 Optimize frame enter/leave code in native compiler 2021-12-11 12:52:35 +01:00
drmortalwombat 4d14cbe3a5 Fix function pointer call detection for fast call selection 2021-12-10 08:31:57 +01:00
drmortalwombat a1fda2b957 Fix float parameter and return values 2021-12-09 21:38:36 +01:00
drmortalwombat cf9f38d4dc Fix stacked fastcall invokation 2021-12-09 12:11:36 +01:00
drmortalwombat 1ac0c2f46a Fix duplicat check for loop head in native code generator 2021-12-08 14:04:32 +01:00
drmortalwombat 18ab7ce079 Fix broken left shift optimization due to branch in basic block 2021-12-06 22:56:03 +01:00
drmortalwombat 75ea2ee439 Add PETSCII string literals 2021-12-06 20:54:11 +01:00
drmortalwombat a8acde291b Fixed charwin petscii screen code conversion 2021-12-06 09:41:25 +01:00
drmortalwombat 695d4cf914 Minor byte code optimization for absolute arrays 2021-12-04 15:26:05 +01:00
drmortalwombat 973e13b776 Optimize absolute array addressing 2021-12-03 22:49:14 +01:00
drmortalwombat e4d24f1aa4 Some native code optimizations 2021-12-02 18:41:59 +01:00
drmortalwombat a66b3873cd Native code optimizations for global arrays 2021-12-01 23:00:57 +01:00
drmortalwombat 0b9163afbe Optimize native code branch placement 2021-12-01 20:26:28 +01:00
drmortalwombat 4f1de9ce89 Reduce over eager code movement 2021-12-01 19:32:49 +01:00
drmortalwombat 7e07f083a6 Fix native code jmp offsets for inline assembly 2021-12-01 08:40:36 +01:00
drmortalwombat f1f3c609fd Join similar instructions on conditional paths 2021-11-30 21:32:49 +01:00
drmortalwombat 5549096cf7 Limit binary and, or and xor of byte operands to byte operations 2021-11-29 22:07:35 +01:00
drmortalwombat 15c65f69aa Change runtime assembler generator use value and return instead of reference 2021-11-29 18:37:15 +01:00
drmortalwombat a6fa114a5b Add runtime assembler functions to c64 library 2021-11-29 17:43:03 +01:00
drmortalwombat ea2b59e64d Fix sprite index in vic.c 2021-11-28 15:17:39 +01:00
drmortalwombat 2003f2f4fd Fixed N flag thrashing due to cross block value forwarding 2021-11-27 23:33:03 +01:00
drmortalwombat 730fb7513e Fix y register thrashing in peephole optimizer 2021-11-27 15:51:17 +01:00
drmortalwombat d02b438a1a Optimize code size 2021-11-27 11:17:15 +01:00
drmortalwombat 0ca6ef8894 Some bytecode optimizations 2021-11-26 22:59:10 +01:00
drmortalwombat ccd6a50043 Optimize byte code interpreter loop 2021-11-25 21:42:06 +01:00
drmortalwombat e9caf064de Fixed type in readme 2021-11-25 07:34:18 +01:00
drmortalwombat 93174c8e68 Add overflow and underflow checking for floats 2021-11-24 20:01:08 +01:00
drmortalwombat 84648fbd88 Optimizing some pointer arithmetic 2021-11-23 21:53:23 +01:00
drmortalwombat 92e01b6298 Bump version number 2021-11-22 22:29:19 +01:00
drmortalwombat 12aa385e38 Optimize bytecode generator 2021-11-22 19:49:02 +01:00
drmortalwombat 6007553d03 Byte code optimizations 2021-11-21 22:53:06 +01:00
drmortalwombat 4af2bc0bb2 Add setjmp and longjmp 2021-11-20 20:25:53 +01:00
drmortalwombat f2dc0091a8 At get to charwin 2021-11-19 08:13:36 +01:00
drmortalwombat b7aaf52f6a Fix empty cwin_fill_rect 2021-11-18 22:51:00 +01:00
drmortalwombat 4017cc386b Add charwin library and matching code generator optimizations 2021-11-18 14:57:43 +01:00
drmortalwombat 594610c302 Bump version number 2021-11-16 21:00:34 +01:00
drmortalwombat cd77372350 Remove superfluous rts from inline assembler blocks that end with a jmp 2021-11-16 20:54:10 +01:00
drmortalwombat 5c66e11ca0 Fold iny into interpreter loop for byte code 2021-11-16 20:24:51 +01:00
drmortalwombat 92b2c34293 Byte code size optimizations 2021-11-16 12:59:16 +01:00
drmortalwombat 0c3e19741c Optimize byte code size 2021-11-16 09:10:39 +01:00
drmortalwombat 2ed784ea17 Optimize signed range comparison 2021-11-13 15:05:53 +01:00
drmortalwombat cb5f5f421f Optimize single conditional path value evaluation 2021-11-09 22:24:29 +01:00
drmortalwombat 7dddcc772b Some peephole optimizing for native compiler 2021-11-08 20:18:40 +01:00
drmortalwombat a65d65d3d1 Add volatile to vic.h raster register 2021-11-08 13:41:00 +01:00
drmortalwombat 5cce611659 Fix native code inner loop detection 2021-11-08 08:45:43 +01:00
drmortalwombat 931c4d875a Reduce register copy for native code fast calls 2021-11-07 17:16:01 +01:00
drmortalwombat d99940a98e Update to version 1.1.45 2021-11-06 20:12:28 +01:00
drmortalwombat f50eb7cd19 Optimizing byte code generator 2021-11-06 17:57:24 +01:00
drmortalwombat 417f65e2c2 Byte code generator optimizations 2021-11-06 14:29:12 +01:00
drmortalwombat a8ed15d67b Optimize inline pointer parameters 2021-11-05 08:46:59 +01:00
drmortalwombat d51a30ed2e Fix array type check 2021-11-04 18:28:35 +01:00
drmortalwombat fe155d40d4 Change word to use int as base 2021-11-04 10:55:37 +01:00
drmortalwombat 180da3de4a Fix array[] parameters in functions 2021-11-04 08:29:54 +01:00
drmortalwombat a3d8c94620 Push XY register usage in shift to later optimization stage 2021-11-03 19:39:28 +01:00
drmortalwombat bfd9522349 Fix conio.c gotoxy 2021-11-03 12:39:24 +01:00
drmortalwombat f862f4e084 Constant folding of pointer plus integer 2021-11-03 07:52:12 +01:00
drmortalwombat 099f3b8a26 Fixe unsigned byte signed const comparison 2021-11-02 17:18:24 +01:00
drmortalwombat dcbd51e75e Fix old asm in conio.c 2021-11-02 14:59:05 +01:00
drmortalwombat 0f485e39c7 Fix sample in readme 2021-11-02 10:24:10 +01:00
drmortalwombat f16edb1c57 Optimize signed byte comparisons 2021-11-01 22:33:02 +01:00
drmortalwombat 40f82ba6ec Fix byte table access 2021-11-01 21:22:02 +01:00
drmortalwombat 2cd7956736 Remove stores to global variables that are never read 2021-11-01 16:08:37 +01:00
drmortalwombat d3cba85efe Optimize global variable alias analysis 2021-11-01 12:42:03 +01:00
drmortalwombat 214ebd93f2 Bump version to 1.1.44 2021-10-31 20:39:28 +01:00
drmortalwombat a52c869099 Avoid needles store to temps before function call 2021-10-31 19:37:54 +01:00
drmortalwombat 135d357dbc Strcpy as intrinsic 2021-10-31 19:14:07 +01:00
drmortalwombat 7e340cc816 Optimize static and global variable usage 2021-10-31 16:22:11 +01:00
drmortalwombat b9cbf525e9 Optimize native code XY index register usage 2021-10-30 22:29:32 +02:00
drmortalwombat 640477f88d Add peephole size optimizations 2021-10-30 10:42:41 +02:00
drmortalwombat b64079bf28 Optimize some constant shifts 2021-10-27 21:01:39 +02:00
drmortalwombat 8ab8b3c2a1 Fix negative array indices 2021-10-26 14:44:25 +02:00
drmortalwombat 342634d5e4 Fix datatflow tracking in shift optimization 2021-10-25 21:53:55 +02:00
drmortalwombat 1074c29092 Fix register spilling optimization 2021-10-24 22:27:08 +02:00
drmortalwombat 480270f4c9 Fix array to pointer cast 2021-10-24 14:58:06 +02:00
drmortalwombat d8ecd34ac6 Add #embed preprocessor directive to import binary data 2021-10-24 12:34:44 +02:00
drmortalwombat 42e4f483c1 Reduce register spilling on function entry/exit 2021-10-23 22:22:49 +02:00
drmortalwombat e057e24918 Added stddef.h 2021-10-23 16:51:27 +02:00
drmortalwombat 55b79ecfce Fix struct scoping 2021-10-23 11:56:30 +02:00
drmortalwombat 33433403b1 Fix optimizer errors 2021-10-23 00:33:09 +02:00
drmortalwombat c351c6521a Fixed signed char arrays in linker 2021-10-21 13:32:20 +02:00
drmortalwombat 00c59ce6a4 Fix native code function pointer 2021-10-21 10:24:21 +02:00
drmortalwombat 7927df6d41 Fix call/return 2021-10-20 23:03:37 +02:00
drmortalwombat 9833656fcf More cartridge hacking 2021-10-19 22:29:23 +02:00
drmortalwombat 6444428489 Prepare cartdridge linking 2021-10-19 09:36:30 +02:00
drmortalwombat 6481e119e4 Fix various errors triggered by fuzzing 2021-10-17 18:20:44 +02:00
drmortalwombat 5010043fc4 Optimize struct member access 2021-10-17 11:54:15 +02:00
drmortalwombat 3520d2a2bd Fix bugs found by llvm lint 2021-10-17 10:40:33 +02:00
drmortalwombat 194c7a2af4 Fix int + pointer operation 2021-10-16 23:07:28 +02:00
drmortalwombat 13dd453728 Save label file as understood by vice 2021-10-16 21:21:44 +02:00
drmortalwombat 55cd076f7b Bump version to 1.1.42 2021-10-16 19:51:54 +02:00
drmortalwombat 001e50ae08 Complete function struct return 2021-10-16 19:46:04 +02:00
drmortalwombat ed52725a01 Remove copies from struct function return 2021-10-16 18:17:54 +02:00
drmortalwombat 19a54432f6 Struct function return value 2021-10-16 16:45:08 +02:00
drmortalwombat 815f64d14c Fix infinite loop unrolling 2021-10-16 15:11:05 +02:00
drmortalwombat c2886e2532 Fix infinite for(;;) loop 2021-10-16 10:49:11 +02:00
drmortalwombat 545b9a6aba Fix cascaded assignment 2021-10-16 10:27:32 +02:00
drmortalwombat 438a926b88 Code size optimization 2021-10-15 21:52:07 +02:00
drmortalwombat 35a4658f28 Fix long offset pointer access in byte code 2021-10-14 22:22:31 +02:00
drmortalwombat 1a30d044c8 Some peephole optimizations for native code 2021-10-14 21:22:03 +02:00
drmortalwombat 9e7773a0f9 Add warning for constant out of bound array access 2021-10-14 18:15:04 +02:00
drmortalwombat b415d02907 Add binary tree evaluation for large switch statements 2021-10-14 17:52:18 +02:00
drmortalwombat e2e6f4ea01 Add command line options for optimization 2021-10-14 16:51:59 +02:00
drmortalwombat fc0f8e2442 Fix conditional operator with pointes and arrays 2021-10-14 13:15:10 +02:00
drmortalwombat 3c891fb61e Fix 16 bit pointer offsets in native code 2021-10-13 22:19:27 +02:00
drmortalwombat 5372d49b50 Petscii translation in stdio and conio 2021-10-12 17:54:10 +02:00
drmortalwombat da57ae00c5 Add vic include file 2021-10-11 22:14:19 +02:00
drmortalwombat 6bd3e3ae97 Remove debug code 2021-10-10 20:58:38 +02:00
drmortalwombat d493bddf8d Improve inline assembler parser 2021-10-10 20:51:21 +02:00
drmortalwombat 0e59af5122 Fix petscii characters changed includes and pragmas 2021-10-10 17:30:57 +02:00
drmortalwombat 11af372509 More autoinline optimizations 2021-10-10 17:14:12 +02:00
drmortalwombat 5e02e48c5a Optimized signed byte code compare 2021-10-09 10:38:25 +02:00
drmortalwombat 210b037dbc Remove sign extended byte loads from byte code 2021-10-08 23:04:27 +02:00
drmortalwombat 32b715382c Add fascall for byte code 2021-10-08 17:41:11 +02:00
drmortalwombat 60489bb79e Refactor inter instrction operator handling 2021-10-08 09:07:01 +02:00
drmortalwombat e7231e27e0 Prepare fastcall 2021-10-07 15:14:23 +02:00
drmortalwombat fb4ae26afb Prepare access to local variables in inline assembler 2021-10-07 10:42:18 +02:00
drmortalwombat df152c2f9b Prepare more than 3 operands per inter instruction 2021-10-06 17:46:42 +02:00
drmortalwombat 15743d3115 Refactor temp handling in inter code 2021-10-06 17:30:41 +02:00
drmortalwombat 330e022a43 Exclude bss segment from prg file 2021-10-05 18:24:03 +02:00
drmortalwombat 9618762234 Bump version to 1.0.38 2021-10-03 20:39:23 +02:00
drmortalwombat 542cb66693 Fixes to get dhrystone.c to compile and run 2021-10-03 20:35:50 +02:00
drmortalwombat 4a822facaa Optimize inline expansion 2021-10-03 11:36:26 +02:00
drmortalwombat acc87d50fe Limit inline expansion depth 2021-10-02 22:39:36 +02:00
drmortalwombat bf825302aa Add function inline expansion 2021-10-02 22:04:42 +02:00
drmortalwombat a0df4e7867 Optimize stack frame for simple functions 2021-10-02 20:56:01 +02:00
drmortalwombat 30becb541e Add long integer support in native and byte code 2021-10-02 17:22:18 +02:00
drmortalwombat 3d9302c90c Support for long integer with byte code 2021-10-02 10:06:13 +02:00
drmortalwombat 0c9992f549 Native code optimizations 2021-10-01 15:54:07 +02:00
drmortalwombat 02305e8bc5 Optimize global arrays and const comparisons 2021-09-30 20:00:47 +02:00
drmortalwombat e846caaf1f New release version 2021-09-29 21:38:02 +02:00
drmortalwombat 9dfbe405a5 Avoid frame pointer in native code if simple stack frame 2021-09-29 19:48:57 +02:00
drmortalwombat 4aa82d539b Optimize pointer increment dereference combos 2021-09-29 17:34:38 +02:00
drmortalwombat ef5cb81a18 Optimized int shifts ge eight 2021-09-29 16:31:17 +02:00
drmortalwombat f205ba1c49 Add strlen to base path call on mac 2021-09-29 12:53:02 +02:00
drmortalwombat bc4aea064a Add missing mac include 2021-09-29 08:02:20 +02:00
drmortalwombat 22dc083283 Cleanup of Mac code 2021-09-28 21:09:39 +02:00
drmortalwombat e2a9cf05ac Add base bat call for mac os 2021-09-28 20:54:35 +02:00
drmortalwombat 3a7e74938e Fix doumentation for command line 2021-09-28 20:03:26 +02:00
drmortalwombat e713dc5940 Direct embedding of inline assembler in native code 2021-09-28 18:35:23 +02:00
drmortalwombat c4a5dafb69 More simple loop optimisations 2021-09-28 16:24:44 +02:00
drmortalwombat e72d28c243 Fix base path in linux 2021-09-27 15:19:16 +02:00
drmortalwombat 1755b4b89d Create bin folder in linux makefile 2021-09-27 13:58:13 +02:00
drmortalwombat 9eb5412848 Merge changes for Mac build 2021-09-27 13:38:45 +02:00
drmortalwombat bffef3e9dd Basic block tail merging 2021-09-26 13:14:56 +02:00
drmortalwombat 2fc414ed6b Byte forwardiong optimisation in native mode 2021-09-25 23:08:45 +02:00
drmortalwombat 1dd63ac708 Fix byte size inc/dec error 2021-09-25 22:50:16 +02:00
drmortalwombat 8e9b0fe54c Add simple native loop optimisation 2021-09-25 21:57:33 +02:00
drmortalwombat f925833884 Move executable into bin folder for windows and linux 2021-09-25 18:20:32 +02:00
drmortalwombat 6b6122bc07 Add full preprocessor support 2021-09-24 20:08:42 +02:00
drmortalwombat fd10525780 Add makefile for linux 2021-09-24 16:17:20 +02:00
drmortalwombat 5c3ff47690 Indirect address, y optimisation for short loops 2021-09-23 17:14:02 +02:00
drmortalwombat 0681c899ae Bump file version 2021-09-23 08:28:53 +02:00
drmortalwombat 123da8c155 Add charmap pragma 2021-09-23 08:26:46 +02:00
drmortalwombat 4ca77ba41a Byte operand sizes fixes and optimizations 2021-09-22 22:49:52 +02:00
drmortalwombat 2cd9a55880 Fix various bugs related to byte size operands 2021-09-22 15:46:20 +02:00
drmortalwombat 9ec846c506 Load/Store constant offset propagation across basic blocks 2021-09-21 22:49:04 +02:00
drmortalwombat 603b62b9d3 Optimize native comparison against zero 2021-09-21 22:44:00 +02:00
drmortalwombat eebc39e53a Fix return type coercion, region based linker 2021-09-21 20:44:19 +02:00
drmortalwombat 3f5f3ee7ea Filenames now full 2021-09-21 15:08:05 +02:00
drmortalwombat 1d64404b24 Change format of error messages 2021-09-21 14:55:11 +02:00
drmortalwombat d9c565d898 Fix local variables with linker sections 2021-09-21 08:41:49 +02:00
drmortalwombat 27d7baaac2 Using linker objects and sections 2021-09-20 22:36:16 +02:00
drmortalwombat 78886f11f7 Native code peephole optimisation for commutative instructions 2021-09-20 13:02:38 +02:00
drmortalwombat d3d20bee26 Prepare section based linker 2021-09-19 22:22:16 +02:00
drmortalwombat 10bb751449 Fix struct over header boundaries 2021-09-19 20:00:36 +02:00
drmortalwombat 3ce8796beb Bump version number 2021-09-19 17:27:07 +02:00
drmortalwombat c5d1e2351e Add support for assembler function as const initialiser 2021-09-19 17:24:48 +02:00
drmortalwombat fae377132f Fix assembler label low/high byte immediate 2021-09-19 16:08:38 +02:00
drmortalwombat 1d761886b5 Refactor intermediate instructions from value to pointer type 2021-09-15 12:01:14 +02:00
drmortalwombat 37828f2baf More byte and long preparations 2021-09-14 21:38:24 +02:00
drmortalwombat e2e20581a6 Prepare byte level optimisations 2021-09-14 16:34:48 +02:00
drmortalwombat 9f8362255f add conio.h 2021-09-13 20:55:31 +02:00
drmortalwombat 913f0d4190 Change line end to 13 in prints 2021-09-13 20:09:18 +02:00
drmortalwombat 97bd5aa988 Merge address calc into load 2021-09-13 17:43:31 +02:00
drmortalwombat 45360a26e7 Forward temp moves across non looping basic blocks 2021-09-13 17:19:53 +02:00
drmortalwombat 9647cdb828 Added global constant propagation 2021-09-13 09:26:58 +02:00
drmortalwombat 8de4bef436 Improved value forwarding across conditiona branches 2021-09-12 22:32:31 +02:00
drmortalwombat 3a94be4a35 Use caller saved registers for temps not overlapping calls 2021-09-12 17:28:02 +02:00
drmortalwombat 87ccd5e221 More autotest 2021-09-12 16:05:23 +02:00
drmortalwombat bb4680845e Fix float x+x optimisation 2021-09-12 15:18:07 +02:00
drmortalwombat dac1fa70b3 Fix array const init by string literal 2021-09-12 14:42:02 +02:00
drmortalwombat ebdd6f0d7d Add fixed offset to pointer base mem access 2021-09-12 14:17:21 +02:00
drmortalwombat 8031ad8dee Add union 2021-09-12 10:04:37 +02:00
drmortalwombat 82d499fdae Native code compiler is functional same level as byte code
Runs all the autotests now in byte code and native code
2021-09-11 22:21:57 +02:00
drmortalwombat 897de02adf Fix unnamed parameters in function prototype 2021-09-11 16:05:31 +02:00
drmortalwombat 93b6aca8a3 More native code generator 2021-09-11 15:01:32 +02:00
drmortalwombat 07f797e577 Formatting options in printf 2021-09-10 16:13:47 +02:00
drmortalwombat fd1626bf16 Byte level dataflow analysis of native code 2021-09-09 23:13:03 +02:00
drmortalwombat f08d847a64 More native code optimisations 2021-09-09 20:23:59 +02:00
drmortalwombat 83f5d634df Resource version bump to 1.0.22 2021-09-09 09:43:53 +02:00
drmortalwombat 3442ee507a Fix floating point native code generation 2021-09-09 09:42:02 +02:00
drmortalwombat fcedf69aff More native code compiler additions 2021-09-08 22:04:01 +02:00
drmortalwombat 056df56eef First shot native code generator
Implements basic load, store compare and add/sub/shift for native compiled functions
2021-09-07 22:35:11 +02:00
drmortalwombat 69a44e90e3 Added test for array init 2021-09-07 13:43:22 +02:00
drmortalwombat 722347609d Fix array of array of char init with strings 2021-09-07 13:37:56 +02:00
drmortalwombat 14f6af66af Fixed array and structure initialisation of locals 2021-09-07 12:44:45 +02:00
409 changed files with 180142 additions and 6638 deletions

19
.gitignore vendored
View File

@ -335,3 +335,22 @@ ASALocalRun/
*.asm *.asm
*.map *.map
*.prg *.prg
*.d
*.d.*
*.o
*.lbl
make/oscar64
*.int
*.bcs
*.crt
**/*.d64
*.tlog
*.res
*.recipe
*.exe
*.dbj
*.json
*.mapd
*.idb
oscar64/Releasex64/oscar64.vcxproj.FileListAbsolute.txt
/oscar64/Debugx64

67
CMakeLists.txt Normal file
View File

@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 3.15)
# Project name and version
project(oscar64 VERSION 1.0 LANGUAGES CXX)
# Define the executable
add_executable(oscar64)
# Glob all source files in the oscar64/ directory
file(GLOB OSCAR64_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/oscar64/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/oscar64/*.h")
# Add the sources to the target
target_sources(${PROJECT_NAME} PRIVATE ${OSCAR64_SOURCES})
# Add header files
target_include_directories(oscar64 PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)
# Compiler settings based on configuration
set_target_properties(oscar64 PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
# Set debug and release configurations
target_compile_definitions(oscar64 PRIVATE $<$<CONFIG:Debug>:_DEBUG;_CONSOLE> $<$<CONFIG:Release>:NDEBUG;_CONSOLE>)
target_compile_options(oscar64 PRIVATE $<$<CONFIG:Debug>:/W3 /WX> $<$<CONFIG:Release>:/O2 /W3>)
# Post-build steps (only for Release builds)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_custom_command(TARGET oscar64 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:oscar64> ${CMAKE_BINARY_DIR}/bin
)
endif()
if (WIN32)
target_link_libraries(oscar64 PRIVATE kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 oleaut32 uuid odbc32 odbccp32 version)
elseif (APPLE)
# Add macOS-specific frameworks to replace Windows libraries
target_link_libraries(${PROJECT_NAME}
"-framework Cocoa" # For GUI and application support
"-framework CoreFoundation" # For Core Foundation utilities (similar to advapi32 or shell32)
"-framework CoreGraphics" # For graphics and rendering (similar to gdi32)
"-framework IOKit" # For hardware interaction
"-framework AppKit" # For GUI (equivalent to user32)
)
elseif (UNIX)
# Add Linux-specific libraries for equivalent functionality
target_link_libraries(${PROJECT_NAME}
pthread # For threading (similar to kernel32)
dl # For dynamic library loading (similar to LoadLibrary)
m # For math library (optional but common on Linux)
X11 # For X Window System (similar to user32 for GUI support)
)
endif()
# Output directories
set_target_properties(oscar64 PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Debug
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Release
)

115
README.md
View File

@ -1,115 +1,40 @@
# oscar64 # oscar64
Optimizing small space C Compiler Assembler and Runtime for C64
## History and motivation Oscar64 is a C/C++ cross compiler running on a modern system (such as a Windows PC, Mac or Linux machine) and targets the classic 6502 family of processors. It is mainly focused on Commodore systems such as the C64, PET or VIC20. The compiler supports C99 and many C++ features up to variadic templates and lambda functions.
It is a sad fact that the 6502 used in the Commodore64 and other home computers of the 80s has a poor code density when it comes to 16 bit code. The C standard requires computations to be made with ints which work best if they have the same size as a pointer. The purpose of this compiler is to eliminate the need to write 6502 assembler code to achieve high code density and fast execution speed. It continues to improve with all the games, demos and tools written by it. It supports disk overlays and banked cartridges for larger projects.
The 6502 also has a very small stack of 256 bytes which cannot be easily addressed and thus cannot be used for local variables. Therefore a second stack for variables has to be maintained, resulting in costly indexing operations. The C64 executes 442 dhrystone V2.2 iteration per second, when compiled with Oscar64 and -O3 (which shows that the ancient dhrystone benchmark is no match to an optimizing compiler).
A C compiler for the 6502 thus generates large binaries if it translates to native machine code. The idea for the **oscar64** compiler is to translate the C source to an intermediate 16 bit byte code with the option to use native machine code for crucial functions. Using embedded assembly for runtime libraries or critical code should also be possible. [Full reference manual](oscar64.md)
[Additional samples and tutorials](https://github.com/drmortalwombat/OscarTutorials)
The resulting compiler is a frankenstein constructed from a converted javascript parser a intermediate code optimizer based on a 15 year old compiler for 64bit x86 code and some new components for the backend. # References
The performance of interpreted code is clearly not as good as native machine code but the penalty for 16bit code is around 40-50% and less than 10% for floating point. Code that can use 8bit my suffer up to a factor of 10 to 20. This is a list of the games written with Oscar64, have a look if you are not convinced that fast paced action games can be written in C/C++ on a C64 (they are all free).
## Limits and Errors [Ball and Chain](https://drmortalwombat.itch.io/ball-and-chain)
The first release of the compiler is severely limited considering it is only two weeks old, so there is quite a lot missing or broken. I hope to cross out most of the problems in the coming weeks. [Balls like a Frog](https://drmortalwombat.itch.io/balls-like-a-frog)
### Language ![cores4](https://github.com/user-attachments/assets/15c2bcc7-eafb-44fb-aec2-e5cb101c687b)
[Corescape](https://drmortalwombat.itch.io/corescape)
* No union type [MetalMayhem](https://drmortalwombat.itch.io/metal-mayhem)
* No long integer
* No struct function return
* Missing const checks for structs and enums
* No static variables in functions
* Missing warnings for all kind of abuses
* no #if in preprocessor
### Linker [Mineshaft Gap](https://drmortalwombat.itch.io/mineshaft-gap)
* No explicit sections for code, data bss or stack [Minotrace](https://drmortalwombat.itch.io/minotrace)
* No media file import
### Standard Libraries [Missile Defence](https://drmortalwombat.itch.io/missile-defence)
* Limited formatting in printf ![cl1b](https://github.com/user-attachments/assets/0d249274-6dab-4284-89e5-ada07fac1986)
* No file functions [Portal Buster](https://drmortalwombat.itch.io/portal-buster)
### Runtime
* No INF and NaN support for floats
* Underflow in float multiply and divide not checked
* Basic zero page variables not restored on stop/restore
### Optimizing
* All global variables are considered volatile
* No loop opmtimization
* Poor bookeeping of callee saved registers
* Missing livetime reduction of intermediates
* No block domination analysis
* No register use for arguments
### Intermediate code generation
* No check for running out of temporary registers
* Wasted 7 codes for far jumps
### Native code generation
* Missing
## Implementation Details
The compiler does a full program compile, the linker step is part of the compilation. It knows all functions during the compilation run and includes only reachable code in the output. Source files are added to the build with the help of a pragma:
#pragma compile("stdio.c")
The byte code interpreter is compiled by the compiler itself and placed in the source file "crt.c". Functions implementing byte codes are marked with a pragma:
#pragma bytecode(BC_CONST_P8, inp_const_p8)
The functions are written in 6502 assembly with the __asm keyword
__asm inp_const_p8
{
lda (ip), y
tax
iny
lda (ip), y
sta $00, x
lda #0
sta $01, x
iny
jmp startup.exec
}
The current byte code program counter is (ip),y. The interpreter loop guarantees that y is always <= 128 and can thus be used to index the additional byte code arguments without the need to check the 16 bit pointer. The interpreter loop itself is quite compact and takes 21 cycles (including the final jump of the byte code function itself). Moving it to zero page would reduce this by another two cycles but is most likely not worth the waste of temporary space.
exec:
lda (ip), y
sta execjmp + 1
iny
bmi incip
execjmp:
jmp (0x0900)
The intermediate code generator assumes a large number of registers so the zero page is used for this purpose. The allocation is not yet final:
* **0x02-0x02** spilling of y register
* **0x03-0x09** workspace for mul/div and floating point routines
* **0x19-0x1a** instruction pointer
* **0x1b-0x1e** integer and floating point accumulator
* **0x1f-0x22** pointers for indirect addressing
* **0x23-0x24** stack pointer
* **0x25-0x26** frame pointer
* **0x43-0x52** caller saved registers
* **0x53-0x8f** callee saved registers
[Roguebot](https://drmortalwombat.itch.io/roguebot)
[Shallow Domains](https://drmortalwombat.itch.io/shallow-domains)
[Veggies vs Undead](https://drmortalwombat.itch.io/veggies-vs-undead)

View File

@ -0,0 +1,48 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
char s[25][41] = {"Q QQ QQQQQ QQQQQQQQQQQQQ",
" QQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQ",
" QQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"",
"",
"",
" QQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ",
"QQQQQQQQQ",
"",
"",
"",
"",
"",
"",
"",
"",
" QQQQQQQQQQQQQQ"};
int main()
{
int i=0, sum = 0;
for (unsigned char i = 0; i < 25; i++)
{
int j = 0;
while (s[i][j])
{
sum += s[i][j] & 3;
j++;
}
}
assert(sum == 391);
return 0;
}

152
autotest/arrayconstruct.cpp Normal file
View File

@ -0,0 +1,152 @@
#include <assert.h>
int t, n, m, k;
struct C1
{
int a;
C1(void);
~C1(void);
C1(const C1 & c);
C1 & operator=(const C1 & c);
};
struct C2
{
C1 nc[10], mc[20];
};
C1::C1(void)
{
a = 1;
n++;
t++;
}
C1::C1(const C1 & c)
{
a = c.a;
k++;
t++;
}
C1 & C1::operator=(const C1 & c)
{
a = c.a;
m++;
return *this;
}
C1::~C1(void)
{
t--;
}
void test_local_init(void)
{
n = 0;
{
C1 c[10];
}
assert(n == 10 && t == 0);
}
void test_member_init(void)
{
n = 0;
{
C2 d;
}
assert(n == 30 && t == 0);
}
void test_member_array_init(void)
{
n = 0;
{
C2 d[5];
}
assert(n == 150 && t == 0);
}
void test_local_copy(void)
{
n = 0;
k = 0;
{
C1 c[10];
C1 d(c[4]);
}
assert(n == 10 && k == 1 && t == 0);
}
void test_member_copy(void)
{
n = 0;
k = 0;
{
C2 d;
C2 e(d);
}
assert(n == 30 && k == 30 && t == 0);
}
void test_local_assign(void)
{
n = 0;
k = 0;
m = 0;
{
C1 c[10];
C1 d[5];
d[4] = c[2];
}
assert(n == 15 && k == 0 && m == 1 && t == 0);
}
void test_member_assign(void)
{
n = 0;
k = 0;
m = 0;
{
C2 d;
C2 e;
e = d;
}
assert(n == 60 && k == 0 && m == 30 && t == 0);
}
int main(void)
{
test_local_init();
test_member_init();
test_member_array_init();
test_local_copy();
test_member_copy();
test_local_assign();
test_member_assign();
return 0;
}

View File

@ -0,0 +1,22 @@
int a[10];
int get(int i)
{
return a[i];
}
void put(int i, int x)
{
a[i] = x;
}
int main(void)
{
for(int j=0; j<10; j++)
put(j, j);
int s = -45;
for(int j=0; j<10; j++)
s += get(j);
return s;
}

23
autotest/arrayinittest.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <assert.h>
int fg[15] = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610};
int main(void)
{
int fl[15] = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610};
int sg = 0, sl = 0;
for(int i=0; i<15; i++)
{
sl += fl[i];
sg += fg[i];
}
assert(sl == 1596);
assert(sg == 1596);
printf("%d %d\n", sl, sg);
return 0;
}

View File

@ -0,0 +1,20 @@
int a(int * p, int x)
{
int y = x + 3;
p[y] = 1;
p[y + 1] = 2;
p[y + 2] = 3;
p[y + 3] = 4;
return p[y] + p[y + 1] + p[y + 2] + p[y + 3];
}
int main(void)
{
int t[16];
return a(t, 4) - 10;
}

View File

@ -11,13 +11,93 @@ int sum(int * a, int s)
return sum; return sum;
} }
void copy(int * d, const int * s, int n)
{
for(int i=0; i<n ; i++)
d[i] = s[i];
}
void reverse(int * d, const int * s, int n)
{
for(int i=0; i<n ; i++)
d[i] = s[n - i - 1];
}
int sumb(int * a, char s)
{
int sum = 0;
for(char i=0; i<s; i++)
{
sum += a[i];
}
return sum;
}
void copyb(int * d, const int * s, char n)
{
for(char i=0; i<n ; i++)
d[i] = s[i];
}
void reverseb(int * d, const int * s, char n)
{
for(char i=0; i<n ; i++)
d[i] = s[n - i - 1];
}
long suml(long * a, char s)
{
long sum = 0;
for(char i=0; i<s; i++)
{
sum += a[i];
}
return sum;
}
void copyl(long * d, const long * s, char n)
{
for(char i=0; i<n ; i++)
d[i] = s[i];
}
void reversel(long * d, const long * s, char n)
{
for(char i=0; i<n ; i++)
d[i] = s[n - i - 1];
}
int main(void) int main(void)
{ {
int a[100]; int a[100], b[100], c[100];
long al[100], bl[100], cl[100];
for(int i=0; i<100; i++) for(int i=0; i<100; i++)
{ {
a[i] = i % 10; a[i] = i % 10;
al[i] = i % 10;
} }
assert(sum(a, 100) == 450); assert(sum(a, 100) == 450);
copy(b, a, 100);
assert(sum(b, 100) == 450);
reverse(c, a, 100);
assert(sum(c, 100) == 450);
assert(sumb(a, 100) == 450);
copyb(b, a, 100);
assert(sumb(b, 100) == 450);
reverseb(c, a, 100);
assert(sumb(c, 100) == 450);
assert(suml(al, 100) == 450);
copyl(bl, al, 100);
assert(suml(bl, 100) == 450);
reversel(cl, al, 100);
assert(suml(cl, 100) == 450);
return 0; return 0;
} }

View File

@ -8,6 +8,7 @@ float sum(float * a, int s)
{ {
sum += a[i]; sum += a[i];
} }
return sum; return sum;
} }
@ -18,6 +19,7 @@ int main(void)
{ {
a[i] = i % 10; a[i] = i % 10;
} }
assert(sum(a, 100) == 450); assert(sum(a, 100) == 450);
return 0; return 0;
} }

16
autotest/arrparam.c Normal file
View File

@ -0,0 +1,16 @@
int a(char p[100])
{
int s = 0;
for(int i=0; i<100; i++)
s += p[i];
return s;
}
int main(void)
{
char c[100];
for(int i=0; i<100; i++)
c[i] = i;
return a(c) - 4950;
}

76
autotest/asmtest.c Normal file
View File

@ -0,0 +1,76 @@
#include <stdio.h>
#include <assert.h>
int asum(int a, int b)
{
return __asm
{
clc
lda a
adc b
sta accu
lda a + 1
adc b + 1
sta accu + 1
};
}
int bsum(int a, int b)
{
puts("Hello\n");
return __asm
{
clc
lda a
adc b
sta accu
lda a + 1
adc b + 1
sta accu + 1
};
}
int b, t[10];
int bsome(int x)
{
return x;
}
int qsum(int a, int (* c)(int))
{
char n = 0;
b = 0;
for(int i=0; i<a; i++)
{
int j = c((char)i);
__asm
{
clc
lda j
adc b
sta b
lda j + 1
adc b + 1
sta b + 1
}
t[n] += i;
n = (n + 1) & 7;
}
return b;
}
int main(void)
{
int x = asum(7007, 8008);
int y = bsum(4004, 9009);
assert(x == 7007 + 8008 && y == 4004 + 9009);
assert(qsum(10, bsome) == 45);
assert(qsum(200, bsome) == 19900);
return 0;
}

View File

@ -0,0 +1,77 @@
#include <stdio.h>
#include <assert.h>
struct X
{
char t;
long l;
};
__striped X xs[16];
X xf[16];
char xp;
__noinline long tt(long n)
{
return n;
}
inline auto & tas(void)
{
return xs[xp].l;
}
inline auto & taf(void)
{
return xf[xp].l;
}
long ts(char n)
{
return tt(tas());
}
long tf(char n)
{
return tt(taf());
}
inline auto bas(void)
{
return xs[xp].l;
}
inline auto baf(void)
{
return xs[xp].l;
}
long bs(char n)
{
return tt(bas());
}
long bf(char n)
{
return tt(baf());
}
int main(void)
{
for(char i=0; i<16; i++)
{
xs[i].l = i * i;
xf[i].l = i * i;
}
for(char i=0; i<16; i++)
{
xp = i;
assert(ts(0) == i * i);
assert(tf(0) == i * i);
assert(bs(0) == i * i);
assert(bf(0) == i * i);
}
return 0;
}

View File

@ -1,36 +1,400 @@
@echo off rem @echo off
..\release\oscar64 -i=../include -rt=../include/crt.c -e stdlibtest.c @call :test rolrortest.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e testint16.c @call :test bitfields.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e recursiontest.c @call :testn autorefreturn.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e strcmptest.c @call :testh opp_string.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e arraytest.c @call :testh opp_array.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e arraytestfloat.c @call :testh opp_vector.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e optiontest.c @call :testh opp_static_vector.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e floatcmptest.c @call :testh opp_vector_string.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e floatmultest.c @call :testh opp_string_init.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
..\release\oscar64 -i=../include -rt=../include/crt.c -e staticconsttest.c @call :testh opp_streamtest.cpp
if %errorlevel% neq 0 goto :error @if %errorlevel% neq 0 goto :error
@call :testh opp_pairtest.cpp
@if %errorlevel% neq 0 goto :error
@call :testh opp_parts.cpp
@if %errorlevel% neq 0 goto :error
@call :testh opp_list.cpp
@if %errorlevel% neq 0 goto :error
@call :testn opp_functional.cpp
@if %errorlevel% neq 0 goto :error
@call :testh operatoroverload.cpp
@if %errorlevel% neq 0 goto :error
@call :testh virtualdestruct.cpp
@if %errorlevel% neq 0 goto :error
@call :testh vcalltest.cpp
@if %errorlevel% neq 0 goto :error
@call :testh vcalltree.cpp
@if %errorlevel% neq 0 goto :error
@call :testh constructortest.cpp
@if %errorlevel% neq 0 goto :error
@call :testn copyconstructor.cpp
@if %errorlevel% neq 0 goto :error
@call :testh copyassign.cpp
@if %errorlevel% neq 0 goto :error
@call :testh arrayconstruct.cpp
@if %errorlevel% neq 0 goto :error
@call :testh stdlibtest.c
@if %errorlevel% neq 0 goto :error
@call :test mathtest.c
@if %errorlevel% neq 0 goto :error
@call :test testint16.c
@if %errorlevel% neq 0 goto :error
@call :test testint32.c
@if %errorlevel% neq 0 goto :error
@call :test testint16mul.c
@if %errorlevel% neq 0 goto :error
@call :test testsigned16mul.c
@if %errorlevel% neq 0 goto :error
@call :test testsigned16div.c
@if %errorlevel% neq 0 goto :error
@call :test recursiontest.c
@if %errorlevel% neq 0 goto :error
@call :test copyinitmove.c
@if %errorlevel% neq 0 goto :error
@call :test fastcalltest.c
@if %errorlevel% neq 0 goto :error
@call :test strlen.c
@if %errorlevel% neq 0 goto :error
@call :test strcmptest.c
@if %errorlevel% neq 0 goto :error
@call :test strcmptest2.c
@if %errorlevel% neq 0 goto :error
@call :test memmovetest.c
@if %errorlevel% neq 0 goto :error
@call :test arraytest.c
@if %errorlevel% neq 0 goto :error
@call :test arraytestfloat.c
@if %errorlevel% neq 0 goto :error
@call :test optiontest.c
@if %errorlevel% neq 0 goto :error
@call :test floatcmptest.c
@if %errorlevel% neq 0 goto :error
@call :test floatmultest.c
@if %errorlevel% neq 0 goto :error
@call :test floatinttest.c
@if %errorlevel% neq 0 goto :error
@call :test staticconsttest.c
@if %errorlevel% neq 0 goto :error
@call :test arrayinittest.c
@if %errorlevel% neq 0 goto :error
@call :test arrayindexintrangecheck.c
@if %errorlevel% neq 0 goto :error
@call :test array2stringinittest.c
@if %errorlevel% neq 0 goto :error
@call :test testint16cmp.c
@if %errorlevel% neq 0 goto :error
@call :test testint8cmp.c
@if %errorlevel% neq 0 goto :error
@call :test testint32cmp.c
@if %errorlevel% neq 0 goto :error
@call :test mixsigncmptest.c
@if %errorlevel% neq 0 goto :error
@call :test testinterval.c
@if %errorlevel% neq 0 goto :error
@call :test cmprangeshortcuttest.c
@if %errorlevel% neq 0 goto :error
@call :test floatstringtest.c
@if %errorlevel% neq 0 goto :error
@call :test sprintftest.c
@if %errorlevel% neq 0 goto :error
@call :test qsorttest.c
@if %errorlevel% neq 0 goto :error
@call :testn plasma.c
@if %errorlevel% neq 0 goto :error
@call :test loopdomtest.c
@if %errorlevel% neq 0 goto :error
@call :test loopboundtest.c
@if %errorlevel% neq 0 goto :error
@call :test byteindextest.c
@if %errorlevel% neq 0 goto :error
@call :test asmtest.c
@if %errorlevel% neq 0 goto :error
@call :testb bitshifttest.c
@if %errorlevel% neq 0 goto :error
@call :test arrparam.c
@if %errorlevel% neq 0 goto :error
@call :test bsstest.c
@if %errorlevel% neq 0 goto :error
@call :test copyintvec.c
@if %errorlevel% neq 0 goto :error
@call :test divmodtest.c
@if %errorlevel% neq 0 goto :error
@call :test divmod32test.c
@if %errorlevel% neq 0 goto :error
@call :test fixmathtest.c
@if %errorlevel% neq 0 goto :error
@call :test enumswitch.c
@if %errorlevel% neq 0 goto :error
@call :test incvector.c
@if %errorlevel% neq 0 goto :error
@call :test structoffsettest2.c
@if %errorlevel% neq 0 goto :error
@call :test funcvartest.c
@if %errorlevel% neq 0 goto :error
@call :test funcarraycall.c
@if %errorlevel% neq 0 goto :error
@call :test structassigntest.c
@if %errorlevel% neq 0 goto :error
@call :test structmembertest.c
@if %errorlevel% neq 0 goto :error
@call :test structarraycopy.c
@if %errorlevel% neq 0 goto :error
@call :test randsumtest.c
@if %errorlevel% neq 0 goto :error
@call :test longcodetest.c
@if %errorlevel% neq 0 goto :error
@call :test scrolltest.c
@if %errorlevel% neq 0 goto :error
@call :test charwintest.c
@if %errorlevel% neq 0 goto :error
@call :test linetest.c
@if %errorlevel% neq 0 goto :error
@call :test ptrinittest.c
@if %errorlevel% neq 0 goto :error
@call :test ptrarraycmptest.c
@if %errorlevel% neq 0 goto :error
@call :test cplxstructtest.c
@if %errorlevel% neq 0 goto :error
@call :testn stripedarraytest.c
@if %errorlevel% neq 0 goto :error
@call :testn mmultest.c
@if %errorlevel% neq 0 goto :error
@call :test tileexpand.cpp
@if %errorlevel% neq 0 goto :error
@exit /b 0
exit /b 0
:error :error
echo Failed with error #%errorlevel%. echo Failed with error #%errorlevel%.
exit /b %errorlevel% exit /b %errorlevel%
:testh
..\bin\oscar64 -e -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -n -dHEAPCHECK %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -xz -Oz -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -Oo -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -Ox -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O0 -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O0 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -Os -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -Os -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O3 -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O3 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O3 -n -dHEAPCHECK %~1
@if %errorlevel% neq 0 goto :error
@exit /b 0
:test
..\bin\oscar64 -e -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O0 -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O0 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -Os -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -Os -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O3 -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O3 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -xz -Oz -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -Oo -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -Ox -n %~1
@if %errorlevel% neq 0 goto :error
@exit /b 0
:testb
..\bin\oscar64 -e -bc %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -bc -O2 %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -bc -O0 %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -bc -Os %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -bc -O3 %~1
@if %errorlevel% neq 0 goto :error
@exit /b 0
:testn
..\bin\oscar64 -e -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O0 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -Os -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O3 -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -xz -Oz -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -Oo -n %~1
@if %errorlevel% neq 0 goto :error
..\bin\oscar64 -e -O2 -Ox -n %~1
@if %errorlevel% neq 0 goto :error
@exit /b 0

354
autotest/bitfields.cpp Normal file
View File

@ -0,0 +1,354 @@
#include <assert.h>
struct A
{
char x : 4;
char y : 1;
char z : 3;
};
A a = {7, 1, 2};
void test_char_fit(void)
{
assert(a.x == 7);
assert(a.y == 1);
assert(a.z == 2);
assert(sizeof(A) == 1);
for(int i=0; i<16; i++)
{
a.x = i;
a.y = 0;
a.z = 3;
assert(a.x == i);
assert(a.y == 0);
assert(a.z == 3);
}
}
struct B
{
char x : 6;
char y : 6;
char z : 6;
char w : 6;
};
B b = {11, 22, 33, 44};
void test_char_cross(void)
{
assert(b.x == 11);
assert(b.y == 22);
assert(b.z == 33);
assert(b.w == 44);
assert(sizeof(B) == 3);
for(int i=0; i<64; i++)
{
b.x = i * 1;
b.y = i * 3;
b.z = i * 5;
b.w = i * 7;
assert(b.x == ((i * 1) & 0x3f));
assert(b.y == ((i * 3) & 0x3f));
assert(b.z == ((i * 5) & 0x3f));
assert(b.w == ((i * 7) & 0x3f));
}
}
struct C
{
unsigned x : 4;
unsigned y : 1;
unsigned z : 3;
};
C c = {7, 1, 2};
void test_word_fit(void)
{
assert(c.x == 7);
assert(c.y == 1);
assert(c.z == 2);
assert(sizeof(C) == 1);
for(int i=0; i<16; i++)
{
c.x = i;
c.y = 0;
c.z = 3;
assert(c.x == i);
assert(c.y == 0);
assert(c.z == 3);
}
}
struct D
{
unsigned x : 10;
unsigned y : 10;
unsigned z : 10;
unsigned w : 10;
};
D d = {111, 222, 333, 444};
void test_word_cross(void)
{
assert(d.x == 111);
assert(d.y == 222);
assert(d.z == 333);
assert(d.w == 444);
assert(sizeof(D) == 5);
for(int i=0; i<1024; i++)
{
d.x = i * 1;
d.y = i * 3;
d.z = i * 5;
d.w = i * 7;
assert(d.x == ((i * 1) & 0x3ff));
assert(d.y == ((i * 3) & 0x3ff));
assert(d.z == ((i * 5) & 0x3ff));
assert(d.w == ((i * 7) & 0x3ff));
}
}
struct E
{
unsigned long x : 4;
unsigned long y : 1;
unsigned long z : 3;
};
E e = {7, 1, 2};
void test_dword_fit(void)
{
assert(e.x == 7);
assert(e.y == 1);
assert(e.z == 2);
assert(sizeof(E) == 1);
for(int i=0; i<16; i++)
{
e.x = i;
e.y = 0;
e.z = 3;
assert(e.x == i);
assert(e.y == 0);
assert(e.z == 3);
}
}
struct F
{
unsigned long x : 20;
unsigned long y : 20;
unsigned long z : 20;
unsigned long w : 20;
};
F f = {111111UL, 222222UL, 333333UL, 444444UL};
void test_dword_cross(void)
{
assert(f.x == 111111UL);
assert(f.y == 222222UL);
assert(f.z == 333333UL);
assert(f.w == 444444UL);
assert(sizeof(F) == 10);
for(int i=0; i<1024; i++)
{
f.x = i * 11UL;
f.y = i * 33UL;
f.z = i * 55UL;
f.w = i * 77UL;
assert(f.x == ((i * 11UL) & 0xfffffUL));
assert(f.y == ((i * 33UL) & 0xfffffUL));
assert(f.z == ((i * 55UL) & 0xfffffUL));
assert(f.w == ((i * 77UL) & 0xfffffUL));
}
}
struct G
{
signed char x : 1;
signed char y : 5;
signed char z : 2;
};
G g = {0, -1, -2};
void test_char_signed(void)
{
assert(g.x == 0);
assert(g.y == -1);
assert(g.z == -2);
assert(sizeof(G) == 1);
for(int i=-16; i<16; i++)
{
g.x = -1;
g.y = i;
g.z = 1;
assert(g.x == -1);
assert(g.y == i);
assert(g.z == 1);
}
}
struct H
{
int x : 10;
int y : 10;
int z : 10;
int w : 10;
};
H h = {111, -222, -333, 444};
void test_word_signed(void)
{
assert(h.x == 111);
assert(h.y == -222);
assert(h.z == -333);
assert(h.w == 444);
assert(sizeof(H) == 5);
for(int i=-32; i<32; i++)
{
h.x = i * 1;
h.y = i * 3;
h.z = i * 5;
h.w = i * 7;
assert(h.x == i * 1);
assert(h.y == i * 3);
assert(h.z == i * 5);
assert(h.w == i * 7);
}
}
void test_inc_char_fit(void)
{
A ai;
ai.x = 7;
ai.y = 1;
ai.z = 2;
for(int i=0; i<16; i++)
{
assert(ai.x == ((7 + i) & 15));
assert(ai.y == ((1 + i) & 1));
assert(ai.z == ((2 + i) & 7));
ai.x++;
ai.y++;
ai.z++;
}
}
void test_inc_char_cross(void)
{
B bi;
bi.x = 11;
bi.y = 22;
bi.z = 33;
bi.w = 44;
for(int i=0; i<64; i++)
{
assert(bi.x == ((11 + i) & 0x3f));
assert(bi.y == ((22 + i) & 0x3f));
assert(bi.z == ((33 + i) & 0x3f));
assert(bi.w == ((44 + i) & 0x3f));
bi.x++;
bi.y++;
bi.z++;
bi.w++;
}
}
void test_add_char_cross(void)
{
B bi= {0};
bi.x = 11;
bi.y = 22;
bi.z = 33;
bi.w = 44;
for(int i=0; i<64; i++)
{
assert(bi.x == ((11 + 5 * i) & 0x3f));
assert(bi.y == ((22 + 21 * i) & 0x3f));
assert(bi.z == ((33 - 4 * i) & 0x3f));
assert(bi.w == ((44 - 11 * i) & 0x3f));
bi.x += 5;
bi.y += 21;
bi.z -= 4;
bi.w -= 11;
}
}
void test_add_word_fit(void)
{
C ci = {0};
ci.x = 7;
ci.y = 1;
ci.z = 2;
for(int i=0; i<16; i++)
{
assert(ci.x == ((7 + 5 * i) & 15));
assert(ci.y == ((1 + 21 * i) & 1));
assert(ci.z == ((2 - 4 * i) & 7));
ci.x += 5;
ci.y += 21;
ci.z -= 4;
}
}
void test_add_word_cross(void)
{
D di = {0};
di.x = 111;
di.y = 222;
di.z = 333;
di.w = 444;
for(int i=0; i<1024; i++)
{
assert(di.x == ((111 + 5 * i) & 0x3ff));
assert(di.y == ((222 + 21 * i) & 0x3ff));
assert(di.z == ((333 - 4 * i) & 0x3ff));
assert(di.w == ((444 - 11 * i) & 0x3ff));
di.x += 5;
di.y += 21;
di.z -= 4;
di.w -= 11;
}
}
int main(void)
{
test_char_fit();
test_char_cross();
test_word_fit();
test_word_cross();
test_dword_fit();
test_dword_cross();
test_char_signed();
test_word_signed();
test_inc_char_fit();
test_inc_char_cross();
test_add_char_cross();
test_add_word_fit();
test_add_word_cross();
return 0;
}

414
autotest/bitshifttest.c Normal file
View File

@ -0,0 +1,414 @@
#include <stdio.h>
#include <assert.h>
#pragma region( main, 0x0a00, 0xd000, , , {code, data, bss, heap, stack} )
unsigned shl1b(int n)
{
return 1 << n;
}
unsigned shl1n(int n)
{
return 1 << n;
}
#pragma native(shl1n)
unsigned shr1b(int n)
{
return 0x8000 >> n;
}
unsigned shr1n(int n)
{
return 0x8000 >> n;
}
#pragma native(shr1n)
unsigned shl4b(int n)
{
return 0x0010 << n;
}
unsigned shl4n(int n)
{
return 0x0010 << n;
}
#pragma native(shl4n)
unsigned shr4b(int n)
{
return 0x0800 >> n;
}
unsigned shr4n(int n)
{
return 0x0800 >> n;
}
#pragma native(shr4n)
unsigned shl8b(int n)
{
return 0x0100 << n;
}
unsigned shl8n(int n)
{
return 0x0100 << n;
}
#pragma native(shl8n)
unsigned shr8b(int n)
{
return 0x0080 >> n;
}
unsigned shr8n(int n)
{
return 0x0080 >> n;
}
#pragma native(shr8n)
void shl8xb(unsigned char xu, signed char xi)
{
unsigned char ua[16];
signed char ia[16];
#assign s 0
#repeat
ua[s] = xu << s;
ia[s] = xi << s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == (unsigned char)(xu << i));
assert(ia[i] == (signed char)(xi << i));
}
}
void shr8xb(unsigned char xu, signed char xi)
{
unsigned char ua[16];
signed char ia[16];
#assign s 0
#repeat
ua[s] = xu >> s;
ia[s] = xi >> s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == (unsigned char)(xu >> i));
assert(ia[i] == (signed char)(xi >> i));
}
}
void shl8xn(unsigned char xu, signed char xi)
{
unsigned char ua[16];
signed char ia[16];
#assign s 0
#repeat
ua[s] = xu << s;
ia[s] = xi << s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == (unsigned char)(xu << i));
assert(ia[i] == (signed char)(xi << i));
}
}
void shr8xn(unsigned char xu, signed char xi)
{
unsigned char ua[16];
signed char ia[16];
#assign s 0
#repeat
ua[s] = xu >> s;
ia[s] = xi >> s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == (unsigned char)(xu >> i));
assert(ia[i] == (signed char)(xi >> i));
}
}
#pragma native(shl8xn)
#pragma native(shr8xn)
void shl16b(unsigned xu, int xi)
{
unsigned ua[16];
int ia[16];
#assign s 0
#repeat
ua[s] = xu << s;
ia[s] = xi << s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == xu << i);
assert(ia[i] == xi << i);
}
}
void shr16b(unsigned xu, int xi)
{
unsigned ua[16];
int ia[16];
#assign s 0
#repeat
ua[s] = xu >> s;
ia[s] = xi >> s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == xu >> i);
assert(ia[i] == xi >> i);
}
}
void shl16n(unsigned xu, int xi)
{
unsigned ua[16];
int ia[16];
#assign s 0
#repeat
ua[s] = xu << s;
ia[s] = xi << s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == xu << i);
assert(ia[i] == xi << i);
}
}
void shr16n(unsigned xu, int xi)
{
unsigned ua[16];
int ia[16];
#assign s 0
#repeat
ua[s] = xu >> s;
ia[s] = xi >> s;
#assign s s + 1
#until s == 16
for(int i=0; i<16; i++)
{
assert(ua[i] == xu >> i);
assert(ia[i] == xi >> i);
}
}
#pragma native(shl16n)
#pragma native(shr16n)
void shl32b(unsigned long xu, long xi)
{
unsigned long ua[32];
long ia[32];
#assign s 0
#repeat
ua[s] = xu << s;
ia[s] = xi << s;
#assign s s + 1
#until s == 32
for(int i=0; i<32; i++)
{
assert(ua[i] == xu << i);
assert(ia[i] == xi << i);
}
}
void shr32b(unsigned long xu, long xi)
{
unsigned long ua[32];
long ia[32];
#assign s 0
#repeat
ua[s] = xu >> s;
ia[s] = xi >> s;
#assign s s + 1
#until s == 32
for(int i=0; i<32; i++)
{
assert(ua[i] == xu >> i);
assert(ia[i] == xi >> i);
}
}
void shl32n(unsigned long xu, long xi)
{
unsigned long ua[32];
long ia[32];
#assign s 0
#repeat
ua[s] = xu << s;
ia[s] = xi << s;
#assign s s + 1
#until s == 32
for(int i=0; i<32; i++)
{
assert(ua[i] == xu << i);
assert(ia[i] == xi << i);
}
}
void shr32n(unsigned long xu, long xi)
{
unsigned long ua[32];
long ia[32];
#assign s 0
#repeat
ua[s] = xu >> s;
ia[s] = xi >> s;
#assign s s + 1
#until s == 32
for(int i=0; i<32; i++)
{
assert(ua[i] == xu >> i);
assert(ia[i] == xi >> i);
}
}
void shl1_32n(void)
{
static const unsigned long m[] = {
#for(i, 32) 1ul << i,
};
for(int i=0; i<32; i++)
{
assert(1ul << i == m[i]);
}
}
#pragma native(shl32n)
#pragma native(shr32n)
int main(void)
{
*(volatile char *)0x01 = 0x36;
for(int i=0; i<32; i++)
{
printf("1: %.4x : %.4x | %.4x : %.4x\n", shl1b(i), shl1n(i), shr1b(i), shr1n(i));
assert(shl1b(i) == shl1n(i));
assert(shr1b(i) == shr1n(i));
}
for(int i=0; i<32; i++)
{
printf("4: %.4x : %.4x | %.4x : %.4x\n", shl4b(i), shl4n(i), shr4b(i), shr4n(i));
assert(shl4b(i) == shl4n(i));
assert(shr4b(i) == shr4n(i));
}
for(int i=0; i<32; i++)
{
printf("8: %.4x : %.4x | %.4x : %.4x\n", shl8b(i), shl8n(i), shr8b(i), shr8n(i));
assert(shl8b(i) == shl8n(i));
assert(shr8b(i) == shr8n(i));
}
shl8xb(0x00, 0x00);
shl8xb(0xff, 0xff);
shl8xb(0x34, 0x34);
shl8xb(0xdc, 0xdc);
shr8xb(0x00, 0x00);
shr8xb(0xff, 0xff);
shr8xb(0x34, 0x34);
shr8xb(0xdc, 0xdc);
shl8xn(0x00, 0x00);
shl8xn(0xff, 0xff);
shl8xn(0x34, 0x34);
shl8xn(0xdc, 0xdc);
shr8xn(0x00, 0x00);
shr8xn(0xff, 0xff);
shr8xn(0x34, 0x34);
shr8xn(0xdc, 0xdc);
shl16b(0x0000, 0x0000);
shl16b(0xffff, 0xffff);
shl16b(0x1234, 0x1234);
shl16b(0xfedc, 0xfedc);
shr16b(0x0000, 0x0000);
shr16b(0xffff, 0xffff);
shr16b(0x1234, 0x1234);
shr16b(0xfedc, 0xfedc);
shl16n(0x0000, 0x0000);
shl16n(0xffff, 0xffff);
shl16n(0x1234, 0x1234);
shl16n(0xfedc, 0xfedc);
shr16n(0x0000, 0x0000);
shr16n(0xffff, 0xffff);
shr16n(0x1234, 0x1234);
shr16n(0xfedc, 0xfedc);
shl32b(0x00000000UL, 0x00000000L);
shl32b(0x00000001UL, 0x00000001L);
shl32b(0xffffffffUL, 0xffffffffL);
shl32b(0x12345678UL, 0x12345678L);
shl32b(0xfedcba98UL, 0xfedcba98L);
shr32b(0x00000000UL, 0x00000000L);
shr32b(0x00000001UL, 0x00000001L);
shr32b(0xffffffffUL, 0xffffffffL);
shr32b(0x12345678UL, 0x12345678L);
shr32b(0xfedcba98UL, 0xfedcba98L);
shl32n(0x00000000UL, 0x00000000L);
shl32n(0x00000001UL, 0x00000001L);
shl32n(0xffffffffUL, 0xffffffffL);
shl32n(0x12345678UL, 0x12345678L);
shl32n(0xfedcba98UL, 0xfedcba98L);
shr32n(0x00000000UL, 0x00000000L);
shr32n(0x00000001UL, 0x00000001L);
shr32n(0xffffffffUL, 0xffffffffL);
shr32n(0x12345678UL, 0x12345678L);
shr32n(0xfedcba98UL, 0xfedcba98L);
shl1_32n();
return 0;
}

27
autotest/bsstest.c Normal file
View File

@ -0,0 +1,27 @@
#include <string.h>
char ch[100];
char p[] = "HELLO";
int v[10];
int w[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int sum(int * k)
{
int s = 0;
for(int i=0; i<10; i++)
s += k[i];
return s;
}
int main(void)
{
strcpy(ch, p);
strcat(ch, " WORLD");
for(int i=0; i<10; i++)
v[i] = w[i];
return strcmp(ch, "HELLO WORLD") + sum(v) - 55;
}

18
autotest/byteindextest.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <assert.h>
char a[20];
int main(void)
{
for(char i=0; i<20; i++)
a[i] = i;
char x = 0;
for(char i=0; i<20; i++)
x += a[i];
assert(x == 190);
return 0;
}

64
autotest/charwintest.c Normal file
View File

@ -0,0 +1,64 @@
#include <c64/charwin.h>
#include <assert.h>
#include <stdio.h>
int main(void)
{
CharWin cw;
cwin_init(&cw, (char *)0x0400, 2, 2, 32, 20);
cwin_clear(&cw);
for(int y=0; y<20; y++)
{
for(int x=0; x<32; x++)
{
assert(cwin_getat_char_raw(&cw, x, y) == ' ');
}
}
for(int y=0; y<20; y++)
{
for(int x=0; x<32; x++)
{
cwin_putat_char(&cw, x, y, p'a' - 1 + x, 7);
}
}
for(int y=0; y<20; y++)
{
for(int x=0; x<32; x++)
{
assert(cwin_getat_char(&cw, x, y) == p'a' -1 + x);
}
}
for(int y=0; y<20; y++)
{
for(int x=0; x<32; x++)
{
cwin_putat_char(&cw, x, y, p'A' - 1 + x, 8);
}
}
for(int y=0; y<20; y++)
{
for(int x=0; x<32; x++)
{
cwin_putat_char_raw(&cw, x, y, x + 32 * y, 8);
}
}
for(int y=0; y<8; y++)
{
for(int x=0; x<32; x++)
{
assert(cwin_getat_char_raw(&cw, x, y) == x + 32 * y);
}
}
return 0;
}

View File

@ -0,0 +1,298 @@
#include <assert.h>
void check_s_lt(void)
{
int a5 = 0, a10 = 0, a15 = 0;
for(int i=5; i<15; i++)
{
if (i < 5)
a5++;
if (i < 10)
a10++;
if (i < 15)
a15++;
}
assert(a5 == 0);
assert(a10 == 5);
assert(a15 == 10);
}
void check_s_le(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(int i=5; i<15; i++)
{
if (i <= 4)
a4++;
if (i <= 5)
a5++;
if (i <= 10)
a10++;
if (i <= 14)
a14++;
if (i <= 15)
a15++;
}
assert(a4 == 0);
assert(a5 == 1);
assert(a10 == 6);
assert(a14 == 10);
assert(a15 == 10);
}
void check_s_ge(void)
{
int a5 = 0, a10 = 0, a15 = 0;
for(int i=5; i<15; i++)
{
if (i >= 5)
a5++;
if (i >= 10)
a10++;
if (i >= 15)
a15++;
}
assert(a5 == 10);
assert(a10 == 5);
assert(a15 == 0);
}
void check_s_gt(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(int i=5; i<15; i++)
{
if (i > 4)
a4++;
if (i > 5)
a5++;
if (i > 10)
a10++;
if (i > 14)
a14++;
if (i > 15)
a15++;
}
assert(a4 == 10);
assert(a5 == 9);
assert(a10 == 4);
assert(a14 == 0);
assert(a15 == 0);
}
void check_s_eq(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(int i=5; i<15; i++)
{
if (i == 4)
a4++;
if (i == 5)
a5++;
if (i == 10)
a10++;
if (i == 14)
a14++;
if (i == 15)
a15++;
}
assert(a4 == 0);
assert(a5 == 1);
assert(a10 == 1);
assert(a14 == 1);
assert(a15 == 0);
}
void check_s_ne(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(int i=5; i<15; i++)
{
if (i != 4)
a4++;
if (i != 5)
a5++;
if (i != 10)
a10++;
if (i != 14)
a14++;
if (i != 15)
a15++;
}
assert(a4 == 10);
assert(a5 == 9);
assert(a10 == 9);
assert(a14 == 9);
assert(a15 == 10);
}
void check_u_lt(void)
{
int a5 = 0, a10 = 0, a15 = 0;
for(unsigned i=5; i<15; i++)
{
if (i < 5)
a5++;
if (i < 10)
a10++;
if (i < 15)
a15++;
}
assert(a5 == 0);
assert(a10 == 5);
assert(a15 == 10);
}
void check_u_le(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(unsigned i=5; i<15; i++)
{
if (i <= 4)
a4++;
if (i <= 5)
a5++;
if (i <= 10)
a10++;
if (i <= 14)
a14++;
if (i <= 15)
a15++;
}
assert(a4 == 0);
assert(a5 == 1);
assert(a10 == 6);
assert(a14 == 10);
assert(a15 == 10);
}
void check_u_ge(void)
{
int a5 = 0, a10 = 0, a15 = 0;
for(unsigned i=5; i<15; i++)
{
if (i >= 5)
a5++;
if (i >= 10)
a10++;
if (i >= 15)
a15++;
}
assert(a5 == 10);
assert(a10 == 5);
assert(a15 == 0);
}
void check_u_gt(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(unsigned i=5; i<15; i++)
{
if (i > 4)
a4++;
if (i > 5)
a5++;
if (i > 10)
a10++;
if (i > 14)
a14++;
if (i > 15)
a15++;
}
assert(a4 == 10);
assert(a5 == 9);
assert(a10 == 4);
assert(a14 == 0);
assert(a15 == 0);
}
void check_u_eq(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(unsigned i=5; i<15; i++)
{
if (i == 4)
a4++;
if (i == 5)
a5++;
if (i == 10)
a10++;
if (i == 14)
a14++;
if (i == 15)
a15++;
}
assert(a4 == 0);
assert(a5 == 1);
assert(a10 == 1);
assert(a14 == 1);
assert(a15 == 0);
}
void check_u_ne(void)
{
int a4 = 0, a5 = 0, a10 = 0, a14 = 0, a15 = 0;
for(unsigned i=5; i<15; i++)
{
if (i != 4)
a4++;
if (i != 5)
a5++;
if (i != 10)
a10++;
if (i != 14)
a14++;
if (i != 15)
a15++;
}
assert(a4 == 10);
assert(a5 == 9);
assert(a10 == 9);
assert(a14 == 9);
assert(a15 == 10);
}
int main(void)
{
check_s_ne();
check_s_eq();
check_s_lt();
check_s_le();
check_s_gt();
check_s_ge();
check_u_ne();
check_u_eq();
check_u_lt();
check_u_le();
check_u_gt();
check_u_ge();
return 0;
}

View File

@ -0,0 +1,165 @@
#include <assert.h>
int t, n;
struct C1
{
int a;
C1(int x);
~C1(void);
};
C1::C1(int x) : a(x)
{
t += a;
n++;
}
C1::~C1(void)
{
t -= a;
}
void test_base(void)
{
n = 0;
{
C1 x(2);
C1 y(1);
}
assert(t == 0 && n == 2);
}
void test_base_loop(void)
{
n = 0;
for(int i=0; i<10; i++)
{
C1 x(2);
C1 y(1);
}
assert(t == 0 && n == 20);
}
struct C2
{
C1 c, d;
C2(void);
};
C2::C2(void)
: c(7), d(11)
{
}
void test_member(void)
{
n = 0;
{
C2 x();
C2 y();
}
assert(t == 0 && n == 4);
}
void test_member_loop(void)
{
n = 0;
for(int i=0; i<10; i++)
{
C2 x();
C2 y();
}
assert(t == 0 && n == 40);
}
struct C3
{
C2 x, y;
};
void test_default(void)
{
n = 0;
{
C3 x();
C3 y();
}
assert(t == 0 && n == 8);
}
void test_default_loop(void)
{
n = 0;
for(int i=0; i<10; i++)
{
C3 x();
C3 y();
}
assert(t == 0 && n == 80);
}
inline void test_inline_x(void)
{
C1 x(1), y(2);
}
void test_inline(void)
{
n = 0;
test_inline_x();
assert(t == 0 && n == 2);
}
inline void test_inline_xr(void)
{
C1 x(1), y(2);
{
C1 x(3);
return;
}
}
void test_inline_return(void)
{
n = 0;
test_inline_xr();
assert(t == 0 && n == 3);
}
int main(void)
{
test_base();
test_base_loop();
test_member();
test_member_loop();
test_default();
test_default_loop();
test_inline();
test_inline_return();
return 0;
}

126
autotest/copyassign.cpp Normal file
View File

@ -0,0 +1,126 @@
#include <assert.h>
int t, n;
struct C0
{
int u;
C0(int a);
~C0(void);
};
C0::C0(int a) : u(a)
{
t += u;
n++;
}
C0::~C0(void)
{
t -= u;
}
struct C1
{
int u;
C1(int a);
~C1(void);
C1(const C1 & c);
C1 & operator=(const C1 & c);
};
C1::C1(int a) : u(a)
{
t += u;
n++;
}
C1::~C1(void)
{
t -= u;
}
C1::C1(const C1 & c) : u(c.u)
{
t += u;
n++;
}
C1 & C1::operator=(const C1 & c)
{
t -= u;
u = c.u;
t += u;
return *this;
}
void test_assign(void)
{
n = 0;
{
C1 c(4);
C1 d(5);
c = d;
}
assert(n == 2 && t == 0);
}
struct C2
{
C1 a, b;
C2(int x, int y) : a(x), b(y)
{}
};
void test_assign_deflt(void)
{
n = 0;
{
C2 c(2, 3);
C2 d(5, 10);
c = d;
}
assert(n == 4 && t == 0);
}
int k;
C2 test_ret_v(void)
{
C2 c(5, 10);
return c;
}
C2 & test_ret_r(C2 & r)
{
return r;
}
void test_assign_return_value(void)
{
n = 0;
{
C2 c(2, 3);
c = test_ret_v();
}
assert(n == 6 && t == 0);
}
int main(void)
{
test_assign();
test_assign_deflt();
test_assign_return_value();
return 0;
}

View File

@ -0,0 +1,215 @@
#include <assert.h>
#include <stdio.h>
int t, n;
struct C0
{
int u;
C0(int a);
~C0(void);
};
C0::C0(int a) : u(a)
{
t += u;
n++;
}
C0::~C0(void)
{
t -= u;
}
struct C1
{
int u;
C1(int a);
~C1(void);
C1(const C1 & c);
};
C1::C1(int a) : u(a)
{
t += u;
n++;
}
C1::~C1(void)
{
t -= u;
}
C1::C1(const C1 & c) : u(c.u)
{
t += u;
n++;
}
void test_dcopy_init(void)
{
n = 0;
{
C0 x(4);
C0 y(x);
}
assert(n == 1 && t == -4);
t = 0;
}
void test_copy_init(void)
{
n = 0;
{
C1 x(4);
C1 y(x);
}
assert(n == 2 && t == 0);
}
struct C2
{
C1 a, b;
C2(void);
};
C2::C2(void) : a(1), b(3)
{}
void test_minit(void)
{
n = 0;
{
C2 x;
}
assert(n == 2 && t == 0);
}
void test_minit_copy(void)
{
n = 0;
{
C2 x;
C2 y(x);
}
assert(n == 4 && t == 0);
}
int k;
void test_param_fv(C2 c)
{
k += c.a.u;
}
void test_param_fr(C2 & c)
{
k += c.a.u;
}
void test_param_value(void)
{
n = 0;
{
C2 x;
test_param_fv(x);
}
assert(n == 4 && t == 0);
}
void test_param_ref(void)
{
n = 0;
{
C2 x;
test_param_fr(x);
}
assert(n == 2 && t == 0);
}
C2 test_ret_v(void)
{
C2 c;
return c;
}
C2 & test_ret_r(C2 & r)
{
return r;
}
void test_return_value(void)
{
n = 0;
{
C2 c(test_ret_v());
}
assert(n == 6 && t == 0);
}
void test_return_reference(void)
{
n = 0;
{
C2 d;
C2 c(test_ret_r(d));
}
assert(n == 2 && t == 0);
}
void test_retparam_value(void)
{
n = 0;
{
test_param_fv(test_ret_v());
}
assert(n == 6 && t == 0);
}
void test_retparam_reference(void)
{
n = 0;
{
test_param_fr(test_ret_v());
}
assert(n == 4 && t == 0);
}
int main(void)
{
test_dcopy_init();
test_copy_init();
test_minit();
test_minit_copy();
test_param_value();
test_param_ref();
test_return_value();
test_retparam_value();
test_retparam_reference();
return 0;
}

27
autotest/copyinitmove.c Normal file
View File

@ -0,0 +1,27 @@
int val(char * c)
{
return c[0];
}
void set(char * c, int a)
{
c[0] = a;
}
int main(void)
{
int sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0;
for(int i=0; i<10; i++)
{
char t[10] = {1};
sum0 += val(t);
sum2 += t[0];
set(t, i);
sum1 += val(t);
sum3 += t[0];
}
return (sum1 - 45) | (sum0 - 10) | (sum3 - 45) | (sum2 - 10);
}

20
autotest/copyintvec.c Normal file
View File

@ -0,0 +1,20 @@
void copyi(int * a, int * b, int n)
{
for(int i=0; i<n; i++)
b[i] = a[i];
}
int main(void)
{
int t[100], s[100];
for(int i=0; i<100; i++)
s[i] = i;
copyi(s, t, 100);
int sum = 0;
for(int i=0; i<100; i++)
sum += t[i];
return sum - 4950;
}

97
autotest/cplxstructtest.c Normal file
View File

@ -0,0 +1,97 @@
#include <stdio.h>
#include <math.h>
#include <assert.h>
struct cplx
{
float r, i;
};
cplx cplx_add(cplx a, cplx b)
{
cplx c;
c.r = a.r + b.r;
c.i = a.i + b.i;
return c;
}
cplx cplx_sub(cplx a, cplx b)
{
cplx c;
c.r = a.r - b.r;
c.i = a.i - b.i;
return c;
}
cplx cplx_mul(cplx a, cplx b)
{
cplx c;
c.r = a.r * b.r - a.i * b.i;
c.i = a.i * b.r + a.r * b.i;
return c;
}
float cplx_abs(cplx a)
{
return sqrt(a.r * a.r + a.i * a.i);
}
cplx cplx_sum(cplx p, const cplx * a, int n)
{
cplx s = {0.0, 0.0};
cplx c = {1.0, 0.0};
for(int i=0; i<n; i++)
{
s = cplx_add(s, cplx_mul(a[i], c));
c = cplx_mul(c, p);
}
return s;
}
int main(void)
{
cplx sig[100];
for(int i=0; i<100; i++)
{
sig[i].r = cos(i * 1.3);
sig[i].i = sin(i * 1.3);
}
cplx c = {1.0, 0.0};
float phi = 0.1 * PI;
cplx t;
t.r = cos(phi); t.i = sin(phi);
float p[20], q[20];
for(int i=0; i<20; i++)
{
p[i] = cplx_abs(cplx_sum(c, sig, 100));
c = cplx_mul(c, t);
}
for(int i=0; i<20; i++)
{
float sumr = 0.0, sumi = 0.0;
for(int j=0; j<100; j++)
{
float co = cos(i * j * 0.1 * PI), si = sin(i * j * 0.1 * PI);
sumr += co * sig[j].r - si * sig[j].i;
sumi += si * sig[j].r + co * sig[j].i;
}
q[i] = sqrt(sumr * sumr + sumi * sumi);
}
#if 1
for(int i=0; i<20; i++)
{
printf("%d, %f - %f\n", i, p[i], q[i]);
}
#endif
for(int i=0; i<20; i++)
assert(fabs(p[i] - q[i]) < 1.0);
return 0;
}

36
autotest/divmod32test.c Normal file
View File

@ -0,0 +1,36 @@
#include <assert.h>
void check(unsigned long l, unsigned long r)
{
unsigned long d = l / r, m = l % r;
assert(d * r + m == l);
assert(m < r);
}
int main(void)
{
for(char i=0; i<28; i++)
{
for(char j=0; j<28; j++)
{
check(0xb3ul << i, 0x2bul << j);
check(0xb3ul << i, 0x01ul << j);
check(0x01ul << i, 0xc2ul << j);
check(0xb31ful << i, 0x2bul << j);
check(0xb354ul << i, 0x01ul << j);
check(0xb3ul << i, 0x2b1cul << j);
check(0xb3ul << i, 0x013ful << j);
check(0xb31ful << i, 0x2b23ul << j);
check(0xb354ul << i, 0x0145ul << j);
check(0xb31f24ul << i, 0x2bul << j);
check(0xb35421ul << i, 0x01ul << j);
check(0xb31f24ul << i, 0x2b23ul << j);
check(0xb35421ul << i, 0x0145ul << j);
check(0xb31f24ul << i, 0x2b2356ul << j);
check(0xb35421ul << i, 0x0145a7ul << j);
}
}
return 0;
}

39
autotest/divmodtest.c Normal file
View File

@ -0,0 +1,39 @@
#include <assert.h>
int main(void)
{
for(unsigned i=0; i<256; i+=11)
{
for(unsigned j=1; j<256; j++)
{
unsigned q = i / j, r = i % j;
assert(q * j + r == i);
assert(r >= 0 && r < j);
}
}
for(unsigned i=0; i<7000; i+=11)
{
for(unsigned j=1; j<i; j*=3)
{
unsigned q = i / j, r = i % j;
assert(q * j + r == i);
assert(r >= 0 && r < j);
}
}
for(unsigned i=0; i<64000; i+=121)
{
for(unsigned j=1; j<i; j*=3)
{
unsigned q = i / j, r = i % j;
assert(q * j + r == i);
assert(r >= 0 && r < j);
}
}
return 0;
}

23
autotest/enumswitch.c Normal file
View File

@ -0,0 +1,23 @@
enum E {
e1, e2, e3, e4
};
int check(E e)
{
switch(e)
{
case e1:
return 10;
case e2:
return 20;
case e3:
return 30;
default:
return 100;
}
}
int main(void)
{
return check(e1) + check(e2) + check(e3) + check(e4) - 160;
}

28
autotest/fastcalltest.c Normal file
View File

@ -0,0 +1,28 @@
#include <assert.h>
#include <stdio.h>
int p1(int a, int b)
{
return a + b;
}
int p2(int a, int b)
{
return a * b;
}
int c1(int x)
{
return x;
}
int c2(int x)
{
return c1(x);
}
int main(void)
{
return p1(5, p2(c2(2), c2(4))) - 13;
}

90
autotest/fixmathtest.c Normal file
View File

@ -0,0 +1,90 @@
#include <fixmath.h>
#include <assert.h>
#include <stdlib.h>
unsigned tval[] = {
1, 2, 16, 128, 255, 256, 4096, 32768, 65535
};
void testmuldiv16u(void)
{
for (char i=0; i<9; i++)
{
assert(lmuldiv16u(tval[i], 0, tval[i]) == 0);
assert(lmuldiv16u(0, tval[i], tval[i]) == 0);
for(char j=0; j<9; j++)
{
assert(lmuldiv16u(tval[i], tval[j], tval[i]) == tval[j]);
assert(lmuldiv16u(tval[j], tval[i], tval[i]) == tval[j]);
}
}
for(int i=0; i<10000; i++)
{
unsigned a = rand();
unsigned b = rand();
unsigned c = rand();
if (c > 0)
{
unsigned long d = (unsigned long)a * (unsigned long) b / c;
if (d < 0x10000l)
assert(lmuldiv16u(a, b, c) == d);
}
}
}
unsigned ival[] = {
1, 2, 16, 128, 255, 256, 4096, 32767,
-1, -2, -16, -128, -255, -256, -4096, -32767
};
void testmuldiv16s(void)
{
for (char i=0; i<16; i++)
{
assert(lmuldiv16s(ival[i], 0, ival[i]) == 0);
assert(lmuldiv16s(0, ival[i], ival[i]) == 0);
for(char j=0; j<16; j++)
{
assert(lmuldiv16s(ival[i], ival[j], ival[i]) == ival[j]);
assert(lmuldiv16s(ival[j], ival[i], ival[i]) == ival[j]);
}
}
for(int i=0; i<10000; i++)
{
int a = rand();
int b = rand();
int c = rand();
if (c > 0)
{
long d = (long)a * (long)b / c;
if (d >= -32768 && d <= 32767)
assert(lmuldiv16s(a, b, c) == d);
}
}
}
void testlmul4f12s(void)
{
for(int i=0; i<20000; i++)
{
int a = rand();
int b = rand();
long d = ((long)a * (long)b) >> 12;
if (d >= -32768 && d <= 32767)
assert(lmul4f12s(a, b) == d);
}
}
int main(void)
{
testlmul4f12s();
testmuldiv16u();
testmuldiv16s();
return 0;
}

View File

@ -12,16 +12,50 @@ bool flt(float a, float b)
return a < b; return a < b;
} }
bool fle(float a, float b)
{
return a <= b;
}
bool fgt(float a, float b) bool fgt(float a, float b)
{ {
return a > b; return a > b;
} }
void cmpflt(float a, float b, bool eq, bool lt, bool gt) bool fge(float a, float b)
{ {
return a >= b;
}
volatile float f;
inline void cmpflt(float a, float b, bool eq, bool lt, bool gt)
{
bool le = eq || lt;
bool ge = eq || gt;
assert(feq(a, b) == eq); assert(feq(a, b) == eq);
assert(flt(a, b) == lt); assert(flt(a, b) == lt);
assert(fgt(a, b) == gt); assert(fgt(a, b) == gt);
assert(fle(a, b) == le);
assert(fge(a, b) == ge);
f = a;
assert(feq(f, b) == eq);
assert(flt(f, b) == lt);
assert(fgt(f, b) == gt);
assert(fle(f, b) == le);
assert(fge(f, b) == ge);
f = b;
assert(feq(a, f) == eq);
assert(flt(a, f) == lt);
assert(fgt(a, f) == gt);
assert(fle(a, f) == le);
assert(fge(a, f) == ge);
} }
int main(void) int main(void)

75
autotest/floatinttest.c Normal file
View File

@ -0,0 +1,75 @@
#include <assert.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
float a;
int i;
long li;
unsigned u;
unsigned long lu;
a = 1.0;
i = 1;
for(int j=0; j<15; j++)
{
assert(i == (int)a);
assert(a == (float)i);
a *= 2.0;
i <<= 1;
}
a = -1.0;
i = -1;
for(int j=0; j<15; j++)
{
assert(i == (int)a);
assert(a == (float)i);
a *= 2.0;
i <<= 1;
}
a = 1.0;
u = 1;
for(int j=0; j<16; j++)
{
assert(u == (unsigned)a);
assert(a == (float)u);
a *= 2.0;
u <<= 1;
}
a = 1.0;
li = 1;
for(int j=0; j<31; j++)
{
assert(li == (long)a);
assert(a == (float)li);
a *= 2.0;
li <<= 1;
}
a = -1.0;
li = -1;
for(int j=0; j<31; j++)
{
assert(li == (long)a);
assert(a == (float)li);
a *= 2.0;
li <<= 1;
}
a = 1.0;
lu = 1;
for(int j=0; j<32; j++)
{
assert(lu == (unsigned long)a);
assert(a == (float)lu);
a *= 2.0;
lu <<= 1;
}
return 0;
}

View File

@ -12,7 +12,7 @@ int main(void)
for(i=0; i<50; i++) for(i=0; i<50; i++)
{ {
// printf("%d %f %f %f\n", i, i * c, a, i * c - a); printf("%d %f %f %f\n", i, i * c, a, i * c - a);
assert(i * c == a); assert(i * c == a);
a += c; a += c;
} }
@ -21,7 +21,7 @@ int main(void)
for(i=1; i<50; i++) for(i=1; i<50; i++)
{ {
// printf("%d %f %f %f\n", i, i * d, a, fabs(i * d - a) / i); printf("%d %f %f %f\n", i, i * d, a, fabs(i * d - a) / i);
assert(fabs(i * d - a) < i * 1.0e-6); assert(fabs(i * d - a) < i * 1.0e-6);
a += d; a += d;
} }

View File

@ -0,0 +1,32 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
int main(void)
{
printf("%f\n", 0.0);
float x = 1.0, y = 1.0;
char xb[20], yb[20];
for(int i=0; i<40; i++)
{
ftoa(x, xb); float xr = atof(xb);
ftoa(y, yb); float yr = atof(yb);
printf("%20g (%s) %20g : %20g (%s) %20g : %10f %10f \n", x, xb, xr, y, yb, yr, fabs(x - xr) / x, fabs(y - yr) / y);
if (fabs(x - xr) / x > 0.00001 || fabs(y - yr) / y > 0.00001)
return -1;
x *= 2.5;
y *= 0.8;
}
return 0;
}

13
autotest/floortest.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <math.h>
int main(void)
{
for(int y=1; y<100; y++)
{
float fz = 100.0 / (float)y;
printf("%d %f %f\n", y, floor(fz * 100.0), fz * 100.0);
}
return 0;
}

30
autotest/funcarraycall.c Normal file
View File

@ -0,0 +1,30 @@
int (*funcs[10])(int);
#assign x 0
#repeat
int f##x(int i)
{
return i + x;
}
#assign x x + 1
#until x == 10
int test(int k)
{
for(char i=0; i<10; i++)
k = funcs[i](k);
return k;
}
int main(void)
{
#assign x 0
#repeat
funcs[x] = f##x;
#assign x x + 1
#until x == 10
int k = test(-45);
return k;
}

72
autotest/funcvartest.c Normal file
View File

@ -0,0 +1,72 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef float (*fop)(float a, float b);
float fadd(float a, float b)
{
return a + b;
}
float fmul(float a, float b)
{
return a * b;
}
struct FNode
{
FNode * left, * right;
float value;
fop call;
};
FNode * root;
float fevalB(FNode * f)
{
if (f->call)
return f->call(fevalB(f->left), fevalB(f->right));
else
return f->value;
}
float fevalN(FNode * f)
{
if (f->call)
return f->call(fevalN(f->left), fevalN(f->right));
else
return f->value;
}
#pragma native(fevalN)
FNode * bop(fop call, FNode * left, FNode * right)
{
FNode * f = (FNode *)malloc(sizeof(FNode));
f->call = call;
f->left = left;
f->right = right;
return f;
}
FNode * bc(float value)
{
FNode * f = (FNode *)malloc(sizeof(FNode));
f->value = value;
return f;
}
int main(void)
{
FNode * tree = bop(fadd, bop(fmul, bc(3), bc(5)), bc(6));
printf("Eval %f, %d\n", fevalB(tree), fevalN(tree));
assert(fevalB(tree) == 3 * 5 + 6);
assert(fevalN(tree) == 3 * 5 + 6);
return 0;
}

22
autotest/incvector.c Normal file
View File

@ -0,0 +1,22 @@
void incv(int * a, int n)
{
for(int i=0; i<n; i++)
a[i] ++;
}
int t[100];
int main(void)
{
for(int i=0; i<100; i++)
t[i] = i;
incv(t, 100);
int s = 0;
for(int i=0; i<100; i++)
s += t[i];
return s - 5050;
}

25
autotest/linetest.c Normal file
View File

@ -0,0 +1,25 @@
#include <gfx/bitmap.h>
#include <assert.h>
char * const Hires = (char *)0x4000;
Bitmap Screen;
ClipRect cr = {0, 0, 320, 200};
int main(void)
{
bm_init(&Screen, Hires, 40, 25);
bmu_rect_clear(&Screen, 0, 0, 320, 200);
bm_line(&Screen, &cr, 0, 0, 199, 199, 0xff, LINOP_SET);
for(int i=0; i<200; i++)
{
assert(Hires[(i & 7) + 320 * (i >> 3) + (i & ~7)] == 0x80 >> (i & 7));
}
return 0;
}

30
autotest/longcodetest.c Normal file
View File

@ -0,0 +1,30 @@
#include <assert.h>
char a[200], b[200];
bool ok = true;
int main(void)
{
#assign ni 0
#repeat
a[ni] = ni & 255;
#assign ni ni + 1
#until ni == 200
#assign ni 0
#repeat
if (ok)
b[ni] = ni & 255;
#assign ni ni + 1
#until ni == 200
int asum = 0, bsum = 0, csum = 0;
for(int i=0; i<200; i++)
{
asum += a[i];
bsum += b[i];
csum += i & 255;
}
return asum + bsum - 2 * csum;
}

94
autotest/loopboundtest.c Normal file
View File

@ -0,0 +1,94 @@
#include <assert.h>
struct S
{
int a[100];
};
int lts(S * s)
{
int x = 0;
for(int i=0; i<100; i++)
x += s->a[i];
return x;
}
int les(S * s)
{
int x = 0;
for(int i=0; i<=99; i++)
x += s->a[i];
return x;
}
int gts(S * s)
{
int x = 0;
for(int i=100; i>0; i--)
x += s->a[i-1];
return x;
}
int ges(S * s)
{
int x = 0;
for(int i=99; i>=0; i--)
x += s->a[i];
return x;
}
int ltu(S * s)
{
unsigned x = 0;
for(int i=0; i<100; i++)
x += s->a[i];
return x;
}
int leu(S * s)
{
unsigned x = 0;
for(int i=0; i<=99; i++)
x += s->a[i];
return x;
}
int gtu(S * s)
{
unsigned x = 0;
for(int i=100; i>0; i--)
x += s->a[i-1];
return x;
}
int geu(S * s)
{
unsigned x = 0;
for(int i=100; i>=1; i--)
x += s->a[i-1];
return x;
}
int main(void)
{
S s;
int k = 0;
for(int i=0; i<100; i++)
{
int t = (i & 15) + 3;
s.a[i] = t;
k += t;
}
assert(lts(&s) == k);
assert(les(&s) == k);
assert(gts(&s) == k);
assert(ges(&s) == k);
assert(ltu(&s) == k);
assert(leu(&s) == k);
assert(gtu(&s) == k);
assert(geu(&s) == k);
return 0;
}

28
autotest/loopdomtest.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <assert.h>
int main(void)
{
int a[10][10];
for(int i=0; i<10; i++)
{
for(int j=0; j<10; j++)
{
a[i][j] = i + j;
}
}
int s = 0;
for(int i=0; i<10; i++)
{
s += a[i][i];
}
assert(s == 90);
return 0;
}

60
autotest/makefile Normal file
View File

@ -0,0 +1,60 @@
SRCS=$(filter-out opp_part1.cpp opp_part2.cpp, $(wildcard *.c *.cpp))
EXES=$(patsubst %.c,%,$(SRCS))
EXES:=$(patsubst %.cpp,%,$(EXES))
all: $(EXES)
%: %.c
$(OSCAR64_CC) -e -bc $<
$(OSCAR64_CC) -e -n $<
$(OSCAR64_CC) -e -O2 -bc $<
$(OSCAR64_CC) -e -O2 -n $<
$(OSCAR64_CC) -e -O0 -bc $<
$(OSCAR64_CC) -e -O0 -n $<
$(OSCAR64_CC) -e -Os -bc $<
$(OSCAR64_CC) -e -Os -n $<
$(OSCAR64_CC) -e -O3 -bc $<
$(OSCAR64_CC) -e -O3 -n $<
%: %.cpp
$(OSCAR64_CXX) -e -bc $<
$(OSCAR64_CXX) -e -n $<
$(OSCAR64_CXX) -e -O2 -bc $<
$(OSCAR64_CXX) -e -O2 -n $<
$(OSCAR64_CXX) -e -O0 -bc $<
$(OSCAR64_CXX) -e -O0 -n $<
$(OSCAR64_CXX) -e -Os -bc $<
$(OSCAR64_CXX) -e -Os -n $<
$(OSCAR64_CXX) -e -O3 -bc $<
$(OSCAR64_CXX) -e -O3 -n $<
# testb
bitshifttest: bitshifttest.c
$(OSCAR64_CC) -e -bc $<
$(OSCAR64_CC) -e -bc -O2 $<
$(OSCAR64_CC) -e -bc -O0 $<
$(OSCAR64_CC) -e -bc -Os $<
$(OSCAR64_CC) -e -bc -O3 $<
$(OSCAR64_CC) -e -n $<
# testn
stripedarraytest: stripedarraytest.c
$(OSCAR64_CC) -e -O2 -n $<
$(OSCAR64_CC) -e -O0 -n $<
$(OSCAR64_CC) -e -Os -n $<
$(OSCAR64_CC) -e -O3 -n $<
autorefreturn: autorefreturn.cpp
$(OSCAR64_CC) -e -O2 -n $<
$(OSCAR64_CC) -e -O0 -n $<
$(OSCAR64_CC) -e -Os -n $<
$(OSCAR64_CC) -e -O3 -n $<
copyconstructor: copyconstructor.cpp
$(OSCAR64_CC) -e -O2 -n $<
$(OSCAR64_CC) -e -O0 -n $<
$(OSCAR64_CC) -e -Os -n $<
$(OSCAR64_CC) -e -O3 -n $<
clean:
@$(RM) *.asm *.bcs *.int *.lbl *.map *.prg

32
autotest/mathtest.c Normal file
View File

@ -0,0 +1,32 @@
#include <math.h>
#include <stdio.h>
#include <assert.h>
int main(void)
{
for(int i=0; i<1000; i++)
{
float w = 0.0123 * i;
float co = cos(w), si = sin(w);
float r = co * co + si * si;
assert(fabs(r - 1) < 0.001);
assert(fabs(sqrt(w * w) - w) < 0.001);
float aw = atan2(si, co);
float co2 = cos(aw), si2 = sin(aw);
assert(fabs(co2 - co) < 0.001);
assert(fabs(si2 - si) < 0.001);
float ex = exp(w), em = exp(-w);
assert(fabs(log(ex) - w) < 0.001);
assert(fabs(log(em) + w) < 0.001);
}
return 0;
}

49
autotest/memmovetest.c Normal file
View File

@ -0,0 +1,49 @@
#include <string.h>
#include <assert.h>
#include <stdio.h>
unsigned b[4096];
void testfwd(unsigned sz)
{
for(unsigned i=0; i<4096; i++)
b[i] = i;
memmove(b + 100, b + 101, 2 * sz);
for(unsigned i=0; i<100; i++)
assert(b[i] == i);
for(unsigned i=100; i<100 + sz; i++)
assert(b[i] == i + 1);
for(unsigned i=100 + sz; i<4096; i++)
assert(b[i] == i);
}
void testback(unsigned sz)
{
for(unsigned i=0; i<4096; i++)
b[i] = i;
memmove(b + 101, b + 100, 2 * sz);
for(unsigned i=0; i<101; i++)
assert(b[i] == i);
for(unsigned i=101; i<101 + sz; i++)
assert(b[i] == i - 1);
for(unsigned i=101 + sz; i<4096; i++)
assert(b[i] == i);
}
int main(void)
{
for(unsigned i=1; i<2048; i *= 2)
{
testfwd(i - 1);
testfwd(i);
testback(i);
testback(i - 1);
}
return 0;
}

64
autotest/mixsigncmptest.c Normal file
View File

@ -0,0 +1,64 @@
#include <assert.h>
int main(void)
{
unsigned n1, n0;
n1 = 0; n0 = 0;
for(int i=-1000; i<2000; i+=37)
{
for(char j=0; j<255; j++)
{
if (i < j)
n1++;
else
n0++;
}
}
assert(n1 == 7893 && n0 == 13017);
n1 = 0; n0 = 0;
for(int i=-1000; i<2000; i+=37)
{
for(char j=0; j<255; j++)
{
if (i <= j)
n1++;
else
n0++;
}
}
assert(n1 == 7899 && n0 == 13011);
n1 = 0; n0 = 0;
for(int i=-1000; i<2000; i+=37)
{
for(char j=0; j<255; j++)
{
if (i >= j)
n1++;
else
n0++;
}
}
assert(n0 == 7893 && n1 == 13017);
n1 = 0; n0 = 0;
for(int i=-1000; i<2000; i+=37)
{
for(char j=0; j<255; j++)
{
if (i > j)
n1++;
else
n0++;
}
}
assert(n0 == 7899 && n1 == 13011);
return 0;
}

43
autotest/mmultest.c Normal file
View File

@ -0,0 +1,43 @@
#include <gfx/vector3d.h>
#include <assert.h>
#include <stdio.h>
Matrix4 ml, mr;
int main(void)
{
for(char i=0; i<16; i++)
{
for(char j=0; j<16; j++)
{
for(char k=0; k<16; k++)
{
ml.m[k] = (i == k) ? 1.0 : 0.0;
mr.m[k] = (j == k) ? 1.0 : 0.0;
}
mat4_mmul(&ml, &mr);
#if 0
printf("%d, %d\n", i, j);
for(char k=0; k<16; k++)
printf("%f ", ml.m[k]);
printf("\n");
#endif
for(char k=0; k<16; k++)
{
char ix = i & 3, iy = i >> 2;
char jx = j & 3, jy = j >> 2;
char kx = k & 3, ky = k >> 2;
if (ky == jy && kx == ix && jx == iy)
assert(ml.m[k] == 1.0);
else
assert(ml.m[k] == 0.0);
}
}
}
return 0;
}

View File

@ -0,0 +1,90 @@
#include <assert.h>
struct A
{
int n;
A(int n_)
: n(n_) {}
A(const A & a)
: n(a.n) {}
A operator+(const A & a) const
{
return A(n + a.n);
}
A operator-(const A & a) const
{
return A(n - a.n);
}
A & operator+=(const A & a)
{
n += a.n;
return *this;
}
A & operator-=(const A & a)
{
n -= a.n;
return *this;
}
A operator-(void) const
{
return A(-n);
}
A & operator++(void)
{
n++;
return *this;
}
A & operator--(void)
{
n--;
return *this;
}
A operator++(int);
A operator--(int);
};
A A::operator++(int)
{
A a(*this);
n++;
return a;
}
A A::operator--(int)
{
A a(*this);
n--;
return a;
}
int main(void)
{
A a(7), b(8), c(9);
assert((++a).n == 8);
assert(a.n == 8);
assert((--a).n == 7);
assert(a.n == 7);
assert((a++).n == 7);
assert(a.n == 8);
assert((a--).n == 8);
assert(a.n == 7);
assert((a + b - c + -a + -b - -c).n == 0);
return 0;
}

23
autotest/opp_array.cpp Normal file
View File

@ -0,0 +1,23 @@
#include <opp/array.h>
#include <assert.h>
int main(void)
{
opp::array<int, 10> a10;
opp::array<int, 20> a20;
for(int i=0; i<10; i++)
a10[i] = i;
for(int i=0; i<20; i++)
a20[i] = i;
int s = 0;
for(int i=0; i<10; i++)
s += a10[i];
for(int i=10; i<20; i++)
s -= a20[i];
assert(s == -100);
return 0;
}

View File

@ -0,0 +1,46 @@
#include <opp/functional.h>
class Node
{
public:
virtual int eval(void) const = 0;
};
class ConstNode : public Node
{
private:
int v;
public:
ConstNode(int v_) : v(v_) {}
virtual int eval(void) const
{
return v;
}
};
class BinaryNode : public Node
{
private:
opp::function<int(int, int)> op;
Node * left, * right;
public:
BinaryNode(opp::function<int(int, int)> op_, Node * left_, Node * right_);
virtual int eval(void) const
{
return op(left->eval(), right->eval());
}
};
inline BinaryNode::BinaryNode(opp::function<int(int, int)> op_, Node * left_, Node * right_)
: op(op_), left(left_), right(right_) {}
int main(void)
{
Node * s1 =
new BinaryNode([=](int a, int b){return a + b;},
new ConstNode(7), new ConstNode(11)
);
return s1->eval() - 18;
}

57
autotest/opp_list.cpp Normal file
View File

@ -0,0 +1,57 @@
#include <opp/list.h>
#include <opp/algorithm.h>
#include <assert.h>
#include <opp/iostream.h>
int main(void)
{
opp::list<int> a;
for(int i=0; i<10; i++)
a.push_back(i);
int s = 0;
for(auto i : a)
s += i;
assert(s == 45);
auto li = a.begin();
for(int i=0; i<5; i++)
{
li = a.erase(li);
li++;
}
s = 0;
for(auto i : a)
s += i;
assert(s == 1 + 3 + 5 + 7 + 9);
opp::list<int> b;
b = a;
s = 0;
for(auto i : b)
s += i;
assert(s == 1 + 3 + 5 + 7 + 9);
opp::list<int> c = opp::list<int>(b);
s = 0;
for(auto i : c)
s += i;
assert(s == 1 + 3 + 5 + 7 + 9);
s = 0;
for(auto i : b)
s += i;
assert(s == 1 + 3 + 5 + 7 + 9);
return 0;
}

28
autotest/opp_pairtest.cpp Normal file
View File

@ -0,0 +1,28 @@
#include <assert.h>
#include <opp/vector.h>
#include <opp/utility.h>
#include <opp/iostream.h>
using namespace opp;
int main(void)
{
vector<pair<int, int> > vii;
for(int i=0; i<100; i++)
vii.push_back(make_pair(i, i * i));
int sum1 = 0;
long sum2 = 0;
for(const auto & v : vii)
{
sum1 += v.first;
sum2 += v.second;
}
assert(sum1 == 4950);
assert(sum2 == 328350l);
return 0;
}

2
autotest/opp_part1.cpp Normal file
View File

@ -0,0 +1,2 @@
#include "opp_part1.h"

40
autotest/opp_part1.h Normal file
View File

@ -0,0 +1,40 @@
#pragma once
#include <opp/vector.h>
class A
{
protected:
int a, b;
public:
A(int a_, int b_)
: a(a_), b(b_)
{}
int sum(void) const
{
return a * b;
}
};
class AS
{
protected:
opp::vector<A> va;
public:
AS(const opp::vector<A> & v)
: va(v)
{}
int sum(void)
{
int s = 0;
for(const auto & a : va)
s += a.sum();
return s;
}
};
#pragma compile("opp_part1.cpp")

13
autotest/opp_part2.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "opp_part2.h"
BS::BS(const opp::vector<A> & v)
: va(v)
{}
int BS::sum(void)
{
int s = 0;
for(const auto & a : va)
s += a.sum();
return s;
}

16
autotest/opp_part2.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include "opp_part1.h"
class BS
{
protected:
opp::vector<A> va;
public:
BS(const opp::vector<A> & v);
int sum(void);
};
#pragma compile("opp_part2.cpp")

25
autotest/opp_parts.cpp Normal file
View File

@ -0,0 +1,25 @@
#include <assert.h>
#include "opp_part1.h"
#include "opp_part2.h"
int main(void)
{
opp::vector<A> va;
va.push_back(A(1, 2));
va.push_back(A(3, 4));
va.push_back(A(6, 4));
va.push_back(A(0, 9));
AS as(va);
va.push_back(A(7, 1));
BS bs(va);
assert(bs.sum() == 2 + 12 + 24 + 7);
assert(as.sum() == 2 + 12 + 24);
return 0;
}

View File

@ -0,0 +1,78 @@
#include <opp/static_vector.h>
#include <opp/algorithm.h>
#include <assert.h>
#include <opp/iostream.h>
int main(void)
{
opp::static_vector<int, 20> a;
for(int i=0; i<10; i++)
a.push_back(i);
int s = 0;
for(int i=0; i<a.size(); i++)
s += a[i];
assert(s == 45);
for(int i=0; i<5; i++)
a.erase(i);
s = 0;
for(int i=0; i<a.size(); i++)
s += a[i];
assert(s == 1 + 3 + 5 + 7 + 9);
opp::static_vector<int, 100> v;
for(int i=0; i<10; i++)
v.push_back(i);
assert(v.size() == 10);
v.insert(0, 20);
assert(v.size() == 11);
v.insert(6, 21);
assert(v.size() == 12);
v.insert(12, 22);
int * fi = opp::find(v.begin(), v.end(), 21);
fi = v.insert(fi, 30);
fi = v.insert(fi, 31);
fi = v.insert(fi, 32);
assert(v.size() == 16);
assert(v[0] == 20);
assert(v[15] == 22);
assert(v[8] == 32);
fi = opp::find(v.begin(), v.end(), 32);
for(int i=0; i<30; i++)
{
fi = v.insert(fi, i + 40);
}
assert(v.size() == 46);
assert(v[28] == 60);
v.erase(10, 10);
for(int i : v)
opp::cout << i << ", ";
opp::cout << "\n";
assert(v.size() == 36);
assert(v[18] == 60);
v.assign(42, 11);
assert(v.size() == 42);
assert(v[0] == 11);
assert(v[15] == 11);
assert(v[41] == 11);
return 0;
}

View File

@ -0,0 +1,83 @@
#include <opp/string.h>
#include <stdlib.h>
#include <assert.h>
#include <opp/sstream.h>
#include <math.h>
using opp::ostringstream;
using opp::istringstream;
using opp::endl;
float fdist(float a, float b)
{
float d = fabs(a - b);
a = fabs(a);
b = fabs(b);
return d / (a > b ? a : b);
}
int main(void)
{
ostringstream os;
for(int i=0; i<40; i++)
{
os << i << endl;
}
istringstream is(os.str());
int j = 0, k = 47;
#if 1
while (is >> k)
{
assert(k == j++);
}
assert(j == 40);
#endif
os.str(opp::string());
#if 0
cout << "[" << os.str() << "]" << endl;
os << "HELLO";
cout << "[" << os.str() << "]" << endl;
#endif
#if 1
float f = 1.0, g = 1.0;
for(int i=0; i<10; i++)
{
os << f << " " << g << endl;
// cout << os.str();
f *= 5.1;
g *= 0.12;
}
is.str(os.str());
f = 1.0, g = 1.0;
float fr, gr;
j = 0;
while (is >> fr >> gr)
{
// cout << f << " " << fr << ", " << g << " " << gr << ", " << fdist(fr, f) << endl;
assert(fdist(fr, f) < 1.0e-5);
assert(fdist(gr, g) < 1.0e-5);
f *= 5.1;
g *= 0.12;
j++;
}
assert(j == 10);
#endif
return 0;
}

103
autotest/opp_string.cpp Normal file
View File

@ -0,0 +1,103 @@
#include <opp/string.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
using opp::string;
static const char HelloWorld[] = "Hello World";
static const char AndBeyond[] = "And Beyond";
static const char And[] = "And";
static const char HelloWorldAndBeyond[] = "Hello World And Beyond";
__noinline void test_create(void)
{
string s1();
string s2(HelloWorld);
string s3(s2);
string s4('a');
assert(!strcmp(s2.tocstr(), HelloWorld));
assert(!strcmp(s3.tocstr(), HelloWorld));
assert(s4.size() == 1 && s4[0] == 'a');
}
__noinline void test_concat(void)
{
string s1();
string s2(HelloWorld);
string s3(AndBeyond);
string s4 = s1 + s2;
string s5 = s2 + " " + s3;
string s6 = s2 + " " + AndBeyond;
assert(!strcmp(s4.tocstr(), HelloWorld));
assert(!strcmp(s5.tocstr(), HelloWorldAndBeyond));
assert(!strcmp(s6.tocstr(), HelloWorldAndBeyond));
}
__noinline void test_find(void)
{
string s1(HelloWorldAndBeyond);
string s2(And);
assert(s1.find(HelloWorld) == 0);
assert(s1.find(AndBeyond) == 12);
assert(s1.find(And) == 12);
assert(s1.find(s2) == 12);
assert(s1.find(' ') == 5);
assert(s1.find(' ', 6) == 11);
}
__noinline void test_assign(void)
{
string s1(HelloWorld);
string s2(AndBeyond);
string s3;
s3 = s1;
s3 = s2;
s3 = s1;
s3 += " ";
s3 += s2;
assert(!strcmp(s3.tocstr(), HelloWorldAndBeyond));
s3 <<= 12;
assert(!strcmp(s3.tocstr(), AndBeyond));
s3 = HelloWorldAndBeyond;
assert(!strcmp(s3.tocstr(), HelloWorldAndBeyond));
s3 >>= 11;
assert(!strcmp(s3.tocstr(), HelloWorld));
}
static char * test;
int main(void)
{
test = new char;
unsigned avail = heapfree();
test_create();
assert(avail == heapfree());
test_concat();
assert(avail == heapfree());
test_find();
assert(avail == heapfree());
test_assign();
assert(avail == heapfree());
delete test;
return 0;
}

View File

@ -0,0 +1,193 @@
#include <opp/string.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
using opp::string;
const string s1;
const string s2 = "Hello";
const string s3{"World"};
const string a1[2];
const string a2[2] = {"Hello", "World"};
const string a3[2] = {opp::string("Hello"), opp::string("World")};
const string d1[3][2];
const string d2[3][2] = {{"Hello", "World"}, {"aaa", "bbb"}, {"ccc", "ddd"}};
const string d3[3][2] =
{{opp::string("Hello"), opp::string("World")},
{opp::string("aaa"), opp::string("bbb")},
{opp::string("ccc"), opp::string("ddd")}};
void test_global_init(void)
{
assert(!strcmp(s1.tocstr(), ""));
assert(!strcmp(s2.tocstr(), "Hello"));
assert(!strcmp(s3.tocstr(), "World"));
}
void test_global_ainit(void)
{
assert(!strcmp(a1[0].tocstr(), ""));
assert(!strcmp(a1[1].tocstr(), ""));
assert(!strcmp(a2[0].tocstr(), "Hello"));
assert(!strcmp(a2[1].tocstr(), "World"));
assert(!strcmp(a3[0].tocstr(), "Hello"));
assert(!strcmp(a3[1].tocstr(), "World"));
}
void test_global_dinit(void)
{
assert(!strcmp(d1[0][0].tocstr(), ""));
assert(!strcmp(d1[2][1].tocstr(), ""));
assert(!strcmp(d2[0][0].tocstr(), "Hello"));
assert(!strcmp(d2[2][1].tocstr(), "ddd"));
assert(!strcmp(d3[0][0].tocstr(), "Hello"));
assert(!strcmp(d3[2][1].tocstr(), "ddd"));
}
void test_local_init(void)
{
const string s1;
const string s2 = "Hello";
const string s3{"World"};
assert(!strcmp(s1.tocstr(), ""));
assert(!strcmp(s2.tocstr(), "Hello"));
assert(!strcmp(s3.tocstr(), "World"));
}
void test_local_ainit(void)
{
const string a1[2];
const string a2[2] = {"Hello", "World"};
const string a3[2] = {opp::string("Hello"), opp::string("World")};
assert(!strcmp(a1[0].tocstr(), ""));
assert(!strcmp(a1[1].tocstr(), ""));
assert(!strcmp(a2[0].tocstr(), "Hello"));
assert(!strcmp(a2[1].tocstr(), "World"));
assert(!strcmp(a3[0].tocstr(), "Hello"));
assert(!strcmp(a3[1].tocstr(), "World"));
}
void test_local_dinit(void)
{
const string d1[3][2];
const string d2[3][2] = {{"Hello", "World"}, {"aaa", "bbb"}, {"ccc", "ddd"}};
const string d3[3][2] =
{{opp::string("Hello"), opp::string("World")},
{opp::string("aaa"), opp::string("bbb")},
{opp::string("ccc"), opp::string("ddd")}};
assert(!strcmp(d1[0][0].tocstr(), ""));
assert(!strcmp(d1[2][1].tocstr(), ""));
assert(!strcmp(d2[0][0].tocstr(), "Hello"));
assert(!strcmp(d2[2][1].tocstr(), "ddd"));
assert(!strcmp(d3[0][0].tocstr(), "Hello"));
assert(!strcmp(d3[2][1].tocstr(), "ddd"));
}
class X
{
public:
const string s1;
const string s2 = "Hello";
const string s3;
const string a1[2];
const string a2[2] = {"Hello", "World"};
const string d1[3][2];
const string d2[3][2] = {{"Hello", "World"}, {"aaa", "bbb"}, {"ccc", "ddd"}};
X() : s3("World") {}
};
void test_member_init(void)
{
X x;
assert(!strcmp(x.s1.tocstr(), ""));
assert(!strcmp(x.s2.tocstr(), "Hello"));
assert(!strcmp(x.s3.tocstr(), "World"));
}
void test_member_ainit(void)
{
X x;
assert(!strcmp(x.a1[0].tocstr(), ""));
assert(!strcmp(x.a1[1].tocstr(), ""));
assert(!strcmp(x.a2[0].tocstr(), "Hello"));
assert(!strcmp(x.a2[1].tocstr(), "World"));
}
void test_member_dinit(void)
{
X x;
assert(!strcmp(x.d1[0][0].tocstr(), ""));
assert(!strcmp(x.d1[2][1].tocstr(), ""));
assert(!strcmp(x.d2[0][0].tocstr(), "Hello"));
assert(!strcmp(x.d2[2][1].tocstr(), "ddd"));
}
void test_copy_init(void)
{
X x;
X y(x);
assert(!strcmp(y.s1.tocstr(), ""));
assert(!strcmp(y.s2.tocstr(), "Hello"));
assert(!strcmp(y.s3.tocstr(), "World"));
}
void test_copy_ainit(void)
{
X x;
X y(x);
assert(!strcmp(y.a1[0].tocstr(), ""));
assert(!strcmp(y.a1[1].tocstr(), ""));
assert(!strcmp(y.a2[0].tocstr(), "Hello"));
assert(!strcmp(y.a2[1].tocstr(), "World"));
}
int main(void)
{
test_global_init();
test_global_ainit();
test_global_dinit();
for(int i=0; i<10000; i++)
{
test_local_init();
test_local_ainit();
}
test_member_init();
test_member_ainit();
test_copy_init();
test_copy_ainit();
return 0;
}

78
autotest/opp_vector.cpp Normal file
View File

@ -0,0 +1,78 @@
#include <opp/vector.h>
#include <opp/algorithm.h>
#include <assert.h>
#include <opp/iostream.h>
int main(void)
{
opp::vector<int> a;
for(int i=0; i<10; i++)
a.push_back(i);
int s = 0;
for(int i=0; i<a.size(); i++)
s += a[i];
assert(s == 45);
for(int i=0; i<5; i++)
a.erase(i);
s = 0;
for(int i=0; i<a.size(); i++)
s += a[i];
assert(s == 1 + 3 + 5 + 7 + 9);
opp::vector<int> v;
for(int i=0; i<10; i++)
v.push_back(i);
assert(v.size() == 10);
v.insert(0, 20);
assert(v.size() == 11);
v.insert(6, 21);
assert(v.size() == 12);
v.insert(12, 22);
int * fi = opp::find(v.begin(), v.end(), 21);
fi = v.insert(fi, 30);
fi = v.insert(fi, 31);
fi = v.insert(fi, 32);
assert(v.size() == 16);
assert(v[0] == 20);
assert(v[15] == 22);
assert(v[8] == 32);
fi = opp::find(v.begin(), v.end(), 32);
for(int i=0; i<30; i++)
{
fi = v.insert(fi, i + 40);
}
assert(v.size() == 46);
assert(v[28] == 60);
v.erase(10, 10);
for(int i : v)
opp::cout << i << ", ";
opp::cout << "\n";
assert(v.size() == 36);
assert(v[18] == 60);
v.assign(42, 11);
assert(v.size() == 42);
assert(v[0] == 11);
assert(v[15] == 11);
assert(v[41] == 11);
return 0;
}

View File

@ -0,0 +1,38 @@
#include <opp/vector.h>
#include <opp/string.h>
#include <assert.h>
#include <stdlib.h>
#include <opp/iostream.h>
using opp::string;
using opp::vector;
string join(const vector<string> & vs)
{
string sj;
for(int i=0; i<vs.size(); i++)
sj += vs[i];
return sj;
}
int main(void)
{
vector<string> vs;
string a;
for(int i=0; i<10; i++)
{
vs.push_back(a);
a += "x";
}
int s = 0;
for(int i=0; i<10; i++)
s += vs[i].size();
assert(s == 45);
assert(join(vs).size() == 45);
return 0;
}

145
autotest/plasma.c Normal file
View File

@ -0,0 +1,145 @@
#include <stdlib.h>
static const char sintab[] = {
128, 131, 134, 137, 140, 144, 147, 150, 153, 156, 159, 162, 165, 168, 171, 174, 177, 179, 182, 185, 188, 191, 193, 196, 199, 201, 204, 206, 209, 211, 213, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 235, 237, 239, 240, 241, 243, 244, 245, 246, 248, 249, 250, 250, 251, 252, 253, 253, 254, 254, 254, 255, 255, 255,
255, 255, 255, 255, 254, 254, 254, 253, 253, 252, 251, 250, 250, 249, 248, 246, 245, 244, 243, 241, 240, 239, 237, 235, 234, 232, 230, 228, 226, 224, 222, 220, 218, 216, 213, 211, 209, 206, 204, 201, 199, 196, 193, 191, 188, 185, 182, 179, 177, 174, 171, 168, 165, 162, 159, 156, 153, 150, 147, 144, 140, 137, 134, 131,
128, 125, 122, 119, 116, 112, 109, 106, 103, 100, 97, 94, 91, 88, 85, 82, 79, 77, 74, 71, 68, 65, 63, 60, 57, 55, 52, 50, 47, 45, 43, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 21, 19, 17, 16, 15, 13, 12, 11, 10, 8, 7, 6, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1,
1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 19, 21, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 43, 45, 47, 50, 52, 55, 57, 60, 63, 65, 68, 71, 74, 77, 79, 82, 85, 88, 91, 94, 97, 100, 103, 106, 109, 112, 116, 119, 122, 125
};
char Screen0[1024], Screen1[1024];
char colormap0[256], colormap1[256];
char colors0[] = {0, 6, 14, 1, 13, 5, 0};
char colors1[] = {0, 9, 7, 1, 15, 12, 0};
unsigned c1A, c1B, c2A, c2B, c3A, c3B;
int d1A, d1B, d2A, d2B, d3A, d3B;
void inithires(void)
{
for(int i=0; i<256; i++)
{
colormap0[i] = colors0[i / 37];
colormap1[i] = colors1[i / 37] << 4;
}
}
inline void doplasma(char * scrn)
{
char xbuf0[40], xbuf1[40];
char ybuf0[25], ybuf1[25];
char c2a = c2A >> 8;
char c2b = c2B >> 8;
char c1a = c1A >> 8;
char c1b = c1B >> 8;
for (char i = 0; i < 25; i++) {
ybuf0[i] = sintab[(c1a + c2a) & 0xff] + sintab[c1b];
c1a += 13;
c1b -= 5;
}
for (char i = 0; i < 40; i++) {
xbuf0[i] = sintab[(c2a + c1b) & 0xff] + sintab[c2b];
c2a += 11;
c2b -= 7;
}
c2a = c2B >> 8;
c2b = c3A >> 8;
c1a = c1B >> 8;
c1b = c3B >> 8;
for (char i = 0; i < 25; i++) {
ybuf1[i] = sintab[(c1b + c2a) & 0xff] + sintab[c1a];
c1a += 4;
c1b -= 6;
}
for (char i = 0; i < 40; i++) {
xbuf1[i] = sintab[(c2b + c1a) & 0xff] + sintab[c2a];
c2a += 7;
c2b -= 9;
}
#pragma unroll(full)
for (char k=0; k<5; k++)
{
char tbuf0[5], tbuf1[5];
#pragma unroll(full)
for (char i = 0; i < 4; i++)
{
tbuf0[i] = ybuf0[5 * k + i + 1] - ybuf0[5 * k + i];
tbuf1[i] = ybuf1[5 * k + i + 1] - ybuf1[5 * k + i];
}
for (signed char i = 39; i >= 0; i--)
{
char t = xbuf0[i] + ybuf0[5 * k];
char u = xbuf1[i] + ybuf1[5 * k];
#pragma unroll(full)
for (char j = 0; j < 5; j++)
{
scrn[40 * j + 200 * k + i] = colormap0[u] | colormap1[u];
t += tbuf0[j];
u += tbuf1[j];
}
}
}
c1A += 8 * ((int)sintab[d1A] - 128);
c1B += 16 * ((int)sintab[d1B] - 128);
c2A += 8 * ((int)sintab[d2A] - 128);
c2B += 16 * ((int)sintab[d2B] - 128);
c3A += 6 * ((int)sintab[d3A] - 128);
c3B += 12 * ((int)sintab[d3B] - 128);
d1A += 3;
d1B += rand() & 3;
d2A += 5;
d2B += rand() & 3;
d3A += 2;
d3B += rand() & 3;
}
void doplasma0(void)
{
doplasma(Screen0);
}
void doplasma1(void)
{
doplasma(Screen1);
}
unsigned checksum(const char * scr)
{
unsigned s = 0x1234;
for(int i=0; i<1024; i++)
{
unsigned m = s & 1;
s >>= 1;
if (m)
s ^= 0x2152;
s ^= scr[i];
}
return s;
}
int main(void)
{
inithires();
doplasma0();
doplasma1();
doplasma0();
doplasma1();
doplasma0();
doplasma1();
return checksum(Screen0) + checksum(Screen1) - 16337;
}

View File

@ -0,0 +1,39 @@
#include <assert.h>
struct X
{
int a;
};
X x[5] = {
{1}, {2}, {3}, {4}, {5}
};
X * y;
int main(void)
{
y = x;
assert(y == x);
y = x + 1;
assert(y == x + 1);
y = &(x[2]);
assert(y == x + 2);
y = x + 3;
assert(y == &(x[3]));
y = x ;
assert(y == (struct X*)x);
y = x;
assert(x == y);
y = x + 1;
assert(x + 1 == y);
y = &(x[2]);
assert(x + 2 == y);
y = x + 3;
assert(&(x[3]) == y);
y = x ;
assert((struct X*)x == y);
return 0;
}

37
autotest/ptrinittest.c Normal file
View File

@ -0,0 +1,37 @@
#if 1
const struct A {
char w;
int b[5];
struct {
int c[5];
} o;
} a = {22,
{4, 5, 6, 7, 8},
{
{4, 5, 6, 7, 8}
}
};
const int * t[4] = {
a.b + 1 + 1
};
const int * v[4] = {
a.o.c + 1 + 1
};
int q[5] = {4, 5, 6, 7, 8};
const int * u[4] = {
q + 2
};
int main(void)
{
return
u[0][0] + (q + 2)[2] - 6 - 8 +
v[0][0] + (a.o.c + 2)[2] - 6 - 8 +
t[0][0] + (a.b + 2)[2] - 6 - 8;
}

83
autotest/qsorttest.c Normal file
View File

@ -0,0 +1,83 @@
#include <string.h>
#include <stdio.h>
#include <assert.h>
struct Node
{
int a;
char s[10];
};
void qsort(Node * n, int s)
{
if (s > 1)
{
Node pn = n[0];
int pi = 0;
for(int i=1; i<s; i++)
{
if (strcmp(n[i].s, pn.s) < 0)
{
n[pi] = n[i];
pi++;
n[i] = n[pi];
}
}
n[pi] = pn;
qsort(n, pi);
qsort(n + pi + 1, s - pi - 1);
}
}
void shuffle(Node * n, int s)
{
for(int i=0; i<s; i++)
{
int t = rand() % s;
Node nt = n[i]; n[i] = n[t]; n[t] = nt;
}
}
void init(Node * n, int s)
{
for(int i=0; i<s; i++)
{
n[i].a = i;
sprintf(n[i].s, "%.5d", i);
}
}
static const int size = 1000;
Node field[size];
void show(Node * n, int s)
{
for(int i=0; i<s; i++)
{
printf("%3d : %3d, %s\n", i, n[i].a, n[i].s);
}
printf("\n");
}
void check(Node * n, int s)
{
for(int i=0; i<s; i++)
{
assert(n[i].a == i);
}
}
int main(void)
{
init(field, size);
// show(field, size);
shuffle(field, size);
// show(field, size);
qsort(field, size);
// show(field, size);
check(field, size);
return 0;
}

16
autotest/randsumtest.c Normal file
View File

@ -0,0 +1,16 @@
// randsumtest
#include <stdlib.h>
#include <assert.h>
int main(void)
{
long lsum = 0;
for(unsigned i=0; i<1000; i++)
lsum += rand();
assert(lsum == 32157742L);
return 0;
}

View File

@ -1,6 +1,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h>
int fib(int a) int fib(int a)
{ {

76
autotest/rolrortest.cpp Normal file
View File

@ -0,0 +1,76 @@
#include <assert.h>
__noinline unsigned long rollright32(unsigned long a) {
unsigned long tmp = a & 1;
return ( a >> 1) + (tmp << 31);
}
__noinline unsigned rollright16(unsigned a) {
unsigned tmp = a & 1;
return ( a >> 1) + (tmp << 15);
}
__noinline char rollright8(char a) {
char tmp = a & 1;
return ( a >> 1) + (tmp << 7);
}
__noinline unsigned long rollleft32(unsigned long a) {
unsigned long tmp = (a >> 31) & 1;
return ( a << 1) + tmp;
}
__noinline unsigned rollleft16(unsigned a) {
unsigned tmp = (a >> 15) & 1;
return ( a << 1) + tmp;
}
__noinline char rollleft8(char a) {
char tmp = (a >> 7) & 1;
return ( a << 1) + tmp;
}
int main() {
unsigned long lv = 0x12345678ul;
unsigned val = 0x1234;
char c=0x12;
unsigned long lvt[33];
unsigned valt[17];
char ct[9];
lvt[0] = lv;
valt[0] = val;
ct[0] = c;
assert(rollleft8(rollright8(c)) == c);
assert(rollleft16(rollright16(val)) == val);
assert(rollleft32(rollright32(lv)) == lv);
for(int i=0; i<32; i++)
lvt[i + 1] = rollright32(lvt[i]);
for(int i=0; i<16; i++)
valt[i + 1] = rollright16(valt[i]);
for(int i=0; i<8; i++)
ct[i + 1] = rollright8(ct[i]);
for(int i=0; i<=32; i++)
{
assert(lvt[32 - i] == lv);
lv = rollleft32(lv);
}
for(int i=0; i<=16; i++)
{
assert(valt[16 - i] == val);
val = rollleft16(val);
}
for(int i=0; i<=8; i++)
{
assert(ct[8 - i] == c);
c = rollleft8(c);
}
return 0;
}

107
autotest/scrolltest.c Normal file
View File

@ -0,0 +1,107 @@
#include <assert.h>
#define Screen ((char *)0x0400)
void scroll_left(void)
{
char * dp = Screen;
for(char y=0; y<25; y++)
{
for(char x=0; x<39; x++)
{
dp[x] = dp[x + 1];
}
dp += 40;
}
}
void scroll_right(void)
{
char * dp = Screen;
for(char y=0; y<25; y++)
{
for(char x=39; x>0; x--)
{
dp[x] = dp[x - 1];
}
dp += 40;
}
}
void scroll_up(void)
{
char * dp = Screen, * sp = dp + 40;
for(char y=0; y<24; y++)
{
for(char x=0; x<40; x++)
{
dp[x] = sp[x];
}
dp = sp;
sp += 40;
}
}
void scroll_down(void)
{
char * dp = Screen + 24 * 40, * sp = dp - 40;
for(char y=0; y<24; y++)
{
for(char x=0; x<40; x++)
{
dp[x] = sp[x];
}
dp = sp;
sp -= 40;
}
}
void fill_screen(void)
{
for(char y=0; y<25; y++)
{
for(char x=0; x<40; x++)
{
Screen[40 * y + x] = 7 * y + x;
}
}
}
void check_screen(int dy, int dx)
{
for(int y=0; y<25; y++)
{
for(int x=0; x<40; x++)
{
int sy = y + dy;
int sx = x + dx;
char c = 7 * y + x;
if (sy >= 0 && sy < 25 && sx >= 0 && sx < 40)
c = 7 * sy + sx;
assert(Screen[40 * y + x] == c);
}
}
}
int main(void)
{
fill_screen();
scroll_left();
check_screen(0, 1);
fill_screen();
scroll_right();
check_screen(0, -1);
fill_screen();
scroll_up();
check_screen(1, 0);
fill_screen();
scroll_down();
check_screen(-1, 0);
return 0;
}

321
autotest/sprintftest.c Normal file
View File

@ -0,0 +1,321 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
void testi(const char * fmt, int val, const char * tst)
{
char buffer[32];
sprintf(buffer, fmt, val);
printf("%s:%s\n", buffer, tst);
assert(!strcmp(buffer, tst));
}
void testu(const char * fmt, unsigned val, const char * tst)
{
char buffer[32];
sprintf(buffer, fmt, val);
printf("%s:%s\n", buffer, tst);
assert(!strcmp(buffer, tst));
}
void testil(const char * fmt, long val, const char * tst)
{
char buffer[32];
sprintf(buffer, fmt, val);
printf("%s:%s\n", buffer, tst);
assert(!strcmp(buffer, tst));
}
void testul(const char * fmt, unsigned long val, const char * tst)
{
char buffer[32];
sprintf(buffer, fmt, val);
printf("%s:%s\n", buffer, tst);
assert(!strcmp(buffer, tst));
}
void testf(const char * fmt, float val, const char * tst)
{
char buffer[32];
sprintf(buffer, fmt, val);
printf("%s:%s\n", buffer, tst);
assert(!strcmp(buffer, tst));
}
int main(void)
{
testi("%d", 0, "0");
testi("%d", 1, "1");
testi("%d", -1, "-1");
testi("%d", 12, "12");
testi("%d", 123, "123");
testi("%d", 1234, "1234");
testi("%d", 12345, "12345");
testi("%d", -12345, "-12345");
testi("%d", 32767, "32767");
testi("%d", -32768, "-32768");
testi("%3d", 0, " 0");
testi("%3d", 1, " 1");
testi("%3d", -1, " -1");
testi("%3d", 12, " 12");
testi("%3d", 123, "123");
testi("%3d", 1234, "1234");
testi("%3d", 12345, "12345");
testi("%3d", -12345, "-12345");
testi("%3d", 32767, "32767");
testi("%3d", -32768, "-32768");
testi("%03d", 0, "000");
testi("%03d", 1, "001");
// testi("%03d", -1, "-01");
testi("%03d", 12, "012");
testi("%03d", 123, "123");
testi("%03d", 1234, "1234");
testi("%03d", 12345, "12345");
testi("%03d", -12345, "-12345");
testi("%03d", 32767, "32767");
testi("%03d", -32768, "-32768");
testi("%-4d", 0, "0 ");
testi("%-4d", 1, "1 ");
testi("%-4d", -1, "-1 ");
testi("%-4d", 12, "12 ");
testi("%-4d", 123, "123 ");
testi("%-4d", 1234, "1234");
testi("%-4d", 12345, "12345");
testi("%-4d", -12345, "-12345");
testi("%-4d", 32767, "32767");
testi("%-4d", -32768, "-32768");
testi("%+d", 0, "+0");
testi("%+d", 1, "+1");
testi("%+d", -1, "-1");
testi("%+d", 12, "+12");
testi("%+d", 123, "+123");
testi("%+d", 1234, "+1234");
testi("%+d", 12345, "+12345");
testi("%+d", -12345, "-12345");
testi("%+d", 32767, "+32767");
testi("%+d", -32768, "-32768");
testil("%ld", 0l, "0");
testil("%ld", 1l, "1");
testil("%ld", -1l, "-1");
testil("%ld", 12l, "12");
testil("%ld", 123l, "123");
testil("%ld", 1234l, "1234");
testil("%ld", 12345l, "12345");
testil("%ld", -12345l, "-12345");
testil("%ld", 32767l, "32767");
testil("%ld", -32768l, "-32768");
testil("%ld", 2147483647l, "2147483647");
testil("%ld", -2147483648l, "-2147483648");
testil("%3ld", 0l, " 0");
testil("%3ld", 1l, " 1");
testil("%3ld", -1l, " -1");
testil("%3ld", 12l, " 12");
testil("%3ld", 123l, "123");
testil("%3ld", 1234l, "1234");
testil("%3ld", 12345l, "12345");
testil("%3ld", -12345l, "-12345");
testil("%3ld", 32767l, "32767");
testil("%3ld", -32768l, "-32768");
testil("%3ld", 2147483647l, "2147483647");
testil("%3ld", -2147483648l, "-2147483648");
testil("%03ld", 0l, "000");
testil("%03ld", 1l, "001");
// testil("%03ld", -1l, "-01");
testil("%03ld", 12l, "012");
testil("%03ld", 123l, "123");
testil("%03ld", 1234l, "1234");
testil("%03ld", 12345l, "12345");
testil("%03ld", -12345l, "-12345");
testil("%03ld", 32767l, "32767");
testil("%03ld", -32768l, "-32768");
testil("%03ld", 2147483647l, "2147483647");
testil("%03ld", -2147483648l, "-2147483648");
testil("%-4ld", 0l, "0 ");
testil("%-4ld", 1l, "1 ");
testil("%-4ld", -1l, "-1 ");
testil("%-4ld", 12l, "12 ");
testil("%-4ld", 123l, "123 ");
testil("%-4ld", 1234l, "1234");
testil("%-4ld", 12345l, "12345");
testil("%-4ld", -12345l, "-12345");
testil("%-4ld", 32767l, "32767");
testil("%-4ld", -32768l, "-32768");
testil("%-4ld", 2147483647l, "2147483647");
testil("%-4ld", -2147483648l, "-2147483648");
testil("%+ld", 0l, "+0");
testil("%+ld", 1l, "+1");
testil("%+ld", -1l, "-1");
testil("%+ld", 12l, "+12");
testil("%+ld", 123l, "+123");
testil("%+ld", 1234l, "+1234");
testil("%+ld", 12345l, "+12345");
testil("%+ld", -12345l, "-12345");
testil("%+ld", 32767l, "+32767");
testil("%+ld", -32768l, "-32768");
testil("%+ld", 2147483647l, "+2147483647");
testil("%+ld", -2147483648l, "-2147483648");
testu("%u", 0, "0");
testu("%u", 1, "1");
testu("%u", 12, "12");
testu("%u", 123, "123");
testu("%u", 1234, "1234");
testu("%u", 12345, "12345");
testu("%u", 32767, "32767");
testu("%u", 32768, "32768");
testu("%u", 65535, "65535");
testu("%x", 0, "0");
testu("%x", 0x49bf, "49BF");
testu("%x", 0xffff, "FFFF");
testu("%3u", 0, " 0");
testu("%3u", 1, " 1");
testu("%3u", 12, " 12");
testu("%3u", 123, "123");
testu("%3u", 1234, "1234");
testu("%3u", 12345, "12345");
testu("%3u", 32767, "32767");
testu("%3u", 32768, "32768");
testu("%3u", 65535, "65535");
testu("%3x", 0, " 0");
testu("%3x", 0x49bf, "49BF");
testu("%3x", 0xffff, "FFFF");
testu("%03u", 0, "000");
testu("%03u", 1, "001");
testu("%03u", 12, "012");
testu("%03u", 123, "123");
testu("%03u", 1234, "1234");
testu("%03u", 12345, "12345");
testu("%03u", 32767, "32767");
testu("%03u", 32768, "32768");
testu("%03u", 65535, "65535");
testu("%03x", 0, "000");
testu("%03x", 0x49bf, "49BF");
testu("%03x", 0xffff, "FFFF");
testu("%-4u", 0, "0 ");
testu("%-4u", 1, "1 ");
testu("%-4u", 12, "12 ");
testu("%-4u", 123, "123 ");
testu("%-4u", 1234, "1234");
testu("%-4u", 12345, "12345");
testu("%-4u", 32767, "32767");
testu("%-4u", 32768, "32768");
testu("%-4u", 65535, "65535");
testu("%-4x", 0, "0 ");
testu("%-4x", 0x49bf, "49BF");
testu("%-4x", 0xffff, "FFFF");
testul("%3lu", 0l, " 0");
testul("%3lu", 1l, " 1");
testul("%3lu", 12l, " 12");
testul("%3lu", 123l, "123");
testul("%3lu", 1234l, "1234");
testul("%3lu", 12345l, "12345");
testul("%3lu", 32767l, "32767");
testul("%3lu", 2147483647l, "2147483647");
testul("%3lu", 4294967295l, "4294967295");
testul("%3lx", 0, " 0");
testul("%3lx", 0x3576fbcdl, "3576FBCD");
testul("%3lx", 0xffffffffl, "FFFFFFFF");
testul("%03lu", 0l, "000");
testul("%03lu", 1l, "001");
testul("%03lu", 12l, "012");
testul("%03lu", 123l, "123");
testul("%03lu", 1234l, "1234");
testul("%03lu", 12345l, "12345");
testul("%03lu", 32767l, "32767");
testul("%03lu", 2147483647l, "2147483647");
testul("%03lu", 4294967295l, "4294967295");
testul("%03lx", 0, "000");
testul("%03lx", 0x3576fbcdl, "3576FBCD");
testul("%03lx", 0xffffffffl, "FFFFFFFF");
testul("%-4lu", 0l, "0 ");
testul("%-4lu", 1l, "1 ");
testul("%-4lu", 12l, "12 ");
testul("%-4lu", 123l, "123 ");
testul("%-4lu", 1234l, "1234");
testul("%-4lu", 12345l, "12345");
testul("%-4lu", 32767l, "32767");
testul("%-4lu", 2147483647l, "2147483647");
testul("%-4lu", 4294967295l, "4294967295");
testul("%-4lx", 0, "0 ");
testul("%-4lx", 0x3576fbcdl, "3576FBCD");
testul("%-4lx", 0xffffffffl, "FFFFFFFF");
testul("%+lu", 0l, "+0");
testul("%+lu", 1l, "+1");
testul("%+lu", 12l, "+12");
testul("%+lu", 123l, "+123");
testul("%+lu", 1234l, "+1234");
testul("%+lu", 12345l, "+12345");
testul("%+lu", 32767l, "+32767");
testul("%+lu", 2147483647l, "+2147483647");
testul("%+lu", 4294967295l, "+4294967295");
testf("%f", 0., "0.000000");
testf("%f", 1., "1.000000");
testf("%f", -1., "-1.000000");
testf("%f", 12., "12.000000");
testf("%f", 123., "123.000000");
testf("%f", 1234., "1234.000000");
testf("%f", 12345., "12345.000000");
testf("%f", 123456., "123456.000000");
testf("%f", 1234567., "1234567.000000");
testf("%f", 0.1, "0.100000");
testf("%f", 0.01, "0.010000");
testf("%f", 0.001, "0.001000");
testf("%f", 0.0001, "0.000100");
testf("%f", 0.00001, "0.000010");
testf("%f", 0.000001, "0.000001");
testf("%5.1f", 0, " 0.0");
testf("%5.1f", 1, " 1.0");
testf("%5.1f", -1, " -1.0");
testf("%5.1f", 10, " 10.0");
testf("%5.1f", -10, "-10.0");
testf("%5.1f", 100, "100.0");
testf("%5.1f", -100, "-100.0");
testf("%5.1f", 0.1, " 0.1");
testf("%5.1f", -0.1, " -0.1");
testf("%5.1f", 0.04, " 0.0");
testf("%5.1f", -0.04, " -0.0");
testf("%5.1f", 0.051, " 0.1");
testf("%5.1f", -0.051, " -0.1");
testf("%+5.1f", 0, " +0.0");
testf("%+5.1f", 1, " +1.0");
testf("%+5.1f", -1, " -1.0");
testf("%+5.1f", 10, "+10.0");
testf("%+5.1f", -10, "-10.0");
testf("%+5.1f", 100, "+100.0");
testf("%+5.1f", -100, "-100.0");
testf("%+5.1f", 0.1, " +0.1");
testf("%+5.1f", -0.1, " -0.1");
testf("%+5.1f", 0.04, " +0.0");
testf("%+5.1f", -0.04, " -0.0");
testf("%+5.1f", 0.051, " +0.1");
testf("%+5.1f", -0.051, " -0.1");
return 0;
}

View File

@ -1,5 +1,6 @@
// stdlibtest // stdlibtest
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -50,16 +51,15 @@ void heapcheck(void)
for(i=0; i<s; i++) for(i=0; i<s; i++)
{ {
if (p[i] != n) if (p[i] != n)
{
printf("MemError %d at %d:%d != %d\n", k, i, n, p[i]);
exit(-2); exit(-2);
} }
}
free(memp[n]); free(memp[n]);
s = rand() % 100 + 3; s = rand() % 100 + 3;
mems[n] = s; mems[n] = s;
memp[n] = malloc(s); memp[n] = malloc(s);
if (!memp[n])
exit(-3);
memset(memp[n], n, s); memset(memp[n], n, s);
} }
} }

28
autotest/strcmptest2.c Normal file
View File

@ -0,0 +1,28 @@
#include <string.h>
#include <assert.h>
char aa[2000], ba[2000];
int main(void)
{
assert(strcmp("abcdefgh", "abcdefgh") == 0);
assert(strcmp("abcdefgh", "abcdemgh") < 0);
assert(strcmp("abcdefgh", "abcdefghi") < 0);
assert(strcmp("abcdefghi", "abcdefgh") > 0);
assert(strcmp("abcdemgh", "abcdefgh") > 0);
for(int i=0; i<1900; i++)
{
aa[i] = 'a' + (i & 7);
}
aa[1900] = 0;
strcpy(ba, aa);
assert(strcmp(aa, ba) == 0);
ba[1000] = 'z';
assert(strcmp(aa, ba) < 0);
assert(strcmp(ba, aa) > 0);
return 0;
}

299
autotest/stripedarraytest.c Normal file
View File

@ -0,0 +1,299 @@
#include <assert.h>
int a100[100];
__striped int b100[100];
__striped int c100[100];
unsigned a256[256];
__striped unsigned b256[256];
__striped unsigned c256[256];
#pragma align(c100, 256)
#pragma align(c256, 256)
void test_ab100(void)
{
for(char i=0; i<100; i++)
{
a100[i] = i * i;
b100[i] = i * i;
c100[i] = i * i;
}
a100[31] = 4711;
b100[31] = 4711;
c100[31] = 4711;
for(char i=0; i<100; i++)
{
a100[i] += i; a100[i] -= 5; a100[i] = a100[i] + a100[99 - i];
b100[i] += i; b100[i] -= 5; b100[i] = b100[i] + b100[99 - i];
c100[i] += i; c100[i] -= 5; c100[i] = c100[i] + c100[99 - i];
}
for(char i=0; i<100; i++)
{
assert(a100[i] == b100[i]);
assert(a100[i] == c100[i]);
}
}
void test_ab256(void)
{
for(unsigned i=0; i<256; i++)
{
a256[i] = i * i;
b256[i] = i * i;
c256[i] = i * i;
}
a256[31] = 4711;
b256[31] = 4711;
c256[31] = 4711;
for(unsigned i=0; i<256; i++)
{
a256[i] += i; a256[i] -= 5; a256[i] = a256[i] + a256[255 - i];
b256[i] += i; b256[i] -= 5; b256[i] = b256[i] + b256[255 - i];
c256[i] += i; c256[i] -= 5; c256[i] = c256[i] + c256[255 - i];
}
for(unsigned i=0; i<256; i++)
{
assert(a256[i] == b256[i]);
assert(a256[i] == c256[i]);
}
}
long la50[50];
__striped long lb50[50];
__striped long lc50[50];
unsigned long la256[256];
__striped unsigned long lb256[256];
__striped unsigned long lc256[256];
#pragma align(lc50, 256)
#pragma align(lc256, 256)
void test_lab50(void)
{
for(char i=0; i<50; i++)
{
long j = i * i;
la50[i] = j * j;
lb50[i] = j * j;
lc50[i] = j * j;
}
la50[31] = 47110815l;
lb50[31] = 47110815l;
lc50[31] = 47110815l;
for(char i=0; i<50; i++)
{
la50[i] += i; la50[i] -= 12345678l; la50[i] = la50[i] + la50[49 - i];
lb50[i] += i; lb50[i] -= 12345678l; lb50[i] = lb50[i] + lb50[49 - i];
lc50[i] += i; lc50[i] -= 12345678l; lc50[i] = lc50[i] + lc50[49 - i];
}
for(char i=0; i<50; i++)
{
assert(la50[i] == lb50[i]);
assert(la50[i] == lc50[i]);
}
}
void test_lab256(void)
{
for(unsigned i=0; i<256; i++)
{
unsigned long j = i * i;
la256[i] = j * j;
lb256[i] = j * j;
lc256[i] = j * j;
}
la256[31] = 47110815ul;
lb256[31] = 47110815ul;
lc256[31] = 47110815ul;
for(unsigned i=0; i<256; i++)
{
la256[i] += i; la256[i] -= 12345678ul; la256[i] = la256[i] + la256[255 - i];
lb256[i] += i; lb256[i] -= 12345678ul; lb256[i] = lb256[i] + lb256[255 - i];
lc256[i] += i; lc256[i] -= 12345678ul; lc256[i] = lc256[i] + lc256[255 - i];
}
for(unsigned i=0; i<256; i++)
{
assert(la256[i] == lb256[i]);
assert(la256[i] == lc256[i]);
}
}
float fa50[50];
__striped float fb50[50];
__striped float fc50[50];
float fa256[256];
__striped float fb256[256];
__striped float fc256[256];
#pragma align(fc50, 256)
#pragma align(fc256, 256)
void test_fab50(void)
{
for(char i=0; i<50; i++)
{
fa50[i] = i * i;
fb50[i] = i * i;
fc50[i] = i * i;
}
fa50[31] = 4711.0815;
fb50[31] = 4711.0815;
fc50[31] = 4711.0815;
for(char i=0; i<50; i++)
{
fa50[i] += i; fa50[i] -= 1234.5678; fa50[i] = fa50[i] + fa50[49 - i];
fb50[i] += i; fb50[i] -= 1234.5678; fb50[i] = fb50[i] + fb50[49 - i];
fc50[i] += i; fc50[i] -= 1234.5678; fc50[i] = fc50[i] + fc50[49 - i];
}
for(char i=0; i<50; i++)
{
assert(fa50[i] == fb50[i]);
assert(fa50[i] == fc50[i]);
}
}
void test_fab256(void)
{
for(unsigned i=0; i<256; i++)
{
fa256[i] = i * i;
fb256[i] = i * i;
fc256[i] = i * i;
}
fa256[31] = 4711.0815;
fb256[31] = 4711.0815;
fc256[31] = 4711.0815;
for(unsigned i=0; i<256; i++)
{
fa256[i] += i; fa256[i] -= 1234.5678; fa256[i] = fa256[i] + fa256[255 - i];
fb256[i] += i; fb256[i] -= 1234.5678; fb256[i] = fb256[i] + fb256[255 - i];
fc256[i] += i; fc256[i] -= 1234.5678; fc256[i] = fc256[i] + fc256[255 - i];
}
for(unsigned i=0; i<256; i++)
{
assert(fa256[i] == fb256[i]);
assert(fa256[i] == fc256[i]);
}
}
unsigned da50[50], db50[50], dc50[50];
unsigned * pa50[50];
__striped unsigned * pb50[50];
__striped unsigned * pc50[50];
#pragma align(pc50, 256)
void test_pab50(void)
{
for(char i=0; i<50; i++)
{
pa50[i] = da50 + (i * 17) % 50;
pb50[i] = db50 + (i * 17) % 50;
pc50[i] = dc50 + (i * 17) % 50;
}
for(char i=0; i<50; i++)
{
*pa50[i] = i * i;
*pb50[i] = i * i;
*pc50[i] = i * i;
}
for(char i=0; i<50; i++)
{
*pa50[i] += i; *pa50[i] -= 5; *pa50[i] = *pa50[i] + *pa50[49 - i];
*pb50[i] += i; *pb50[i] -= 5; *pb50[i] = *pb50[i] + *pb50[49 - i];
*pc50[i] += i; *pc50[i] -= 5; *pc50[i] = *pc50[i] + *pc50[49 - i];
}
for(char i=0; i<50; i++)
{
assert(*pa50[i] == *pb50[i]);
assert(*pa50[i] == *pc50[i]);
assert(da50[i] == db50[i]);
assert(da50[i] == dc50[i]);
}
}
unsigned da50_4[50][4], db50_4[50][4], dc50_4[50][4];
void test_pab50_4(void)
{
for(char i=0; i<50; i++)
{
pa50[i] = da50_4[(i * 17) % 50];
pb50[i] = db50_4[(i * 17) % 50];
pc50[i] = dc50_4[(i * 17) % 50];
}
for(char k=0; k<4; k++)
{
for(char i=0; i<50; i++)
{
pa50[i][k] = i * i;
pb50[i][k] = i * i;
pc50[i][k] = i * i;
}
}
for(char k=0; k<4; k++)
{
for(char i=0; i<50; i++)
{
pa50[i][k] += i; pa50[i][k] -= 5; pa50[i][k] = pa50[i][k] + pa50[49 - i][k];
pb50[i][k] += i; pb50[i][k] -= 5; pb50[i][k] = pb50[i][k] + pb50[49 - i][k];
pc50[i][k] += i; pc50[i][k] -= 5; pc50[i][k] = pc50[i][k] + pc50[49 - i][k];
}
}
for(char k=0; k<4; k++)
{
for(char i=0; i<50; i++)
{
assert(pa50[i][k] == pb50[i][k]);
assert(pa50[i][k] == pc50[i][k]);
assert(da50_4[i][k] == db50_4[i][k]);
assert(da50_4[i][k] == dc50_4[i][k]);
}
}
}
int main(void)
{
test_ab100();
test_ab256();
test_lab50();
test_lab256();
test_fab50();
test_fab256();
test_pab50();
test_pab50_4();
return 0;
}

27
autotest/strlen.c Normal file
View File

@ -0,0 +1,27 @@
#include <string.h>
#include <assert.h>
char lstr[1025];
int main(void)
{
#if 1
assert(strlen("") == 0);
assert(strlen("1") == 1);
assert(strlen("12") == 2);
assert(strlen("123") == 3);
assert(strlen("1234") == 4);
assert(strlen("12345") == 5);
assert(strlen("123456") == 6);
#endif
#if 1
char * dp = lstr;
for(int i=0; i<1024; i++)
{
*dp = 0;
assert(strlen(lstr) == i);
*dp++ = 'a';
}
#endif
return 0;
}

View File

@ -0,0 +1,49 @@
struct Point
{
int x, y;
};
Point tcorners[8], pcorners[8];
int bm_line(void)
{
return 0;
}
void drawCube(void)
{
for(char i=0; i<8; i++)
{
if (!(i & 1))
bm_line();
if (!(i & 2))
bm_line();
if (!(i & 4))
bm_line();
pcorners[i] = tcorners[i];
}
}
int main(void)
{
for(int i=0; i<8; i++)
{
tcorners[i].x = (i + 1) * 3;
tcorners[i].y = (i + 1) * 7;
}
drawCube();
int sum = 0;
for(int i=0; i<8; i++)
{
sum += pcorners[i].x;
sum -= tcorners[i].y;
}
return sum + 144;
}

View File

@ -0,0 +1,31 @@
#include <stdio.h>
struct Vec3
{
float x, y, z;
};
Vec3 v;
Vec3 vadd(Vec3 s1, Vec3 s2)
{
Vec3 r;
r.x = s1.x + s2.x;
r.y = s1.y + s2.y;
r.z = s1.z + s2.z;
return r;
}
int main(void)
{
Vec3 m = {1, 2, -3}, u = {4, 5, -9}, t = {7, -2, -5};
v.x = 99;
v.y = 100;
v.z = 101;
v = vadd(m, vadd(u, t));
return v.x + v.y + v.z;
}

View File

@ -0,0 +1,50 @@
#include <assert.h>
struct A
{
int x[100], y[100];
};
struct V
{
int x, y, z;
};
void copy(A * a)
{
for(int i=0; i<100; i++)
a->x[i] = a->y[i];
}
void shuffle(V * v)
{
for(int i=0; i<100; i++)
v[i].x = v[i].y;
}
int main(void)
{
A a;
V v[100];
for(int i=0; i<100; i++)
{
a.y[i] = i;
v[i].y = i;
}
copy(&a);
shuffle(v);
for(int i=0; i<100; i++)
{
assert(a.x[i] == i);
assert(v[i].x == i);
}
return 0;
}

View File

@ -0,0 +1,25 @@
struct A
{
int x;
struct B
{
int m;
struct C
{
int w;
} c;
} b;
} q;
int test(A * a)
{
a->b.c.w = 1;
return a->b.c.w;
}
int main(void)
{
return test(&q) - 1;
}

48
autotest/switchlooptest.c Normal file
View File

@ -0,0 +1,48 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char text[14];
for(char i=0; i<12; i++)
{
switch (i)
{
case 0:
text[i] = 'H';
break;
case 1:
text[i] = 'E';
break;
case 2:
case 3:
case 9:
text[i] = 'L';
break;
case 4:
case 7:
text[i] = 'O';
break;
case 5:
text[i] = ' ';
break;
case 6:
text[i] = 'W';
break;
case 8:
text[i] = 'R';
break;
case 10:
text[i] = 'D';
break;
default:
text[i] = 0;
}
}
printf("<%s>\n", text);
return 0;
}

426
autotest/testint16cmp.c Normal file
View File

@ -0,0 +1,426 @@
#include <stdio.h>
#include <assert.h>
bool beq(int a, int b)
{
return a == b;
}
bool blt(int a, int b)
{
return a < b;
}
bool bgt(int a, int b)
{
return a > b;
}
bool ble(int a, int b)
{
return a <= b;
}
bool bge(int a, int b)
{
return a >= b;
}
bool neq(int a, int b)
{
return a == b;
}
#pragma native(neq)
bool nlt(int a, int b)
{
return a < b;
}
#pragma native(nlt)
bool ngt(int a, int b)
{
return a > b;
}
#pragma native(ngt)
bool nle(int a, int b)
{
return a <= b;
}
#pragma native(nle)
bool nge(int a, int b)
{
return a >= b;
}
#pragma native(nge)
bool beqz(int a)
{
return a == 0;
}
bool bltz(int a)
{
return a < 0;
}
bool bgtz(int a)
{
return a > 0;
}
bool blez(int a)
{
return a <= 0;
}
bool bgez(int a)
{
return a >= 0;
}
bool neqz(int a)
{
return a == 0;
}
#pragma native(neqz)
bool nltz(int a)
{
return a < 0;
}
#pragma native(nltz)
bool ngtz(int a)
{
return a > 0;
}
#pragma native(ngtz)
bool nlez(int a)
{
return a <= 0;
}
#pragma native(nlez)
bool ngez(int a)
{
return a >= 0;
}
#pragma native(ngez)
bool bequz(unsigned a)
{
return a == 0;
}
bool bltuz(unsigned a)
{
return a < 0;
}
bool bgtuz(unsigned a)
{
return a > 0;
}
bool bleuz(unsigned a)
{
return a <= 0;
}
bool bgeuz(unsigned a)
{
return a >= 0;
}
bool nequz(unsigned a)
{
return a == 0;
}
#pragma native(nequz)
bool nltuz(unsigned a)
{
return a < 0;
}
#pragma native(nltuz)
bool ngtuz(unsigned a)
{
return a > 0;
}
#pragma native(ngtuz)
bool nleuz(unsigned a)
{
return a <= 0;
}
#pragma native(nleuz)
bool ngeuz(unsigned a)
{
return a >= 0;
}
#pragma native(ngeuz)
bool beq1(int a)
{
return a == 1;
}
bool blt1(int a)
{
return a < 1;
}
bool bgt1(int a)
{
return a > 1;
}
bool ble1(int a)
{
return a <= 1;
}
bool bge1(int a)
{
return a >= 1;
}
bool neq1(int a)
{
return a == 1;
}
#pragma native(neq1)
bool nlt1(int a)
{
return a < 1;
}
#pragma native(nlt1)
bool ngt1(int a)
{
return a > 1;
}
#pragma native(ngt1)
bool nle1(int a)
{
return a <= 1;
}
#pragma native(nle1)
bool nge1(int a)
{
return a >= 1;
}
#pragma native(nge1)
void cmp(int a, int b)
{
bool beqf = beq(a, b), bltf = blt(a, b), bgtf = bgt(a, b), blef = ble(a, b), bgef = bge(a, b);
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
printf("BYTE %d, %d : EQ %d LT %d GT %d\r", a, b, beqf, bltf, bgtf);
printf("NATIVE %d, %d : EQ %d LT %d GT %d\r", a, b, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpz(int a)
{
bool beqf = beqz(a), bltf = bltz(a), bgtf = bgtz(a), blef = blez(a), bgef = bgez(a);
bool neqf = neqz(a), nltf = nltz(a), ngtf = ngtz(a), nlef = nlez(a), ngef = ngez(a);
printf("BYTE %d, 0 : EQ %d LT %d GT %d\r", a, beqf, bltf, bgtf);
printf("NATIVE %d, 0 : EQ %d LT %d GT %d\r", a, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpuz(unsigned a)
{
bool beqf = bequz(a), bltf = bltuz(a), bgtf = bgtuz(a), blef = bleuz(a), bgef = bgeuz(a);
bool neqf = nequz(a), nltf = nltuz(a), ngtf = ngtuz(a), nlef = nleuz(a), ngef = ngeuz(a);
printf("BYTE %u, 0 : EQ %u LT %d GT %u\r", a, beqf, bltf, bgtf);
printf("NATIVE %u, 0 : EQ %u LT %d GT %u\r", a, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmp1(int a)
{
bool beqf = beq1(a), bltf = blt1(a), bgtf = bgt1(a), blef = ble1(a), bgef = bge1(a);
bool neqf = neq1(a), nltf = nlt1(a), ngtf = ngt1(a), nlef = nle1(a), ngef = nge1(a);
printf("BYTE %d, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, beqf, bltf, bgtf, blef, bgef);
printf("NATIVE %d, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, neqf, nltf, ngtf, nlef, ngef);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
int main(void)
{
cmp( 0, 1);
cmp( 0, -1);
cmp( 1, 0);
cmp(-1, 0);
cmp(1, 1);
cmp(1, 2);
cmp(2, 1);
cmp(-1, -1);
cmp(-1, -2);
cmp(-2, -1);
cmp( 1, -1);
cmp( 1, -2);
cmp( 2, -1);
cmp(-1, 1);
cmp(-1, 2);
cmp(-2, 1);
cmp( 0, 10000);
cmp( 0, -10000);
cmp( 10000, 0);
cmp(-10000, 0);
cmp(10000, 10000);
cmp(10000, 20000);
cmp(20000, 10000);
cmp(-10000, -10000);
cmp(-10000, -20000);
cmp(-20000, -10000);
cmp( 10000, -10000);
cmp( 10000, -20000);
cmp( 20000, -10000);
cmp(-10000, 10000);
cmp(-10000, 20000);
cmp(-20000, 10000);
cmp(-30000, 30000);
cmp(-30000, -30000);
cmp( 30000, 30000);
cmp( 30000, -30000);
cmp( 0, 1024);
cmp( 0, -1024);
cmp( 1024, 0);
cmp(-1024, 0);
cmp(1024, 1024);
cmp(1024, 1025);
cmp(1025, 1024);
cmp(-1024, -1024);
cmp(-1024, -1025);
cmp(-1025, -1024);
cmp( 1024, -1024);
cmp( 1024, -1025);
cmp( 1025, -1024);
cmp(-1024, 1024);
cmp(-1024, 1025);
cmp(-1025, 1024);
cmpz(0);
cmpz(1);
cmpz(255);
cmpz(256);
cmpz(10000);
cmpz(20000);
cmpz(-1);
cmpz(-255);
cmpz(-256);
cmpz(-10000);
cmpz(-20000);
cmpuz(0);
cmpuz(1);
cmpuz(255);
cmpuz(256);
cmpuz(10000);
cmpuz(20000);
cmpuz(40000);
cmpuz(32767);
cmpuz(32768);
cmpuz(65535);
cmp1(0);
cmp1(1);
cmp1(2);
cmp1(3);
cmp1(255);
cmp1(256);
cmp1(10000);
cmp1(20000);
cmp1(-1);
cmp1(-2);
cmp1(-3);
cmp1(-255);
cmp1(-256);
cmp1(-10000);
cmp1(-20000);
return 0;
}

23
autotest/testint16mul.c Normal file
View File

@ -0,0 +1,23 @@
#include <assert.h>
int mul[32][32];
int main(void)
{
for(int i=0; i<32; i++)
for(int j=0; j<32; j++)
mul[i][j] = i * j;
#assign xi 0
#repeat
for(int j=0; j<32; j++)
{
assert(mul[xi][j] == xi * j);
assert(mul[j][xi] == j * xi);
}
#assign xi xi + 1
#until xi == 32
return 0;
}

166
autotest/testint32.c Normal file
View File

@ -0,0 +1,166 @@
#include <assert.h>
void testmuli(long a, long b, long ab)
{
assert (a * b == ab);
}
void testmulu(unsigned long a, unsigned long b, unsigned long ab)
{
assert (a * b == ab);
}
void testdivi(long a, long b, long ab)
{
assert (a / b == ab);
}
void shltesti(long a, long b, long ab)
{
assert (a << b == ab);
}
void shrtesti(long a, long b, long ab)
{
assert (a >> b == ab);
}
long sieve(long size)
{
bool sieve[1000];
for(long i=0; i<size; i+=2)
{
sieve[i] = false;
sieve[i+1] = true;
}
sieve[2] = true;
for (long i = 3; i * i < size;)
{
long j = i * i;
while (j < size)
{
sieve[j] = false;
j += 2 * i;
}
do {i++;} while (i < size && !sieve[i]);
}
long num = 0;
for(long i=0; i<size; i++)
{
if (sieve[i])
num++;
}
return num;
}
int main(void)
{
testmuli(0, 0, 0);
testmuli(1, 0, 0);
testmuli(0, 1, 0);
testmuli( 1, 1, 1);
testmuli(-1, 1, -1);
testmuli(-1, -1, 1);
testmuli( 1, -1, -1);
testmuli(5, 5, 25);
testmuli( 127, 255, 32385);
testmuli(-127, 255, -32385);
testmuli( 127, -255, -32385);
testmuli(-127, -255, 32385);
testmuli( 1237, 1024, 1266688l);
testmuli(-1237, 1024, -1266688l);
testmuli( 1237, -1024, -1266688l);
testmuli(-1237, -1024, 1266688l);
testmuli( 1024, 1237, 1266688l);
testmuli( 1024,-1237, -1266688l);
testmuli( -1024, 1237, -1266688l);
testmuli( -1024,-1237, 1266688l);
testmulu(0x00000001, 0x0000003c, 0x0000003c);
testmulu(0x00000100, 0x0000003c, 0x00003c00);
testmulu(0x00010000, 0x0000003c, 0x003c0000);
testmulu(0x01000000, 0x0000003c, 0x3c000000);
testmulu(0x0000003c, 0x00000001, 0x0000003c);
testmulu(0x0000003c, 0x00000100, 0x00003c00);
testmulu(0x0000003c, 0x00010000, 0x003c0000);
testmulu(0x0000003c, 0x01000000, 0x3c000000);
testmulu(0x0000004b, 0x0000003c, 0x00001194);
testmulu(0x00004b00, 0x0000003c, 0x00119400);
testmulu(0x004b0000, 0x0000003c, 0x11940000);
testmulu(0x4b000000, 0x0000003c, 0x94000000);
testmulu(0x0000003c, 0x0000004b, 0x00001194);
testmulu(0x0000003c, 0x00004b00, 0x00119400);
testmulu(0x0000003c, 0x004b0000, 0x11940000);
testmulu(0x0000003c, 0x4b000000, 0x94000000);
testdivi( 1, 1, 1);
testdivi(-1, 1, -1);
testdivi( 1, -1, -1);
testdivi(-1, -1, 1);
testdivi( 11, 4, 2);
testdivi(-11, 4, -2);
testdivi( 11, -4, -2);
testdivi(-11, -4, 2);
shltesti( 17, 1, 34);
shltesti(-17, 1, -34);
shltesti( 1700, 1, 3400);
shltesti(-1700, 1, -3400);
shrtesti( 34, 1, 17);
shrtesti(-34, 1, -17);
shrtesti( 3400, 1, 1700);
shrtesti(-3400, 1, -1700);
shrtesti( -1, 15, -1);
shrtesti(32767, 15, 0);
shrtesti( -1, 14, -1);
shrtesti(32767, 14, 1);
shltesti( -1, 14, -16384);
shltesti( 1, 14, 16384);
assert(sieve(200) == 47);
assert(sieve(1000) == 169);
long a = 0, b = 0;
for(long i=0; i<10000; i++)
{
assert( 177 * i == a);
assert(-177 * i == b);
a += 177;
b -= 177;
}
long c = 0, d = 0;
for(long i=0; i<177; i++)
{
assert( 10000 * i == c);
assert(-10000 * i == d);
c += 10000;
d -= 10000;
}
long e = 0, f = 0;
for(long i=0; i<177000l; i += 1000)
{
assert( 1024 * i == e);
assert(-1024 * i == f);
e += 1024000l;
f -= 1024000l;
}
return 0;
}

499
autotest/testint32cmp.c Normal file
View File

@ -0,0 +1,499 @@
#include <stdio.h>
#include <assert.h>
bool beq(long a, long b)
{
return a == b;
}
bool blt(long a, long b)
{
return a < b;
}
bool bgt(long a, long b)
{
return a > b;
}
bool ble(long a, long b)
{
return a <= b;
}
bool bge(long a, long b)
{
return a >= b;
}
bool neq(long a, long b)
{
return a == b;
}
#pragma native(neq)
bool nlt(long a, long b)
{
return a < b;
}
#pragma native(nlt)
bool ngt(long a, long b)
{
return a > b;
}
#pragma native(ngt)
bool nle(long a, long b)
{
return a <= b;
}
#pragma native(nle)
bool nge(long a, long b)
{
return a >= b;
}
#pragma native(nge)
inline bool ieq(long a, long b)
{
return a == b;
}
inline bool ilt(long a, long b)
{
return a < b;
}
inline bool igt(long a, long b)
{
return a > b;
}
inline bool ile(long a, long b)
{
return a <= b;
}
inline bool ige(long a, long b)
{
return a >= b;
}
bool beqz(long a)
{
return a == 0;
}
bool bltz(long a)
{
return a < 0;
}
bool bgtz(long a)
{
return a > 0;
}
bool blez(long a)
{
return a <= 0;
}
bool bgez(long a)
{
return a >= 0;
}
bool neqz(long a)
{
return a == 0;
}
#pragma native(neqz)
bool nltz(long a)
{
return a < 0;
}
#pragma native(nltz)
bool ngtz(long a)
{
return a > 0;
}
#pragma native(ngtz)
bool nlez(long a)
{
return a <= 0;
}
#pragma native(nlez)
bool ngez(long a)
{
return a >= 0;
}
#pragma native(ngez)
bool beq1(long a)
{
return a == 1;
}
bool blt1(long a)
{
return a < 1;
}
bool bgt1(long a)
{
return a > 1;
}
bool ble1(long a)
{
return a <= 1;
}
bool bge1(long a)
{
return a >= 1;
}
bool neq1(long a)
{
return a == 1;
}
#pragma native(neq1)
bool nlt1(long a)
{
return a < 1;
}
#pragma native(nlt1)
bool ngt1(long a)
{
return a > 1;
}
#pragma native(ngt1)
bool nle1(long a)
{
return a <= 1;
}
#pragma native(nle1)
bool nge1(long a)
{
return a >= 1;
}
#pragma native(nge1)
bool beqm(long a)
{
return a == -1;
}
bool bltm(long a)
{
return a < -1;
}
bool bgtm(long a)
{
return a > -1;
}
bool blem(long a)
{
return a <= -1;
}
bool bgem(long a)
{
return a >= -1;
}
bool neqm(long a)
{
return a == -1;
}
#pragma native(neqm)
bool nltm(long a)
{
return a < -1;
}
#pragma native(nltm)
bool ngtm(long a)
{
return a > -1;
}
#pragma native(ngtm)
bool nlem(long a)
{
return a <= -1;
}
#pragma native(nlem)
bool ngem(long a)
{
return a >= -1;
}
#pragma native(ngem)
void cmpc(long a, long b)
{
bool beqf = beq(a, b), bltf = blt(a, b), bgtf = bgt(a, b), blef = ble(a, b), bgef = bge(a, b);
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
printf("BYTE %ld, %ld : EQ %d LT %d GT %d\r", a, b, beqf, bltf, bgtf);
printf("NATIVE %ld, %ld : EQ %d LT %d GT %d\r", a, b, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpi(long a, long b)
{
bool ieqf = ieq(a, b), iltf = ilt(a, b), igtf = igt(a, b), ilef = ile(a, b), igef = ige(a, b);
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
printf("INLINE %ld, %ld : EQ %d LT %d GT %d\r", a, b, ieqf, iltf, igtf);
printf("NATIVE %ld, %ld : EQ %d LT %d GT %d\r", a, b, neqf, nltf, ngtf);
assert(ieqf == neqf);
assert(iltf == nltf);
assert(igtf == ngtf);
assert(ilef == nlef);
assert(igef == ngef);
}
void cmp(long a, long b)
{
cmpc(a, b);
cmpi(a, b);
}
void cmpz(long a)
{
bool beqf = beqz(a), bltf = bltz(a), bgtf = bgtz(a), blef = blez(a), bgef = bgez(a);
bool neqf = neqz(a), nltf = nltz(a), ngtf = ngtz(a), nlef = nlez(a), ngef = ngez(a);
printf("BYTE %ld, 0 : EQ %d LT %d GT %d\r", a, beqf, bltf, bgtf);
printf("NATIVE %ld, 0 : EQ %d LT %d GT %d\r", a, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmp1(long a)
{
bool beqf = beq1(a), bltf = blt1(a), bgtf = bgt1(a), blef = ble1(a), bgef = bge1(a);
bool neqf = neq1(a), nltf = nlt1(a), ngtf = ngt1(a), nlef = nle1(a), ngef = nge1(a);
printf("BYTE %ld, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, beqf, bltf, bgtf, blef, bgef);
printf("NATIVE %ld, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, neqf, nltf, ngtf, nlef, ngef);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpm(long a)
{
bool beqf = beqm(a), bltf = bltm(a), bgtf = bgtm(a), blef = blem(a), bgef = bgem(a);
bool neqf = neqm(a), nltf = nltm(a), ngtf = ngtm(a), nlef = nlem(a), ngef = ngem(a);
printf("BYTE %ld, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, beqf, bltf, bgtf, blef, bgef);
printf("NATIVE %ld, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, neqf, nltf, ngtf, nlef, ngef);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
int main(void)
{
cmp( 0, 1);
cmp( 0, -1);
cmp( 1, 0);
cmp(-1, 0);
cmp(1, 1);
cmp(1, 2);
cmp(2, 1);
cmp(-1, -1);
cmp(-1, -2);
cmp(-2, -1);
cmp( 1, -1);
cmp( 1, -2);
cmp( 2, -1);
cmp(-1, 1);
cmp(-1, 2);
cmp(-2, 1);
cmp( 0, 10000);
cmp( 0, -10000);
cmp( 10000, 0);
cmp(-10000, 0);
cmp(10000, 10000);
cmp(10000, 20000);
cmp(20000, 10000);
cmp(-10000, -10000);
cmp(-10000, -20000);
cmp(-20000, -10000);
cmp( 10000, -10000);
cmp( 10000, -20000);
cmp( 20000, -10000);
cmp(-10000, 10000);
cmp(-10000, 20000);
cmp(-20000, 10000);
cmp( 10000000L, -10000000L);
cmp( 10000000L, -20000000L);
cmp( 20000000L, -10000000L);
cmp(-10000000L, 10000000L);
cmp(-10000000L, 20000000L);
cmp(-20000000L, 10000000L);
cmp( 0, 1024);
cmp( 0, -1024);
cmp( 1024, 0);
cmp(-1024, 0);
cmp(1024, 1024);
cmp(1024, 1025);
cmp(1025, 1024);
cmp(-1024, -1024);
cmp(-1024, -1025);
cmp(-1025, -1024);
cmp( 1024, -1024);
cmp( 1024, -1025);
cmp( 1025, -1024);
cmp(-1024, 1024);
cmp(-1024, 1025);
cmp(-1025, 1024);
cmpz(0);
cmpz(1);
cmpz(255);
cmpz(256);
cmpz(10000);
cmpz(20000);
cmpz(-1);
cmpz(-255);
cmpz(-256);
cmpz(-10000);
cmpz(-20000);
cmp1(0);
cmp1(1);
cmp1(2);
cmp1(3);
cmp1(255);
cmp1(256);
cmp1(10000);
cmp1(20000);
cmp1(1000000l);
cmp1(2000000l);
cmp1(100000000l);
cmp1(200000000l);
cmp1(-1);
cmp1(-2);
cmp1(-3);
cmp1(-255);
cmp1(-256);
cmp1(-10000);
cmp1(-20000);
cmp1(-1000000l);
cmp1(-2000000l);
cmp1(-100000000l);
cmp1(-200000000l);
cmpm(0);
cmpm(1);
cmpm(2);
cmpm(3);
cmpm(255);
cmpm(256);
cmpm(10000);
cmpm(20000);
cmpm(1000000l);
cmpm(2000000l);
cmpm(100000000l);
cmpm(200000000l);
cmpm(-1);
cmpm(-2);
cmpm(-3);
cmpm(-255);
cmpm(-256);
cmpm(-10000);
cmpm(-20000);
cmpm(-1000000l);
cmpm(-2000000l);
cmpm(-100000000l);
cmpm(-200000000l);
return 0;
}

555
autotest/testint8cmp.c Normal file
View File

@ -0,0 +1,555 @@
#include <stdio.h>
#include <assert.h>
typedef signed char int8;
typedef unsigned char uint8;
bool beq(int8 a, int8 b)
{
return a == b;
}
bool blt(int8 a, int8 b)
{
return a < b;
}
bool bgt(int8 a, int8 b)
{
return a > b;
}
bool ble(int8 a, int8 b)
{
return a <= b;
}
bool bge(int8 a, int8 b)
{
return a >= b;
}
bool neq(int8 a, int8 b)
{
return a == b;
}
#pragma native(neq)
bool nlt(int8 a, int8 b)
{
return a < b;
}
#pragma native(nlt)
bool ngt(int8 a, int8 b)
{
return a > b;
}
#pragma native(ngt)
bool nle(int8 a, int8 b)
{
return a <= b;
}
#pragma native(nle)
bool nge(int8 a, int8 b)
{
return a >= b;
}
#pragma native(nge)
bool beqz(int8 a)
{
return a == 0;
}
bool bltz(int8 a)
{
return a < 0;
}
bool bgtz(int8 a)
{
return a > 0;
}
bool blez(int8 a)
{
return a <= 0;
}
bool bgez(int8 a)
{
return a >= 0;
}
bool neqz(int8 a)
{
return a == 0;
}
#pragma native(neqz)
bool nltz(int8 a)
{
return a < 0;
}
#pragma native(nltz)
bool ngtz(int8 a)
{
return a > 0;
}
#pragma native(ngtz)
bool nlez(int8 a)
{
return a <= 0;
}
#pragma native(nlez)
bool ngez(int8 a)
{
return a >= 0;
}
#pragma native(ngez)
bool bequz(uint8 a)
{
return a == 0;
}
bool bltuz(uint8 a)
{
return a < 0;
}
bool bgtuz(uint8 a)
{
return a > 0;
}
bool bleuz(uint8 a)
{
return a <= 0;
}
bool bgeuz(uint8 a)
{
return a >= 0;
}
bool nequz(uint8 a)
{
return a == 0;
}
#pragma native(nequz)
bool nltuz(uint8 a)
{
return a < 0;
}
#pragma native(nltuz)
bool ngtuz(uint8 a)
{
return a > 0;
}
#pragma native(ngtuz)
bool nleuz(uint8 a)
{
return a <= 0;
}
#pragma native(nleuz)
bool ngeuz(uint8 a)
{
return a >= 0;
}
#pragma native(ngeuz)
bool beq1(int8 a)
{
return a == 1;
}
bool blt1(int8 a)
{
return a < 1;
}
bool bgt1(int8 a)
{
return a > 1;
}
bool ble1(int8 a)
{
return a <= 1;
}
bool bge1(int8 a)
{
return a >= 1;
}
bool neq1(int8 a)
{
return a == 1;
}
#pragma native(neq1)
bool nlt1(int8 a)
{
return a < 1;
}
#pragma native(nlt1)
bool ngt1(int8 a)
{
return a > 1;
}
#pragma native(ngt1)
bool nle1(int8 a)
{
return a <= 1;
}
#pragma native(nle1)
bool nge1(int8 a)
{
return a >= 1;
}
#pragma native(nge1)
void cmp(int8 a, int8 b)
{
bool beqf = beq(a, b), bltf = blt(a, b), bgtf = bgt(a, b), blef = ble(a, b), bgef = bge(a, b);
bool neqf = neq(a, b), nltf = nlt(a, b), ngtf = ngt(a, b), nlef = nle(a, b), ngef = nge(a, b);
printf("BYTE %d, %d : EQ %d LT %d GT %d\r", a, b, beqf, bltf, bgtf);
printf("NATIVE %d, %d : EQ %d LT %d GT %d\r", a, b, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpz(int8 a)
{
bool beqf = beqz(a), bltf = bltz(a), bgtf = bgtz(a), blef = blez(a), bgef = bgez(a);
bool neqf = neqz(a), nltf = nltz(a), ngtf = ngtz(a), nlef = nlez(a), ngef = ngez(a);
printf("BYTE %d, 0 : EQ %d LT %d GT %d\r", a, beqf, bltf, bgtf);
printf("NATIVE %d, 0 : EQ %d LT %d GT %d\r", a, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpuz(uint8 a)
{
bool beqf = bequz(a), bltf = bltuz(a), bgtf = bgtuz(a), blef = bleuz(a), bgef = bgeuz(a);
bool neqf = nequz(a), nltf = nltuz(a), ngtf = ngtuz(a), nlef = nleuz(a), ngef = ngeuz(a);
printf("BYTE %d, 0 : EQ %d LT %d GT %d\r", a, beqf, bltf, bgtf);
printf("NATIVE %d, 0 : EQ %d LT %d GT %d\r", a, neqf, nltf, ngtf);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmp1(int8 a)
{
bool beqf = beq1(a), bltf = blt1(a), bgtf = bgt1(a), blef = ble1(a), bgef = bge1(a);
bool neqf = neq1(a), nltf = nlt1(a), ngtf = ngt1(a), nlef = nle1(a), ngef = nge1(a);
printf("BYTE %d, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, beqf, bltf, bgtf, blef, bgef);
printf("NATIVE %d, 1 : EQ %d LT %d GT %d LE %d GE %d\r", a, neqf, nltf, ngtf, nlef, ngef);
assert(beqf == neqf);
assert(bltf == nltf);
assert(bgtf == ngtf);
assert(blef == nlef);
assert(bgef == ngef);
}
void cmpu(char a, char b, bool lt, bool gt, bool eq)
{
bool clt = a < b, cgt = a > b, ceq = a == b;
bool nlt = a >= b, ngt = a <= b, neq = a != b;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", a, b, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
void cmpu100(char a, bool lt, bool gt, bool eq)
{
bool clt = a < 100, cgt = a > 100, ceq = a == 100;
bool nlt = a >= 100, ngt = a <= 100, neq = a != 100;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", a, 100, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
void cmpu100r(char b, bool lt, bool gt, bool eq)
{
bool clt = 100 < b, cgt = 100 > b, ceq = 100 == b;
bool nlt = 100 >= b, ngt = 100 <= b, neq = 100 != b;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", 100, b, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
void cmpu1000(char a, bool lt, bool gt, bool eq)
{
bool clt = a < 1000, cgt = a > 1000, ceq = a == 1000;
bool nlt = a >= 1000, ngt = a <= 1000, neq = a != 1000;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", a, 1000, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
void cmpu1000r(char b, bool lt, bool gt, bool eq)
{
bool clt = 1000< b, cgt = 1000 > b, ceq = 1000 == b;
bool nlt = 1000 >= b, ngt = 1000 <= b, neq = 1000 != b;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", 1000, b, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
void cmpum100(char a, bool lt, bool gt, bool eq)
{
bool clt = a < -100, cgt = a > -100, ceq = a == -100;
bool nlt = a >= -100, ngt = a <= -100, neq = a != -100;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", a, -100, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
void cmpum100r(char b, bool lt, bool gt, bool eq)
{
bool clt = -100 < b, cgt = -100 > b, ceq = -100 == b;
bool nlt = -100 >= b, ngt = -100 <= b, neq = -100 != b;
printf("CPMPU %d, %d LT %d%d%d GT %d%d%d EQ %d%d%d\n", -100, b, lt, clt, nlt, gt, cgt, ngt, eq, ceq, neq);
assert(clt == lt);
assert(cgt == gt);
assert(ceq == eq);
assert(nlt != lt);
assert(ngt != gt);
assert(neq != eq);
}
int main(void)
{
cmp( 0, 1);
cmp( 0, -1);
cmp( 1, 0);
cmp(-1, 0);
cmp(1, 1);
cmp(1, 2);
cmp(2, 1);
cmp(-1, -1);
cmp(-1, -2);
cmp(-2, -1);
cmp( 1, -1);
cmp( 1, -2);
cmp( 2, -1);
cmp(-1, 1);
cmp(-1, 2);
cmp(-2, 1);
cmp( 0, 100);
cmp( 0, -100);
cmp( 100, 0);
cmp(-100, 0);
cmp(10, 10);
cmp(10, 20);
cmp(20, 10);
cmp(-10, -10);
cmp(-10, -20);
cmp(-20, -10);
cmp( 10, -10);
cmp( 10, -20);
cmp( 20, -10);
cmp(-10, 10);
cmp(-10, 20);
cmp(-20, 10);
cmp(-30, 30);
cmp(-30, -30);
cmp( 30, 30);
cmp( 30, -30);
cmp( 0, 127);
cmp( 0, -128);
cmp( 127, 0);
cmp(-128, 0);
cmp( 127, 127);
cmp( 127, -128);
cmp(-128, 127);
cmp(-128, -128);
cmpz(0);
cmpz(1);
cmpz(127);
cmpz(-1);
cmpz(-128);
cmpuz(0);
cmpuz(1);
cmpuz(127);
cmpuz(128);
cmpuz(255);
cmp1(0);
cmp1(1);
cmp1(2);
cmp1(3);
cmp1(127);
cmp1(-1);
cmp1(-2);
cmp1(-3);
cmp1(-128);
cmpu(0, 0, false, false, true);
cmpu(0, 1, true, false, false);
cmpu(1, 0, false ,true, false);
cmpu(128, 128, false, false, true);
cmpu( 0, 128, true, false, false);
cmpu(128, 0, false ,true, false);
cmpu(255, 255, false, false, true);
cmpu( 0, 255, true, false, false);
cmpu(255, 0, false ,true, false);
cmpu(127, 127, false, false, true);
cmpu(128, 255, true, false, false);
cmpu(255, 128, false ,true, false);
cmpu100(100, false, false, true);
cmpu100( 0, true, false, false);
cmpu100(130, false, true, false);
cmpu100r(100, false, false, true);
cmpu100r(130, true, false, false);
cmpu100r( 0, false, true, false);
cmpum100( 0, false, true, false);
cmpum100(130, false, true, false);
cmpum100r(130, true, false, false);
cmpum100r( 0, true, false, false);
cmpu1000(100, true, false, false);
cmpu1000( 0, true, false, false);
cmpu1000(130, true, false, false);
cmpu1000r(100, false, true, false);
cmpu1000r(130, false, true, false);
cmpu1000r( 0, false, true, false);
return 0;
}

58
autotest/testinterval.c Normal file
View File

@ -0,0 +1,58 @@
#include <assert.h>
void testint0(void)
{
int a0n = 0, an0 = 0;
int b0n = 0, bn0 = 0;
for(int i=-1000; i<1000; i++)
{
if (i >= 0 && i < 500)
a0n += 1;
if (i < 500 && i >= 0)
an0 += 1;
if (i >= 0 && i <= 499)
b0n += 1;
if (i <= 499 && i >= 0)
bn0 += 1;
}
assert(a0n == 500);
assert(an0 == 500);
assert(b0n == 500);
assert(bn0 == 500);
}
typedef signed char int8;
void testbyte0(void)
{
int8 a0n = 0, an0 = 0;
int8 b0n = 0, bn0 = 0;
for(int8 i=-100; i<100; i++)
{
if (i >= 0 && i < 50)
a0n += 1;
if (i < 50 && i >= 0)
an0 += 1;
if (i >= 0 && i <= 49)
b0n += 1;
if (i <= 49 && i >= 0)
bn0 += 1;
}
assert(a0n == 50);
assert(an0 == 50);
assert(b0n == 50);
assert(bn0 == 50);
}
int main(void)
{
testint0();
testbyte0();
return 0;
}

View File

@ -0,0 +1,29 @@
#include <assert.h>
int multab[32];
void fill_mulli(int m)
{
#pragma unroll(full)
for(int i=-16; i<16; i++)
if (i != 0)
multab[i + 16] = m / i;
}
void check_mulli(int m)
{
for(int i=-16; i<16; i++)
if (i != 0)
assert(multab[i + 16] == m / i);
}
int main(void)
{
for(int i=-1024; i<=1024; i++)
{
fill_mulli(i);
check_mulli(i);
}
return 0;
}

View File

@ -0,0 +1,27 @@
#include <assert.h>
int multab[32];
void fill_mulli(int m)
{
#pragma unroll(full)
for(int i=-16; i<16; i++)
multab[i + 16] = m * i;
}
void check_mulli(int m)
{
for(int i=-16; i<16; i++)
assert(multab[i + 16] == m * i);
}
int main(void)
{
for(int i=-1024; i<=1024; i++)
{
fill_mulli(i);
check_mulli(i);
}
return 0;
}

83
autotest/tileexpand.cpp Normal file
View File

@ -0,0 +1,83 @@
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#define MAP_WIDTH 10
#define MAP_HEIGHT 2
#define TITLE_TILE_WIDTH 4
#define TITLE_TILE_HEIGHT 4
#define PTR_SCREEN ((char *)0xc000)
#define PTR_BUFFER ((char *)0xc400)
#define PTR_COLOR ((char *)0xd800)
#define PTR_FONTCHARSET ((char *)0xd800)
const char TitleMap[1024] = {
#for(i, 1024) i * 17,
};
const char TitleTiles[4096] = {
#for(i, 4096) i * 31,
};
// Custom screen address
extern char* const Screen = PTR_SCREEN;
// Color mem address
extern char* const Color = PTR_COLOR;
void RenderLogo(char screenY)
{
char * sp = Screen;
char * cp = Color;
const char * mp = TitleMap;
for(char ty=0; ty < MAP_HEIGHT; ty++)
{
for(char tx=0; tx< MAP_WIDTH; tx++)
{
char ti = mp[tx];
const char* tp = TitleTiles + (TITLE_TILE_WIDTH * TITLE_TILE_HEIGHT) * ti;
for(char y=0; y<TITLE_TILE_HEIGHT; y++)
{
for(char x=0; x<TITLE_TILE_WIDTH; x++)
{
char c = tp[TITLE_TILE_WIDTH * y + x];
sp[40 * (y + screenY) + x] = c;
cp[40 * (y + screenY) + x] = 1;
}
}
sp += TITLE_TILE_WIDTH;
cp += TITLE_TILE_WIDTH;
}
sp += 120;
cp += 120;
mp += MAP_WIDTH;
}
}
void VerifyLogo(char screenY)
{
for(char dy=0; dy<MAP_HEIGHT * TITLE_TILE_HEIGHT; dy++)
{
for(char dx=0; dx<MAP_WIDTH * TITLE_TILE_WIDTH; dx++)
{
char ty = dy / TITLE_TILE_HEIGHT, iy = dy % TITLE_TILE_HEIGHT;
char tx = dx / TITLE_TILE_WIDTH, ix = dx % TITLE_TILE_WIDTH;
int si = TitleMap[MAP_WIDTH * ty + tx] * TITLE_TILE_WIDTH * TITLE_TILE_HEIGHT + TITLE_TILE_WIDTH * iy + ix;
int di = 40 * (dy + screenY) + dx;
assert(Screen[di] == TitleTiles[si]);
}
}
}
int main(void)
{
RenderLogo(1);
VerifyLogo(1);
return 0;
}

93
autotest/vcalltest.cpp Normal file
View File

@ -0,0 +1,93 @@
#include <assert.h>
struct A
{
virtual int f(int x);
};
struct B : A
{
virtual int f(int x);
};
struct C : A
{
virtual int f(int x);
virtual int g(int y, int z);
};
struct D : B
{
virtual int f(int x);
};
struct E : C
{
virtual int f(int x);
virtual int g(int y, int z);
};
struct F : C
{
virtual int g(int y, int z);
};
int A::f(int x)
{
return x * 1;
}
int B::f(int x)
{
return x * 2;
}
int C::f(int x)
{
return x * 3;
}
int C::g(int y, int z)
{
return (y + z) * 3;
}
int D::f(int x)
{
return x * 4;
}
int E::f(int x)
{
return x * 5;
}
int E::g(int y, int z)
{
return (y + z) * 5;
}
int F::g(int y, int z)
{
return (y + z) * 6;
}
int main(void)
{
A a;
B b;
C c;
D d;
E e;
F f;
assert(a.f(3) == c.f(1));
assert(b.f(4) == d.f(2));
assert(e.f(2) == b.f(5));
assert(f.f(5) == e.f(3));
assert(c.g(3, 2) == e.g(1, 2));
assert(c.g(1, 5) == f.g(0, 3));
return 0;
}

79
autotest/vcalltree.cpp Normal file
View File

@ -0,0 +1,79 @@
#include <assert.h>
struct Node
{
virtual float eval(void)
{
return 1.0e6;
}
};
struct ConstNode : Node
{
float c;
ConstNode(float c_)
: c(c_) {}
virtual float eval(void)
{
return c;
}
};
struct BinopNode : Node
{
Node * left, * right;
BinopNode(Node * left_, Node * right_)
: left(left_), right(right_)
{}
};
struct AddNode : BinopNode
{
AddNode(Node * left_, Node * right_)
: BinopNode(left_, right_)
{}
virtual float eval(void)
{
return left->eval() + right->eval();
}
};
struct SubNode : BinopNode
{
SubNode(Node * left_, Node * right_)
: BinopNode(left_, right_)
{}
virtual float eval(void)
{
return left->eval() - right->eval();
}
};
struct MulNode : BinopNode
{
MulNode(Node * left_, Node * right_)
: BinopNode(left_, right_)
{}
virtual float eval(void)
{
return left->eval() * right->eval();
}
};
int main(void)
{
Node * n =
new SubNode(
new MulNode(new ConstNode(4), new ConstNode(5)),
new AddNode(new ConstNode(12), new ConstNode(7)));
assert(n->eval() == 1.0);
return 0;
}

View File

@ -0,0 +1,63 @@
#include <assert.h>
int a, b, c;
struct A
{
A(void)
{
a++;
}
virtual ~A(void)
{
a--;
}
};
struct B : A
{
B(void)
{
b++;
}
virtual ~B(void)
{
b--;
}
};
struct C : B
{
C(void)
{
c++;
}
virtual ~C(void)
{
c--;
}
};
int main()
{
A * t[3];
t[0] = new A();
t[1] = new B();
t[2] = new C();
assert(a == 3 && b == 2 && c == 1);
delete t[0];
delete t[1];
delete t[2];
assert(a == 0 && b == 0 && c == 0);
return 0;
}

201
include/audio/sidfx.c Normal file
View File

@ -0,0 +1,201 @@
#include "sidfx.h"
enum SIDFXState
{
SIDFX_IDLE,
SIDFX_RESET_0,
SIDFX_RESET_1,
SIDFX_READY,
SIDFX_PLAY,
SIDFX_WAIT
};
__striped static struct SIDFXChannel
{
const SIDFX * volatile com;
byte delay, priority;
volatile byte cnt;
volatile SIDFXState state;
unsigned freq, pwm;
} channels[3];
void sidfx_init(void)
{
for(char i=0; i<3; i++)
{
channels[i].com = nullptr;
channels[i].state = SIDFX_IDLE;
channels[i].priority = 0;
channels[i].delay = 1;
}
}
bool sidfx_idle(byte chn)
{
return channels[chn].state == SIDFX_IDLE;
}
char sidfx_cnt(byte chn)
{
return channels[chn].cnt;
}
void sidfx_play(byte chn, const SIDFX * fx, byte cnt)
{
SIDFXState ns = channels[chn].state;
if (ns == SIDFX_IDLE)
ns = SIDFX_READY;
else if (channels[chn].priority <= fx->priority)
ns = SIDFX_RESET_0;
else
return;
channels[chn].state = SIDFX_IDLE;
channels[chn].delay = 1;
channels[chn].com = fx;
channels[chn].cnt = cnt - 1;
channels[chn].priority = fx->priority;
channels[chn].state = ns;
}
void sidfx_stop(byte chn)
{
channels[chn].com = nullptr;
if (channels[chn].state != SIDFX_IDLE)
{
channels[chn].state = SIDFX_RESET_0;
channels[chn].delay = 1;
}
}
inline void sidfx_loop_ch(byte ch)
{
if (channels[ch].state)
{
const SIDFX * com = channels[ch].com;
channels[ch].delay--;
if (channels[ch].delay)
{
if (com->dfreq)
{
channels[ch].freq += com->dfreq;
sid.voices[ch].freq = channels[ch].freq;
}
if (com->dpwm)
{
channels[ch].pwm += com->dpwm;
sid.voices[ch].pwm = channels[ch].pwm;
}
}
while (!channels[ch].delay)
{
switch (channels[ch].state)
{
case SIDFX_IDLE:
channels[ch].delay = 1;
break;
case SIDFX_RESET_0:
sid.voices[ch].ctrl = 0;
sid.voices[ch].attdec = 0;
sid.voices[ch].susrel = 0;
if (com)
channels[ch].state = SIDFX_READY;
else
channels[ch].state = SIDFX_IDLE;
channels[ch].delay = 1;
break;
case SIDFX_RESET_1:
sid.voices[ch].ctrl = SID_CTRL_TEST;
sid.voices[ch].ctrl = 0;
sid.voices[ch].attdec = 0;
sid.voices[ch].susrel = 0;
channels[ch].state = SIDFX_READY;
break;
case SIDFX_READY:
channels[ch].freq = com->freq;
channels[ch].pwm = com->pwm;
sid.voices[ch].freq = com->freq;
sid.voices[ch].pwm = com->pwm;
sid.voices[ch].attdec = com->attdec;
sid.voices[ch].susrel = com->susrel;
sid.voices[ch].ctrl = com->ctrl;
if (com->ctrl & SID_CTRL_GATE)
{
channels[ch].delay = com->time1;
channels[ch].state = SIDFX_PLAY;
}
else
{
channels[ch].delay = com->time0;
channels[ch].state = SIDFX_PLAY;
}
break;
case SIDFX_PLAY:
if (com->time0)
{
sid.voices[ch].ctrl = com->ctrl & ~SID_CTRL_GATE;
channels[ch].delay = com->time0 - 1;
channels[ch].state = SIDFX_WAIT;
}
else if (channels[ch].cnt)
{
char sr = com->susrel & 0xf0;
com++;
char ctrl = com->ctrl;
if ((com->attdec & 0xef) == 0 && (ctrl & SID_CTRL_GATE) && (com->susrel & 0xf0) > sr)
{
sid.voices[ch].ctrl = ctrl & ~SID_CTRL_GATE;
sid.voices[ch].ctrl = ctrl | SID_CTRL_GATE;
}
channels[ch].cnt--;
channels[ch].com = com;
channels[ch].priority = com->priority;
channels[ch].state = SIDFX_READY;
}
else
{
com = nullptr;
channels[ch].state = SIDFX_RESET_0;
}
break;
case SIDFX_WAIT:
if (channels[ch].cnt)
{
com++;
channels[ch].cnt--;
channels[ch].com = com;
channels[ch].priority = com->priority;
if (com->ctrl & SID_CTRL_GATE)
channels[ch].state = SIDFX_RESET_0;
else
channels[ch].state = SIDFX_READY;
}
else
{
com = nullptr;
channels[ch].state = SIDFX_RESET_0;
}
break;
}
}
}
}
void sidfx_loop_2(void)
{
sidfx_loop_ch(2);
}
void sidfx_loop(void)
{
for(byte ch=0; ch<3; ch++)
sidfx_loop_ch(ch);
}

31
include/audio/sidfx.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef SIDFX_H
#define SIDFX_H
#include <c64/sid.h>
struct SIDFX
{
unsigned freq, pwm;
byte ctrl, attdec, susrel;
int dfreq, dpwm;
byte time1, time0;
byte priority;
};
void sidfx_init(void);
inline bool sidfx_idle(byte chn);
inline void sidfx_play(byte chn, const SIDFX * fx, byte cnt);
void sidfx_stop(byte chn);
char sidfx_cnt(byte chn);
void sidfx_loop(void);
void sidfx_loop_2(void);
#pragma compile("sidfx.c")
#endif

84
include/c128/bank1.c Normal file
View File

@ -0,0 +1,84 @@
#include "bank1.h"
#include "mmu.h"
#include <string.h>
void bnk1_init(void)
{
mmu.cr = 0x3e;
memcpy((char *)0xfc00, (char *)0xf000, 0x0300);
xmmu.rcr |= 0x0c;
mmu.cr = 0x3f;
}
#pragma code(bnk1code)
char bnk1_readb(volatile char * p)
{
mmu.bank1 = 0;
char c = *p;
mmu.bank0 = 0;
return c;
}
unsigned bnk1_readw(volatile unsigned * p)
{
mmu.bank1 = 0;
unsigned w = *p;
mmu.bank0 = 1;
return w;
}
unsigned long bnk1_readl(volatile unsigned long * p)
{
mmu.bank1 = 0;
unsigned long l = *p;
mmu.bank0 = 3;
return l;
}
void bnk1_readm(char * dp, volatile char * sp, unsigned size)
{
while (size > 0)
{
mmu.bank1 = 0;
char c = * sp++;
mmu.bank0 = c;
*dp++ = c;
size--;
}
}
void bnk1_writeb(volatile char * p, char b)
{
mmu.bank1 = b;
*p = b;
mmu.bank0 = b;
}
void bnk1_writew(volatile unsigned * p, unsigned w)
{
mmu.bank1 = w;
*p = w;
mmu.bank0 = w;
}
void bnk1_writel(volatile unsigned long * p, unsigned long l)
{
mmu.bank1 = l;
*p = l;
mmu.bank0 = l;
}
void bnk1_writem(volatile char * dp, const char * sp, unsigned size)
{
while (size > 0)
{
char c = * sp++;
mmu.bank1 = c;
*dp++ = c;
mmu.bank0 = c;
size--;
}
}
#pragma code(code)

34
include/c128/bank1.h Normal file
View File

@ -0,0 +1,34 @@
#ifndef C128_BANK1_H
#define C128_BANK1_H
#pragma section( bnk1code, 0)
#pragma region( bnk1code, 0xf000, 0xf300, , , {bnk1code}, 0xfc00 )
void bnk1_init(void);
#pragma code(bnk1code)
__noinline char bnk1_readb(volatile char * p);
__noinline unsigned bnk1_readw(volatile unsigned * p);
__noinline unsigned long bnk1_readl(volatile unsigned long * p);
__noinline void bnk1_readm(char * dp, volatile char * sp, unsigned size);
__noinline void bnk1_writeb(volatile char * p, char b);
__noinline void bnk1_writew(volatile unsigned * p, unsigned w);
__noinline void bnk1_writel(volatile unsigned long * p, unsigned long l);
__noinline void bnk1_writem(volatile char * dp, const char * sp, unsigned size);
#pragma code(code)
#pragma compile("bank1.c")
#endif

8
include/c128/mmu.c Normal file
View File

@ -0,0 +1,8 @@
#include "mmu.h"
inline char mmu_set(char cr)
{
char pcr = mmu.cr;
mmu.cr = cr;
return pcr;
}

35
include/c128/mmu.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef C128_MMU_H
#define C128_MMU_H
#include <c64/types.h>
struct MMU
{
volatile byte cr;
volatile byte bank0;
volatile byte bank1;
volatile byte bank14;
volatile byte bankx;
};
struct XMMU
{
volatile byte cr;
volatile byte pcr[4];
volatile byte mcr;
volatile byte rcr;
volatile word page0;
volatile word page1;
volatile byte vr;
};
#define mmu (*((struct MMU *)0xff00))
#define xmmu (*((struct XMMU *)0xd500))
inline char mmu_set(char cr);
#pragma compile("mmu.c")
#endif

Some files were not shown because too many files have changed in this diff Show More