Initial code commit

This commit is contained in:
Robert Miles 2018-11-07 20:12:55 -05:00
commit 4b962f3e57
5 changed files with 181 additions and 0 deletions

114
.gitignore vendored Normal file
View File

@ -0,0 +1,114 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/

6
README.md Normal file
View File

@ -0,0 +1,6 @@
# 6502gen
Goal list:
- [ ] Macros
- [ ] Repeat

2
gen6502.py Normal file
View File

@ -0,0 +1,2 @@
def asm(i):
return i

25
test.py Normal file
View File

@ -0,0 +1,25 @@
import gen6502,testdata
success = 0
count = 0
total = 1
pl = len(str(total))
dpl = 41-pl
def pad(s,c,p=".",l=False):
if l:
return ((p*c)+s)[-c:]
return (s+(p*c))[:c]
def assume(n,i,e,r=None):
if r is None:
r = i
global success, count, total
count += 1
try:
assert i
print("{}[PASS]".format(pad("[{}/{!s}] {}".format(pad(str(count),pl," ",True),total,n),dpl)))
except AssertionError as ex:
print("{}[FAIL] ({})".format(pad("[{}/{!s}] {}".format(pad(str(count),pl," ",True),total,n),dpl),e.format(r)))
assume("Macros",gen6502.asm(testdata.input_1)==testdata.result_1,"Result was:\n{}",gen6502.asm(testdata.input_1))

34
testdata.py Normal file
View File

@ -0,0 +1,34 @@
input_1 = """MACRO: screenloop
lda $fe
tax
inc {0},x
END
Loop:
screenloop $200
screenloop $300
screenloop $400
screenloop $500
ldx #$ff
spin1:
dex
bne spin1
jmp Loop
"""
result_1 = """Loop:
lda $fe
tax
inc $200,x
lda $fe
tax
inc $300,x
lda $fe
tax
inc $400,x
lda $fe
tax
inc $500,x
ldx #$ff
spin1:
dex
bne spin1
jmp Loop"""