Пример #1
0
def main():
    fileIN = input("Enter File path without extension .asm i.e. ./rect/RectL ")
    if "./" not in fileIN:
        file = "./" + fileIN.lower() + "/" + fileIN[0].upper(
        ) + fileIN[1:].lower()
    else:
        file = fileIN

    fileASM = file + ".asm"
    fileANS = file + ".hack"
    fileOUT = file + "OUT.hack"

    try:
        t = open(fileOUT, 'x')
        t.close()
    except:
        pass
    OUTPUT = open(fileOUT, 'w')

    p.init(fileASM)
    p.DoublePass(OUTPUT)
    OUTPUT.close()

    binary = FileRead(fileOUT)
    answers = FileRead(fileANS)
    check = checkAll(binary, answers).split('\n')

    for i in range(len(binary) - 1):
        print("\n", i, " binary ", binary[i], "\n", i, " answer ", answers[i])

    if "Incorrect" not in check:
        print("\nCorrect Results")
    else:
        print("\nIncorrect Results")
Пример #2
0
def main():
    file = "./rect/Rect"
    fileASM = file + ".asm"
    fileANS = file + ".hack"

    p.init(fileASM)
    p.DoublePass()

    binary = c.buildCode(p).split('\n')
    answers = answer(fileANS)
    check = checkAll(binary, answers).split('\n')

    for i in range(len(binary) - 1):
        print("\n", i, " ", binary[i], "\n", i, " ", answers[i], " \t",
              check[i])