1 Replies - 607 Views - Last Post: 23 April 2014 - 09:36 PM

Nested loop crash - Assembly

Posted 23 April 2014 - 08:40 PM

I've been working on this program for a while and I've hit a point where I don't know what is causing it to crash. It assembles fine, but it seems right when it hits the Innerloop it'll crash. The program is supposed to have one student open all the lockers, and the second student will open/close every second one and so on until all squared numbers are open. I think my problem may lie with Xor, but I am not entirely too sure, because even if I change it to use the mov instruction with conditioned jumps, it'll still crash. The Array is set to 101 because we're supposed to work with 1-100 not 0-99.

Replies To: Nested loop crash - Assembly

Re: Nested loop crash - Assembly

Posted 23 April 2014 - 09:36 PM

Here:

mov esi, OFFSET Locker

You are moving the address off Locker into esi.

Here:

xor Locker[esi], 1

You are using the value in esi (the address of Locker) as an index into Locker. This is definitely wrong and way, way out of the array bounds. You will also get a crash at the end since there is not a ret.