copapy/tools/make_example.py

34 lines
692 B
Python
Raw Normal View History

from copapy import _binwrite, cpvalue
from copapy.backend import Write, compile_to_instruction_list
2025-10-12 20:22:30 +00:00
import copapy
def test_compile() -> None:
2025-10-18 21:20:40 +00:00
c1 = cpvalue(9)
2025-10-12 20:22:30 +00:00
#ret = [c1 / 4, c1 / -4, c1 // 4, c1 // -4, (c1 * -1) // 4]
2025-10-14 21:09:07 +00:00
ret = [c1 // 3.3 + 5]
2025-10-12 20:22:30 +00:00
out = [Write(r) for r in ret]
il, _ = compile_to_instruction_list(out, copapy.generic_sdb)
2025-10-12 20:22:30 +00:00
# run program command
il.write_com(_binwrite.Command.RUN_PROG)
2025-10-12 20:22:30 +00:00
il.write_com(_binwrite.Command.READ_DATA)
2025-10-12 20:22:30 +00:00
il.write_int(0)
il.write_int(36)
il.write_com(_binwrite.Command.END_COM)
2025-10-12 20:22:30 +00:00
print('* Data to runner:')
il.print()
il.to_file('bin/test.copapy')
if __name__ == "__main__":
test_compile()