assembly - Purpose of ARM parallel instructions ASX and SAX? -


can explain when it's beneficial use parallel add/subtract arm instructions asx and/or sax? in situation/algorithm 1 need exhange halfwords, add , subtract upper/lower halfwords? below explanation of each:

asx

  • exchange halfwords of rm, add top halfwords , subtract bottom halfwords.

sax

  • exchange halfwords of rm, subtract top halfwords , add bottom halfwords.

like russ schultz said in comment useful audio encoded l+r , l-r channels. used like:

ldr r1, [r0]      ; r1 = (l-r):(l+r) shasx r1, r1, r1  ; r1 = ((l-r)+(l+r))/2:((l+r)-(l-r))/2                    ;    = (2l/2):(2r/2)                   ;    = l:r   ror r1, r1, #16   ; r1 = r:l str r1, [r0] 

the swapping of third operand's top , bottom halfwords necessary 2 different components can added/subtracted each other. without exchange you'd ((l-r)+(l-r))/2:((l+r)-(l+r))/2 = (2(l-r)/2):(0/2) = (l-r):0.


Comments