git @ Cat's Eye Technologies SixtyPical / 2607e40
Update notes in README. Cat's Eye Technologies 8 years ago
1 changed file(s) with 67 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
101101 to the same address. (This is, however, not yet implemented, and may not be
102102 implemented for a while.)
103103
104 ### Pseudo-Instructions ###
105
106 Along with instructions which map to the 6502 instruction set, SixtyPical
107 supplies some instructions which are slightly more abstract and powerful.
108 For lack of a better term, I'm calling them "pseudo-instructions" here.
109 (But I would really like a better term.)
110
111 In a macro assembler, these pseudo-instructions would be implemented with
112 macros. However, macros, being textual-substitution-based, are a pain to
113 analyze. By providing the functions as built-in instructions, we can
114 easily work them into the type system. Also, there are some macros that are
115 so common and useful that it makes sense for them to be built-ins, with
116 standardized, prescriptive names.
117
118 Such pseudo-instructions are:
119
120 * `copy`, which copies a value from one storage location to another.
121 This is a typesafe way to copy 16-bit `word`s and `vector`s.
122 In the future, it may handle 8-bit values and immediate values too.
123 * `save`, which is not yet implemented. Intended to be used in `with`
124 blocks when you want to save a value but you don't want to use the
125 stack. Pairs well with block-level temporary `reserve`d addresses.
126
104127 ### "It's a Partial Solution" ###
105128
106129 SixtyPical does not attempt to force your typed, abstractly interpreted
142165 are written out explicitly and pedantically. Still, there are places where
143166 an added `foldr` or two would not be unwelcome...
144167
168 The 6502 semantics, which are arguably RISC-like (load/store architecture)
169 are translated into an intermediate representation which is arguably CISC-like.
170 For example, `lda`, `sta`, `ldx`, and `tax` all become kinds of `COPY`
171 internally. This internal instruction set is much smaller than the 6502's,
172 and thus is usually easier to analyze.
173
174 Notes
175 -----
176
177 This is not quite the right place for this, but I need to write it down
178 somewhere:
179
180 6502 machine code supports an indirect `jmp`, but not an indirect `jsr`.
181 But an indirect `jsr` is very easy to simulate with an indirect `jmp`.
182 Instead of
183
184 launch:
185 copy whatever to vector
186 jsr (vector)
187 ...
188
189 Just say
190
191 launch:
192 copy whatever to vector
193 jsr indirect_jsr
194 ...
195
196 indirect_jsr:
197 jmp (vector)
198
199 Then the `rts` at the end of your routine pointed to by `vector` will
200 return you to where you `jsr`ed.
201
202 Because the above is so easy to write, SixtyPical will probably not support
203 a `jsr (vector)` form (unless it would somehow make analysis easier, but
204 it probably won't.)
205
145206 TODO
146207 ----
147208
148209 * Initial values for reserved tables
149210 * Character tables ("strings" to everybody else)
150211 * Addressing modes — indexed mode on more instructions
151 * `jsr (vector)`
212 * Rename and lift temporaries in nested blocks
213 * Tail-recursion optimization
152214 * `jmp routine`
215 * Enforce that `jmp`s come at ends of blocks(?)
153216 * `outputs` on externals
154217 * Routine is a kind of StorageLocation? (Location)?
155 * remove DELTA -> ADD/SUB (requires carry be notated on ADD and SUB though)
218 * Test that `pha` restores the A register
219 * Test poisonining of flags
220 * Test output of flags