示例#1
0
 def test_asm_compiler_scrolling_5(self):
     cart = Cartridge()
     cart.path = "fixtures/nesasm/scrolling/"
     f = open("fixtures/nesasm/scrolling/scrolling5.asm")
     code = f.read()
     f.close()
     tokens = lexical(code)
     ast = syntax(tokens)
     opcodes = semantic(ast, cart=cart)
示例#2
0
文件: compiler.py 项目: yxda/pyNES
def compile(code, path):

    cart = Cartridge()
    cart.path = path

    tokens = lexical(code)
    ast = syntax(tokens)
    opcodes = semantic(ast, True, cart)

    return opcodes
示例#3
0
def compile(code, path):

    cart = Cartridge()
    cart.path = path

    tokens = lexical(code)
    ast = syntax(tokens)
    opcodes = semantic(ast, True, cart)

    return opcodes
示例#4
0
    def test_asm_compiler(self):
        cart = Cartridge()
        cart.path = 'fixtures/movingsprite/'

        opcodes = semantic(self.ast, True, cart=cart)

        self.assertIsNotNone(opcodes)
        bin = ''.join([chr(opcode) for opcode in opcodes])
        f = open('fixtures/movingsprite/movingsprite.nes', 'rb')
        content = f.read()
        f.close()
        self.assertHexEquals(content, bin)
示例#5
0
    def test_asm_compiler(self):
        cart = Cartridge()
        cart.path = 'fixtures/movingsprite/'

        opcodes = semantic(self.ast, True, cart=cart)

        self.assertIsNotNone(opcodes)
        bin = ''.join([chr(opcode) for opcode in opcodes])
        f = open('fixtures/movingsprite/movingsprite.nes', 'rb')
        content = f.read()
        f.close()
        self.assertHexEquals(content, bin)
示例#6
0
    def assertAsmResults(self, source_file, bin_file):
        path = 'fixtures/nerdynights/scrolling/'
        f = open (path + source_file)
        code = f.read()
        f.close()
        tokens = lexical(code)
        ast = syntax(tokens)

        cart = Cartridge()
        cart.path = 'fixtures/nerdynights/scrolling/'

        opcodes = semantic(ast, True, cart=cart)

        self.assertIsNotNone(opcodes)
        bin = ''.join([chr(opcode) for opcode in opcodes])
        f = open(path + bin_file, 'rb')
        content = f.read()
        f.close()
        self.assertHexEquals(content,bin)
示例#7
0
    def assertAsmResults(self, source_file, bin_file):
        path = 'fixtures/nerdynights/background/'
        f = open(path + source_file)
        code = f.read()
        f.close()
        tokens = lexical(code)
        ast = syntax(tokens)

        cart = Cartridge()
        cart.path = 'fixtures/nerdynights/background/'

        opcodes = semantic(ast, True, cart=cart)

        self.assertIsNotNone(opcodes)
        bin = ''.join([chr(opcode) for opcode in opcodes])
        f = open(path + bin_file, 'rb')
        content = f.read()
        f.close()
        self.assertHexEquals(content, bin)