meow.git

mne.py

espurr
#!/bin/python3
# meow - 6502 assembler
# Copyright (C) 2024 ArcNyxx
# see LICENCE file for licensing information

mnes = []
with open("mne.txt") as file:
    for mne in file:
        mnes.append(mne.strip())

print("switch (str[0]) {")

char = '\0'
for mne in mnes:
    if char != mne[0]:
        if char != '\0':
            print("\treturn INV;")

        print(f"case '{mne[0]}':")
        char = mne[0]

    print(f"\tif (str[1] == '{mne[1]}' && str[2] == '{mne[2]}')")
    print(f"\t\treturn {mne};")

print("default:")
print("\treturn INV;")
print("}")

print()
print()
print()

print("switch (inst) {")
for mne in mnes:
    print(f"case {mne}:")
    print("\tswitch (mode) {")
    print("\tdefault:")
    print("\t\treturn 0xff;")
    print("\t}")

print("default:")
print("\treturn 0xff;")
print("}")