view python/ppci/target/msp430/msp430.py @ 345:b4882ff0ed06

Added more arm isa tests
author Windel Bouwman
date Sun, 02 Mar 2014 17:12:08 +0100
parents 86b02c98a717
children 3bb7dcfe5529
line wrap: on
line source

import struct
import types
from ..basetarget import Register, Instruction, Target
from ppci.asmnodes import ASymbol, ANumber
from ppci import CompilerError
from .registers import r10, r11, r12, r13, r14, r15
from .instructions import Reti, Mov, Add

# Create the target class (singleton):

class Msp430Target(Target):
    def __init__(self):
        super().__init__('msp430')

        # Registers:
        self.add_keyword('r10')
        self.add_keyword('r11')
        self.add_keyword('r12')
        self.add_keyword('r13')
        self.add_keyword('r14')
        self.add_keyword('r15')
        self.add_rule('reg', ['r10'], lambda rhs: r10)
        self.add_rule('reg', ['r11'], lambda rhs: r11)
        self.add_rule('reg', ['r12'], lambda rhs: r12)
        self.add_rule('reg', ['r13'], lambda rhs: r13)
        self.add_rule('reg', ['r14'], lambda rhs: r14)
        self.add_rule('reg', ['r15'], lambda rhs: r15)

        # Instructions rules:
        self.add_keyword('mov')
        self.add_instruction(['mov', 'reg', ',', 'reg'],
            lambda rhs: Mov(rhs[1], rhs[3]))
        self.add_instruction(['mov', 'imm16', ',', 'reg'],
            lambda rhs: Mov(rhs[1], rhs[3]))

        self.add_keyword('add')
        self.add_instruction(['add', 'reg', ',', 'reg'],
            lambda rhs: Add(rhs[1], rhs[3]))

        self.add_keyword('reti')
        self.add_instruction(['reti'], lambda rhs: Reti())



msp430target = Msp430Target()


# Target description for the MSP430 processor


msp430target.registers.append(r10)
msp430target.registers.append(r11)
msp430target.registers.append(r12)
msp430target.registers.append(r13)
msp430target.registers.append(r14)
msp430target.registers.append(r15)