tags:

views:

75

answers:

2

How can the following instructions make any sense?

xor eax,eax
mov eax,[eax]

When you XOR eax, you get zero most of the time, so can you dereference what is at address [eax] (in this case eax contains 0) and put it back into eax?

Someone please clarify?

+2  A: 

Not sure what you want clarified.

xor eax, eax 

Will generate 0 always.

dereferencing 0 will most often result in a page fault. That is, unless there is a valid page at address 0...

Bahbar
+4  A: 

Where did this code come from? And what OS is it intended to run on?

I see two possibilities:

  1. This code is supposed to generate an intentional segmentation fault.

  2. The code is intended to run on a system where there is a valid page at address 0, and it's trying to access whatever is there.

Martin B