Esempio n. 1
0
def xori(line):
    rs = int(line[6:11], 2)
    ra = int(line[11:16], 2)
    ui = int(line[16:32], 2)
    t1 = int(mem_man.read_register(rs)[-16:], 2)
    t2 = str(t1 ^ ui)
    mem_man.update_register(ra, t2)
Esempio n. 2
0
def lbz(line):
    rt = int(line[6:11], 2)
    ra = int(line[11:16], 2)
    ds = int(line[16:32], 2)
    t1 = int(mem_man.read_register(ra), 2)
    ea = ds + t1
    data = mem_man.read_memory(ea)
    mem_man.update_register(rt, data)
Esempio n. 3
0
def lhz(line):
    rt = int(line[6:11], 2)
    ra = int(line[11:16], 2)
    ds = int(line[16:32], 2)
    t1 = int(mem_man.read_register(ra), 2)
    ea = ds + t1
    datum1 = mem_man.read_memory(ea)
    datum2 = mem_man.read_memory(ea + 1)
    data = datum2 + datum1
    mem_man.update_register(rt, data)
Esempio n. 4
0
def instruction_extsw(line):
    instruction = "srad"
    #extracting operands
    opind1 = int(line[6:11], 2)
    opind2 = int(line[11:16], 2)
    rctemp = line[31]
    op1 = mem_man.read_register(opind1)
    filler = op1[32]
    op2 = ""
    for i in range(32):
        op2 = op2 + filler
    op2 = op2 + op1[32:]
    mem_man.update_register(opind2, op2)
Esempio n. 5
0
def instruction_add(line):
    instruction = "Add"
    opind1 = int(line[6:11], 2)
    opind2 = int(line[11:16], 2)
    opind3 = int(line[16:21], 2)
    rctemp = line[31]
    #action=op1+"<- ("+op2+") AND ("+op3+")"
    #print details
    op1 = ""
    op2 = mem_man.read_register(opind2)
    op3 = mem_man.read_register(opind3)
    op1 = bin(int(op2, 2) + int(op3, 2))[2:]
    mem_man.update_register(opind1, op1)
Esempio n. 6
0
def instruction_sld(line):
    instruction = "sld"
    #extracting operands
    opind1 = int(line[6:11], 2)
    opind2 = int(line[11:16], 2)
    opind3 = int(line[16:21], 2)
    rctemp = line[31]

    op1 = mem_man.read_register(opind1)
    op3 = mem_man.read_register(opind3)
    n = int(op3[-7:], 2)
    op2 = op1[n:]
    for i in range(n):
        op2 = op2 + "0"
    mem_man.update_register(opind2, op2)
Esempio n. 7
0
def ld(line):
    rt = int(line[6:11], 2)
    ra = int(line[11:16], 2)
    ds = int(line[16:30], 2)
    t1 = int(mem_man.read_register(ra), 2)
    disp = ds * 4
    ea = int(disp) + int(t1)
    datum1 = mem_man.read_memory(ea)
    datum2 = mem_man.read_memory(ea + 1)
    datum3 = mem_man.read_memory(ea + 2)
    datum4 = mem_man.read_memory(ea + 3)
    datum5 = mem_man.read_memory(ea + 4)
    datum6 = mem_man.read_memory(ea + 5)
    datum7 = mem_man.read_memory(ea + 6)
    datum8 = mem_man.read_memory(ea + 7)
    data = datum8 + datum7 + datum6 + datum5 + datum4 + datum3 + datum2 + datum1
    mem_man.update_register(rt, data)
Esempio n. 8
0
def instruction_srad(line):
    instruction = "srad"
    #extracting operands
    opind1 = int(line[6:11], 2)
    opind2 = int(line[11:16], 2)
    opind3 = int(line[16:21], 2)
    rctemp = line[31]

    op1 = mem_man.read_register(opind1)
    op3 = mem_man.read_register(opind3)
    n = int(op3[-7:], 2)
    op2 = ""
    filler = op1[0]
    for i in range(n):
        op2 = op2 + filler
    op2 = op2 + op1[:-n]
    mem_man.update_register(opind2, op2)
Esempio n. 9
0
def instruction_xor(line):
    instruction = "Xor"
    #extracting operands
    opind1 = int(line[6:11], 2)
    opind2 = int(line[11:16], 2)
    opind3 = int(line[16:21], 2)
    rctemp = line[31]
    #action=op1+"<- ("+op2+") AND ("+op3+")"
    #print details
    op1 = ""
    op2 = mem_man.read_register(opind2)
    op3 = mem_man.read_register(opind3)
    for i in range(64):
        if (op2[i] == op3[i]):
            op1 = op1 + "0"
        else:
            op1 = op1 + "1"
    mem_man.update_register(opind1, op1)
Esempio n. 10
0
def instruction_subf(line):
    instruction = "subf"
    #extracting operands
    opind1 = int(line[6:11], 2)
    opind2 = int(line[11:16], 2)
    opind3 = int(line[16:21], 2)
    rctemp = line[31]
    #action=op1+"<- ("+op2+") AND ("+op3+")"
    #print details
    op1 = ""
    temp = ""
    op2 = mem_man.read_register(opind2)
    op3 = mem_man.read_register(opind3)
    for i in range(64):
        if (op2[i] == "0"):
            temp = temp + "1"
        else:
            temp = temp + "0"
    op2 = temp
    op1 = bin(int(op2, 2) + int(op3, 2) + int("1", 2))[2:]
    mem_man.update_register(opind1, op1)