Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this RSB instruction do?

Tags:

assembly

arm

I am trying to figure out what does this ARM assembly line does:

RSB r1, r2, r3, LSL #1

I am referring to RSB description from keil page but this example does not quite fit: http://www.keil.com/support/man/docs/armasm/armasm_dom1361289891932.htm I would appreciate all help.

like image 774
Łukasz Przeniosło Avatar asked Feb 04 '17 16:02

Łukasz Przeniosło


People also ask

What is MLA instruction?

The MLA instruction multiplies the values from Rn and Rm , adds the value from Ra , and places the least significant 32 bits of the result in Rd . The MLS instruction multiplies the values from Rn and Rm , subtracts the result from the value from Ra , and places the least significant 32 bits of the final result in Rd .

What is MSR instruction?

A model-specific register (MSR) is any of various control registers in the x86 instruction set used for debugging, program execution tracing, computer performance monitoring, and toggling certain CPU features.

What is LDRH?

Load Register Halfword (immediate) calculates an address from a base register value and an immediate offset, loads a halfword from memory, zero-extends it to form a 32-bit word, and writes it to a register. It can use offset, post-indexed, or pre-indexed addressing.

What does STR do in arm?

STR instructions store a register value into memory. The memory address to load from or store to is at an offset from the register Rn . The offset is specified by the register Rm and can be shifted left by up to 3 bits using LSL . The value to load or store can be a byte, halfword, or word.


1 Answers

The RSB instruction is a Reverse SuBtract without carry.
The documentation indicates the syntax:

RSB{S}{cond} {Rd}, Rn, Operand2

The following usage can then be explained:

RSB r1, r2, r3, LSL #1  
  1. r3, LSL #1 is Operand2 → r3 register logical left-shifted by 1 bit
  2. r2 is Rn
  3. r1 is Rd

So the operation uses r1, r2 and r3 registers as follows: r1 = (r3 << 1) - r2

like image 63
Laurent H. Avatar answered Oct 06 '22 23:10

Laurent H.