И все-же, я не уверен, что этот код
Код
000116 ea4f71e0 ASR r1,r0,#31
00011a eb007111 ADD r1,r0,r1,LSR #28
00011e f3c11107 UBFX r1,r1,#4,#8
есть расширение знака при делении на 16.
Может, все-таки, округление?
upd. Всё, нашел! В книге "ARM System Developer’s Guide" имеется точный ответ.
If your code uses addition, subtraction, and multiplication, then there is no performance
difference between signed and unsigned operations. However, there is a difference when it
comes to division. Consider the following short example that averages two integers:
int average_v1(int a, int B )
{
return (a+B )/2;
}
This compiles to
average_v1
ADD r0,r0,r1 ; r0 = a + b
ADD r0,r0,r0,LSR #31 ; if (r0<0) r0++
MOV r0,r0,ASR #1 ; r0 = r0>>1
MOV pc,r14 ; return r0
Notice that the compiler adds one to the sum before shifting by right if the sum is
negative. In other words it replaces x/2 by the statement:
(x<0) ? ((x+1)>>1): (x>>1)
В-общем, при делении на положительную константу U лучше не игнорировать.