13 | 13 |
Types
|
14 | 14 |
-----
|
15 | 15 |
|
16 | |
There are five *primitive types* in SixtyPical:
|
|
16 |
There are six *primitive types* in SixtyPical:
|
17 | 17 |
|
18 | 18 |
* bit (2 possible values)
|
19 | 19 |
* byte (256 possible values)
|
20 | 20 |
* word (65536 possible values)
|
21 | 21 |
* routine (code stored somewhere in memory, read-only)
|
22 | 22 |
* vector (address of a routine)
|
23 | |
|
24 | |
There is also one *type constructor*:
|
25 | |
|
26 | |
* X table (256 entries, each holding a value of type X)
|
27 | |
|
28 | |
This constructor can only be applied to one type, `byte`.
|
|
23 |
* pointer (address of a byte in a buffer)
|
|
24 |
|
|
25 |
There are also two *type constructors*:
|
|
26 |
|
|
27 |
* X table (256 entries, each holding a value of type X, where X is `byte`)
|
|
28 |
* buffer[N] (N entries; each entry is a byte; N is a power of 2, ≤ 64K)
|
29 | 29 |
|
30 | 30 |
Memory locations
|
31 | 31 |
----------------
|
|
126 | 126 |
that literal integers in the code are always immediate values. (But this
|
127 | 127 |
may change at some point.)
|
128 | 128 |
|
|
129 |
### Buffers and Pointers ###
|
|
130 |
|
|
131 |
Roughly speaking, a `buffer` is a table that can be longer than 256 bytes,
|
|
132 |
and a `pointer` is an address within a buffer.
|
|
133 |
|
|
134 |
A `pointer` is implemented as a zero-page memory location, and accessing the
|
|
135 |
buffer pointed to is implemented with "indirect indexed" addressing, as in
|
|
136 |
|
|
137 |
LDA ($02), Y
|
|
138 |
STA ($02), Y
|
|
139 |
|
|
140 |
There are extended modes of `copy` for using these types of memory location.
|
|
141 |
See `copy` below, but here is some illustrative example code:
|
|
142 |
|
|
143 |
copy ^buf, ptr // this is the only way to initialize a pointer
|
|
144 |
add ptr, 4 // ok, but only if it does not exceed buffer's size
|
|
145 |
ld y, 0 // you must set this to something yourself
|
|
146 |
copy [ptr] + y, byt // read memory through pointer, into byte
|
|
147 |
copy 100, [ptr] + y // write memory through pointer (still trashes a)
|
|
148 |
|
|
149 |
where `ptr` is a user-defined storage location of `pointer` type, and the
|
|
150 |
`+ y` part is mandatory.
|
|
151 |
|
129 | 152 |
Routines
|
130 | 153 |
--------
|
131 | 154 |
|
|
236 | 259 |
After execution, dest is considered initialized, and `z` and `n`, and
|
237 | 260 |
`a` are considered uninitialized.
|
238 | 261 |
|
|
262 |
There are two extra modes that this instruction can be used in. The first is
|
|
263 |
to load an address into a pointer:
|
|
264 |
|
|
265 |
copy ^<src-memory-location>, <dest-memory-location>
|
|
266 |
|
|
267 |
This copies the address of src into dest. In this case, src must be
|
|
268 |
of type buffer, and dest must be of type pointer. src will not be
|
|
269 |
considered a memory location that is read, since it is only its address
|
|
270 |
that is being retrieved.
|
|
271 |
|
|
272 |
The second is to read or write indirectly through a pointer.
|
|
273 |
|
|
274 |
copy [<src-memory-location>] + y, <dest-memory-location>
|
|
275 |
copy <src-memory-location>, [<dest-memory-location>] + y
|
|
276 |
|
|
277 |
In both of these, the memory location in the `[]+y` syntax must be
|
|
278 |
a pointer.
|
|
279 |
|
|
280 |
The first copies the contents of memory at the pointer (offset by the `y`
|
|
281 |
register) into a byte memory location.
|
|
282 |
|
|
283 |
The second copies a literal byte, or a byte memory location, into
|
|
284 |
the contents of memory at the pointer (offset by the `y` register).
|
|
285 |
|
|
286 |
In addition to the constraints above, `y` must be initialized before
|
|
287 |
this mode is used.
|
|
288 |
|
239 | 289 |
### add dest, src ###
|
240 | 290 |
|
241 | 291 |
add <dest-memory-location>, <src-memory-location>
|
|
358 | 408 |
* All memory locations listed in the called routine's `trashes` are considered
|
359 | 409 |
to now be uninitialized.
|
360 | 410 |
* All memory locations listed in the called routine's `outputs` are considered
|
361 | |
to not be initialized.
|
|
411 |
to now be initialized.
|
362 | 412 |
|
363 | 413 |
### goto ###
|
364 | 414 |
|