ARM disassembler output: when there are two arguments instead of three

I am trying to annotate a disassembly block for an exam practice. Here is what I have done so far:

00000190 <mystery>:
190:   2300      movs    r3, #0            // move address 190 (offset 0) into r3 ?
192:   e004      b.n     19e <mystery+0xe> // if 19e then branch to mystery
194:   f010 0f01 tst.w   r0, #1  ; 0x1     // update flags to 1 in status register
198:   bf18      it      ne                // if 198 not equal to ??? then ???
19a:   3301      addne   r3, #1            // add to r3 if not equal to 19a offset 1?
19c:   1040      asrs    r0, r0, #1        // shift r0 right one spot (leave it in r0)
19e:   2800      cmp     r0, #0            // compare contents of r0 against 0 ?
1a0:   d1f8      bne.n   194 <mystery+0x4> // branch to 194 if not equal to something at line 194?
1a2:   4618      mov     r0, r3            // move r3 wholecloth into r0
1a4:   4770      bx      lr                // branch(return from the mystery function)
1a6:   bf00      nop                       // No operation

So my comments are pretty rudimentary and are likely to be massively wrong, but most of all I really don't understand what instructions like 190 or 19a mean. There are only two arguments instead of three, so how does it work?

Taking as an example

19a:   3301      addne   r3, #1

My interpretation of this is still: if not equal to X, then add Y to r3? What is X and Y? Should I use the result from the previous line? If so, which argument (of the standard three) replaces it?

Blah!

I agree that I have no idea what I'm doing, and completely misinterpret everything.

Please send help!

+3
3

1) TST , ANDS, , . , TST r0, #1 (r0 1). , Z (), , 0 r0 .

2) IT "If-Then" . 4 . , NE IT ( Thumb-2). NE " ", , ? , Z, " ". , ADD , Z , .. r0 0.

3) CMP/BNE. CMP . Z, r0 0. BNE Z , (.. R0 0).

-C, :

r3 = 0
goto test_loop;
loop:
  Z = (r0 & 1) == 0;
  if (!Z)
    r3 += 1;
  r0 = r0 >> 1
test_loop:
  Z = (r0 - 0) == 0;
  if (!Z) goto loop;
  r0 = r3;
  return;

, "" C:

r3 = 0;
while ( r0 != 0 )
{
  if ( r0 & 1 )
    r3++;
  r0 >>= 1;
}
return r3;

, r0.

, . , .


. . :

b.n     19e <mystery+0xe>

, . (19), ( 190, 19 - + 0xe).

, , , ARM ( ) . TST CMP ( ), , IT .

+3
190:   2300      movs    r3, #0    // assign the value 0 to R3, affecting
                                   // the status flags (the S suffix)

19a:   3301      addne   r3, #1    // add 1 to r3 IF the previous comparison was
                                   // Not Equal to 0

ne , movs.

+3

ARM ARM (ARM Architectural Reference Manual), . , ARM, ARM- ( ) . , , . , ne, nz, cs, nc .. . , , , addne. ARM ( ) , / . , , , s, . , , , ? . addnes, , .

, , , , .

, thumb2, frankenstein ARM . , , , , binutils binutils-isms ( ). , , , , , , , r1, r2 , , , r1, r2, . ARM / , , , , , gnu.

Thus, I did not expect that I could execute the output of the disassembly and reassemble this syntax for these two reasons. Additional materials will help you understand the specific instruction that has been encoded.

+2
source

All Articles