1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-15 14:29:32 +00:00
Commit Graph

298 Commits

Author SHA1 Message Date
Chris Pressey
30e839033c First cut at serialization of fallthru-optimized routines. 2018-04-04 15:09:48 +01:00
Chris Pressey
e39dbf68ed Call it fall_in_map. 2018-04-04 14:16:49 +01:00
Chris Pressey
448849ac4b Successfully break cycle. 2018-04-04 14:01:17 +01:00
Chris Pressey
50433ac860 Find cycles in fallthru map. Try to break them; not right, yet. 2018-04-04 13:37:32 +01:00
Chris Pressey
a0d3ea8167 Add a dedicated module for a dedicated FallthruAnalyzer. 2018-04-04 11:09:39 +01:00
Chris Pressey
237a8b5b39 Lessen dependence on the internals of ParsingContext. 2018-03-29 17:31:14 +01:00
Chris Pressey
a759f4414b Make tests pass again. 2018-03-29 16:50:07 +01:00
Chris Pressey
8f1e35fb39 Add some tests, some failing, for expected fallthru maps. 2018-03-29 16:44:06 +01:00
Chris Pressey
b33998cddc First cut at building fallthru map. Needs tests. 2018-03-29 15:07:44 +01:00
Chris Pressey
fa1b0cfae1 Support branching and looping on the n flag. 2018-03-29 14:45:28 +01:00
Chris Pressey
ebe53f540c Fix bug when zero page address was $00. 2018-03-29 11:46:56 +01:00
Chris Pressey
eadf1eb4ae A byte or word table can be initialized with a list of constants. 2018-03-29 11:09:02 +01:00
Chris Pressey
2f513f7291 Initial support for initializing byte tables with list of bytes. 2018-03-29 10:45:18 +01:00
Chris Pressey
9b912de17c Accessing zero-page with ld and st generates zero-page opcodes. 2018-03-29 10:31:42 +01:00
Chris Pressey
1f992f8dbd Support of NOP opcode. 2018-03-28 14:52:16 +01:00
Chris Pressey
0093c7b7d9 First cut at support for targetting the Atari 2600. 2018-03-28 14:20:53 +01:00
Chris Pressey
bb0e7aa992 Track the gotos that we have encountered in a routine. 2018-03-27 17:27:09 +01:00
Chris Pressey
6744ad29a9 Beginnings of modularity. 2018-03-27 16:23:22 +01:00
Chris Pressey
d9e625db30 Clean up driver code, add filename to error messages. 2018-03-27 15:55:29 +01:00
Chris Pressey
3f0e36a67c Add symbolic constants. 2018-03-27 12:36:33 +01:00
Chris Pressey
b91c3ed2f1 Add three more tests. Ensure they pass. 2018-03-26 17:40:43 +01:00
Chris Pressey
ceaae962d5 Make tests pass. Add two more tests towards completeness of spec. 2018-03-26 12:48:57 +01:00
Chris Pressey
96fbe03ce7 Make compilation tests pass. 2018-03-14 16:27:33 +00:00
Chris Pressey
adb53f7a04 Almost compile for loops correctly. 2018-03-14 15:33:11 +00:00
Chris Pressey
b79059faa4 Two seperate words looks better. 2018-03-14 09:51:24 +00:00
Chris Pressey
9a9db83fc6 Analyze the range in the for loop. All unit tests pass again. 2018-03-13 17:44:44 +00:00
Chris Pressey
7a3b52dc1e More correct determination of tail position for purposes of goto. 2018-03-13 17:00:49 +00:00
Chris Pressey
689670a69e Small bugfixes and changes. 2018-03-13 09:25:06 +00:00
Chris Pressey
994449ecb0 Make the loop variable unwriteable in the body of the "for" loop. 2018-03-08 17:41:42 +00:00
Chris Pressey
f73a2313bd Add some failing tests for analyzing "for". 2018-03-08 17:17:49 +00:00
Chris Pressey
d815e05e0c Syntax for "open-faced for loop". 2018-03-08 16:54:12 +00:00
Chris Pressey
bda0202dee Confirm that AND clips the range and INC/DEC invalidate it. 2018-03-06 15:42:12 +00:00
Chris Pressey
1eaec602e3 The exception object now contains an AST node, renders name. 2018-03-06 14:39:47 +00:00
Chris Pressey
42cbd73a20 Show line numbers in static analysis errors (clumsily.) 2018-03-06 13:13:18 +00:00
Chris Pressey
e44c802314 Syntax errors have line numbers in them now. 2018-03-06 12:23:57 +00:00
Chris Pressey
9ad34ed34f Refine the AST classes even more. 2018-03-06 10:43:23 +00:00
Chris Pressey
8a7e3aaebb Flatten more. 2018-03-05 15:32:08 +00:00
Chris Pressey
1180d2fe2a Attempt to flatten the code for generating code for copy. 2018-03-05 15:22:47 +00:00
Chris Pressey
c194808e64 Label the various cases for compiling a copy instruction. 2018-03-05 13:23:09 +00:00
Chris Pressey
c85159a9c0 Start trying to clean up the code for compiling copy. 2018-03-05 12:34:24 +00:00
Chris Pressey
b579e8b2eb Refs have indexes. Instructions do not. 2018-03-05 12:19:27 +00:00
Chris Pressey
0a83d90515 Tighten structure of AST more. 2018-03-05 12:13:15 +00:00
Chris Pressey
4b43ba734e Make AST more structured (borrowed from ALPACA.) 2018-03-05 11:55:06 +00:00
Chris Pressey
b42aa8b051 Fix error message. 2018-03-05 11:28:08 +00:00
Chris Pressey
d24e9fa2e1 I can no longer see a reason to require that it is a power of two. 2018-03-05 10:38:20 +00:00
Chris Pressey
42c4bed36e Make tests pass. 2018-02-16 15:46:55 +00:00
Chris Pressey
0e0a3d552a Implement Context.copy_range(), ranges for constants. Progress! 2018-02-14 16:35:19 +00:00
Chris Pressey
0687da80d5 Some headway on context.assert_in_range(). 2018-02-14 15:54:57 +00:00
Chris Pressey
2897a04718 Get and set top of range of a location. Make AND do this to A reg. 2018-02-14 15:13:35 +00:00
Chris Pressey
93e2dada16 Check for table size (in parser, thus tests are for syntax.) 2018-02-14 13:53:22 +00:00
Chris Pressey
ab33331924 Associate a range with each meaningful storage location in context. 2018-02-14 13:31:03 +00:00
Chris Pressey
5fa8c69bd2 Don't fudge the name of IndexRefs; dig in to find the ref's name. 2018-02-13 17:17:27 +00:00
Chris Pressey
f6fa1ec7d2 Remove need for forward keyword in forward reference in copy. 2018-02-12 15:59:20 +00:00
Chris Pressey
08ec0e46a3 Remove the need for parens in vector (routine ...) table type. 2018-02-12 14:53:49 +00:00
Chris Pressey
e9d9c717bb More statics in demo game. 2018-02-09 16:57:49 +00:00
Chris Pressey
7a024f3062 Compile static storage location access. 2018-02-09 16:13:09 +00:00
Chris Pressey
52fb1dc6b9 Inch toward compiling statics. 2018-02-09 14:44:41 +00:00
Chris Pressey
71cded0297 Move compiler towards being able to compile access to statics. 2018-02-09 14:13:39 +00:00
Chris Pressey
55331e9c54 Statics are always writeable. Statics are always meaningful. 2018-02-09 13:35:59 +00:00
Chris Pressey
b829836cdc Ability to parse static definitions and look them up. 2018-02-09 12:33:45 +00:00
Chris Pressey
ca1c877a60 Support indirect refs in st, e.g. st a, [ptr] + y. 2018-02-09 11:23:18 +00:00
Chris Pressey
a7365731ca Even if we goto another routine, we can't trash an output. 2018-02-08 16:37:40 +00:00
Chris Pressey
b20b664748 Implement the "union rule for trashes" when analyzing if blocks. 2018-02-08 14:04:51 +00:00
Chris Pressey
3f1f3bf16e Set a location as touched when trashed with a trash instruction. 2018-02-08 13:43:06 +00:00
Chris Pressey
f92e1f15bf Tired: copy [ptr]+y, a. Wired: ld a, [ptr]+y. 2018-02-08 11:58:24 +00:00
Chris Pressey
34daad0e56 Make ld parse to a IndexedRef or IndirectRef (latter still todo.) 2018-02-08 11:04:11 +00:00
Chris Pressey
7c8f113c07 Properly store address (not contents) of routine into vector table. 2018-02-07 13:56:17 +00:00
Chris Pressey
6c1c1cb153 Include final RTS when emitting trampolines for indirect calls. 2018-02-07 11:11:14 +00:00
Chris Pressey
ed1ed3eb5d Always analyze before compiling. 2018-02-06 16:14:44 +00:00
Chris Pressey
43b3a088b0 Use a vector table in the demo game. 2018-02-06 15:03:59 +00:00
Chris Pressey
9778e083c1 Move test, add test, add assertion. 2018-02-06 11:52:50 +00:00
Chris Pressey
70ecd52e8a Retain some syntax compatibility: make table a postfix operator. 2018-02-06 11:34:21 +00:00
Chris Pressey
44ee8efbef When backpatching constraints, don't strip ones we've already done. 2018-02-06 10:28:41 +00:00
Chris Pressey
612ae588f7 Add some tests, fix some bugs, show that one bug remains. 2018-02-06 10:05:56 +00:00
Chris Pressey
c12a76e106 Make assertions more robust, in hopes of hunting down bugs. 2018-02-06 09:52:01 +00:00
Chris Pressey
74f8675761 Start of typedef support. 2018-02-05 18:12:48 +00:00
Chris Pressey
0be721667a Kind-of not-pretty syntax refactor to support adding typedefs. 2018-02-05 17:01:25 +00:00
Chris Pressey
15072eff52 The evaluator doesn't add much and keeps falling behind; remove it. 2018-02-05 13:17:23 +00:00
Chris Pressey
20c824743e Fix table access bug where index wasn't required to be initialized. 2018-02-05 12:35:19 +00:00
Chris Pressey
11d6c08369 In fact the 'src' should never (I think?) be 'touched'. 2018-02-05 12:08:33 +00:00
Chris Pressey
7dfd2cfe0c Allow copying a routine directly into a vector table. 2018-02-05 12:04:28 +00:00
Chris Pressey
bbd3a84c00 Retain silly 'name inside the type' syntax (a la C) for now. 2018-02-05 11:18:35 +00:00
Chris Pressey
a082aee001 NOt 100% sure it's correct, but it seems close. 2018-02-02 17:56:50 +00:00
Chris Pressey
13e6654088 Executable types are compatible with other executable types. 2018-02-02 17:48:57 +00:00
Chris Pressey
0fff8e4f0a Begin to implement vector tables, stuck at a type equality problem. 2018-02-02 17:45:07 +00:00
Chris Pressey
eb1974eb8a Vector tables can be parsed. 2018-02-02 17:18:25 +00:00
Chris Pressey
b29716fccf Constraints for vector come immediately after the type expression. 2018-02-02 17:16:31 +00:00
Chris Pressey
4abedc0442 Centralize helper, use it elsewhere. 2018-02-02 17:05:15 +00:00
Chris Pressey
548905dce4 Initialized byte tables need not have all 256 bytes initialized. 2018-02-02 16:31:23 +00:00
Chris Pressey
d69766afbe Marginally more informative error message. 2017-12-14 11:54:39 +00:00
Chris Pressey
1d8f1af964 Fix bug in copy []+y, a. "Hero" no longer leaves a trail. 2017-12-13 17:00:21 +00:00
Chris Pressey
b477c5e786 Don't trash a in copy if a is the dest of the copy, for now. 2017-12-13 16:18:36 +00:00
Chris Pressey
f9dc730f88 copy []+y, a to indirectly read byte into the a register. 2017-12-13 16:11:02 +00:00
Chris Pressey
c7861d375c trash indicates a value is no longer considered meaningful. 2017-12-13 15:23:06 +00:00
Chris Pressey
5f535c963e Subtract word (constant or memory location) from word memory location. 2017-12-13 14:07:59 +00:00
Chris Pressey
75cc1f6b25 Factor out utility method for selecting addressing mode. 2017-12-13 12:14:26 +00:00
Chris Pressey
f87bcf5ee4 Initial work on initialized byte tables. 2017-12-12 16:41:49 +00:00
Chris Pressey
50390b0787 Can copy a literal word to a word table. 2017-12-12 16:04:59 +00:00
Chris Pressey
63f75a26b4 Initialized word type memory locations. 2017-12-12 15:34:51 +00:00
Chris Pressey
4854077cce Correctly analyze repeat { ... } forever loops. 2017-12-12 15:18:59 +00:00
Chris Pressey
0194d37bbd forward modifier on location expression, instead of assign. 2017-12-12 14:23:34 +00:00
Chris Pressey
b7b28830d7 Introducing a new pseudo-opcode is rarely an elegant solution. 2017-12-12 14:09:17 +00:00
Chris Pressey
dbbd99ffe5 Change how backpatching instructions is implemented. 2017-12-12 13:54:35 +00:00
Chris Pressey
19dd089a03 Allow call and goto routines defined further down in the source. 2017-12-12 13:17:00 +00:00
Chris Pressey
45bc4bd0a0 Tighten assumption when comparing LocationRefs. 2017-12-12 12:54:16 +00:00
Chris Pressey
60df162625 Refactor: common method to backpatch labels. 2017-12-12 12:51:19 +00:00
Chris Pressey
8dc44673fa LocationRefs are equal if names/type are; this needed __str__ tho. 2017-12-12 12:45:47 +00:00
Chris Pressey
e46c6f6c6e Improve error messaging yet more. Game kind of has game states now. 2017-12-12 09:59:43 +00:00
Chris Pressey
82e33ab476 Improve error messaging when constraints are exceeded. 2017-12-12 09:42:16 +00:00
Chris Pressey
ec2e051518 Constraint sets may only contain labels, which are resolved late. 2017-12-11 17:49:02 +00:00
Chris Pressey
2216fcec17 copy from word storage to word table and back, indexed by x or y. 2017-12-11 12:02:48 +00:00
Chris Pressey
b86e7491d5 Copy word to word table. 2017-12-11 11:43:53 +00:00
Chris Pressey
bef1aba8ce Do not assume every label refers to a word-sized chunk of memory. 2017-12-11 10:42:42 +00:00
Chris Pressey
404f8c72a3 We really need to review how storage location labels are emitted. 2017-12-08 16:59:31 +00:00
Chris Pressey
84ca6c4e96 Break the ground where we need to implement word table read/write. 2017-12-08 15:53:18 +00:00
Chris Pressey
aa5e4119da Copy indexed location to location. All tests pass again. 2017-12-08 15:07:15 +00:00
Chris Pressey
689ed37f2e Beginnings of implementing word tables. One test still fails. 2017-12-08 13:41:48 +00:00
Chris Pressey
ad8e0647a4 Use right endianness when copying literal word into storage. 2017-12-07 16:49:43 +00:00
Chris Pressey
75cf18d3a2 Add word (constant or memory loc) to pointer (unchecked for now). 2017-12-07 14:14:43 +00:00
Chris Pressey
a4fd0e590b Adding a word memory location to another word memory location. 2017-12-07 13:15:21 +00:00
Chris Pressey
92525fd482 Adding a constant word to a memory location. 2017-12-07 12:48:56 +00:00
Chris Pressey
cf679b293a Ability to --debug analysis. Make 16-bit addition test pass. 2017-12-07 11:49:15 +00:00
Chris Pressey
97d00637d2 Initial work on adding 16-bit constants to a 16-bit location. 2017-12-07 11:31:46 +00:00
Chris Pressey
d84566a880 Write stored values, and read values, through pointers. 2017-12-01 13:52:56 +00:00
Chris Pressey
32389e4422 Require that the program does ^buf to get at the address of buf. 2017-12-01 12:36:58 +00:00
Chris Pressey
a95cbb0f47 Introduce IndirectRef and use it instead of adhoc 'copy[]+y' opcode. 2017-12-01 11:44:40 +00:00
Chris Pressey
19a196f765 Compile copy[]+y. 2017-11-24 16:56:55 +00:00
Chris Pressey
c8c69a2a7d Fix problem with test case, and with serializing as zero page. 2017-11-24 13:42:14 +00:00
Chris Pressey
e41dd1aa01 Attempt to add Zero Page addressing; the emitter may need rethink. 2017-11-24 13:09:10 +00:00
Chris Pressey
c91574186b First pass of buffer, pointer, copy b, [p] + y, indirect indexed. 2017-11-24 12:35:36 +00:00
Chris Pressey
42438dd97f Beginning of: buffers and pointers. 2017-11-24 11:30:20 +00:00
Chris Pressey
c33e6ef0e9 Assert that the loop variable is meaningful in repeat. Unit test. 2017-11-20 16:39:39 +00:00
Chris Pressey
22cc7bfc11 Support copy'ing a word constant to a word location. Joystick eg. 2017-11-20 15:18:21 +00:00
Chris Pressey
563aaeba47 Remove low/high byte operators until I've thought about it more. 2017-11-17 15:54:50 +00:00
Chris Pressey
9d6ca0b2b4 Low and high address operators, parsing and execution thereof. 2016-06-16 11:10:43 -05:00
Chris Pressey
e2daa33dc5 Compile copy byte to byte and word to word. 2016-06-16 11:10:03 -05:00
Chris Pressey
fc8c85e670 word types, with syntax and analysis thereof 2016-06-16 11:08:57 -05:00
Chris Pressey
007c81acad Split scanner off from parser module, into own module. 2016-06-16 11:04:03 -05:00
Chris Pressey
7b1ee60a73 Initial value for locations: changed syntax, executes, compiles. 2016-06-16 11:03:31 -05:00
Chris Pressey
b5763e84b4 Constants (such as routines) cannot be given in call-constraints. 2015-10-22 20:01:02 +01:00
Chris Pressey
0d3ac8c247 {Low,High}AddressByte emittables to fix copy, make indirect call! 2015-10-22 16:20:10 +01:00
Chris Pressey
0b2b5d904e Implement indirect JSRs with trampolines in theory; doesn't work. 2015-10-22 15:45:16 +01:00
Chris Pressey
0361016e4c Bring the rest of the tests up to date with the new names. 2015-10-22 09:48:26 +01:00
Chris Pressey
cc433e9c64 Try to improve error messages, thus breaking many unit tests. 2015-10-21 19:43:44 +01:00
Chris Pressey
45310b8f9c It's getting a little chaotic. Needs better error messages! 2015-10-21 17:05:49 +01:00
Chris Pressey
16450e06d5 Compile goto's. 2015-10-21 15:51:52 +01:00
Chris Pressey
bb6ad5d3cf Refactor Analyzer. Get analysis tests passing once again. 2015-10-21 15:45:14 +01:00
Chris Pressey
49d07cee5f Attempt to analyze goto. Looks like it'll need some rewriting. 2015-10-21 11:41:52 +01:00
Chris Pressey
6e0ca3838e Recast Evaluator as an object. Handle goto inside it. 2015-10-20 14:39:32 +01:00
Chris Pressey
be76b9a00d Syntax for goto. 2015-10-20 14:10:33 +01:00