def A64_adr(obj, p, immlo, immhi, Rd): obj.page = p == 1 if obj.page == 1: obj.imm = env.cst((immhi << 14) + (immlo << 12), 64) else: obj.imm = env.cst((immhi << 2) + immlo, 64) obj.d = sp2z(env.Xregs[Rd]) obj.operands = [obj.d, obj.imm] obj.type = type_data_processing
def A64_CCMx(obj, sf, imm5, cond, Rn, nzcv): obj.datasize = 64 if (sf == 1) else 32 regs = env.Xregs if sf == 1 else env.Wregs obj.n = sp2z(regs[Rn]) obj.imm = env.cst(imm5, obj.datasize) obj.flags = env.cst(nzcv, 4) obj.misc['cond'] = env.CONDITION[cond][0] obj.cond = env.CONDITION[cond][1] obj.operands = [obj.n, obj.imm, obj.nzcv, obj.cond] obj.type = type_data_processing
def A64_generic(obj, p, immlo, immhi, Rd): obj.page = (p == 1) if obj.page == 1: obj.mnemonic += 'P' obj.imm = env.cst(immhi << 14 + immlo << 12, 64) else: obj.imm = env.cst(immhi << 2 + immlo, 64) obj.d = sp2z(env.Xregs[Rd]) obj.operands = [obj.d, obj.imm] obj.type = type_data_processing
def A64_generic(obj, b5, b40, imm14, Rt): obj.datasize = 64 if b5 == 1 else 32 obj.bitpos = b5 << 5 + b40 obj.offset = env.cst(imm14 << 2, 16).signextend(64) obj.t = sp2z(env.Xregs[Rt]) if b5 == 1 else sp2z(env.Wregs[Rt]) obj.operands = [obj.t, obj.bitpos, obj.offset] obj.type = type_data_processing
def A64_CBx(obj, sf, imm19, Rt): obj.datasize = 64 if (sf == 1) else 32 regs = env.Xregs if sf == 1 else env.Wregs obj.t = sp2z(regs[Rt]) obj.offset = env.cst(imm19 << 2, 21).signextend(64) obj.operands = [obj.t, obj.offset] obj.type = type_control_flow
def A64_generic(obj, sf, hw, imm16, Rd): if sf == 1 and hw & 2 == 1: raise InstructionError(obj) obj.datasize = 64 if sf == 1 else 32 pos = hw << 4 obj.imm = env.cst(imm16, 16) << pos obj.d = sp2z(env.Xregs[Rd]) if sf == 1 else sp2z(env.Wregs[Rd]) obj.operands = [obj.d, obj.imm] obj.type = type_data_processing
def A64_CCMx_reg(obj, sf, Rm, cond, Rn, nzcv): obj.datasize = 64 if (sf == 1) else 32 regs = env.Xregs if sf == 1 else env.Wregs obj.n = sp2z(regs[Rn]) obj.m = sp2z(regs[Rm]) obj.flags = env.cst(nzcv, 4) obj.misc["cond"] = env.CONDITION[cond][0] obj.cond = env.CONDITION[cond][1] obj.operands = [obj.n, obj.m, obj.flags, obj.cond] obj.type = type_data_processing
def A64_msr(obj,op1,CRm,op2): try: obj.pstatefield = {0b000101:env.SPSel, 0b011110:env.DAIFSet, 0b011111:env.DAIFClr}[op1<<3+op2] except KeyError: raise InstructionError(obj) obj.imm = env.cst(CRm,4) obj.operands = [obj.pstatefield,obj.imm] obj.type = type_cpu_state
def A64_load_store(obj, opc, imm7, Rt2, Rn, Rt): x = opc >> 1 obj.scale = 2 + x obj.datasize = 8 << obj.scale obj.offset = env.cst(imm7, 7).signextend(64) << obj.scale regs = env.Xregs if opc else env.Wregs obj.t = sp2z(regs[Rt]) obj.t2 = sp2z(regs[Rt2]) obj.n = env.Xregs[Rn] obj.operands = [obj.t, obj.t2, obj.n, obj.offset] obj.type = type_data_processing
def A64_EXTR(obj, sf, N, Rm, imms, Rn, Rd): if sf != N: raise InstructionError(obj) if sf == 0 and imms > 31: raise InstructionError(obj) obj.datasize = 64 if (sf == 1) else 32 regs = env.Xregs if sf == 1 else env.Wregs obj.d = sp2z(regs[Rd]) obj.n = sp2z(regs[Rn]) obj.m = sp2z(regs[Rm]) obj.lsb = env.cst(imms, 6) obj.operands = [obj.d, obj.n, obj.m, obj.lsb] obj.type = type_data_processing
def A64_generic(obj, sf, S, shift, imm12, Rn, Rd): obj.datasize = 64 if (sf == 1) else 32 obj.setflags = (S == 1) regs = env.Xregs if sf == 1 else env.Wregs if shift == 0: imm = imm12 elif shift == 1: imm = imm12 << 12 else: raise InstructionError(obj) obj.imm = env.cst(imm, obj.datasize) obj.n = regs[Rn] obj.d = regs[Rd] if S == 0 else sp2z(regs[Rd]) obj.operands = [obj.d, obj.n, obj.imm] obj.type = type_data_processing
def A64_load_store(obj, opc, imm19, Rt): obj.offset = env.cst(imm19 << 2, 21).signextend(64) if opc == 0b11: #PRFM: obj.prfop = Rt obj.operands = [obj.prfop, obj.offset] obj.type = type_cpu_state return obj.signed = False obj.size = 4 << opc if opc == 2: obj.size = 4 obj.signed = True obj.t = sp2z(env.Xregs[Rt]) if obj.size == 8 else sp2z(env.Wregs[Rt]) obj.operands = [obj.t, obj.offset] obj.type = type_data_processing
def A64_load_store(obj, size, opc, imm12, Rn, Rt): obj.scale = size obj.datasize = 8 << obj.scale obj.offset = env.cst(imm12, 64) << obj.scale obj.n = env.Xregs[Rn] if opc & 2 == 0: obj.regsize = 64 if size == 0b11 else 32 obj.signed = False else: if size == 0b11: # special case of PRFM obj.prfop = Rt obj.operands = [obj.prfop, obj.n, obj.offset] obj.type = type_cpu_state return obj.regsize = 32 if opc & 1 == 1 else 64 obj.signed = True obj.t = sp2z(env.Xregs[Rt]) if obj.regsize == 64 else sp2z(env.Wregs[Rt]) obj.operands = [obj.t, obj.n, obj.offset] obj.type = type_data_processing
def A64_generic(obj, CRm): obj.imm = env.cst(CRm, 4) obj.operands = [obj.imm] obj.type = type_cpu_state
def A64_sync(obj, CRm, op2): obj.imm = env.cst(CRm << 3 + op2, 7) obj.operands = [obj.imm] obj.type = type_cpu_state
def A64_generic(obj, imm16): obj.imm = env.cst(imm16, 16) obj.operands = [obj.imm] obj.type = type_cpu_state
def A64_B(obj, imm26): obj.offset = env.cst(imm26 << 2, 28).signextend(64) obj.operands = [obj.offset] obj.type = type_control_flow
def A64_Bcond(obj, imm19, cond): obj.offset = env.cst(imm19 << 2, 21).signextend(64) obj.misc['cond'] = env.CONDITION[cond][0] obj.cond = env.CONDITION[cond][1] obj.operands = [obj.offset] obj.type = type_control_flow