Exemple #1
0
    def execute(pc, text):
        nimonic, val, inst = map(ord, text[0:3])
        pcInc = 2

        if val == 7:
            # system call
            None
        else:
            raise Exception("interrupt received unknown value: " + str(val))
        pcInc += 1

        if inst == 0x04:
            # write
            offset, length = write.getArgv(text[pcInc:])
            write.execute(offset - pc, length, text)
            pcInc += write.getArgc()

        elif inst == 0x01:
            # exit
            exit.execute()
            pcInc += exit.getArgc()

        else:
            raise Exception("unknown systemcall specified")

        return pcInc
Exemple #2
0
    def execute(pc, text):
        nimonic, val, inst = map(ord, text[0:3])

        printInst(pc, convNum(text, 2), 'int ' + str(val))
        pcInc = 2

        if val == 7:
            # system call
            None
        else:
            raise Exception("interrupt received unknown value: " + str(val))

        if inst == 0x04:
            # write
            pcInc += Interrupt.printReverse(
                pc+pcInc, write.getArgc(), text[pcInc:], 'write'
            )

        elif inst == 0x01:
            # exit
            pcInc += Interrupt.printReverse(
                pc+pcInc, exit.getArgc(), text[pcInc:], 'exit'
            )

        else:
            raise Exception("unknown systemcall specified")

        return pcInc