├── ISA-SRISC.xlsx
├── LICENSE
├── README.md
├── RISC-CPU.xlsx
├── ROM.xlsx
└── assembler
├── CONDITIONS.S
├── Excel-ASM8.xml
├── FPS.s
├── ball.s
├── border.s
├── borderSingelColor.s
├── compileExcelASM8.py
├── copyImage.s
├── image.bin
├── instTest.s
└── palette.s
/ISA-SRISC.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InkboxSoftware/excelRISC-CPU/8668489da7184bc4a488b9fdbb3d3048eb14c82f/ISA-SRISC.xlsx
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Excel 8-Bit RISC CPU
2 | The Excel 8-Bit RISC CPU repository contains the following main files:
3 | ```
4 | RISC-CPU.xlsx - The main spreadsheet which contains the CPU
5 | ROM.xlsx - The ROM spreadsheet read by the RISC-CPU excel file
6 | ISA-SRISC.xlsx - CPU's ISA documentation
7 | compileExcelASM8.py - The Excel-ASM8 compiler
8 | Excel-ASM8.xml - Markdown for the Excel-ASM8 language compatible with Notepad++
9 | Other sample programs to be found in the assembler folder
10 | ```
11 |
12 | The RISC-CPU.xlsx file features an 8-bit RISC CPU running a 10 instruction ISA. The system has 1 register, a stack, 1KB RAM, 1KB ROM, and a 16x16 64-color display.
13 |
14 | **Excel note: Iterative Calcuation must be turned on.** This can be done by going to File -> Options -> Formulas -> then Enable Iterative Calculation. Remember to **set Maximum Iterations to 1**
15 | **The ROM.xlsx file path must also be updated**
16 |
17 | The CPU runs off a clock signal set in B2. This clock signal will update under the normal conditions of recalculation within an Excel spreadsheet. Pressing the F9 key will recalculate the spreadsheet.
18 |
19 | The Reset Button in the L2 cell, if set to true, will reset the PC register, stack, and RAM back to 0.
20 |
21 | The computer in the CPU.xlsx file can be controlled either in automatic or manual mode. This is controlled by the button in F2. If set to true, when the clock signal from B2 is high, then the CPU will carry out the operation specified in the override slot. If false, then the CPU will execute the operation retrieved from ROM at the address specified by the PC register.
22 |
23 | The CPU is designed to run according to the instruction set architecture specified in the ISA-SRISC.xlsx spreadsheet.
24 |
25 | Press the F9 key to update the CPU clock. Hold down the F9 key to run a program at full speed.
26 |
27 | To assemble a program using the compileExcelASM8.py assembler into an excel spreadsheet:
28 | ```
29 | py compileExcelASM8.py [program.s] ROM.xlsx
30 | ```
31 |
32 | Excel-ASM8 has only 10 instructions. The assembler is not case sensitive. Both decimal and hexadecimal numbers are supported.
33 |
34 | #### LDI
35 | ```
36 | LDI #102 ; load value 102 into register
37 | LDI $FF ; load value 255 into register
38 | LDI VAR ; load value specified by variable VAR
39 | ```
40 | #### PUSH
41 | ```
42 | PUSH ; pushes current register value onto top of stack
43 | ; value still remains in register
44 | ; stack pointer is decreased
45 | ```
46 | #### POP
47 | ```
48 | POP ; pops top of stack into register
49 | ; stack pointer is increased
50 | ```
51 | #### LDR
52 | ```
53 | LDR ; uses the value at the top of stack as address to read value into register from ROM
54 | ; pops top of stack and increases stack pointer
55 | ```
56 | #### STR
57 | ```
58 | STR ; uses register's value as the RAM address to store the value in top of the stack
59 | ; pops top of stack and increases stack pointer
60 | ```
61 | #### ADD
62 | ```
63 | ADD ; adds the register's value, top of stack, and the carry flag, stored in the register
64 | ; pops top of stack and increases stack pointer
65 | ```
66 | #### CMP
67 | ```
68 | CMP #01
69 | CMP $F0 ; compares register's value to the immediate operand in the instruction, only affecting the system's Carry/Zero flag
70 | ```
71 | #### BGE
72 | ```
73 | BGE LABEL ; if the Carry/Zero flag is set then the system will jump to the label
74 | BGE $30 ; the immediate value is a signed byte in range from -128 to 127.
75 | ; any referenced label must be in that range
76 | ```
77 | #### CLC
78 | ```
79 | CLC ; sets system Carry/Zero flag to 0
80 | ```
81 | #### SEC
82 | ```
83 | SEC ; sets system Carry/Zero flag to 1
84 | ```
85 |
86 | Given that the system's register is only 8-bytes wide, in order to address the full 1KB of RAM the 0th memory cells acts as the current working block number 0 to 7.
87 | All LDR/STR specified addresses less than 128 will always access the block 0. Any address greater than or equal to 128 will add ((blockNumber * 128) - 128) to the specified address.
88 | Blocks 6 and 7 of RAM control the screen's pixels, with 1 pixel per memory cell. Only 64 colors are provided in conditional formatting.
89 |
90 | ### Color Palette
91 | The following image represents the system's color palette:
92 |
93 | 
94 |
95 | Example setting the 1st and last pixels to color $0F (red).
96 | ```
97 | ;SET PAGE TO 6
98 | LDI $06
99 | PUSH
100 | LDI $00
101 | STR ;PAGE NOW SET TO 6
102 | ;STORE IN FIRST PIXEL OF SCREEN
103 | LDI $0F ;RED
104 | PUSH
105 | LDI $80 ;128 WILL BE SUBTRACTED FROM THIS ADDRESS, SO $80 IS EQUIVLENT TO ADDRESSING THE ROM BLOCK'S Oth MEMORY CELL
106 | STR
107 |
108 | ;SET PAGE TO 7
109 | LDI $07
110 | PUSH
111 | LDI $00
112 | STR ;PAGE NOW SET TO 7
113 | ;STORE PIXEL IN LAST CELL
114 | LDI $0F ;RED
115 | PUSH
116 | LDI $FF
117 | STR
118 | ```
119 |
120 |
121 | ## Psuedo Instructions
122 | ### Labels
123 | ```
124 | LOOP: ; loop name followed by colon
125 | LDI #01
126 | PUSH
127 | LDI #02
128 | CLC
129 | ADD
130 | SEC
131 | BGE LOOP ; jumps back to the label named LOOP
132 | ```
133 | ### Variables
134 | ```
135 | VAR = #244 ; all variables must be less than 255
136 | F00 = $01
137 | ```
138 |
139 | ### ORG
140 | ```
141 | ORG $100 ; sets the location of the next instruction to the immediate value operand in range from 0 to 1023
142 | ; specified value must be further than the current length of program
143 | ```
144 | ### INC
145 | ```
146 | INC "file.bin" ; copies the binary file into the program starting from the current address of this instruction
147 | ```
148 |
149 |
--------------------------------------------------------------------------------
/RISC-CPU.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InkboxSoftware/excelRISC-CPU/8668489da7184bc4a488b9fdbb3d3048eb14c82f/RISC-CPU.xlsx
--------------------------------------------------------------------------------
/ROM.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InkboxSoftware/excelRISC-CPU/8668489da7184bc4a488b9fdbb3d3048eb14c82f/ROM.xlsx
--------------------------------------------------------------------------------
/assembler/CONDITIONS.S:
--------------------------------------------------------------------------------
1 |
2 | LDR $00
3 | COUNTLOOP:
4 | ADD $01
5 | CMP $FF
6 | BGE COUNTLOOP
7 |
8 | JMP END
9 |
10 | LDR $00
11 | ADD $01
12 | ADD $01
13 | ADD $01
14 | ADD $01
15 | ADD $01
16 | ADD $01
17 |
18 |
19 | LABEL:
20 | SEC
21 | BGE LABEL
22 |
23 | ;=
24 | CMP COND
25 | BGE TESTEQ
26 | SEC
27 | BGE FAIL
28 | TESTEQ:
29 | CMP COND+1
30 | BGE FAIL
31 | SEC
32 | BGE PASS
33 |
34 | ;>
35 | CMP COND
36 | BGE TESTEQ
37 | SEC
38 | BGE FAIL
39 | TESTEQ:
40 | CMP COND+1
41 | BGE PASS
42 | SEC
43 | BGE FAIL
44 |
45 | ;<
46 | CMP COND
47 | BGE FAIL
48 | SEC
49 | BGE PASS
50 |
51 | ;>=
52 | CMP COND
53 | BGE PASS
54 | SEC
55 | BGE FAIL
56 |
57 | ;<=
58 | CMP COND
59 | BGE TESTEQ
60 | SEC
61 | BGE PASS
62 | TESTEQ:
63 | CMP COND+1
64 | BGE FAIL
65 | SEC
66 | BGE PASS
67 |
68 |
69 |
--------------------------------------------------------------------------------
/assembler/Excel-ASM8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | 00; 01 02 03 04
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | BGE
LDI
CMP
ADD
PUSH
POP
LDR
STR
CLC
SEC
ORG
28 |
29 | $
#
@
30 | .INC
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/assembler/FPS.s:
--------------------------------------------------------------------------------
1 | ;PROGRAM USED TO HELP ESTIMATE THE SPEED OF THE CPU
2 |
3 | START:
4 | LDI #00
5 | ADDLOOP:
6 | PUSH
7 | LDI #01
8 | CLC
9 | ADD
10 | SEC
11 | BGE ADDLOOP
12 |
13 | ORG $300
14 | ADD
15 |
--------------------------------------------------------------------------------
/assembler/ball.s:
--------------------------------------------------------------------------------
1 | ;THIS PROGRAM MOVES A BOUNCING BALL AROUND THE BORDERS OF THE SCREEN
2 | ;THE BALL'S INITIAL STARTING POSITION IS $55
3 | ;ONLY THE LEFT SIDE COLLISION WORKS PROPERLY
4 | ;BECAUSE UHH....
5 |
6 | ;THE REST OF THE PROGRAM IS LEFT AS AN EXCERCISE FOR THOSE INTERESTED
7 |
8 | BALLADDRESS = $01
9 | BALLDIRADDRESS = $02
10 | LASTBALLADDRESS = $03
11 | BALLCOLORADDRESS = $04
12 | BALLX = $05
13 | BALLY = $06
14 |
15 | INIT:
16 | ;SET BALL TO LOCATION $55
17 | LDI $55
18 | PUSH
19 | PUSH
20 | LDI BALLADDRESS
21 | STR
22 | LDI LASTBALLADDRESS
23 | STR
24 | ;SET X AND Y TO 5 (EASIER THAN RUNNING CALCS TO CHECK THEM LATER)
25 | LDI $05
26 | PUSH
27 | PUSH
28 | LDI BALLX
29 | STR
30 | LDI BALLY
31 | STR
32 | ;BALL DIRECTION DEFAUL TO 0
33 | ;SET COLOR TO $3E
34 | LDI $3E
35 | PUSH
36 | LDI BALLCOLORADDRESS
37 | STR
38 |
39 | MOVEBALL:
40 | ;INCREASE BALL IN DIRECTION
41 | LDI BALLDIRADDRESS
42 | PUSH
43 | LDR ;DIRECTION NOW IN REGISTER
44 | CMP #03
45 | BGE MOVEBOTTOMRIGHT
46 | CMP #02
47 | ;BGE MOVETOPLEFT
48 | CMP #01
49 | ;BGE MOVETOPRIGHT
50 | MOVEBOTTOMLEFT:
51 | ;SUB 1 FROM LOCATION
52 | LDI BALLADDRESS
53 | PUSH
54 | LDR
55 | PUSH
56 | LDI $FF
57 | CLC
58 | ADD
59 | PUSH
60 | LDI BALLADDRESS
61 | STR
62 | ;DECREASE X, INCREASE Y
63 | LDI BALLX
64 | PUSH
65 | LDR
66 | PUSH
67 | LDI $FF
68 | CLC
69 | ADD
70 | PUSH
71 | PUSH
72 | LDI BALLX
73 | STR
74 | POP
75 | CMP $01
76 | BGE MOVEY-BOTTOMLEFT
77 | ;CHANGE DIRECTION TO 3
78 | LDI #03
79 | PUSH
80 | LDI BALLDIRADDRESS
81 | STR
82 | MOVEY-BOTTOMLEFT:
83 | ;ADD 16 TO LOCATION
84 | LDI BALLADDRESS
85 | PUSH
86 | LDR
87 | PUSH
88 | LDI $10
89 | CLC
90 | ADD
91 | PUSH
92 | LDI BALLADDRESS
93 | STR
94 | ;BALL-Y
95 | LDI BALLY
96 | PUSH
97 | LDR
98 | PUSH
99 | LDI #01
100 | CLC
101 | ADD
102 | PUSH
103 | PUSH
104 | LDI BALLY
105 | STR
106 | POP
107 | CMP $0F
108 | BGE CHANGEY-BOTTOMLEFT
109 | SEC
110 | BGE DRAWBALL
111 | CHANGEY-BOTTOMLEFT:
112 | ;ELSE SET BALL DIRECTION TO 1
113 | LDI #01
114 | PUSH
115 | LDI BALLDIRADDRESS
116 | STR
117 | ;END-MOVEBOTTOMLEFT
118 | SEC
119 | BGE DRAWBALL
120 | BACKPEDAL-BALL:
121 | SEC
122 | BGE MOVEBALL
123 | MOVEBOTTOMRIGHT:
124 | ;ADD 1 TO LOCATION
125 | LDI BALLADDRESS
126 | PUSH
127 | LDR
128 | PUSH
129 | LDI $01
130 | CLC
131 | ADD
132 | PUSH
133 | LDI BALLADDRESS
134 | STR
135 | ;INCREASE X, INCREASE Y
136 | LDI BALLX
137 | PUSH
138 | LDR
139 | PUSH
140 | LDI $01
141 | CLC
142 | ADD
143 | PUSH
144 | PUSH
145 | LDI BALLX
146 | STR
147 | POP
148 | CMP $0F
149 | BGE CHANGEBOTTOMX
150 | SEC
151 | BGE MOVEY-BOTTOMLEFT
152 | CHANGEBOTTOMX:
153 | ;CHANGE DIRECTION TO 0
154 | LDI #00
155 | PUSH
156 | LDI BALLDIRADDRESS
157 | STR
158 |
159 | SEC
160 | BGE MOVEY-BOTTOMLEFT
161 |
162 | MOVETOPLEFT:
163 |
164 | SEC
165 | BGE DRAWBALL
166 |
167 | MOVETOPRIGHT:
168 |
169 | SEC
170 | BGE DRAWBALL
171 |
172 |
173 |
174 | DRAWBALL:
175 | ;DRAW TO SCREEN
176 | LDI BALLADDRESS
177 | PUSH
178 | LDR
179 | CMP #128 ;IF DIRECTION LESS THAN 128, SET PAGE TO 6, ADD 128 TO LOCATION
180 | BGE DRAWMORETHAN128
181 | DRAWLESSTHAN128:
182 | ;BALL ADDRESS IN REGISTER (NOT NEEDED YET SO IGNORE FOR NOW)
183 | LDI #06 ;SET BLOCK TO 6
184 | PUSH
185 | LDI #00
186 | STR ;BLOCK NOW SET
187 | ;GET COLOR VALUE
188 | LDI BALLCOLORADDRESS
189 | PUSH
190 | LDR
191 | PUSH ;NOW ON TOP OF STACK
192 | LDI BALLADDRESS
193 | PUSH
194 | LDR
195 | PUSH
196 | LDI #128
197 | CLC
198 | ADD ;ADJUSTED ADDRESS NOW IN REGISTER
199 | STR
200 | SEC
201 | BGE AFTERDRAW
202 |
203 | DRAWMORETHAN128:
204 | ;SET BLOCK TO 7
205 | LDI #07
206 | PUSH
207 | LDI #00
208 | STR ;BLOCK NOW SET TO 7
209 | ;GET COLOR VALUE
210 | LDI BALLCOLORADDRESS
211 | PUSH
212 | LDR
213 | PUSH ;NOW ON TOP OF STACK
214 | LDI BALLADDRESS
215 | PUSH
216 | LDR
217 | STR ;DRAW
218 |
219 | AFTERDRAW:
220 | ;INCREASE BALL COLOR
221 | LDI BALLCOLORADDRESS
222 | PUSH
223 | LDR
224 | PUSH
225 | LDI $FC
226 | CLC
227 | ADD
228 | PUSH
229 | PUSH
230 | LDI BALLCOLORADDRESS
231 | STR
232 | POP
233 | CMP #64
234 | BGE RESETBALLCOLOR
235 | BACKTOBEGINING:
236 | SEC
237 | BGE BACKPEDAL-BALL
238 | RESETBALLCOLOR:
239 | LDI $3E
240 | PUSH
241 | LDI BALLCOLORADDRESS
242 | STR
243 | SEC
244 | BGE BACKTOBEGINING
--------------------------------------------------------------------------------
/assembler/border.s:
--------------------------------------------------------------------------------
1 | ;THIS PROGRAM DRAWS A BORDER AROUND THE EDGE OF THE 16x16px SCREEN
2 | ;THE BORDER POSITIONS ARE FIRST CALCULATED
3 | ;THEN DRAWN ONE AT A TIME
4 |
5 | COLORADDRESS = $01
6 | CURRENTADDRESS = $02
7 | BORDERADDRESS = $03
8 |
9 | ;INIT BORDERADDRESS TO $10
10 | LDI $10
11 | PUSH
12 | LDI BORDERADDRESS
13 | STR
14 |
15 | ;LOADING BORDER LOCATIONS:
16 | TOPROW:
17 | ;0 TO 15
18 | LDI CURRENTADDRESS
19 | PUSH
20 | LDR
21 | PUSH
22 | LDI BORDERADDRESS
23 | PUSH
24 | LDR
25 | STR
26 | ;INCREASE BORDERADDRESS
27 | LDI BORDERADDRESS
28 | PUSH
29 | LDR
30 | PUSH
31 | LDI $01
32 | CLC
33 | ADD
34 | PUSH
35 | LDI BORDERADDRESS
36 | STR
37 | ;INCREASE CURRENTADDRESS
38 | LDI CURRENTADDRESS
39 | PUSH
40 | LDR
41 | PUSH
42 | LDI $01
43 | CLC
44 | ADD
45 | ;SAVE
46 | PUSH
47 | PUSH
48 | LDI CURRENTADDRESS
49 | STR
50 | ;CHECK IF AT $10
51 | POP
52 | CMP $10
53 | BGE LEFTROW
54 | ;BACK TO TOP
55 | SEC
56 | BGE TOPROW
57 |
58 | LEFTROW:
59 | ;$10 TO $E0
60 | LDI CURRENTADDRESS
61 | PUSH
62 | LDR
63 | PUSH
64 | LDI BORDERADDRESS
65 | PUSH
66 | LDR
67 | STR
68 | ;INCREASE BORDERADDRESS
69 | LDI BORDERADDRESS
70 | PUSH
71 | LDR
72 | PUSH
73 | LDI $01
74 | CLC
75 | ADD
76 | PUSH
77 | LDI BORDERADDRESS
78 | STR
79 | ;INCREASE CURRENTADDRESS
80 | LDI CURRENTADDRESS
81 | PUSH
82 | LDR
83 | PUSH
84 | LDI $10
85 | CLC
86 | ADD
87 | ;SAVE
88 | PUSH
89 | PUSH
90 | LDI CURRENTADDRESS
91 | STR
92 | ;CHECK IF AT $F0
93 | POP
94 | CMP $F0
95 | BGE BOTTOMROW
96 | ;BACK TO TOP
97 | SEC
98 | BGE LEFTROW
99 |
100 | BOTTOMROW:
101 | ;$F0 TO $FF
102 | LDI CURRENTADDRESS
103 | PUSH
104 | LDR
105 | PUSH
106 | LDI BORDERADDRESS
107 | PUSH
108 | LDR
109 | STR
110 | ;CHECK IF AT $FF
111 | LDI CURRENTADDRESS
112 | PUSH
113 | LDR
114 | CMP $FF
115 | BGE RIGHTROWINIT
116 | ;INCREASE BORDERADDRESS
117 | LDI BORDERADDRESS
118 | PUSH
119 | LDR
120 | PUSH
121 | LDI $01
122 | CLC
123 | ADD
124 | PUSH
125 | LDI BORDERADDRESS
126 | STR
127 | ;INCREASE CURRENTADDRESS
128 | LDI CURRENTADDRESS
129 | PUSH
130 | LDR
131 | PUSH
132 | LDI $01
133 | CLC
134 | ADD
135 | ;SAVE
136 | PUSH
137 | LDI CURRENTADDRESS
138 | STR
139 | ;BACK TO TOP
140 | SEC
141 | BGE BOTTOMROW
142 |
143 | RIGHTROWINIT:
144 | ;INCREASE BORDERADDRESS
145 | LDI BORDERADDRESS
146 | PUSH
147 | LDR
148 | PUSH
149 | LDI $01
150 | CLC
151 | ADD
152 | PUSH
153 | LDI BORDERADDRESS
154 | STR
155 |
156 | ;SET CURRENTADDRESS TO $1F
157 | LDI $1F
158 | PUSH
159 | LDI CURRENTADDRESS
160 | STR
161 | RIGHTROW:
162 | ;$1F TO $EF
163 | LDI CURRENTADDRESS
164 | PUSH
165 | LDR
166 | PUSH
167 | LDI BORDERADDRESS
168 | PUSH
169 | LDR
170 | STR
171 | ;INCREASE BORDERADDRESS
172 | LDI BORDERADDRESS
173 | PUSH
174 | LDR
175 | PUSH
176 | LDI $01
177 | CLC
178 | ADD
179 | PUSH
180 | LDI BORDERADDRESS
181 | STR
182 | ;INCREASE CURRENTADDRESS
183 | LDI CURRENTADDRESS
184 | PUSH
185 | LDR
186 | PUSH
187 | LDI $10
188 | CLC
189 | ADD
190 | ;SAVE
191 | PUSH
192 | PUSH
193 | LDI CURRENTADDRESS
194 | STR
195 | ;CHECK IF AT $FF
196 | POP
197 | CMP $FF
198 | BGE SETCOLOR
199 | ;BACK TO TOP
200 | SEC
201 | BGE RIGHTROW
202 |
203 | SETCOLOR:
204 | ;DRAWING THE BORDER OF THE SCREEN
205 | LDI $0B ;COLOR
206 | PUSH
207 | LDI COLORADDRESS
208 | STR
209 |
210 | ;RESET BORDERADDRESS TO $10 TO READ INDIRECTLY
211 | LDI $10
212 | PUSH
213 | LDI BORDERADDRESS
214 | STR
215 |
216 | SEC
217 | BGE DRAW
218 |
219 | DRAWPIXEL:
220 | ;TEST IF AT END
221 | LDI BORDERADDRESS
222 | PUSH
223 | LDR
224 | PUSH
225 | LDR
226 | CMP $01
227 | BGE DRAW
228 | SEC
229 | BGE END
230 | DRAW:
231 | ;DRAW TO SCREEN
232 | LDI BORDERADDRESS
233 | PUSH
234 | LDR
235 | PUSH
236 | LDR
237 | CMP #128 ;IF DIRECTION LESS THAN 128, SET PAGE TO 6, ADD 128 TO LOCATION
238 | BGE DRAWMORETHAN128
239 | DRAWLESSTHAN128:
240 | ;BALL ADDRESS IN REGISTER (NOT NEEDED YET SO IGNORE FOR NOW)
241 | LDI #06 ;SET BLOCK TO 6
242 | PUSH
243 | LDI #00
244 | STR ;BLOCK NOW SET
245 | ;GET COLOR VALUE
246 | LDI COLORADDRESS
247 | PUSH
248 | LDR
249 | PUSH ;NOW ON TOP OF STACK
250 | LDI BORDERADDRESS
251 | PUSH
252 | LDR
253 | PUSH
254 | LDR
255 | PUSH
256 | LDI #128
257 | CLC
258 | ADD ;ADJUSTED ADDRESS NOW IN REGISTER
259 | STR
260 | SEC
261 | BGE AFTERDRAW
262 |
263 | DRAWMORETHAN128:
264 | ;SET BLOCK TO 7
265 | LDI #07
266 | PUSH
267 | LDI #00
268 | STR ;BLOCK NOW SET TO 7
269 | ;GET COLOR VALUE
270 | LDI COLORADDRESS
271 | PUSH
272 | LDR
273 | PUSH ;NOW ON TOP OF STACK
274 | LDI BORDERADDRESS
275 | PUSH
276 | LDR
277 | PUSH
278 | LDR
279 | STR ;DRAW
280 |
281 | AFTERDRAW:
282 | ;INCREASE COLOR BY $2
283 | LDI COLORADDRESS
284 | PUSH
285 | LDR
286 | PUSH
287 | LDI $02
288 | CLC
289 | ADD
290 | PUSH
291 | LDI COLORADDRESS
292 | STR
293 |
294 | ;INCREASE BORDERADDRESS
295 | LDI BORDERADDRESS
296 | PUSH
297 | LDR
298 | PUSH
299 | LDI #01
300 | CLC
301 | ADD
302 | PUSH
303 | LDI BORDERADDRESS
304 | STR
305 |
306 | ;BACK TO THE BEGINING OF THE DRAW LOOP
307 | SEC
308 | BGE DRAWPIXEL
309 |
310 | END:
311 | BGE END
312 |
--------------------------------------------------------------------------------
/assembler/borderSingelColor.s:
--------------------------------------------------------------------------------
1 | ;THIS PROGRAM DRAWS A BORDER AROUND THE EDGE OF THE 16x16px SCREEN
2 | ;THE BORDER POSITIONS ARE FIRST CALCULATED
3 | ;THEN DRAWN ONE AT A TIME
4 |
5 | COLORADDRESS = $01
6 | CURRENTADDRESS = $02
7 | BORDERADDRESS = $03
8 |
9 | ;INIT BORDERADDRESS TO $10
10 | LDI $10
11 | PUSH
12 | LDI BORDERADDRESS
13 | STR
14 |
15 | ;LOADING BORDER LOCATIONS:
16 | TOPROW:
17 | ;0 TO 15
18 | LDI CURRENTADDRESS
19 | PUSH
20 | LDR
21 | PUSH
22 | LDI BORDERADDRESS
23 | PUSH
24 | LDR
25 | STR
26 | ;INCREASE BORDERADDRESS
27 | LDI BORDERADDRESS
28 | PUSH
29 | LDR
30 | PUSH
31 | LDI $01
32 | CLC
33 | ADD
34 | PUSH
35 | LDI BORDERADDRESS
36 | STR
37 | ;INCREASE CURRENTADDRESS
38 | LDI CURRENTADDRESS
39 | PUSH
40 | LDR
41 | PUSH
42 | LDI $01
43 | CLC
44 | ADD
45 | ;SAVE
46 | PUSH
47 | PUSH
48 | LDI CURRENTADDRESS
49 | STR
50 | ;CHECK IF AT $10
51 | POP
52 | CMP $10
53 | BGE LEFTROW
54 | ;BACK TO TOP
55 | SEC
56 | BGE TOPROW
57 |
58 | LEFTROW:
59 | ;$10 TO $E0
60 | LDI CURRENTADDRESS
61 | PUSH
62 | LDR
63 | PUSH
64 | LDI BORDERADDRESS
65 | PUSH
66 | LDR
67 | STR
68 | ;INCREASE BORDERADDRESS
69 | LDI BORDERADDRESS
70 | PUSH
71 | LDR
72 | PUSH
73 | LDI $01
74 | CLC
75 | ADD
76 | PUSH
77 | LDI BORDERADDRESS
78 | STR
79 | ;INCREASE CURRENTADDRESS
80 | LDI CURRENTADDRESS
81 | PUSH
82 | LDR
83 | PUSH
84 | LDI $10
85 | CLC
86 | ADD
87 | ;SAVE
88 | PUSH
89 | PUSH
90 | LDI CURRENTADDRESS
91 | STR
92 | ;CHECK IF AT $F0
93 | POP
94 | CMP $F0
95 | BGE BOTTOMROW
96 | ;BACK TO TOP
97 | SEC
98 | BGE LEFTROW
99 |
100 | BOTTOMROW:
101 | ;$F0 TO $FF
102 | LDI CURRENTADDRESS
103 | PUSH
104 | LDR
105 | PUSH
106 | LDI BORDERADDRESS
107 | PUSH
108 | LDR
109 | STR
110 | ;CHECK IF AT $FF
111 | LDI CURRENTADDRESS
112 | PUSH
113 | LDR
114 | CMP $FF
115 | BGE RIGHTROWINIT
116 | ;INCREASE BORDERADDRESS
117 | LDI BORDERADDRESS
118 | PUSH
119 | LDR
120 | PUSH
121 | LDI $01
122 | CLC
123 | ADD
124 | PUSH
125 | LDI BORDERADDRESS
126 | STR
127 | ;INCREASE CURRENTADDRESS
128 | LDI CURRENTADDRESS
129 | PUSH
130 | LDR
131 | PUSH
132 | LDI $01
133 | CLC
134 | ADD
135 | ;SAVE
136 | PUSH
137 | LDI CURRENTADDRESS
138 | STR
139 | ;BACK TO TOP
140 | SEC
141 | BGE BOTTOMROW
142 |
143 | RIGHTROWINIT:
144 | ;INCREASE BORDERADDRESS
145 | LDI BORDERADDRESS
146 | PUSH
147 | LDR
148 | PUSH
149 | LDI $01
150 | CLC
151 | ADD
152 | PUSH
153 | LDI BORDERADDRESS
154 | STR
155 |
156 | ;SET CURRENTADDRESS TO $1F
157 | LDI $1F
158 | PUSH
159 | LDI CURRENTADDRESS
160 | STR
161 | RIGHTROW:
162 | ;$1F TO $EF
163 | LDI CURRENTADDRESS
164 | PUSH
165 | LDR
166 | PUSH
167 | LDI BORDERADDRESS
168 | PUSH
169 | LDR
170 | STR
171 | ;INCREASE BORDERADDRESS
172 | LDI BORDERADDRESS
173 | PUSH
174 | LDR
175 | PUSH
176 | LDI $01
177 | CLC
178 | ADD
179 | PUSH
180 | LDI BORDERADDRESS
181 | STR
182 | ;INCREASE CURRENTADDRESS
183 | LDI CURRENTADDRESS
184 | PUSH
185 | LDR
186 | PUSH
187 | LDI $10
188 | CLC
189 | ADD
190 | ;SAVE
191 | PUSH
192 | PUSH
193 | LDI CURRENTADDRESS
194 | STR
195 | ;CHECK IF AT $FF
196 | POP
197 | CMP $FF
198 | BGE SETCOLOR
199 | ;BACK TO TOP
200 | SEC
201 | BGE RIGHTROW
202 |
203 | SETCOLOR:
204 | ;DRAWING THE BORDER OF THE SCREEN
205 | LDI $0F ;SINGLE COLOR
206 | PUSH
207 | LDI COLORADDRESS
208 | STR
209 |
210 | ;RESET BORDERADDRESS TO $10 TO READ INDIRECTLY
211 | LDI $10
212 | PUSH
213 | LDI BORDERADDRESS
214 | STR
215 |
216 | SEC
217 | BGE DRAW
218 |
219 | DRAWPIXEL:
220 | ;TEST IF AT END
221 | LDI BORDERADDRESS
222 | PUSH
223 | LDR
224 | PUSH
225 | LDR
226 | CMP $01
227 | BGE DRAW
228 | SEC
229 | BGE END
230 | DRAW:
231 | ;DRAW TO SCREEN
232 | LDI BORDERADDRESS
233 | PUSH
234 | LDR
235 | PUSH
236 | LDR
237 | CMP #128 ;IF DIRECTION LESS THAN 128, SET PAGE TO 6, ADD 128 TO LOCATION
238 | BGE DRAWMORETHAN128
239 | DRAWLESSTHAN128:
240 | ;BALL ADDRESS IN REGISTER (NOT NEEDED YET SO IGNORE FOR NOW)
241 | LDI #06 ;SET BLOCK TO 6
242 | PUSH
243 | LDI #00
244 | STR ;BLOCK NOW SET
245 | ;GET COLOR VALUE
246 | LDI COLORADDRESS
247 | PUSH
248 | LDR
249 | PUSH ;NOW ON TOP OF STACK
250 | LDI BORDERADDRESS
251 | PUSH
252 | LDR
253 | PUSH
254 | LDR
255 | PUSH
256 | LDI #128
257 | CLC
258 | ADD ;ADJUSTED ADDRESS NOW IN REGISTER
259 | STR
260 | SEC
261 | BGE AFTERDRAW
262 |
263 | DRAWMORETHAN128:
264 | ;SET BLOCK TO 7
265 | LDI #07
266 | PUSH
267 | LDI #00
268 | STR ;BLOCK NOW SET TO 7
269 | ;GET COLOR VALUE
270 | LDI COLORADDRESS
271 | PUSH
272 | LDR
273 | PUSH ;NOW ON TOP OF STACK
274 | LDI BORDERADDRESS
275 | PUSH
276 | LDR
277 | PUSH
278 | LDR
279 | STR ;DRAW
280 |
281 | AFTERDRAW:
282 | ;INCREASE BORDERADDRESS
283 | LDI BORDERADDRESS
284 | PUSH
285 | LDR
286 | PUSH
287 | LDI #01
288 | CLC
289 | ADD
290 | PUSH
291 | LDI BORDERADDRESS
292 | STR
293 |
294 | ;BACK TO THE BEGINING OF THE DRAW LOOP
295 | SEC
296 | BGE DRAWPIXEL
297 |
298 | END:
299 | BGE END
300 |
--------------------------------------------------------------------------------
/assembler/compileExcelASM8.py:
--------------------------------------------------------------------------------
1 | #COMPILER FOR EXCEL-ASM8
2 | #USE: py compileExcelASM8.py [program.s] ROM.xlsx
3 |
4 | import sys
5 | import os
6 | import time
7 | import math
8 | from openpyxl import load_workbook
9 |
10 | compiled = False;
11 | filePath = ""
12 | spreadsheet = ""
13 | startTime = 0
14 | data = []
15 | program = []
16 | output = []
17 | PROGRAMLENGTH = 1024
18 |
19 | labelOpen = False
20 | labelToUse = ""
21 | RED = '\033[91m';
22 | ENDCOLOR = '\033[0m';
23 |
24 | def integerError(lineNumber):
25 | print(RED + "\tInteger outside of expected range, line: " + str(lineNumber)+ ENDCOLOR)
26 | exit()
27 |
28 | def syntaxError(lineNumber):
29 | print(RED + "\tSyntax Error, line: " + str(lineNumber)+ ENDCOLOR)
30 | exit()
31 |
32 | def labelError(lineNumber):
33 | print(RED + "\tUnreferenced label detected before line " + str(lineNumber) + ENDCOLOR)
34 | exit()
35 |
36 | def referenceNotFoundError(labelName):
37 | print(RED + "\tReference to variable or label not found, " + str(labelName) + ENDCOLOR)
38 | exit()
39 |
40 | def unrecognizedError(lineNumber):
41 | print(RED + "\tUnrecognized Instruction, line " + str(lineNumber) + ENDCOLOR)
42 | exit()
43 |
44 | def varSequenceError(lineNumber):
45 | print(RED + "\tVariables must be defined before program code, line " + str(lineNumber) + ENDCOLOR)
46 | exit()
47 |
48 | def varUseError(lineNumber):
49 | print(RED + "\tVariable cannot be used like label, var: " + str(lineNumber) + ENDCOLOR)
50 | exit()
51 |
52 | def orgError(lineNumber):
53 | print(RED + "\tProgram Count exceeds target address, line " + str(lineNumber) + ENDCOLOR)
54 | exit()
55 |
56 | def incResourceError(resourceName, lineNumber):
57 | print(RED + "\tResource " + resourceName + " could not be found, line " + str(lineNumber) + ENDCOLOR)
58 | exit()
59 |
60 | def lengthError(exceededWords):
61 | print(RED + "\tProgram length exceeds available RAM by " + str(exceededWords) + " bytes" + ENDCOLOR)
62 | exit()
63 |
64 | def ROMbookError():
65 | print(RED + "\tCould not save to specified workbook, make sure the file is closed and try again" + ENDCOLOR)
66 | exit()
67 |
68 | def ROMbookNotFoundError(spreadsheet):
69 | print(RED + "\tROM book " + spreadsheet + " not found" + ENDCOLOR)
70 | exit()
71 |
72 | def labelOutOfReachError(labelName, labelLineNumber, originLine):
73 | print(RED + "\tLabel " + labelName + " line: " + str(labelLineNumber) + " out of branch range [-128, 127] from line: " + str(originLine) + ENDCOLOR)
74 | exit()
75 |
76 |
77 | def createLine(label, operations):
78 | return [label, operations]
79 |
80 | def getCurrentAddress():
81 | address = len(data)
82 | for operations in program:
83 | address = address + len(operations[1])
84 | return address
85 |
86 | def getDistanceToLabel(labelName, originOperation):
87 | if (originOperation < 0):
88 | return None
89 | location = 0
90 | for operations in program:
91 | if (labelName == operations[0]):
92 | distance = location - originOperation
93 | if (distance < -128 or distance > 127):
94 | labelOutOfReachError(labelName, location, originOperation)
95 | distance = distance + 128 #reformat to signed byte
96 | return distance
97 | location = location + len(operations[1])
98 | return None
99 |
100 | def getVarValue(varName):
101 | for var in data:
102 | if (varName == var[0]):
103 | return var[1]
104 | return -1
105 |
106 | def includeBIN(fileName):
107 | with open(fileName, "rb") as incFile:
108 | while (BYTE := incFile.read(1)):
109 | value = int.from_bytes(BYTE)
110 | program.append(createLine("", [value]))
111 |
112 | return
113 |
114 | def parseNumber(numberString, lineNumber, isOrgInst=False):
115 | prefix = numberString[0]
116 | numberString = numberString[1:]
117 | result = 0
118 | varVal = getVarValue(prefix + numberString) #check if references variable
119 | if (prefix == "$" or prefix == "@"): #hex or address
120 | result = int(numberString, 16)
121 | if ((result > 255 and not(isOrgInst)) or (result >= PROGRAMLENGTH and isOrgInst)):
122 | integerError(lineNumber)
123 | elif (prefix == "#"): #decimal
124 | result = int(numberString)
125 | if ((result > 255 and not(isOrgInst)) or (result >= PROGRAMLENGTH and isOrgInst)):
126 | integerError(lineNumber)
127 | elif(not(varVal == -1)): #is variable
128 | return parseNumber(varVal, lineNumber)
129 | else: #is a label address
130 | result = getDistanceToLabel(prefix + numberString, -lineNumber) #negative because first pass is positive
131 | #second pass is negative for calculating distance between future branches
132 | if (result == None and lineNumber <= -1): #second time around
133 | referenceNotFoundError(prefix + numberString)
134 | elif (result == None):
135 | return "LABEL-" + (prefix + numberString)
136 | if ((result > 255 and not(isOrgInst)) or (result >= PROGRAMLENGTH and isOrgInst)):
137 | integerError(lineNumber)
138 | if (result < 0):
139 | integerError(lineNumber)
140 | return result
141 |
142 | def encode(line, lineNumber):
143 | #convert to list of integers
144 | opcode = line[0]
145 | operand0 = 0
146 | twoByte = False
147 | #check instruction format:
148 | if (opcode == "BGE"):
149 | if (not(len(line) == 2)):
150 | syntaxError(lineNumber)
151 | twoByte = True
152 | operand0 = 0
153 | operand1 = parseNumber(line[1], lineNumber)
154 | elif (opcode == "LDI"):
155 | if (not(len(line) == 2)):
156 | syntaxError(lineNumber)
157 | twoByte = True
158 | operand0 = 1
159 | operand1 = parseNumber(line[1], lineNumber)
160 | elif (opcode == "CMP"):
161 | if (not(len(line) == 2)):
162 | syntaxError(lineNumber)
163 | twoByte = True
164 | operand0 = 2
165 | operand1 = parseNumber(line[1], lineNumber)
166 | elif (opcode == "ADD"):
167 | if (not(len(line) == 1)):
168 | syntaxError(lineNumber)
169 | operand0 = 3
170 | elif (opcode == "PUSH"):
171 | if (not(len(line) == 1)):
172 | syntaxError(lineNumber)
173 | operand0 = 4
174 | elif (opcode == "POP"):
175 | if (not(len(line) == 1)):
176 | syntaxError(lineNumber)
177 | operand0 = 5
178 | elif (opcode == "LDR"):
179 | if (not(len(line) == 1)):
180 | syntaxError(lineNumber)
181 | operand0 = 6
182 | elif (opcode == "STR"):
183 | if (not(len(line) == 1)):
184 | syntaxError(lineNumber)
185 | operand0 = 7
186 | elif (opcode == "CLC"):
187 | if (not(len(line) == 1)):
188 | syntaxError(lineNumber)
189 | operand0 = 8
190 | elif (opcode == "SEC"):
191 | if (not(len(line) == 1)):
192 | syntaxError(lineNumber)
193 | operand0 = 9
194 | elif (len(line) == 3 and line[1] == "="): #variables
195 | if (len(program) > 0):
196 | varSequenceError(lineNumber)
197 | data.append(createLine(line[0], line[2]))
198 | return None
199 | elif (opcode == "ORG"):
200 | if (not(len(line) == 2)):
201 | syntaxError(lineNumber)
202 | targetAddress = parseNumber(line[1], lineNumber, True)
203 | currentAddress = getCurrentAddress()
204 | if (currentAddress > targetAddress):
205 | orgError(lineNumber)
206 | while(currentAddress < targetAddress):
207 | program.append(createLine("", [0]))
208 | currentAddress = currentAddress + 1
209 | return None
210 | elif (opcode == ".INC"):
211 | if (not(len(line) == 2)):
212 | syntaxError(lineNumber)
213 | line[1] = line[1].replace("\"", "")
214 | line[1] = line[1].replace("\'", "")
215 | if (not(os.path.isfile(line[1]))):
216 | incResourceError(line[1], lineNumber)
217 | includeBIN(line[1])
218 | return None
219 | else:
220 | unrecognizedError(lineNumber)
221 |
222 | if (not twoByte):
223 | return [operand0]
224 | else:
225 | return [operand0, operand1]
226 |
227 | def parseProgram():
228 | global output
229 | global compiled
230 | for operations in program:
231 | for value in operations[1]:
232 | output.append(value)
233 | if (len(output) > PROGRAMLENGTH):
234 | lengthError(len(output) - PROGRAMLENGTH)
235 | compiled = True
236 | return
237 |
238 | def parseUnmarkedLabels():
239 | pLine = 0
240 | instCount = 0
241 | for operations in program:
242 | valLine = 0
243 | for val in operations[1]:
244 | if ("LABEL" in str(val)):
245 | program[pLine][1][valLine] = parseNumber(val[6:], -instCount)
246 | valLine = valLine + 1
247 | instCount = instCount + len(operations[1])
248 | pLine = pLine + 1
249 | return
250 |
251 | def compileASM(filepath):
252 | file = open(filepath, "r")
253 | lineNumber = 1 #file line number for specifying errors
254 | for line in file:
255 | line = line.upper()
256 | line = line.split(";") #getting rid of comments
257 | line[0] = line[0].replace("\n", "") #removing return line
258 | line[0] = line[0].replace("\r", "")
259 | line[0] = line[0].strip()
260 | if (len(line[0]) > 0):
261 | parseLine(line[0], lineNumber)
262 | lineNumber = lineNumber + 1
263 | parseUnmarkedLabels()
264 | parseProgram()
265 | compileResults()
266 |
267 | def parseLine(line, lineNumber):
268 | global labelOpen
269 | global labelToUse
270 | labelLine = line.split(":");
271 | label = labelLine[0]
272 | if (":" in line and len(labelLine[1]) <= 1):
273 | if (labelOpen):
274 | labelError(lineNumber)
275 | labelToUse = label #add a label with no operations to program
276 | labelOpen = True
277 | return
278 | elif (":" not in line):
279 | if (labelOpen):
280 | label = labelToUse
281 | labelOpen = False
282 | else:
283 | label = ""
284 | else:
285 | if (labelOpen):
286 | labelError(lineNumber)
287 | line = labelLine[1].strip()
288 | line = line.split(" ")
289 | operations = encode(line, lineNumber)
290 | if (not(operations == None)):
291 | program.append(createLine(label, operations))
292 | return
293 |
294 | def sendToSpreadsheet():
295 | #load excel file
296 | workbook = load_workbook(filename = spreadsheet)
297 | #open workbook
298 | sheet = workbook.active
299 | i = 0
300 | while (i < PROGRAMLENGTH):
301 | if (i < len(output)):
302 | sheet.cell(row = math.floor(i / 16) + 3, column = (i % 16) + 1, value = output[i])
303 | else:
304 | sheet.cell(row = math.floor(i / 16) + 3, column = (i % 16) + 1, value = 0)
305 | i = i + 1
306 | #save the file
307 |
308 | try:
309 | workbook.save(filename = spreadsheet)
310 | except:
311 | ROMbookError()
312 | return
313 |
314 | def compileResults():
315 | if (not(compiled)):
316 | print(RED + "\tProgram could not be compiled" + ENDCOLOR)
317 | else:
318 | print("\tProgram compiled Successfully")
319 | print("\tProgram length in words: " + str(getCurrentAddress()))
320 | print("\tWriting to spreadsheet ROM...")
321 | sendToSpreadsheet()
322 | print("\tFinished in " + str(time.time()-startTime)[:6] + "s")
323 | exit()
324 |
325 | if __name__ == "__main__":
326 | startTime = time.time()
327 | os.system('color')
328 | print("\tStarting operation...")
329 |
330 | if (len(sys.argv) == 3):
331 | filePath = sys.argv[1]
332 | spreadsheet = sys.argv[2]
333 | elif (len(sys.argv) == 1):
334 | print(RED + "\tInsufficent arguments, no ASM file specified" + ENDCOLOR)
335 | compileResults()
336 | elif (len(sys.argv) == 2):
337 | print(RED + "\tInsufficent arguments, no target spreadsheet specified" + ENDCOLOR)
338 | compileResults()
339 | else:
340 | print(RED + "\tToo Many Arguments" + ENDCOLOR)
341 | compileResults()
342 |
343 | if (not(os.path.isfile(spreadsheet))):
344 | ROMbookNotFoundError(spreadsheet)
345 | if (not(os.path.isfile(filePath))):
346 | print(RED + "\tFile " + filePath + " not found" + ENDCOLOR)
347 | compileResults()
348 | compileASM(filePath)
--------------------------------------------------------------------------------
/assembler/copyImage.s:
--------------------------------------------------------------------------------
1 |
2 | INSERT:
3 | .inc "image.bin"
4 |
5 | SEC
6 | ENDLOOP:
7 | BGE ENDLOOP
--------------------------------------------------------------------------------
/assembler/image.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InkboxSoftware/excelRISC-CPU/8668489da7184bc4a488b9fdbb3d3048eb14c82f/assembler/image.bin
--------------------------------------------------------------------------------
/assembler/instTest.s:
--------------------------------------------------------------------------------
1 | ;PROGRAM FOR TESTING THE EXCEL-ASM8 ASSEMBLER
2 | ;PASSED SUCESSFULLY
3 |
4 | VAR = #200
5 | VAR2 = $80
6 | VAR3 = $08
7 |
8 | START:
9 | LDI VAR
10 | CMP VAR
11 | BGE NEXT
12 |
13 | SEC
14 | TRAP1:
15 | BGE TRAP1
16 |
17 | NEXT:
18 | LDI #12
19 | CMP VAR
20 | BGE TRAP2
21 | SEC
22 | BGE NEXT2
23 |
24 | TRAP2:
25 | BGE TRAP2
26 |
27 | NEXT2:
28 | LDI VAR2
29 | PUSH
30 | LDI VAR3
31 | SEC
32 | CLC
33 | ADD ;RESULT SHOULD BE #136
34 | PUSH
35 | LDI $00
36 | POP
37 | ;TESTING STORE AND LOAD FROM ADDRESS:
38 | LDI #199
39 | PUSH
40 | LDI #02
41 | STR
42 | LDI #02
43 | PUSH
44 | LDR ;SHOULD READ #199 FROM ADDRESS $002
45 |
46 | END:
47 | ;LOOP BACK TO BEGINING:
48 | SEC
49 | BGE START
50 |
51 |
52 |
53 | BGE #20
54 | CMP $FA
55 | LDI $04
56 |
57 |
58 |
--------------------------------------------------------------------------------
/assembler/palette.s:
--------------------------------------------------------------------------------
1 | ;THIS PROGRAM REVEALS THE COLOR PALETTE OF THE EXCEL SRISC SYSTEM
2 |
3 | VAR = #200
4 | VAR2 = $80
5 | VAR3 = $08
6 |
7 | START:
8 | ;CHANGE RAM PAGE TO PAGE 6
9 | LDI $06
10 | PUSH
11 | LDI $00
12 | STR
13 |
14 | ;0 IN ADDRES 67, ADD 8 EVERY 8 STORES
15 |
16 | LDI $FF
17 | PUSH
18 |
19 | ;STORING ADDRESS IN $01
20 | LDI #67
21 | PUSH
22 | LDI $01
23 | STR
24 |
25 | ;8 COUNT IN ADDRESS $02 (NO NEED ALREADY AT 0)
26 | ;LDI #00
27 | ;PUSH
28 | ;LDI $02
29 | ;STR
30 |
31 | DRAWLINE0:
32 | LDI $01
33 | CLC
34 | ADD
35 | PUSH
36 | PUSH
37 | CMP #32
38 | BGE DRAWPART2
39 | ;LOAD ADDRESS INCREASE, THEN LOAD AGAIN
40 | LDI $01
41 | PUSH
42 | LDR
43 | PUSH
44 | CLC
45 | LDI #01
46 | ADD
47 | PUSH
48 | LDI $01
49 | STR
50 | PUSH
51 | LDR
52 | PUSH
53 | LDI $80
54 | CLC
55 | ADD
56 | STR
57 | ;CHECK FOR EVERY 8
58 | LDI $02
59 | PUSH
60 | LDR
61 | PUSH
62 | CLC
63 | LDI #01
64 | ADD
65 | CMP #08
66 | BGE ADD8
67 | AFTER8:
68 | ;R NOW LOADED WITH NEW COUNT
69 | PUSH
70 | LDI #02
71 | STR
72 | SEC
73 | BGE DRAWLINE0
74 |
75 | ADD8: ;R = 8, MUST RETURN R = 0
76 | ;INCREASE THE VALUE IN $01 BY 8
77 | LDI #01
78 | PUSH
79 | LDR
80 | PUSH
81 | LDI #08
82 | CLC
83 | ADD
84 | PUSH
85 | LDI #01
86 | STR
87 | LDI #0
88 | SEC
89 | BGE AFTER8
90 |
91 | DRAWPART2:
92 | ;POP BOTH FROM STACK AND DECREASE BY 1:
93 | POP
94 | LDI $FF
95 | CLC
96 | ADD
97 | PUSH
98 | ;SET PAGE TO 7
99 | LDI $07
100 | PUSH
101 | LDI $00
102 | STR
103 |
104 | ;SET ADDRESS TO 3
105 | LDI #03
106 | PUSH
107 | LDI $01
108 | STR
109 |
110 | DRAWLINE1:
111 | LDI $01
112 | CLC
113 | ADD
114 | PUSH
115 | PUSH
116 | CMP #64
117 | BGE ENDLOOP
118 | ;LOAD ADDRESS INCREASE, THEN LOAD AGAIN
119 | LDI $01
120 | PUSH
121 | LDR
122 | PUSH
123 | CLC
124 | LDI #01
125 | ADD
126 | PUSH
127 | LDI $01
128 | STR
129 | PUSH
130 | LDR
131 | PUSH
132 | LDI $80
133 | CLC
134 | ADD
135 | STR
136 | ;CHECK FOR EVERY 8
137 | LDI $02
138 | PUSH
139 | LDR
140 | PUSH
141 | CLC
142 | LDI #01
143 | ADD
144 | CMP #08
145 | BGE ADD8-2
146 | AFTER8-2:
147 | ;R NOW LOADED WITH NEW COUNT
148 | PUSH
149 | LDI #02
150 | STR
151 | SEC
152 | BGE DRAWLINE1
153 |
154 | ADD8-2: ;R = 8, MUST RETURN R = 0
155 | ;INCREASE THE VALUE IN $01 BY 8
156 | LDI #01
157 | PUSH
158 | LDR
159 | PUSH
160 | LDI #08
161 | CLC
162 | ADD
163 | PUSH
164 | LDI #01
165 | STR
166 | LDI #0
167 | SEC
168 | BGE AFTER8-2
169 |
170 | SEC
171 | ENDLOOP:
172 | BGE ENDLOOP
173 |
174 |
175 |
176 |
--------------------------------------------------------------------------------