Exercise 2 of the ARM chapter has a rather short disassembly compared to the first exercise. Again, we are tasked with the decompilation of the provided function mystery2
.
The disassembly is as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
| 01: mystery2
02: 28 B1 CBZ R0, loc_C672
03: 90 F8 63 00 LDRB.W R0, [R0,#0x63]
04: 00 38 SUBS R0, #0
05: 18 BF IT NE
06: 01 20 MOVNE R0, #1
07: 70 47 BX LR
08: loc_C672
09: 01 20 MOVS R0, #1
10: 70 47 BX LR
11: ; End of function mystery2
|
First of all, we notice that the function has been compiled in Thumb mode, as there are several instructions having a width of 16 bits, which is not possible in ARM mode. Furthermore, the instructions CBZ
and IT
are specific to Thumb mode and not available in ARM mode.