예제 #1
0
 def test_nop_sngl(self):
     tokens = lexical('NOP')
     self.assertEquals(1 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_IMPLIED', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xea])
예제 #2
0
 def test_org_fffa(self):
     tokens = lexical('.org $FFFA')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast)
예제 #3
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)
예제 #4
0
 def test_rts_sngl(self):
     tokens = lexical("RTS")
     self.assertEquals(1, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_IMPLIED", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x60])
예제 #5
0
파일: sei_test.py 프로젝트: BmanisKing/Mine
 def test_sei_sngl(self):
     tokens = list(lexical("SEI"))
     self.assertEquals(1, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_IMPLIED", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x78])
예제 #6
0
파일: sed_test.py 프로젝트: BmanisKing/Mine
 def test_sed_sngl(self):
     tokens = list(lexical('SED'))
     self.assertEquals(1, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMPLIED', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xf8])
예제 #7
0
파일: cli_test.py 프로젝트: yxda/pyNES
 def test_cli_sngl(self):
     tokens = list(lexical('CLI'))
     self.assertEquals(1, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMPLIED', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x58])
예제 #8
0
 def test_bank_0(self):
     tokens = lexical('.bank 0')
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_ARGUMENT', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast)
예제 #9
0
 def test_org_fffa(self):
     tokens = lexical('.org $FFFA')
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast)
예제 #10
0
 def test_bank_0(self):
     tokens = lexical('.bank 0')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_ARGUMENT', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast)
예제 #11
0
 def test_bne_rel(self):
     tokens = lexical("BNE $10")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ADDRESS", tokens[1]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_RELATIVE", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0xD0, 0x0E])
예제 #12
0
 def test_lsr_imm_with_binary(self):
     tokens = lexical("LSR #%00000100")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_BINARY_NUMBER", tokens[1]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_IMMEDIATE", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x4A, 0x04])
예제 #13
0
 def test_lsr_imm_with_decimal(self):
     tokens = lexical("LSR #10")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_DECIMAL_NUMBER", tokens[1]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_IMMEDIATE", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x4A, 0x0A])
예제 #14
0
 def test_lsr_acc(self):
     tokens = lexical("LSR A")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ACCUMULATOR", tokens[1]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_ACCUMULATOR", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x4A])
예제 #15
0
파일: bpl_test.py 프로젝트: acs022/pyNES
 def test_bpl_rel(self):
     tokens = lexical('BPL $10')
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_RELATIVE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x10, 0x0e])
예제 #16
0
 def test_sbc_imm(self):
     tokens = lexical("SBC #$10")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_HEX_NUMBER", tokens[1]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_IMMEDIATE", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0xE9, 0x10])
예제 #17
0
 def test_asl_imm(self):
     tokens = lexical('ASL #$10')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_HEX_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x0a, 0x10])
예제 #18
0
파일: cmp_test.py 프로젝트: BmanisKing/Mine
 def test_cmp_imm(self):
     tokens = list(lexical('CMP #$10'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_HEX_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xc9, 0x10])
예제 #19
0
파일: lsr_test.py 프로젝트: BmanisKing/Mine
 def test_lsr_acc(self):
     tokens = list(lexical('LSR A'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ACCUMULATOR', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ACCUMULATOR', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x4a])
예제 #20
0
파일: ldy_test.py 프로젝트: ebennaga/pyNES
 def test_ldy_imm_with_binary(self):
     tokens = list(lexical('LDY #%00000100'))
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_BINARY_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xa0, 0x04])
예제 #21
0
 def test_ora_imm_with_binary(self):
     tokens = lexical('ORA #%00000100')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_BINARY_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x09, 0x04])
예제 #22
0
 def test_ora_imm_with_decimal(self):
     tokens = lexical('ORA #10')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x09, 0x0a])
예제 #23
0
파일: sty_test.py 프로젝트: ebennaga/pyNES
 def test_sty_zp(self):
     tokens = list(lexical('STY $00'))
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ZEROPAGE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x84, 0x00])
예제 #24
0
 def test_ora_zp(self):
     tokens = lexical('ORA $00')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ZEROPAGE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x05, 0x00])
예제 #25
0
 def test_ldy_abs(self):
     tokens = lexical('LDY $1234')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ABSOLUTE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xac, 0x34, 0x12])
예제 #26
0
파일: beq_test.py 프로젝트: joskid/pyNES
 def test_beq_rel(self):
     tokens = lexical('BEQ $10')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_RELATIVE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xf0, 0x0e])
예제 #27
0
파일: ldy_test.py 프로젝트: ebennaga/pyNES
 def test_ldy_imm_with_decimal(self):
     tokens = list(lexical('LDY #10'))
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xa0, 0x0a])
예제 #28
0
 def test_bit_zp(self):
     tokens = lexical("BIT $00")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ADDRESS", tokens[1]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_ZEROPAGE", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x24, 0x00])
예제 #29
0
파일: ldy_test.py 프로젝트: ebennaga/pyNES
 def test_ldy_abs(self):
     tokens = list(lexical('LDY $1234'))
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ABSOLUTE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xac, 0x34, 0x12])
예제 #30
0
파일: lsr_test.py 프로젝트: joskid/pyNES
 def test_lsr_acc(self):
     tokens = lexical('LSR A')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ACCUMULATOR', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ACCUMULATOR', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x4a])
예제 #31
0
 def test_inesmir(self):
     tokens = list(lexical('.inesmir 1'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_ARGUMENT', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast, True)
     # self.assertEquals(1, get_var('inesmir'))
     self.assertEquals(code[7], 1)
예제 #32
0
파일: jmp_test.py 프로젝트: acs022/pyNES
 def test_jmp_abs(self):
     tokens = lexical('JMP $1234')
     self.assertEquals(2 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('$1234', tokens[1]['value'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ABSOLUTE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x4c, 0x34, 0x12])
예제 #33
0
 def test_jsr_abs(self):
     tokens = list(lexical('JSR $1234'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('$1234', tokens[1]['value'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ABSOLUTE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x20, 0x34, 0x12])
예제 #34
0
 def test_inesmir(self):
     tokens = lexical('.inesmir 1')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_ARGUMENT', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast, True)
     #self.assertEquals(1, get_var('inesmir'))
     self.assertEquals(code[7], 1)
예제 #35
0
 def test_bit_abs(self):
     tokens = lexical("BIT $1234")
     self.assertEquals(2, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ADDRESS", tokens[1]["type"])
     self.assertEquals("$1234", tokens[1]["value"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_ABSOLUTE", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0x2C, 0x34, 0x12])
예제 #36
0
 def test_db_3(self):
     tokens = lexical('.db $80, $00, $03, $80')
     self.assertEquals(8, len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     #self.assertEquals('T_HEX_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast)
     self.assertIsNotNone(code)
     expected = [0x80, 0x0, 0x03, 0x80]
     self.assertEquals(expected, code)
예제 #37
0
파일: ldy_test.py 프로젝트: yxda/pyNES
 def test_ldy_absx(self):
     tokens = list(lexical('LDY $1234,X'))
     self.assertEquals(4, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ABSOLUTE_X', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xbc, 0x34, 0x12])
예제 #38
0
파일: lda_test.py 프로젝트: acs022/pyNES
 def test_lda_absx(self):
     tokens = lexical('LDA $1234,X')
     self.assertEquals(4 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ABSOLUTE_X', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xbd, 0x34, 0x12])
예제 #39
0
 def test_db_3(self):
     tokens = list(lexical('.db $80, $00, $03, $80'))
     self.assertEquals(8, len(tokens))
     self.assertEquals('T_DIRECTIVE', tokens[0]['type'])
     # self.assertEquals('T_HEX_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_DIRECTIVE', ast[0]['type'])
     code = semantic(ast)
     self.assertIsNotNone(code)
     expected = [0x80, 0x0, 0x03, 0x80]
     self.assertEquals(expected, code)
예제 #40
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)
예제 #41
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)
예제 #42
0
파일: inc_test.py 프로젝트: BmanisKing/Mine
 def test_inc_zpx(self):
     tokens = list(lexical("INC $10,X"))
     self.assertEquals(4, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ADDRESS", tokens[1]["type"])
     self.assertEquals("T_SEPARATOR", tokens[2]["type"])
     self.assertEquals("T_REGISTER", tokens[3]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_ZEROPAGE_X", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0xF6, 0x10])
예제 #43
0
 def test_sbc_absy(self):
     tokens = lexical("SBC $1234,Y")
     self.assertEquals(4, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ADDRESS", tokens[1]["type"])
     self.assertEquals("T_SEPARATOR", tokens[2]["type"])
     self.assertEquals("T_REGISTER", tokens[3]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_ABSOLUTE_Y", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0xF9, 0x34, 0x12])
예제 #44
0
파일: stx_test.py 프로젝트: yxda/pyNES
 def test_stx_zpy(self):
     tokens = list(lexical('STX $10,Y'))
     self.assertEquals(4, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ZEROPAGE_Y', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x96, 0x10])
예제 #45
0
파일: and_test.py 프로젝트: ebennaga/pyNES
 def test_and_absy(self):
     tokens = list(lexical('AND $1234,Y'))
     self.assertEquals(4 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ABSOLUTE_Y', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x39, 0x34, 0x12])
예제 #46
0
 def test_ora_zpx(self):
     tokens = lexical('ORA $10,X')
     self.assertEquals(4, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ZEROPAGE_X', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x15, 0x10])
예제 #47
0
 def test_ora_absy(self):
     tokens = lexical('ORA $1234,Y')
     self.assertEquals(4, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ABSOLUTE_Y', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x19, 0x34, 0x12])
예제 #48
0
파일: ldy_test.py 프로젝트: ebennaga/pyNES
 def test_ldy_zpx(self):
     tokens = list(lexical('LDY $10,X'))
     self.assertEquals(4 , len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ZEROPAGE_X', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0xb4, 0x10])
예제 #49
0
파일: inc_test.py 프로젝트: BmanisKing/Mine
 def test_inc_absx(self):
     tokens = list(lexical("INC $1234,X"))
     self.assertEquals(4, len(tokens))
     self.assertEquals("T_INSTRUCTION", tokens[0]["type"])
     self.assertEquals("T_ADDRESS", tokens[1]["type"])
     self.assertEquals("$1234", tokens[1]["value"])
     self.assertEquals("T_SEPARATOR", tokens[2]["type"])
     self.assertEquals("T_REGISTER", tokens[3]["type"])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals("S_ABSOLUTE_X", ast[0]["type"])
     code = semantic(ast)
     self.assertEquals(code, [0xFE, 0x34, 0x12])
예제 #50
0
파일: and_test.py 프로젝트: joskid/pyNES
 def test_and_imm(self):
     '''
     Test the logical operation AND between $10(Decimal 16)
     and the content of the Accumulator
     '''
     tokens = lexical('AND #$10')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_HEX_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x29, 0x10])
예제 #51
0
파일: and_test.py 프로젝트: joskid/pyNES
 def test_and_imm_with_binary(self):
     '''
     Test the logical operation AND between #%00000100 (Decimal 4)
     and the content of the Accumulator
     '''
     tokens = lexical('AND #%00000100')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_BINARY_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x29, 0x04])
예제 #52
0
 def test_adc_imm_with_decimal(self):
     '''
     Test the arithmetic operation ADC between decimal 10
     and the content of the accumulator.
     '''
     tokens = list(lexical('ADC #10'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_DECIMAL_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x69, 0x0A])
예제 #53
0
파일: and_test.py 프로젝트: joskid/pyNES
 def test_and_zp(self):
     '''
     Test the logical operation AND between the content of
     accumulator and the content of zero page address $00
     '''
     tokens = lexical('AND $00')
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ZEROPAGE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x25, 0x00])
예제 #54
0
 def test_adc_imm_with_binary(self):
     '''
     Test the arithmetic operation ADC between binary %00000100
     (Decimal 4) and the content of the accumulator.
     '''
     tokens = list(lexical('ADC #%00000100'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_BINARY_NUMBER', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_IMMEDIATE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x69, 0x04])
예제 #55
0
 def test_adc_zp(self):
     '''
     Test the arithmetic operation ADC between the content of
     the accumulator and the content of the zero page address.
     '''
     tokens = list(lexical('ADC $00'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ZEROPAGE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x65, 0x00])
예제 #56
0
 def test_ora_indy(self):
     tokens = lexical('ORA ($20),Y')
     self.assertEquals(6, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_OPEN', tokens[1]['type'])
     self.assertEquals('T_ADDRESS', tokens[2]['type'])
     self.assertEquals('T_CLOSE', tokens[3]['type'])
     self.assertEquals('T_SEPARATOR', tokens[4]['type'])
     self.assertEquals('T_REGISTER', tokens[5]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_INDIRECT_Y', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x11, 0x20])
예제 #57
0
 def test_sta_absx(self):
     tokens = lexical('STA $1234,X')
     self.assertEquals(4 , len(tokens))
     token = tokens[0]
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('$1234', tokens[1]['value'])
     self.assertEquals('T_SEPARATOR', tokens[2]['type'])
     self.assertEquals('T_REGISTER', tokens[3]['type'])
     ast = syntax(tokens)
     self.assertEquals(1 , len(ast))
     self.assertEquals('S_ABSOLUTE_X', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x9D, 0x34, 0x12])
예제 #58
0
    def test_jsr_abs(self):
        tokens = lexical('JSR $1234')
        self.assertEquals(2, len(tokens))
        self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
        self.assertEquals('T_ADDRESS', tokens[1]['type'])
        self.assertEquals('$1234', tokens[1]['value'])
        ast = syntax(tokens)
        self.assertEquals(1, len(ast))
        self.assertEquals('S_ABSOLUTE', ast[0]['type'])
        code = semantic(ast)
        self.assertEquals(code, [0x20, 0x34, 0x12])


#TODO: http://www.6502.buss.hk/6502-instruction-set/jmp says that there is a indirect
예제 #59
0
 def test_adc_abs(self):
     '''
     Test the arithmetic operation ADC between the content of
     the accumulator and the content located at address $1234.
     '''
     tokens = list(lexical('ADC $1234'))
     self.assertEquals(2, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_ADDRESS', tokens[1]['type'])
     self.assertEquals('$1234', tokens[1]['value'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_ABSOLUTE', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x6d, 0x34, 0x12])
예제 #60
0
파일: eor_test.py 프로젝트: yxda/pyNES
 def test_eor_indx(self):
     tokens = list(lexical('EOR ($20,X)'))
     self.assertEquals(6, len(tokens))
     self.assertEquals('T_INSTRUCTION', tokens[0]['type'])
     self.assertEquals('T_OPEN', tokens[1]['type'])
     self.assertEquals('T_ADDRESS', tokens[2]['type'])
     self.assertEquals('$20', tokens[2]['value'])
     self.assertEquals('T_SEPARATOR', tokens[3]['type'])
     self.assertEquals('T_REGISTER', tokens[4]['type'])
     self.assertEquals('T_CLOSE', tokens[5]['type'])
     ast = syntax(tokens)
     self.assertEquals(1, len(ast))
     self.assertEquals('S_INDIRECT_X', ast[0]['type'])
     code = semantic(ast)
     self.assertEquals(code, [0x41, 0x20])