weston
weston

Reputation: 54801

Fourth parameter on ARM SUBtract instruction

Can someone explain/confirm this (particularly the SUB line) to me:

CMP align,#2
CMPNE align,#5
CMPNE align,#8
SUBEQ xpos,xpos,width,LSR#1

I was thinking it might be equivilant to the c code:

if ((align==2) || (align==5) || (align==8))
{
  xpos -= width >> 1;
}

I have found this documentation but I don't understand the forth parameter, imm12. It just says:

The SUB instruction subtracts the value of Operand2 or imm12 from the value in Rn.

Upvotes: 1

Views: 318

Answers (1)

Michael
Michael

Reputation: 58467

Your assumption about what the code does looks correct to me.

but I don't understand the forth parameter, imm12

The fourth parameter is not imm12, but rather a shift operation on width (which I assume to be an alias for one of the general purpose registers).

Upvotes: 3

Related Questions