NefMoto

Technical => Reverse Engineering => Topic started by: elRey on July 09, 2014, 12:48:03 PM



Title: Why the extra step? assembly code
Post by: elRey on July 09, 2014, 12:48:03 PM
Why is line #4 used instead of moving r5 into 381F0A ?

Code:
calls   0, IRRFilt16bit_32bitRes0_6cae
mov     word_381F1C, r4
mov     word_381F1E, r5
mov     r2, word_381F1E
mov     pvdksf_w_word_381F0A, r2
cmp     r2, pvdkmx_w_word_381F08

vs

Code:
calls   0, IRRFilt16bit_32bitRes0_6cae
mov     word_381F1C, r4
mov     word_381F1E, r5
mov     pvdksf_w_word_381F0A, r5
cmp     r2, pvdkmx_w_word_381F08

Is there a reason for the extra mov and use of r2 ?

Thanks,
Rey


Title: Re: Why the extra step? assembly code
Post by: phila_dot on July 09, 2014, 01:47:58 PM
r5 is input and output for that filter IIRC


Title: Re: Why the extra step? assembly code
Post by: elRey on July 09, 2014, 01:58:30 PM
OK, but why can't it be moved into 381F0A also?


Title: Re: Why the extra step? assembly code
Post by: nyet on July 09, 2014, 02:13:33 PM
Code:
calls   0, IRRFilt16bit_32bitRes0_6cae
mov     word_381F1C, r4
mov     word_381F1E, r5
mov     pvdksf_w_word_381F0A, r5
cmp     r2, pvdkmx_w_word_381F08

I assume you mean:

Code:
calls   0, IRRFilt16bit_32bitRes0_6cae
mov     word_381F1C, r4
mov     word_381F1E, r5
mov     pvdksf_w_word_381F0A, r5
cmp     r5, pvdkmx_w_word_381F08

Perhaps a copy is needed in r2? As a return value? Or a future op?


Title: Re: Why the extra step? assembly code
Post by: phila_dot on July 09, 2014, 02:16:19 PM
No, you're right.

It's an uneccessary step.

Obviously in your example r5 would need to be used for the cmp as well.

There is alot of weird stuff that you will find including obfuscation.


Title: Re: Why the extra step? assembly code
Post by: elRey on July 09, 2014, 02:36:15 PM
Yes, sorry, I missed that cmp. I thought it was a mov. So, yes, cmp r5, ... Just trying make some space for custom code.

Thanks,
Rey