#!/usr/bin/env python3 # planck - # Copyright (C) 2021 nineties # import os import sys import operator import ctypes import platform from struct import pack, unpack RUNTIME_NAME = "Python {}".format(platform.python_version()) COPYRIGHT = "Copyright (c) 2021 Koichi Nakamura " VERSION = "{}:{}".format(RUNTIME_NAME, COPYRIGHT) MEMORY_SIZE = 0x40000 memory = bytearray(MEMORY_SIZE) CELL = 4 STACK_SIZE = 0x400 RSTACK_SIZE = 0x400 HERE_CELL = 0 LATEST_CELL = CELL sp = MEMORY_SIZE rp = MEMORY_SIZE - STACK_SIZE ip = 0 np = 0 ALIGN_MASK = ~(CELL - 1) def aligned(n): return (n + CELL - 1) & ALIGN_MASK def align(): write(HERE_CELL, aligned(read(HERE_CELL))) def readi(addr): return unpack('