From 6afbf581f7d28594f7c9936896e90206c176a370 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Fri, 1 Dec 2017 15:10:16 +0000 Subject: [PATCH] Deal with the inputs/outputs of buffers, in a weak way. --- HISTORY.markdown | 1 + README.markdown | 8 ++++++-- tests/SixtyPical Analysis.md | 29 +++++++++++++++++++++-------- tests/SixtyPical Compilation.md | 15 +++++++++------ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/HISTORY.markdown b/HISTORY.markdown index b0477b2..fefecd8 100644 --- a/HISTORY.markdown +++ b/HISTORY.markdown @@ -6,6 +6,7 @@ History of SixtyPical * Explicit word literals prefixed with `word` token. * Can `copy` literals into user-defined destinations. +* Fixed bug where loop variable wasn't being checked at end of `repeat` loop. * `buffer` and `pointer` types. * `copy ^` syntax to load the addr of a buffer into a pointer. * `copy []+y` syntax to read and write values to and from memory through a pointer. diff --git a/README.markdown b/README.markdown index c07b0e2..f97d617 100644 --- a/README.markdown +++ b/README.markdown @@ -41,9 +41,10 @@ Documentation TODO ---- -Insist the buffer being read or written to through pointer, appears in approporiate set. +### Add to pointer. -Add to pointer. +And then write a little demo "game" where you can move a block around the screen with +the joystick. ### `word table` and `vector table` types @@ -58,6 +59,9 @@ are trashed inside the block. ### And at some point... +* `copy x, [ptr] + y` +* Maybe even `copy [ptra] + y, [ptrb] + y`, which can be compiled to indirect LDA then indirect STA! +* Check that the buffer being read or written to through pointer, appears in approporiate inputs or outputs set. * initialized `byte table` memory locations * always analyze before executing or compiling, unless told not to * `trash` instruction. diff --git a/tests/SixtyPical Analysis.md b/tests/SixtyPical Analysis.md index b27ee2e..c07db8a 100644 --- a/tests/SixtyPical Analysis.md +++ b/tests/SixtyPical Analysis.md @@ -1176,9 +1176,20 @@ Can't `copy` from a `word` to a `byte`. Buffers and pointers. -Note that `^buf` is not considered "reading" buf, so does not require it in `inputs`. -TODO: If reading from it through a pointer, it *should* require it in `inputs`. -TODO: If writing to it through a pointer, it *should* require it in `outputs`. +Note that `^buf` is a constant value, so it by itself does not require `buf` to be +listed in any input/output sets. + +However, if the code reads from it through a pointer, it *should* be in `inputs`. + +Likewise, if the code writes to it through a pointer, it *should* be in `outputs`. + +Of course, unless you write to *all* the bytes in a buffer, some of those bytes +might not be meaningful. So how meaningful is this check? + +This is an open problem. + +For now, convention says: if it is being read, list it in `inputs`, and if it is +being modified, list it in both `inputs` and `outputs`. Write literal through a pointer. @@ -1186,7 +1197,8 @@ Write literal through a pointer. | pointer ptr | | routine main - | outputs y //, buf + | inputs buf + | outputs y, buf | trashes a, z, n, ptr | { | ld y, 0 @@ -1201,7 +1213,8 @@ It does use `y`. | pointer ptr | | routine main - | // outputs buf + | inputs buf + | outputs buf | trashes a, z, n, ptr | { | copy ^buf, ptr @@ -1216,8 +1229,8 @@ Write stored value through a pointer. | byte foo | | routine main - | inputs foo - | outputs y //, buf + | inputs foo, buf + | outputs y, buf | trashes a, z, n, ptr | { | ld y, 0 @@ -1233,7 +1246,7 @@ Read through a pointer. | byte foo | | routine main - | // inputs buf + | inputs buf | outputs foo | trashes a, y, z, n, ptr | { diff --git a/tests/SixtyPical Compilation.md b/tests/SixtyPical Compilation.md index a48b833..64e2d77 100644 --- a/tests/SixtyPical Compilation.md +++ b/tests/SixtyPical Compilation.md @@ -342,7 +342,9 @@ goto. | } = 00c0a0c84c06c060a2c860 -Buffers and pointers. +### Buffers and Pointers + +Load address into pointer. | buffer[2048] buf | pointer ptr @ 254 @@ -357,12 +359,13 @@ Buffers and pointers. | } = 00c0a000a90b85fea9c085ff60 -Writing literal through a pointer. +Write literal through a pointer. | buffer[2048] buf | pointer ptr @ 254 | | routine main + | inputs buf | outputs buf, y | trashes a, z, n, ptr | { @@ -379,8 +382,8 @@ Write stored value through a pointer. | byte foo | | routine main - | inputs foo - | outputs y //, buf + | inputs foo, buf + | outputs y, buf | trashes a, z, n, ptr | { | ld y, 0 @@ -389,14 +392,14 @@ Write stored value through a pointer. | } = 00c0a000a91085fea9c085ffad12c091fe60 -Reading through a pointer. +Read through a pointer. | buffer[2048] buf | pointer ptr @ 254 | byte foo | | routine main - | // inputs buf + | inputs buf | outputs y, foo | trashes a, z, n, ptr | {