Example #1
0
def generate_jr(fields):  # Chequear que no de error porque fields es una sola palabra
    opcode = "000000"
    rs = dec_to_binary.strdec_to_bin(int((fields[0])[1:-1]), 5)
    return str(opcode + rs + "000000000000000001000")
Example #2
0
def rd_rs_shamt(fields):
    rs = dec_to_binary.strdec_to_bin(int((fields[1])[1:-1]), 5)
    rd = dec_to_binary.strdec_to_bin(int((fields[0])[1:-1]), 5)
    shamt = dec_to_binary.strdec_to_bin(int((fields[2])[:-1]), 5)
    return str(rs + "00000" + rd + shamt)
Example #3
0
def rt_offset_base(fields):
    base = dec_to_binary.strdec_to_bin(int((fields[1].split("($")[1])[:-2]), 5)
    rt = dec_to_binary.strdec_to_bin(int((fields[0])[1:-1]), 5)
    offset = dec_to_binary.strdec_to_bin(int(fields[1].split("($")[0]), 16)
    return str(base + rt + offset)
Example #4
0
def rt_immediate(fields):
    rt = dec_to_binary.strdec_to_bin(int((fields[0])[1:-1]), 5)
    immediate = dec_to_binary.strdec_to_bin(int((fields[1])[:-1]), 16)
    return str(rt + immediate)
Example #5
0
def rs_rt_offset(fields):
    rs = dec_to_binary.strdec_to_bin(int((fields[0])[1:-1]), 5)
    rt = dec_to_binary.strdec_to_bin(int((fields[1])[1:-1]), 5)
    offset = dec_to_binary.strdec_to_bin(int((fields[2])[:-1]), 16)
    return str(rs + rt + offset)
Example #6
0
def rd_rs_rt(fields):
    rs = dec_to_binary.strdec_to_bin(int((fields[1])[1:-1]), 5)
    rt = dec_to_binary.strdec_to_bin(int((fields[2])[1:-1]), 5)
    rd = dec_to_binary.strdec_to_bin(int((fields[0])[1:-1]), 5)
    return str(rs + rt + rd)
Example #7
0
def generate_jal(fields):  # Chequear que no de error porque fields es una sola palabra
    opcode = "000011"
    target = dec_to_binary.strdec_to_bin(int((fields[0])[:-1]), 26)
    return str(opcode + target)