Exemplo n.º 1
0
    def test_pseudo_instructions(self):
        # LLI
        op_ori = 0x2A << 26
        r5_rd = 0x5 << 21

        self.assert_asm_instr(
            assemble_instruction("lli", [Id("$r5"), Number(12)], ("text", 0x1000), {}, {})[0], op_ori | r5_rd | 12
        )

        # RET
        op_jr = 0x16 << 26
        r31_rd = 31 << 21
        r30_rd = 30 << 21

        self.assert_asm_instr(assemble_instruction("ret", [], (), {}, {})[0], op_jr | r31_rd)
Exemplo n.º 2
0
    def test_pseudo_instructions(self):
        # LLI
        op_ori = 0x2A << 26
        r5_rd = 0x5 << 21

        self.assert_asm_instr(
            assemble_instruction('lli', [Id('$r5'), Number(12)],
                                 ('text', 0x1000), {}, {})[0],
            op_ori | r5_rd | 12)

        # RET
        op_jr = 0x16 << 26
        r31_rd = 31 << 21
        r30_rd = 30 << 21

        self.assert_asm_instr(
            assemble_instruction('ret', [], (), {}, {})[0], op_jr | r31_rd)
Exemplo n.º 3
0
    def test_assemble_instruction_error(self):
        # nonexisting instruction
        self.assert_instr_error(assemble_instruction, "joe", "", "", "", "")

        # wrong number of arguments
        self.assert_instr_error(assemble_instruction, "add", [1, 2], "", "", "")

        # bad types of arguments
        self.assert_instr_error(assemble_instruction, "add", [1, 2, 6], "", "", "")

        # Sanity test for a simple valid instruction
        self.assert_asm_instr(
            assemble_instruction("add", [Id("$r4"), Id("$s6"), Id("$zero")], ("text", 0x1000), {}, {})[0], 0x00980000
        )
Exemplo n.º 4
0
    def test_assemble_instruction_error(self):
        # nonexisting instruction
        self.assert_instr_error(assemble_instruction, 'joe', '', '', '', '')

        # wrong number of arguments
        self.assert_instr_error(assemble_instruction, 'add', [1, 2], '', '',
                                '')

        # bad types of arguments
        self.assert_instr_error(assemble_instruction, 'add', [1, 2, 6], '', '',
                                '')

        # Sanity test for a simple valid instruction
        self.assert_asm_instr(
            assemble_instruction(
                'add',
                [Id('$r4'), Id('$s6'), Id('$zero')], ('text', 0x1000), {},
                {})[0], 0x00980000)
Exemplo n.º 5
0
    def test_assemble_instruction_error(self):
        # nonexisting instruction
        self.assert_instr_error(
            assemble_instruction, 'joe', '', '', '', '')

        # wrong number of arguments
        self.assert_instr_error(
            assemble_instruction, 'add', [1, 2], '', '', '')

        # bad types of arguments
        self.assert_instr_error(
            assemble_instruction, 'add', [1, 2, 6], '', '', '')

        # Sanity test for a simple valid instruction
        self.assert_asm_instr(
            assemble_instruction(
                'add',
                [Id('$r4'), Id('$s6'), Id('$zero')],
                ('text', 0x1000), {}, {})[0],
            0x00980000)
Exemplo n.º 6
0
 def test_eret(self):
     op_eret = 0x3E << 26
     self.assert_asm_instr(
         assemble_instruction('eret', [], (), {}, {})[0],
         op_eret)
Exemplo n.º 7
0
 def test_eret(self):
     op_eret = 0x3E << 26
     self.assert_asm_instr(
         assemble_instruction('eret', [], (), {}, {})[0], op_eret)