-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Support lsr.w on ARMv7 THUMB #1363
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,16 @@ def read(self, nbits=None, with_carry=False): | |
value += self.cpu.instruction.size | ||
if self.is_shifted(): | ||
shift = self.op.shift | ||
value, carry = self.cpu._shift(value, shift.type, shift.value, carry) | ||
# XXX: This is unnecessary repetition. | ||
if shift.type in range(cs.arm.ARM_SFT_ASR_REG, cs.arm.ARM_SFT_RRX_REG + 1): | ||
if self.cpu.mode == cs.CS_MODE_THUMB: | ||
amount = shift.value.read() | ||
else: | ||
src_reg = self.cpu.instruction.reg_name(shift.value).upper() | ||
amount = self.cpu.regfile.read(src_reg) | ||
else: | ||
amount = shift.value | ||
value, carry = self.cpu._shift(value, shift.type, amount, carry) | ||
if self.op.subtracted: | ||
value = -value | ||
if with_carry: | ||
|
@@ -580,12 +589,7 @@ def _shift(cpu, value, _type, amount, carry): | |
amount = 1 | ||
|
||
elif _type in range(cs.arm.ARM_SFT_ASR_REG, cs.arm.ARM_SFT_RRX_REG + 1): | ||
if cpu.mode == cs.CS_MODE_THUMB: | ||
src = amount.read() | ||
else: | ||
src_reg = cpu.instruction.reg_name(amount).upper() | ||
src = cpu.regfile.read(src_reg) | ||
amount = Operators.EXTRACT(src, 0, 8) | ||
amount = Operators.EXTRACT(amount, 0, 8) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that below we use e.g. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I won't have much time to look into this in the near future due to other priorities, but to address your point about |
||
|
||
if amount == 0: | ||
return value, carry | ||
|
@@ -1494,12 +1498,15 @@ def _SR(cpu, insn_id, dest, op, *rest): | |
carry = cpu.regfile.read("APSR_C") | ||
if rest and rest[0].type == "register": | ||
# FIXME we should make Operand.op private (and not accessible) | ||
result, carry = cpu._shift(op.read(), srtype, rest[0].op.reg, carry) | ||
src_reg = cpu.instruction.reg_name(rest[0].op.reg).upper() | ||
amount = cpu.regfile.read(src_reg) | ||
result, carry = cpu._shift(op.read(), srtype, amount, carry) | ||
elif rest and rest[0].type == "immediate": | ||
amount = rest[0].read() | ||
result, carry = cpu._shift(op.read(), srtype, amount, carry) | ||
elif cpu.mode == cs.CS_MODE_THUMB: | ||
result, carry = cpu._shift(dest.read(), srtype, op, carry) | ||
amount = op.read() | ||
result, carry = cpu._shift(dest.read(), srtype, amount, carry) | ||
else: | ||
result, carry = op.read(with_carry=True) | ||
dest.write(result) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are here, could you check if this is still the case in latest Capstone (4.0.1), please?
This way maybe we can remove this if/elif here.