The following assember instruction is given:
SUB[R1], 8[-R2]
The form this instruction is calculated:
op1 = op1 - op2
The first operand is addressed "register indirectly". The second one is addressed "register indexed" with pre-decrement ("n[-Rx]
").
I have changed that to:
add #7, R2
sub [R1], [R2]
sub #8, R2
I try to explain why I got that:
8[-R2]
is written also like this: R2-1+8= R2+7
, so I added 7
to R2
at beginning.
Next line is clear.
Last line I remove 8 from R2 because is saying "pre-decrement".
I hope is all ok? I hope I described our personal way of writing good enough (I know there are other ways of writing, notation but we use this...)
This is no homework I only ask to understand it and I make this task for my own learn.