git @ Cat's Eye Technologies SixtyPical / 6afbf58
Deal with the inputs/outputs of buffers, in a weak way. Chris Pressey 4 years ago
4 changed file(s) with 37 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
55
66 * Explicit word literals prefixed with `word` token.
77 * Can `copy` literals into user-defined destinations.
8 * Fixed bug where loop variable wasn't being checked at end of `repeat` loop.
89 * `buffer` and `pointer` types.
910 * `copy ^` syntax to load the addr of a buffer into a pointer.
1011 * `copy []+y` syntax to read and write values to and from memory through a pointer.
4040 TODO
4141 ----
4242
43 Insist the buffer being read or written to through pointer, appears in approporiate set.
43 ### Add to pointer.
4444
45 Add to pointer.
45 And then write a little demo "game" where you can move a block around the screen with
46 the joystick.
4647
4748 ### `word table` and `vector table` types
4849
5758
5859 ### And at some point...
5960
61 * `copy x, [ptr] + y`
62 * Maybe even `copy [ptra] + y, [ptrb] + y`, which can be compiled to indirect LDA then indirect STA!
63 * Check that the buffer being read or written to through pointer, appears in approporiate inputs or outputs set.
6064 * initialized `byte table` memory locations
6165 * always analyze before executing or compiling, unless told not to
6266 * `trash` instruction.
11751175
11761176 Buffers and pointers.
11771177
1178 Note that `^buf` is not considered "reading" buf, so does not require it in `inputs`.
1179 TODO: If reading from it through a pointer, it *should* require it in `inputs`.
1180 TODO: If writing to it through a pointer, it *should* require it in `outputs`.
1178 Note that `^buf` is a constant value, so it by itself does not require `buf` to be
1179 listed in any input/output sets.
1180
1181 However, if the code reads from it through a pointer, it *should* be in `inputs`.
1182
1183 Likewise, if the code writes to it through a pointer, it *should* be in `outputs`.
1184
1185 Of course, unless you write to *all* the bytes in a buffer, some of those bytes
1186 might not be meaningful. So how meaningful is this check?
1187
1188 This is an open problem.
1189
1190 For now, convention says: if it is being read, list it in `inputs`, and if it is
1191 being modified, list it in both `inputs` and `outputs`.
11811192
11821193 Write literal through a pointer.
11831194
11851196 | pointer ptr
11861197 |
11871198 | routine main
1188 | outputs y //, buf
1199 | inputs buf
1200 | outputs y, buf
11891201 | trashes a, z, n, ptr
11901202 | {
11911203 | ld y, 0
12001212 | pointer ptr
12011213 |
12021214 | routine main
1203 | // outputs buf
1215 | inputs buf
1216 | outputs buf
12041217 | trashes a, z, n, ptr
12051218 | {
12061219 | copy ^buf, ptr
12151228 | byte foo
12161229 |
12171230 | routine main
1218 | inputs foo
1219 | outputs y //, buf
1231 | inputs foo, buf
1232 | outputs y, buf
12201233 | trashes a, z, n, ptr
12211234 | {
12221235 | ld y, 0
12321245 | byte foo
12331246 |
12341247 | routine main
1235 | // inputs buf
1248 | inputs buf
12361249 | outputs foo
12371250 | trashes a, y, z, n, ptr
12381251 | {
341341 | }
342342 = 00c0a0c84c06c060a2c860
343343
344 Buffers and pointers.
344 ### Buffers and Pointers
345
346 Load address into pointer.
345347
346348 | buffer[2048] buf
347349 | pointer ptr @ 254
356358 | }
357359 = 00c0a000a90b85fea9c085ff60
358360
359 Writing literal through a pointer.
361 Write literal through a pointer.
360362
361363 | buffer[2048] buf
362364 | pointer ptr @ 254
363365 |
364366 | routine main
367 | inputs buf
365368 | outputs buf, y
366369 | trashes a, z, n, ptr
367370 | {
378381 | byte foo
379382 |
380383 | routine main
381 | inputs foo
382 | outputs y //, buf
384 | inputs foo, buf
385 | outputs y, buf
383386 | trashes a, z, n, ptr
384387 | {
385388 | ld y, 0
388391 | }
389392 = 00c0a000a91085fea9c085ffad12c091fe60
390393
391 Reading through a pointer.
394 Read through a pointer.
392395
393396 | buffer[2048] buf
394397 | pointer ptr @ 254
395398 | byte foo
396399 |
397400 | routine main
398 | // inputs buf
401 | inputs buf
399402 | outputs y, foo
400403 | trashes a, z, n, ptr
401404 | {