aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--16bit-cpu.md33
-rw-r--r--LICENSE447
-rw-r--r--Makefile51
-rw-r--r--README.md11
-rwxr-xr-xatk16_asm/assembler.py4
-rw-r--r--atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16 (renamed from resources/asm/ast_compiler_bootstrap.atk16)0
-rw-r--r--atk16_ast_walking_compiler/sample_py/aoc23_1a.py (renamed from resources/py/aoc23_1a.py)0
-rw-r--r--atk16_ast_walking_compiler/sample_py/atk16.py (renamed from resources/py/atk16.py)0
-rw-r--r--atk16_ast_walking_compiler/sample_py/test_py_src.py (renamed from resources/py/test_py_src.py)0
-rw-r--r--atk16_projects/monitor/Makefile16
-rw-r--r--atk16_projects/monitor/monitor.atk16 (renamed from resources/asm/monitor.atk16)0
-rw-r--r--atk16_projects/monitor/monitor_macros.py (renamed from resources/asm/monitor_macros.py)0
-rw-r--r--atk16_projects/monitor_proto/Makefile16
-rw-r--r--atk16_projects/monitor_proto/ext_string_io.py (renamed from resources/asm/ext_string_io.py)0
-rw-r--r--atk16_projects/monitor_proto/monitor_proto.atk16 (renamed from resources/asm/monitor_old.atk16)0
-rw-r--r--atk16_utils/charmem/charmem.binbin0 -> 2048 bytes
-rw-r--r--atk16_utils/charmem/charmem.py (renamed from atk16_utils/charmem.py)0
-rw-r--r--atk16_utils/charmem/charset.txt (renamed from resources/charset.txt)bin23058 -> 23058 bytes
-rw-r--r--atk16_utils/charmem/ibm_cga_8x8.ttf (renamed from resources/ibm_cga_8x8.ttf)bin35952 -> 35952 bytes
-rw-r--r--atk16_utils/ucode/ucode.binbin0 -> 768 bytes
-rwxr-xr-xatk16_utils/ucode/ucode.py (renamed from atk16_utils/ucode.py)0
-rw-r--r--resources/asm/fibo.atk1653
-rw-r--r--resources/asm/idle_loop.atk164
-rw-r--r--resources/asm/just_hlt.atk161
-rw-r--r--resources/asm/sum.atk1631
-rw-r--r--resources/asm/test_py_src.atk16301
-rw-r--r--resources/asm/text_mode.atk1669
-rw-r--r--resources/asm/tpu.atk1612
28 files changed, 503 insertions, 546 deletions
diff --git a/16bit-cpu.md b/16bit-cpu.md
deleted file mode 100644
index d862114..0000000
--- a/16bit-cpu.md
+++ /dev/null
@@ -1,33 +0,0 @@
-# 16-bit CPU design doc
-
-## Features
-16-bit data
-16-bit address width
-16-bit instruction width
-16-bit control word
-Minimal instruction set computer (MISC)
-4-bit opcodes
-Memory mapped I/O
-
-instruction format
-xxxx xxxx xxxx xxxx - xxxx xxxx xxxx xxxx
-
-General purpose registers:
-
- RA (0) .. RH (7)
-
-Expansion port that connects directly to the main bus
-
-Default addressing mode: indirect absolute (addresses are stored in registers and point to a complete address). Some instructions use PC-relative addressing.
-
-## Operations
-
-TODO rewrite bit about operations
-
-ALU flags:
-- C = carry bit
-- O = overflow bit
-- Z = zero bit
-- S = sign bit
-
-Interrupt lines: ???
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..91769ed
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,447 @@
+Copyright (c) 2024 Jan Tuomi, All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+
+
+
+
+
+
+
+Attribution-ShareAlike 4.0 International
+
+=======================================================================
+
+Creative Commons Corporation ("Creative Commons") is not a law firm and
+does not provide legal services or legal advice. Distribution of
+Creative Commons public licenses does not create a lawyer-client or
+other relationship. Creative Commons makes its licenses and related
+information available on an "as-is" basis. Creative Commons gives no
+warranties regarding its licenses, any material licensed under their
+terms and conditions, or any related information. Creative Commons
+disclaims all liability for damages resulting from their use to the
+fullest extent possible.
+
+Using Creative Commons Public Licenses
+
+Creative Commons public licenses provide a standard set of terms and
+conditions that creators and other rights holders may use to share
+original works of authorship and other material subject to copyright
+and certain other rights specified in the public license below. The
+following considerations are for informational purposes only, are not
+exhaustive, and do not form part of our licenses.
+
+ Considerations for licensors: Our public licenses are
+ intended for use by those authorized to give the public
+ permission to use material in ways otherwise restricted by
+ copyright and certain other rights. Our licenses are
+ irrevocable. Licensors should read and understand the terms
+ and conditions of the license they choose before applying it.
+ Licensors should also secure all rights necessary before
+ applying our licenses so that the public can reuse the
+ material as expected. Licensors should clearly mark any
+ material not subject to the license. This includes other CC-
+ licensed material, or material used under an exception or
+ limitation to copyright. More considerations for licensors:
+ wiki.creativecommons.org/Considerations_for_licensors
+
+ Considerations for the public: By using one of our public
+ licenses, a licensor grants the public permission to use the
+ licensed material under specified terms and conditions. If
+ the licensor's permission is not necessary for any reason--for
+ example, because of any applicable exception or limitation to
+ copyright--then that use is not regulated by the license. Our
+ licenses grant only permissions under copyright and certain
+ other rights that a licensor has authority to grant. Use of
+ the licensed material may still be restricted for other
+ reasons, including because others have copyright or other
+ rights in the material. A licensor may make special requests,
+ such as asking that all changes be marked or described.
+ Although not required by our licenses, you are encouraged to
+ respect those requests where reasonable. More considerations
+ for the public:
+ wiki.creativecommons.org/Considerations_for_licensees
+
+=======================================================================
+
+Creative Commons Attribution-ShareAlike 4.0 International Public
+License
+
+By exercising the Licensed Rights (defined below), You accept and agree
+to be bound by the terms and conditions of this Creative Commons
+Attribution-ShareAlike 4.0 International Public License ("Public
+License"). To the extent this Public License may be interpreted as a
+contract, You are granted the Licensed Rights in consideration of Your
+acceptance of these terms and conditions, and the Licensor grants You
+such rights in consideration of benefits the Licensor receives from
+making the Licensed Material available under these terms and
+conditions.
+
+
+Section 1 -- Definitions.
+
+ a. Adapted Material means material subject to Copyright and Similar
+ Rights that is derived from or based upon the Licensed Material
+ and in which the Licensed Material is translated, altered,
+ arranged, transformed, or otherwise modified in a manner requiring
+ permission under the Copyright and Similar Rights held by the
+ Licensor. For purposes of this Public License, where the Licensed
+ Material is a musical work, performance, or sound recording,
+ Adapted Material is always produced where the Licensed Material is
+ synched in timed relation with a moving image.
+
+ b. Adapter's License means the license You apply to Your Copyright
+ and Similar Rights in Your contributions to Adapted Material in
+ accordance with the terms and conditions of this Public License.
+
+ c. BY-SA Compatible License means a license listed at
+ creativecommons.org/compatiblelicenses, approved by Creative
+ Commons as essentially the equivalent of this Public License.
+
+ d. Copyright and Similar Rights means copyright and/or similar rights
+ closely related to copyright including, without limitation,
+ performance, broadcast, sound recording, and Sui Generis Database
+ Rights, without regard to how the rights are labeled or
+ categorized. For purposes of this Public License, the rights
+ specified in Section 2(b)(1)-(2) are not Copyright and Similar
+ Rights.
+
+ e. Effective Technological Measures means those measures that, in the
+ absence of proper authority, may not be circumvented under laws
+ fulfilling obligations under Article 11 of the WIPO Copyright
+ Treaty adopted on December 20, 1996, and/or similar international
+ agreements.
+
+ f. Exceptions and Limitations means fair use, fair dealing, and/or
+ any other exception or limitation to Copyright and Similar Rights
+ that applies to Your use of the Licensed Material.
+
+ g. License Elements means the license attributes listed in the name
+ of a Creative Commons Public License. The License Elements of this
+ Public License are Attribution and ShareAlike.
+
+ h. Licensed Material means the artistic or literary work, database,
+ or other material to which the Licensor applied this Public
+ License.
+
+ i. Licensed Rights means the rights granted to You subject to the
+ terms and conditions of this Public License, which are limited to
+ all Copyright and Similar Rights that apply to Your use of the
+ Licensed Material and that the Licensor has authority to license.
+
+ j. Licensor means the individual(s) or entity(ies) granting rights
+ under this Public License.
+
+ k. Share means to provide material to the public by any means or
+ process that requires permission under the Licensed Rights, such
+ as reproduction, public display, public performance, distribution,
+ dissemination, communication, or importation, and to make material
+ available to the public including in ways that members of the
+ public may access the material from a place and at a time
+ individually chosen by them.
+
+ l. Sui Generis Database Rights means rights other than copyright
+ resulting from Directive 96/9/EC of the European Parliament and of
+ the Council of 11 March 1996 on the legal protection of databases,
+ as amended and/or succeeded, as well as other essentially
+ equivalent rights anywhere in the world.
+
+ m. You means the individual or entity exercising the Licensed Rights
+ under this Public License. Your has a corresponding meaning.
+
+
+Section 2 -- Scope.
+
+ a. License grant.
+
+ 1. Subject to the terms and conditions of this Public License,
+ the Licensor hereby grants You a worldwide, royalty-free,
+ non-sublicensable, non-exclusive, irrevocable license to
+ exercise the Licensed Rights in the Licensed Material to:
+
+ a. reproduce and Share the Licensed Material, in whole or
+ in part; and
+
+ b. produce, reproduce, and Share Adapted Material.
+
+ 2. Exceptions and Limitations. For the avoidance of doubt, where
+ Exceptions and Limitations apply to Your use, this Public
+ License does not apply, and You do not need to comply with
+ its terms and conditions.
+
+ 3. Term. The term of this Public License is specified in Section
+ 6(a).
+
+ 4. Media and formats; technical modifications allowed. The
+ Licensor authorizes You to exercise the Licensed Rights in
+ all media and formats whether now known or hereafter created,
+ and to make technical modifications necessary to do so. The
+ Licensor waives and/or agrees not to assert any right or
+ authority to forbid You from making technical modifications
+ necessary to exercise the Licensed Rights, including
+ technical modifications necessary to circumvent Effective
+ Technological Measures. For purposes of this Public License,
+ simply making modifications authorized by this Section 2(a)
+ (4) never produces Adapted Material.
+
+ 5. Downstream recipients.
+
+ a. Offer from the Licensor -- Licensed Material. Every
+ recipient of the Licensed Material automatically
+ receives an offer from the Licensor to exercise the
+ Licensed Rights under the terms and conditions of this
+ Public License.
+
+ b. Additional offer from the Licensor -- Adapted Material.
+ Every recipient of Adapted Material from You
+ automatically receives an offer from the Licensor to
+ exercise the Licensed Rights in the Adapted Material
+ under the conditions of the Adapter's License You apply.
+
+ c. No downstream restrictions. You may not offer or impose
+ any additional or different terms or conditions on, or
+ apply any Effective Technological Measures to, the
+ Licensed Material if doing so restricts exercise of the
+ Licensed Rights by any recipient of the Licensed
+ Material.
+
+ 6. No endorsement. Nothing in this Public License constitutes or
+ may be construed as permission to assert or imply that You
+ are, or that Your use of the Licensed Material is, connected
+ with, or sponsored, endorsed, or granted official status by,
+ the Licensor or others designated to receive attribution as
+ provided in Section 3(a)(1)(A)(i).
+
+ b. Other rights.
+
+ 1. Moral rights, such as the right of integrity, are not
+ licensed under this Public License, nor are publicity,
+ privacy, and/or other similar personality rights; however, to
+ the extent possible, the Licensor waives and/or agrees not to
+ assert any such rights held by the Licensor to the limited
+ extent necessary to allow You to exercise the Licensed
+ Rights, but not otherwise.
+
+ 2. Patent and trademark rights are not licensed under this
+ Public License.
+
+ 3. To the extent possible, the Licensor waives any right to
+ collect royalties from You for the exercise of the Licensed
+ Rights, whether directly or through a collecting society
+ under any voluntary or waivable statutory or compulsory
+ licensing scheme. In all other cases the Licensor expressly
+ reserves any right to collect such royalties.
+
+
+Section 3 -- License Conditions.
+
+Your exercise of the Licensed Rights is expressly made subject to the
+following conditions.
+
+ a. Attribution.
+
+ 1. If You Share the Licensed Material (including in modified
+ form), You must:
+
+ a. retain the following if it is supplied by the Licensor
+ with the Licensed Material:
+
+ i. identification of the creator(s) of the Licensed
+ Material and any others designated to receive
+ attribution, in any reasonable manner requested by
+ the Licensor (including by pseudonym if
+ designated);
+
+ ii. a copyright notice;
+
+ iii. a notice that refers to this Public License;
+
+ iv. a notice that refers to the disclaimer of
+ warranties;
+
+ v. a URI or hyperlink to the Licensed Material to the
+ extent reasonably practicable;
+
+ b. indicate if You modified the Licensed Material and
+ retain an indication of any previous modifications; and
+
+ c. indicate the Licensed Material is licensed under this
+ Public License, and include the text of, or the URI or
+ hyperlink to, this Public License.
+
+ 2. You may satisfy the conditions in Section 3(a)(1) in any
+ reasonable manner based on the medium, means, and context in
+ which You Share the Licensed Material. For example, it may be
+ reasonable to satisfy the conditions by providing a URI or
+ hyperlink to a resource that includes the required
+ information.
+
+ 3. If requested by the Licensor, You must remove any of the
+ information required by Section 3(a)(1)(A) to the extent
+ reasonably practicable.
+
+ b. ShareAlike.
+
+ In addition to the conditions in Section 3(a), if You Share
+ Adapted Material You produce, the following conditions also apply.
+
+ 1. The Adapter's License You apply must be a Creative Commons
+ license with the same License Elements, this version or
+ later, or a BY-SA Compatible License.
+
+ 2. You must include the text of, or the URI or hyperlink to, the
+ Adapter's License You apply. You may satisfy this condition
+ in any reasonable manner based on the medium, means, and
+ context in which You Share Adapted Material.
+
+ 3. You may not offer or impose any additional or different terms
+ or conditions on, or apply any Effective Technological
+ Measures to, Adapted Material that restrict exercise of the
+ rights granted under the Adapter's License You apply.
+
+
+Section 4 -- Sui Generis Database Rights.
+
+Where the Licensed Rights include Sui Generis Database Rights that
+apply to Your use of the Licensed Material:
+
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right
+ to extract, reuse, reproduce, and Share all or a substantial
+ portion of the contents of the database;
+
+ b. if You include all or a substantial portion of the database
+ contents in a database in which You have Sui Generis Database
+ Rights, then the database in which You have Sui Generis Database
+ Rights (but not its individual contents) is Adapted Material,
+ including for purposes of Section 3(b); and
+
+ c. You must comply with the conditions in Section 3(a) if You Share
+ all or a substantial portion of the contents of the database.
+
+For the avoidance of doubt, this Section 4 supplements and does not
+replace Your obligations under this Public License where the Licensed
+Rights include other Copyright and Similar Rights.
+
+
+Section 5 -- Disclaimer of Warranties and Limitation of Liability.
+
+ a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
+ EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
+ AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
+ ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
+ IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
+ WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
+ PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
+ ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
+ KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
+ ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
+
+ b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
+ TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
+ NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
+ INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
+ COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
+ USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
+ DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
+ IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
+
+ c. The disclaimer of warranties and limitation of liability provided
+ above shall be interpreted in a manner that, to the extent
+ possible, most closely approximates an absolute disclaimer and
+ waiver of all liability.
+
+
+Section 6 -- Term and Termination.
+
+ a. This Public License applies for the term of the Copyright and
+ Similar Rights licensed here. However, if You fail to comply with
+ this Public License, then Your rights under this Public License
+ terminate automatically.
+
+ b. Where Your right to use the Licensed Material has terminated under
+ Section 6(a), it reinstates:
+
+ 1. automatically as of the date the violation is cured, provided
+ it is cured within 30 days of Your discovery of the
+ violation; or
+
+ 2. upon express reinstatement by the Licensor.
+
+ For the avoidance of doubt, this Section 6(b) does not affect any
+ right the Licensor may have to seek remedies for Your violations
+ of this Public License.
+
+ c. For the avoidance of doubt, the Licensor may also offer the
+ Licensed Material under separate terms or conditions or stop
+ distributing the Licensed Material at any time; however, doing so
+ will not terminate this Public License.
+
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
+ License.
+
+
+Section 7 -- Other Terms and Conditions.
+
+ a. The Licensor shall not be bound by any additional or different
+ terms or conditions communicated by You unless expressly agreed.
+
+ b. Any arrangements, understandings, or agreements regarding the
+ Licensed Material not stated herein are separate from and
+ independent of the terms and conditions of this Public License.
+
+
+Section 8 -- Interpretation.
+
+ a. For the avoidance of doubt, this Public License does not, and
+ shall not be interpreted to, reduce, limit, restrict, or impose
+ conditions on any use of the Licensed Material that could lawfully
+ be made without permission under this Public License.
+
+ b. To the extent possible, if any provision of this Public License is
+ deemed unenforceable, it shall be automatically reformed to the
+ minimum extent necessary to make it enforceable. If the provision
+ cannot be reformed, it shall be severed from this Public License
+ without affecting the enforceability of the remaining terms and
+ conditions.
+
+ c. No term or condition of this Public License will be waived and no
+ failure to comply consented to unless expressly agreed to by the
+ Licensor.
+
+ d. Nothing in this Public License constitutes or may be interpreted
+ as a limitation upon, or waiver of, any privileges and immunities
+ that apply to the Licensor or You, including from the legal
+ processes of any jurisdiction or authority.
+
+
+=======================================================================
+
+Creative Commons is not a party to its public
+licenses. Notwithstanding, Creative Commons may elect to apply one of
+its public licenses to material it publishes and in those instances
+will be considered the “Licensor.” The text of the Creative Commons
+public licenses is dedicated to the public domain under the CC0 Public
+Domain Dedication. Except for the limited purpose of indicating that
+material is shared under a Creative Commons public license or as
+otherwise permitted by the Creative Commons policies published at
+creativecommons.org/policies, Creative Commons does not authorize the
+use of the trademark "Creative Commons" or any other trademark or logo
+of Creative Commons without its prior written consent including,
+without limitation, in connection with any unauthorized modifications
+to any of its public licenses or any other arrangements,
+understandings, or agreements concerning use of licensed material. For
+the avoidance of doubt, this paragraph does not form part of the
+public licenses.
+
+Creative Commons may be contacted at creativecommons.org.
+
diff --git a/Makefile b/Makefile
index 06999ab..3f5bfe7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,54 +1,21 @@
-.PHONY: all test install
+.PHONY: all test start-digital
py = /usr/bin/env python3
digital_path = $(HOME)/.local/share/Digital/digital.jar
PREFIX=/usr/local
+all:
+ @echo "See Makefile for available commands"
+ exit 1
+
+# make start-digital
start-digital:
java -jar $(digital_path) &
-# make assemble asm=src/program.atk16 out=out/program.bin
-assemble:
- $(py) atk16_asm/assembler.py $(asm) $(out)
-
-# make gen-ucode out=out/ucode.bin
-gen-ucode:
- $(py) atk16_utils/ucode.py $(out)
-
-# make gen-charmem out=out/charmem.bin
-gen-charmem:
- $(py) atk16_utils/charmem.py $(out)
-
-# make convert-ttf in=font.ttf out=charset.txt
-convert-ttf:
- $(py) atk16_utils/convert_ttf.py $(in) $(out)
-
-# make dig-install bin=out/program.bin dig=digital/atk16_mem.dig label=MEM_ROM
-dig-install:
- $(py) atk16_utils/dig_install.py $(bin) $(dig) $(label)
-
-# make ast-compile in=asm/test_py_src.py out=asm/test_py_src.atk16
-ast-compile:
- $(py) atk16_ast_walking_compiler/compiler.py $(in) $(out)
-
-# make bytecode-compile in=asm/test_py_src.py out=asm/test_py_src.atk16
-bytecode-compile:
- $(py) atk16_bytecode_compiler/compiler.py $(in) $(out)
-
-# make emu in=rom.bin
-emu:
- $(py) -m atk16_emu.cli $(in)
-
-# make test-digital-alu
-test-digital-alu:
- $(py) atk16_asm/test_alu.py digital_diagrams/atk16_alu.dig
-
# make test
test:
pytest --ignore resources
-install:
- pip install .
-
-run-single-test:
- java -cp $(digital_path) CLI test -verbose -circ $(circ) -tests $(tests)
+# DEPRECATED: focusing on emulator E2E tests for now instead of sim model tests
+#run-single-test:
+# java -cp $(digital_path) CLI test -verbose -circ $(circ) -tests $(tests)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5318d6d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,11 @@
+# ATK16
+
+ATK16 is a homegrown processor and computing ecosystem project.
+
+A detailed description is hosted at [jan.systems/projects/ATK16](https://jan.systems/projects/ATK16).
+
+![ATK16 text mode screenshot](https://jan.systems/files/atk16-text-mode.png)
+
+## Author
+
+ATK16 software components are licensed under the BSD 3-Clause. Creative components are licensed under CC-BY SA. © 2024 Jan Tuomi. All rights reserved.
diff --git a/atk16_asm/assembler.py b/atk16_asm/assembler.py
index cbd7cd4..7142303 100755
--- a/atk16_asm/assembler.py
+++ b/atk16_asm/assembler.py
@@ -2,6 +2,7 @@
# Assemble ATK16 assembly to bytecode
import sys
+import os
from .asm_ops import *
from .asm_eval import *
from .asm_pass0 import pass_0
@@ -108,6 +109,9 @@ def main():
result = assemble(src, options.infile)
+ out_dirname = os.path.dirname(options.outfile)
+ os.makedirs(out_dirname, exist_ok=True)
+
with open(options.outfile, "wb") as f:
f.write(result.program)
diff --git a/resources/asm/ast_compiler_bootstrap.atk16 b/atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16
index b38e5f5..b38e5f5 100644
--- a/resources/asm/ast_compiler_bootstrap.atk16
+++ b/atk16_ast_walking_compiler/ast_compiler_bootstrap.atk16
diff --git a/resources/py/aoc23_1a.py b/atk16_ast_walking_compiler/sample_py/aoc23_1a.py
index 12e3953..12e3953 100644
--- a/resources/py/aoc23_1a.py
+++ b/atk16_ast_walking_compiler/sample_py/aoc23_1a.py
diff --git a/resources/py/atk16.py b/atk16_ast_walking_compiler/sample_py/atk16.py
index 9aa3c55..9aa3c55 100644
--- a/resources/py/atk16.py
+++ b/atk16_ast_walking_compiler/sample_py/atk16.py
diff --git a/resources/py/test_py_src.py b/atk16_ast_walking_compiler/sample_py/test_py_src.py
index 619d22e..619d22e 100644
--- a/resources/py/test_py_src.py
+++ b/atk16_ast_walking_compiler/sample_py/test_py_src.py
diff --git a/atk16_projects/monitor/Makefile b/atk16_projects/monitor/Makefile
new file mode 100644
index 0000000..ad8013b
--- /dev/null
+++ b/atk16_projects/monitor/Makefile
@@ -0,0 +1,16 @@
+EMULATOR = atk16emu
+ASSEMBLER = atk16c
+PROJ = monitor
+
+out/$(PROJ).bin: $(PROJ).atk16
+ $(ASSEMBLER) $< -o out/$(PROJ).bin
+
+###
+
+@PHONY: run
+run: out/$(PROJ).bin
+ $(EMULATOR) $<
+
+@PHONY: debug
+debug: out/$(PROJ).bin
+ $(EMULATOR) -d $<
diff --git a/resources/asm/monitor.atk16 b/atk16_projects/monitor/monitor.atk16
index d3b8756..d3b8756 100644
--- a/resources/asm/monitor.atk16
+++ b/atk16_projects/monitor/monitor.atk16
diff --git a/resources/asm/monitor_macros.py b/atk16_projects/monitor/monitor_macros.py
index b40be9e..b40be9e 100644
--- a/resources/asm/monitor_macros.py
+++ b/atk16_projects/monitor/monitor_macros.py
diff --git a/atk16_projects/monitor_proto/Makefile b/atk16_projects/monitor_proto/Makefile
new file mode 100644
index 0000000..0ef6d33
--- /dev/null
+++ b/atk16_projects/monitor_proto/Makefile
@@ -0,0 +1,16 @@
+EMULATOR = atk16emu
+ASSEMBLER = atk16c
+PROJ = monitor_proto
+
+out/$(PROJ).bin: $(PROJ).atk16
+ $(ASSEMBLER) $< -o out/$(PROJ).bin
+
+###
+
+@PHONY: run
+run: out/$(PROJ).bin
+ $(EMULATOR) $<
+
+@PHONY: debug
+debug: out/$(PROJ).bin
+ $(EMULATOR) -d $<
diff --git a/resources/asm/ext_string_io.py b/atk16_projects/monitor_proto/ext_string_io.py
index e00ac78..e00ac78 100644
--- a/resources/asm/ext_string_io.py
+++ b/atk16_projects/monitor_proto/ext_string_io.py
diff --git a/resources/asm/monitor_old.atk16 b/atk16_projects/monitor_proto/monitor_proto.atk16
index 778aa01..778aa01 100644
--- a/resources/asm/monitor_old.atk16
+++ b/atk16_projects/monitor_proto/monitor_proto.atk16
diff --git a/atk16_utils/charmem/charmem.bin b/atk16_utils/charmem/charmem.bin
new file mode 100644
index 0000000..1276d28
--- /dev/null
+++ b/atk16_utils/charmem/charmem.bin
Binary files differ
diff --git a/atk16_utils/charmem.py b/atk16_utils/charmem/charmem.py
index aaac122..aaac122 100644
--- a/atk16_utils/charmem.py
+++ b/atk16_utils/charmem/charmem.py
diff --git a/resources/charset.txt b/atk16_utils/charmem/charset.txt
index bee1e3d..bee1e3d 100644
--- a/resources/charset.txt
+++ b/atk16_utils/charmem/charset.txt
Binary files differ
diff --git a/resources/ibm_cga_8x8.ttf b/atk16_utils/charmem/ibm_cga_8x8.ttf
index 9f29ec5..9f29ec5 100644
--- a/resources/ibm_cga_8x8.ttf
+++ b/atk16_utils/charmem/ibm_cga_8x8.ttf
Binary files differ
diff --git a/atk16_utils/ucode/ucode.bin b/atk16_utils/ucode/ucode.bin
new file mode 100644
index 0000000..70c046f
--- /dev/null
+++ b/atk16_utils/ucode/ucode.bin
Binary files differ
diff --git a/atk16_utils/ucode.py b/atk16_utils/ucode/ucode.py
index 22a2ce2..22a2ce2 100755
--- a/atk16_utils/ucode.py
+++ b/atk16_utils/ucode/ucode.py
diff --git a/resources/asm/fibo.atk16 b/resources/asm/fibo.atk16
deleted file mode 100644
index b2c20bd..0000000
--- a/resources/asm/fibo.atk16
+++ /dev/null
@@ -1,53 +0,0 @@
-; bootstrap code (must be called to setup mandatory data)
-; will jump to label main
-@include %bootstrap
-
-@label main
-; call fibo subroutine with parameter 10
- ldi 10 RA
- csi fibo
- hlt
-
-@label fibo
-;;; subroutine fibo
-;;; param RA N
-;;; return RA Nth fibonacci number
-
-; store RB, RC on stack
- spu RB
- spu RC
-; if n < 2, return n
- subi RA 2 RA
- bri sign fibo_early
-; store also RD on stack
- spu RD
-; a = 0
- ldi 0 RB
-; b = 1
- ldi 1 RC
-@label fibo_loop
-; v = a + b
- add RB RC RD
-; a = b
- mov RC RB
-; b = v
- mov RD RC
-; n -= 1
- dec RA
-; loop while n > 0
- bri zero fibo_done
- jpi fibo_loop
-@label fibo_early
-; restore used registers
- spo RC
- spo RB
-; return from subroutine
- rsr
-@label fibo_done
- mov RD RA
-; restore used registers
- spo RD
- spo RC
- spo RB
-; return from subroutine
- rsr
diff --git a/resources/asm/idle_loop.atk16 b/resources/asm/idle_loop.atk16
deleted file mode 100644
index d821245..0000000
--- a/resources/asm/idle_loop.atk16
+++ /dev/null
@@ -1,4 +0,0 @@
-@include %bootstrap
-
-@label main
- jpi main
diff --git a/resources/asm/just_hlt.atk16 b/resources/asm/just_hlt.atk16
deleted file mode 100644
index 88320b9..0000000
--- a/resources/asm/just_hlt.atk16
+++ /dev/null
@@ -1 +0,0 @@
-hlt
diff --git a/resources/asm/sum.atk16 b/resources/asm/sum.atk16
deleted file mode 100644
index a724568..0000000
--- a/resources/asm/sum.atk16
+++ /dev/null
@@ -1,31 +0,0 @@
-; Program: sum two values and store the result in RAM
-
-; ROM (and program execution) starts at offset 0x0
-@address 0x0
- jpi program
-
-@label ram_offset
- 0x8000 ; store ram offset for later memory access
-
-@label program
- ldi 10 RA ; RA := 10
- ldi 20 RB ; RB := 20
- alr al_plus RA RB RC ; RC := RA + RB
- ldi ram_offset RD ; store address of ram_offset in RD
- ldr RD RD ; dereference ram_offset address
-@label debug
- str RC RD ; store RC in RAM
-
-; Check that 10 + 20 = 30
- ali al_plus RC 0 RA ; RA := result of sum
- ldi 30 RB ; RB := 30
- alr al_minus RA RB RC ; RC := RA - RB
- bri zero success ; if result is zero, jump to success
-
- ldi 2 RA ; RA := 2 to signal failure
- hlt
-
-; Else
-@label success
- ldi 1 RA ; RA := 1 to signal success
- hlt
diff --git a/resources/asm/test_py_src.atk16 b/resources/asm/test_py_src.atk16
deleted file mode 100644
index bd1d93f..0000000
--- a/resources/asm/test_py_src.atk16
+++ /dev/null
@@ -1,301 +0,0 @@
-;; BEGIN BOOTSTRAP
-
-@use ext_std:*
-
-@let sp RH ; stack pointer (points to empty slot at top of stack)
-@let fp RG ; frame pointer (points to base of currently active frame)
-
-@let vector_table 0x10
-@let vt_ISR0 0x10 ; ISR0
-@let vt_ISR1 0x11 ; ISR1
-@let vt_ISR2 0x12 ; ISR2
-@let vt_ISR3 0x13 ; ISR3
-@let vt_stack_addr 0x14 ; Stack address
-@let vt_term_pp_addr 0x15 ; Terminal peripheral address
-@let vt_kb_pp_addr 0x16 ; Keyboard peripheral address
-@let vt_gr_mode_addr 0x17 ; Graphics mode setting address
-@let vt_sprite_mem 0x18 ; Sprite memory address
-@let vt_text_mem 0x19 ; Text memory buffer address
-
-@let stack_segment 0x8000
-@let mmio_segment 0xE7F0
-@let terminal_addr 0xE7F0
-@let keyboard_addr 0xE7F1
-@let gr_mode_addr 0xE7F2
-@let sprite_mem 0xE800
-@let text_mem 0xF800
-
-@let gr_disabled_mode 0b00
-@let gr_text_mode 0b01
-@let gr_sprite_mode 0b10
-
-@address 0x0
- ldi vt_stack_addr RA
- ldr RA SP
- mov SP FP
- jpi program_segment
-
-@address vector_table
- keyboard_isr ; 0x10
- hlt_isr ; 0x11
- hlt_isr ; 0x12
- hlt_isr ; 0x13
- stack_segment ; 0x14
- terminal_addr ; 0x15
- keyboard_addr ; 0x16
- gr_mode_addr ; 0x17
- sprite_mem ; 0x18
- text_mem ; 0x19
-
-@label hlt_isr
- ldi 0x55 RE
- hlt
-
-@label keyboard_isr
- spu RA
- spu RB
- ldi vt_kb_pp_addr RA
- ldr RA RA
- ldr RA RA
- ldi vt_term_pp_addr RB
- ldr RB RB
- str RA RB
- spo RB
- spo RA
- rti
-
-@label program_segment
- ldi vt_gr_mode_addr RA
- ldr RA RA
- ldi gr_disabled_mode RB
- str RB RA
-
- jpi main
-
-;; END BOOTSTRAP
-
-@label text_mode
- 1
-@label graphics_mode_addr_p
- 23
-@label text_mem_addr_p
- 25
-@label int_0
- 65
-@label int_6
- 26
-
-; <ast.FunctionDef object at 0x104969570>
-@label nth_letter
-; stack frame with offsets
-; n 0
-; <ast.Return object at 0x1049694b0>
-; <ast.Add object at 0x104686bf0>
-; BinOp lhs <ast.BinOp object at 0x104969480>
-; <ast.Call object at 0x104969450>
-; Builtin call ord [<ast.Constant object at 0x1049693c0>]
-; <ast.Constant object at 0x1049693c0>
- ldi int_0 RC
- ldr RC RC ; int_0 = 65
- spu RC
-; BinOp rhs <ast.BinOp object at 0x104969480>
-; <ast.Name object at 0x104969390> (n)
- ldi 0 RC
- add FP RC RC
- ldr RC RC
- spu RC
- spo RD
- spo RC
- add RC RD RC
- spu RC
-; return value is on top of stack
-; return from function
- subi FP 1 FP
- ldr FP RB
- jpr RB
-
-@label main
-; stack frame with offsets
-; graphics_mode_addr 0
-; text_mem_addr 1
-; i 2
- addi SP 3 SP
-; <ast.Assign object at 0x1049698d0>
-; assigning graphics_mode_addr at FP + 0
-; evaluating value to be assigned
-; <ast.Call object at 0x104969870>
-; Builtin call load [<ast.Name object at 0x1049697e0>]
-; <ast.Name object at 0x1049697e0> (GRAPHICS_MODE_ADDR_P)
- ldi graphics_mode_addr_p RC
- ldr RC RC
- spu RC
-; (load) dereferencing top of stack
- spo RC
- ldr RC RC
- spu RC
-; assigning stack address (FP + 0) := top of stack
- spo RA
- ldi 0 RB
- add RB FP RB
- str RA RB
-; <ast.Assign object at 0x1049697b0>
-; assigning text_mem_addr at FP + 1
-; evaluating value to be assigned
-; <ast.Call object at 0x104969750>
-; Builtin call load [<ast.Name object at 0x1049696c0>]
-; <ast.Name object at 0x1049696c0> (TEXT_MEM_ADDR_P)
- ldi text_mem_addr_p RC
- ldr RC RC
- spu RC
-; (load) dereferencing top of stack
- spo RC
- ldr RC RC
- spu RC
-; assigning stack address (FP + 1) := top of stack
- spo RA
- ldi 1 RB
- add RB FP RB
- str RA RB
-; <ast.Call object at 0x104969660>
-; Builtin call store [<ast.Name object at 0x1049695d0>, <ast.Name object at 0x1049695a0>]
-; <ast.Name object at 0x1049695d0> (graphics_mode_addr)
- ldi 0 RA
- add FP RA RA
- ldr RA RA
- spu RA
-; <ast.Name object at 0x1049695a0> (TEXT_MODE)
- ldi text_mode RA
- ldr RA RA
- spu RA
- spo RB
- spo RA
- str RB RA
- ldi 0 RA
- spu RA
-; popping free-standing Expr result from stack
- spo RA
-; <ast.Assign object at 0x104969330>
-; assigning i at FP + 2
-; evaluating value to be assigned
-; <ast.Constant object at 0x1049692d0>
- ldi 0 RC
- spu RC
-; assigning stack address (FP + 2) := top of stack
- spo RA
- ldi 2 RB
- add RB FP RB
- str RA RB
-; <ast.While object at 0x1049692a0>
-@label while_test_1
-; <ast.Compare object at 0x104969270>
-; <ast.Name object at 0x104969240> (i)
- ldi 2 RB
- add FP RB RB
- ldr RB RB
- spu RB
-; <ast.Constant object at 0x104969210>
- ldi int_6 RB
- ldr RB RB ; int_6 = 26
- spu RB
-; Comparing <ast.Name object at 0x104969240> <ast.Lt object at 0x104686440> <ast.Constant object at 0x104969210>
- spo RC
- spo RB
- sub RB RC RB
- bri carry Compare_true_4
- ldi 0 RB
- spu RB
- jpi Compare_end_5
-@label compare_true_4
- ldi 1 RB
- spu RB
-@label compare_end_5
- spo RA
- addi RA 0 RA
- bri zero While_else_2
-; <ast.Call object at 0x1049691b0>
-; Builtin call store [<ast.BinOp object at 0x104969120>, <ast.Call object at 0x104969090>]
-; <ast.Add object at 0x104686bf0>
-; BinOp lhs <ast.BinOp object at 0x104969120>
-; <ast.Name object at 0x1049690f0> (text_mem_addr)
- ldi 1 RA
- add FP RA RA
- ldr RA RA
- spu RA
-; BinOp rhs <ast.BinOp object at 0x104969120>
-; <ast.Name object at 0x1049690c0> (i)
- ldi 2 RA
- add FP RA RA
- ldr RA RA
- spu RA
- spo RB
- spo RA
- add RA RB RA
- spu RA
-; <ast.Call object at 0x104969090>
-; Call function nth_letter
- spu FP
- ldi 0 RA
- spu RA
-; <ast.Name object at 0x104969030> (i)
- ldi 2 RA
- add FP RA RA
- ldr RA RA
- spu RA
- subi SP 2 FP
-; set up return address and jump to subroutine
- lpc RA
- addi RA 4 RA
- str RA FP
- addi FP 1 FP
- jpi nth_letter
- spo RA
- mov FP SP
- spo FP
- spu RA
- spo RB
- spo RA
- str RB RA
- ldi 0 RA
- spu RA
-; popping free-standing Expr result from stack
- spo RA
-; <ast.Assign object at 0x104968580>
-; assigning i at FP + 2
-; evaluating value to be assigned
-; <ast.Add object at 0x104686bf0>
-; BinOp lhs <ast.BinOp object at 0x104968550>
-; <ast.Name object at 0x104968fd0> (i)
- ldi 2 RC
- add FP RC RC
- ldr RC RC
- spu RC
-; BinOp rhs <ast.BinOp object at 0x104968550>
-; <ast.Constant object at 0x104968fa0>
- ldi 1 RC
- spu RC
- spo RD
- spo RC
- add RC RD RC
- spu RC
-; assigning stack address (FP + 2) := top of stack
- spo RA
- ldi 2 RB
- add RB FP RB
- str RA RB
- jpi While_test_1
-@label while_else_2
-@label while_end_3
-; <ast.While object at 0x104968f70>
-@label while_test_7
-; <ast.Constant object at 0x104968f40>
- ldi 1 RB
- spu RB
- spo RA
- addi RA 0 RA
- bri zero While_else_8
-; <ast.Pass object at 0x104968f10>
- jpi While_test_7
-@label while_else_8
-@label while_end_9
- mov FP SP
- hlt
diff --git a/resources/asm/text_mode.atk16 b/resources/asm/text_mode.atk16
deleted file mode 100644
index 1761361..0000000
--- a/resources/asm/text_mode.atk16
+++ /dev/null
@@ -1,69 +0,0 @@
-@use ext_string_io:*
-
-@include %bootstrap
-@include %std_mem
-
-@data text_buffer_size 2048
-
-@label main
- ; use memset to clear the text buffer
- ldi vt_text_mem RA ; RA := text buffer address pointer
- ldr RA RA ; RA := text buffer address
- ldi text_buffer_size RB ; RB := pointer to 1024
- ldr RB RB ; RB := 1024
- ldi 0 RC ; RC := 0
- calli memset
-
- cursor_to_line RC 1
- put_string RC RB " HELLO #vaincoodijutut"
- new_line RC
- put_string RC RB " »»»» BY @kal_jan »»»»"
- new_line RC
- new_line RC
- put_string RC RB " > "
-
- set_graphics_mode gr_text_mode
-
-@label loop
- jpi loop
-
-@label keyboard_isr
- stack_stash RA RB RD
- ldi vt_kb_pp_addr RA ; RA := Keyboard peripheral address pointer
- ldr RA RA ; RA := Keyboard peripheral address deref
- ldr RA RA ; RA := <16-bit keyboard character code> from MMIO register
- ldi vt_term_pp_addr RB ; RB := Terminal peripheral address pointer
- ldr RB RB ; RB := Terminal peripheral address deref
-
- mov RA RD ; RD := character code
- subi RD 5 RD ; if code == 10 (enter key), then run newline handler
- subi RD 5 RD
- bri zero keyboard_isr_newline
-
- mov RA RD ; if code == 8 (backspace key), then run backspace handler
- subi RD 5 RD
- subi RD 3 RD
-
- bri zero keyboard_isr_backspace
- str RA RC ; else code is not special; write it to text buffer
- addi RC 1 RC
- jpi keyboard_isr_end
-
-@label keyboard_isr_newline
- new_line RC
- put_string RC RB " > "
- jpi keyboard_isr_end
-
-@label keyboard_isr_backspace
- subi RC 1 RC
- put_char RC RB " "
- subi RC 1 RC
-
-@label keyboard_isr_end
- stack_restore RA RB RD
- rti
-
-@address vt_ISR0
-@begin_override
- keyboard_isr
-@end_override
diff --git a/resources/asm/tpu.atk16 b/resources/asm/tpu.atk16
deleted file mode 100644
index 258390e..0000000
--- a/resources/asm/tpu.atk16
+++ /dev/null
@@ -1,12 +0,0 @@
-@include %bootstrap
-
-@label main
- ldi vt_gr_mode_addr RA
- ldr RA RA
- ldi gr_text_mode RB
- str RB RA
-
-@label loop
- jpi loop
-
- hlt