Пример #1
0
def label_position():
    '''
    A function that get label position
    '''
    file_name = str(sys.argv[2])
    a = input.list_labels(input.parse_file(file_name)[0])

    return (a[0][1], a[0][0])
Пример #2
0
def get_label_num():
    '''
    A function that get number of label
    '''
    argv = sys.argv
    tran_dict = input.parse_file(argv[2])[1]
    label_num = len(tran_dict)
    return label_num
Пример #3
0
def get_label_num():
    '''
    A function that get number of label
    '''
    argv = sys.argv
    file_name = str(argv[2])
    a = input.list_labels(input.parse_file(file_name)[0])
    label_num = len(a)
    return label_num
Пример #4
0
def get_ins():
    '''
    A function that get all the instrction, and store in a list
    '''
    argv = sys.argv
    ins_list, tran_dict = input.parse_file(argv[2])
    jump_ins = []
    for x in range(len(ins_list)):
        if (ins_list[x][0] == "bne") or (ins_list[x][0] == "beq"):
            ins_list[x][3] = tran_dict[int(ins_list[x][3])].strip("$")
            jump_ins.append(x)

    res = []

    for x in ins_list:
        if ins_list.index(x) in jump_ins:
            res.append(x[0] + " $" + x[1] + ",$" + x[2] + "," + x[3])
        else:
            res.append(input.instruction_to_string(x))
    return res
Пример #5
0
                            cycle[j][cycle_num - 1] = -1
                        else:
                            cycle[j][cycle_num - 1] = cycle_num - j
                            if (cycle_num - j == 5):  #WB finished this ins
                                finished_ins += 1
                                get_register(register_list,
                                             instruction_split(ins_list[j]))
                                #get register updated

        print_cycle(cycle, cycle_num, ins_num, ins_list)  #print cycle
        print_register(register_list)  #print register
        cycle_num += 1  #increment for cycle
    print("-" * 82)
    print("END OF SIMULATION")


if __name__ == "__main__":
    argv = sys.argv
    if argv[1] == "F":
        label_num = get_label_num()
        if label_num == 0:
            forward_no_label()
        elif label_num == 1:
            forward_with_one_label()
        else:
            print("got fvcked")
    else:
        filename = str(argv[2])
        _list = input.parse_file(argv[2])[0]
        no_forward(filename, _list)