def helper_all(binary, opc, size, wback, postIndex, offset, rtKey, rnKey, scale, instr): if (opc[0] == '0'): if (opc[1] == '1'): memOp = const.MEM_OP_LOAD else: memOp = const.MEM_OP_STORE if (size == '11'): regSize = 64 else: regSize = 32 signed = False else: if (size == '11'): memOp = const.MEM_OP_PREFETCH else: memOp = const.MEM_OP_LOAD if opc[1] == '1': regSize = 32 else: regSize = 64 signed = True dataSize = 8 << scale '''wb_unknown = False rt_unknown = False''' # commenting - assuming them to be false always address = utilFunc.getRegValueByStringkey(binary[22:27], '1') address = utilFunc.uInt(address) if not (postIndex): address = address + offset if (memOp == const.MEM_OP_STORE): data = utilFunc.getRegValueByStringkey(binary[27:32], '0') utilFunc.storeToMemory(data, address, dataSize) elif (memOp == const.MEM_OP_LOAD): data = utilFunc.fetchFromMemory(address, dataSize) if (data == const.TRAP): utilFunc.finalize_simple(instr) print "HEY!!! There seems to be a problem - memory location can not be accessed" print "Moving ahead without executing the instruction" return if (signed): data = utilFunc.signExtend(data, regSize) else: data = utilFunc.zeroExtend(data, regSize) utilFunc.setRegValue(rtKey, data.zfill(64), '0') if (wback): if postIndex: address = address + offset address = utilFunc.intToBinary(address, 64) utilFunc.setRegValue(rnKey, address, '1') utilFunc.finalize_simple(instr)
def helper_all(binary, opc, size, wback, postIndex, offset, rtKey, rnKey, scale, instr): if(opc[0] == '0'): if(opc[1] == '1'): memOp = const.MEM_OP_LOAD else: memOp = const.MEM_OP_STORE if(size == '11'): regSize = 64 else: regSize = 32 signed = False else: if(size == '11'): memOp = const.MEM_OP_PREFETCH else: memOp = const.MEM_OP_LOAD if opc[1] == '1': regSize = 32 else: regSize = 64 signed = True dataSize = 8 << scale '''wb_unknown = False rt_unknown = False''' # commenting - assuming them to be false always address = utilFunc.getRegValueByStringkey(binary[22:27], '1') address = utilFunc.uInt(address) if not(postIndex): address = address + offset if(memOp == const.MEM_OP_STORE): data = utilFunc.getRegValueByStringkey(binary[27:32], '0') utilFunc.storeToMemory(data, address, dataSize) elif(memOp == const.MEM_OP_LOAD): data = utilFunc.fetchFromMemory(address, dataSize) if(data == const.TRAP): utilFunc.finalize_simple(instr) print "HEY!!! There seems to be a problem - memory location can not be accessed" print "Moving ahead without executing the instruction" return if(signed): data = utilFunc.signExtend(data, regSize) else: data = utilFunc.zeroExtend(data, regSize) utilFunc.setRegValue(rtKey, data.zfill(64), '0') if(wback): if postIndex: address = address + offset address = utilFunc.intToBinary(address, 64) utilFunc.setRegValue(rnKey, address, '1') utilFunc.finalize_simple(instr)
def helper_reg_unsignedOffset(binary, instr): rtKey = utilFunc.getRegKeyByStringKey(binary[27:32]) rnKey = utilFunc.getRegKeyByStringKey(binary[22:27]) imm12 = binary[10:22] opc = binary[8:10] size = binary[0:2] wback = False postIndex = False scale = utilFunc.uInt(size) offset = utilFunc.lsl(utilFunc.zeroExtend(imm12, 64), scale) offset = utilFunc.sInt(offset, 64) instr += str(rtKey) + ", [x" + str(rnKey) + ", #" + str(offset) + "]" helper_all(binary, opc, size, wback, postIndex, offset, rtKey, rnKey, scale, instr)