So I am working on a Binary Bomb assignment and have gotten stuck. Tried looking at other questions and guides but mine seems to be completely different from what is describ
Then it grabs the first number from the array which in this case is 10 and puts it into $eax at +=<+51>.
Wrong. <+51>
reads the first number you entered, not the first number from the array. It's then masked into the 0..15 range by discarding the top bits, and is written back to the local variable where it came from. It also lives on in eax
, of course.
The array contains 4 byte integers and there are 15 of them. As such you can print it using x/15wd
.
Now to the loop. edx
is obviously just keeping track of the iteration count, no surprise there. <+83>
is the interesting part: it replaces eax
with the value of the array item whose index eax
currently holds. That is eax = array[eax]
. ecx
is of course just summing up the array elements you have visited, that's again easy. The exit condition is when you hit the array item that has value 15.
What it all boils down is that this array is really a linked list. The end of the list is marked by a 15. The first number you enter is used as a starting point for list traversal. It should be selected such that you have 11 elements until the end of the list (see <+96>
). The second input number should equal the sum of the array items visited.